CIFS Protocol
WRITE_ANDX
The WRITE_ANDX packet defines the data portion of the CIFS client request and server response packets for the command code WRITE_ANDX. The data portion follows immediately on the packet header, the first field, WordCount, being the same field as WordCount in the packet header SMB_Header.
Field name Displacement Length
(bytes) (bytes)
Client_Request
WordCount 0 1
ANDXCommand 1 1
ANDXReserved 2 1
ANDXOffset 3 2
Fid 5 2
Offset 7 4
Reserved 11 4
WriteMode 15 2
CountBytesRemai 17 2
DataLengthHigh 19 2
DataLength 21 2
DataOffset 23 2
OffsetHigh 25 4
ByteCount 29 2
Pad[] 31 Variable
Data[ DataLengt * Variable
Server_Response
WordCount 0 1
ANDXCommand 1 1
ANDXReserved 2 1
ANDXOffset 3 2
Count 5 2
Remaining 7 2
CountHigh 9 2
Reserved 11 2
ByteCount 13 2
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 1 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 2 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 3 0 | 1 |
|
Fields
- Write_AndX
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 1 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 2 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 3 0 | 1 |
Server_Response |
Data type: union
Data portions for client request and server response. - Client_Request
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 1 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 2 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 3 0 | 1 |
WordCount | ANDXCommand | ANDXReserved | ANDXOffset | Fid | Offset | Reserved | WriteMode | CountBytesRemaining | DataLengthHigh | DataLength | DataOffset | OffsetHigh | | ByteCount | Pad[] | Data[ DataLength ] |
Data type: struct
Client request data portion. - WordCount
Data type: UCHAR
Count of parameter words. - ANDXCommand
Data type: UCHAR
Secondary command. If no secondary command exists, the value is 0xFF.0XFF
SMB_COM_CLOSE
SMB_COM_LOCK_AND_READ
SMB_COM_READ
SMB_COM_READ_ANDX
SMB_COM_WRITE_ANDX
- ANDXReserved
Data type: UCHAR
Reserved. This value must be 0 (zero). - ANDXOffset
Data type: USHORT
Offset to the WordCount location of the following command. - Fid
Data type: USHORT
File identifier or handle. - Offset
Data type: ULONG
Offset in bytes of write start position in the file. - Reserved
Data type: ULONG
Reserved. This value must be 0 (zero). - WriteMode
Data type: USHORT
Write mode bits. Set to 0 (zero) for writethrough. - CountBytesRemaining
Data type: USHORT
Count of bytes remaining to satisfy the client request. - DataLengthHigh
Data type: USHORT
If CAP_LARGE_WRITEX, the value is set to the high 16 bits of DataLength. Otherwise, the value must be 0 (zero). - DataLength
Data type: USHORT
Number of data bytes in buffer. The value is greater than 0 (zero). - DataOffset
Data type: USHORT
Offset to data bytes. - OffsetHigh
Data type: ULONG
High 32 bits of offset. This value is set if WordCount is 14. - ByteCount
Data type: USHORT
Count of data bytes. - Pad[]
Data type: UCHAR
Pad to SHORT or LONG. - Data[ DataLength ]
Data type: UCHAR
Array of data bytes to write.
- Server_Response
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 1 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 2 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 3 0 | 1 |
WordCount | ANDXCommand | ANDXReserved | ANDXOffset | | Count | Remaining | | CountHigh | Reserved | | ByteCount |
Data type: struct
Server response data portion. - WordCount
Data type: UCHAR
Count of parameter words. - ANDXCommand
Data type: UCHAR
Secondary command. If no secondary command exists, the value is 0xFF. - ANDXReserved
Data type: UCHAR
Reserved. Must be 0 (zero). - ANDXOffset
Data type: USHORT
Offset to the WordCount location of the following command. - Count
Data type: USHORT
Count of bytes written. - Remaining
Data type: USHORT
Reserved. - CountHigh
Data type: USHORT
High 16 bits of Count. - Reserved
Data type: USHORT
Reserved. - ByteCount
Data type: USHORT
Count of data bytes. The value is 0 (zero).
Remarks
A ByteCount value of 0 (zero) transfers 0 bytes of data to the file, but does not truncate the file. To truncate a file, use a client request such as SMB_COM_WRITE.
In the client request, if the WriteMode bit0 is set and the Fid value refers to a disk file, the server response is sent after the data is on stable storage.
If the negotiated dialect is NTLM 0.12 or later, the 14-word format of this SMB may be used to access portions of files requiring offsets expressed as 64 bits. Otherwise, the OffsetHigh field must be omitted from the request.
If CAP_LARGE_WRITEX was indicated by the server in the NEGOTIATE response, the client request DataLength field is combined with DataLengthHigh to form a 32-bit value which may exceed the negotiated buffer size. In the server response, Count is combined with CountHigh.
The following error codes may be returned:
- ERRDOS/ERRnoaccess
- ERRDOS/ERRbadfid
- ERRDOS/ERRlock
- ERRDOS/ERRbadaccess
- ERRSRV/ERRinvid
- ERRSRV/ERRbaduid
See Also
Royalty-Free CIFS Technical Reference License Agreement