Compartilhar via


2.2.4.32.1 Request

 SMB_Parameters
   {
   UCHAR  WordCount;
   Words
     {
     UCHAR  AndXCommand;
     UCHAR  AndXReserved;
     USHORT AndXOffset;
     USHORT FID;
     UCHAR  TypeOfLock;
     UCHAR  NewOpLockLevel;
     ULONG  Timeout;
     USHORT NumberOfRequestedUnlocks;
     USHORT NumberOfRequestedLocks;
     }
   }
 SMB_Data
   {
   USHORT ByteCount;
   Bytes
     {
     LOCKING_ANDX_RANGE Unlocks[NumberOfRequestedUnlocks];
     LOCKING_ANDX_RANGE Locks[NumberOfRequestedLocks];
     }
   }
            

SMB_Header: Flags (1 byte): If the server sends an OpLock Break Notification to a client holding an OpLock, the SMB_FLAGS_REPLY bit (0x80) MUST be clear (0) to indicate that the message is a request. This is the only instance in the protocol in which the server sends a request message.


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

SMB_Parameters (17 bytes)

...

...

...

...

SMB_Data (variable)

...

SMB_Parameters (17 bytes):


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

Words (16 bytes)

...

...

...

WordCount (1 byte): This field MUST be 0x08.

Words (16 bytes):


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

AndXCommand

AndXReserved

AndXOffset

FID

TypeOfLock

NewOpLockLevel

Timeout

NumberOfRequestedUnlocks

NumberOfRequestedLocks

AndXCommand (1 byte): The command code for the next SMB command in the packet. This value MUST be set to 0xFF if there are no additional SMB commands in the client request packet.

AndXReserved (1 byte): A reserved field. This MUST be set to 0x00 when this request is sent, and the server MUST ignore this value when the message is received.

AndXOffset (2 bytes): This field MUST be set to the offset, in bytes, from the start of the SMB_Header (section 2.2.3.1) to the start of the WordCount field in the next SMB command in this packet. This field is valid only if the AndXCommand field is not set to 0xFF. If AndXCommand is 0xFF, this field MUST be ignored by the server.

FID (2 bytes): This field MUST be a valid 16-bit unsigned integer indicating the file from which the data SHOULD be read.

TypeOfLock (1 byte): This field is an 8-bit unsigned integer bit mask indicating the nature of the lock request and the format of the LOCKING_ANDX_RANGE data. If the negotiated protocol is NT LAN Manager or later, CAP_LARGE_FILES was negotiated and LARGE_FILES bit is set, then the Locks and Unlocks arrays are in the large file 64-bit offset LOCKING_ANDX_RANGE format. This allows specification of 64-bit offsets for very large files.

If TypeOfLock has the SHARED_LOCK bit set, the lock is specified as a shared read-only lock. If shared read-only locks cannot be supported by a server, the server SHOULD map the lock to an exclusive lock for both read and write. Locks for both read and write messages in which TypeOfLock bit READ_WRITE_LOCK is set SHOULD be prohibited by the server, and the server SHOULD return an implementation-specific error to the client. If TypeOfLock has the CHANGE_LOCKTYPE bit set, the client is requesting that the server atomically change the lock type from a shared lock to an exclusive lock, or vice versa. If the server cannot do this in an atomic fashion, the server MUST reject this request and return an implementation-specific error to the client. Closing a file with locks still in force causes the locks to be released in a nondeterministic order.

If the Locks vector contains one and only one entry (NumberOfRequestedLocks == 1) and TypeOfLock has the CANCEL_LOCK bit set, the client is requesting that the server cancel a previously requested but unacknowledged lock. This allows the client to cancel lock requests that can wait forever to complete (see Timeout below).

Lock type and bitmask

Meaning

READ_WRITE_LOCK

0x00

Request for an exclusive read and write lock.

SHARED_LOCK

0x01

Request for a shared read-only lock.

OPLOCK_RELEASE

0x02

When sent from the server to the client in an OpLock Break Notification, this bit indicates to the client that an OpLock change has occurred on the FID supplied in the request. The client MUST set this bit when sending the OpLock Break Request message acknowledging the OpLock Break.

CHANGE_LOCKTYPE

0x04

Request to atomically change the lock type from a shared lock to an exclusive lock or vice versa for the specified Locks.<39>

CANCEL_LOCK

0x08

Request to cancel all outstanding lock requests for the specified FID and PID.<40>

LARGE_FILES

0x10

Indicates that the LOCKING_ANDX_RANGE format is the 64-bit file offset version. If this flag is not set, then the LOCKING_ANDX_RANGE format is the 32-bit file offset version.

NewOpLockLevel (1 byte): This field is valid only in SMB_COM_LOCKING_ANDX (0x24) (section 2.2.4.32) SMB requests sent from the server to the client in response to a change in an existing OpLock's state. This field is an 8-bit unsigned integer indicating the OpLock level now in effect for the FID in the request. If NewOpLockLevel is 0x00, the client possesses no OpLocks on the file at all. If NewOpLockLevel is 0x01, then the client possesses a Level II OpLock.

Timeout (4 bytes): This field is a 32-bit unsigned integer value. Timeout is the maximum amount of time to wait, in milliseconds, for the byte range(s) specified in Locks to become locked. A Timeout value of 0x00000000 indicates that the server fails immediately if any lock range specified is already locked and cannot be locked by this request. A Timeout value of -1 (0xFFFFFFFF) indicates that the server waits as long as it takes (wait forever) for each byte range specified to become unlocked so that it can be locked by this request. Any other value of Timeout specifies the maximum number of milliseconds to wait for all lock ranges specified in Locks to become available and to be locked by this request.

NumberOfRequestedUnlocks (2 bytes): This field is a 16-bit unsigned integer value containing the number of entries in the Unlocks array.

NumberOfRequestedLocks (2 bytes): This field is a 16-bit unsigned integer value containing the number of entries in the Locks array.

SMB_Data (variable):


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

ByteCount

Bytes (variable)

...

ByteCount (2 bytes): This field MUST be greater than or equal to 0x0000.

Bytes (variable):


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

Unlocks (variable)

...

Locks (variable)

...

Unlocks (variable): An array of byte ranges to be unlocked. If 32-bit offsets are being used, this field uses LOCKING_ANDX_RANGE32 (see below) and is (10 * NumberOfRequestedUnlocks) bytes in length. If 64-bit offsets are being used, this field uses LOCKING_ANDX_RANGE64 (see below) and is (20 * NumberOfRequestedUnlocks) bytes in length.

Locks (variable): An array of byte ranges to be locked. If 32-bit offsets are being used, this field uses LOCKING_ANDX_RANGE32 (see following) and is (10 * NumberOfRequestedLocks) bytes in length. If 64-bit offsets are being used, this field uses LOCKING_ANDX_RANGE64 (see following) and is (20 * NumberOfRequestedLocks) bytes in length.

The LOCKING_ANDX_RANGE32 data type has the following structure.

 LOCKING_ANDX_RANGE32
   {
   USHORT PID;
   ULONG  ByteOffset;
   ULONG  LengthInBytes;
   }
            

PID (2 bytes): The PID of the process requesting the locking change.

ByteOffset (4 bytes): The 32-bit unsigned integer value that is the offset into the file at which the locking change MUST begin.

LengthInBytes (4 bytes): The 32-bit unsigned integer value that is the number of bytes, beginning at OffsetInBytes, that MUST be locked or unlocked.

The LOCKING_ANDX_RANGE64 data type has the following structure.

 LOCKING_ANDX_RANGE64
   {
   USHORT PID;
   USHORT Pad;
   ULONG  ByteOffsetHigh;
   ULONG  ByteOffsetLow;
   ULONG  LengthInBytesHigh;
   ULONG  LengthInBytesLow;
   }
            

PID (2 bytes): The PID of the process requesting the locking change.

Pad (2 bytes): This field pads the structure to DWORD alignment and MUST be zero (0x0000).

OffsetInBytesHigh (4 bytes): The 32-bit unsigned integer value that is the high 32 bits of a 64-bit offset into the file at which the locking change MUST begin.

OffsetInBytesLow (4 bytes): The 32-bit unsigned integer value that is the low 32 bits of a 64-bit offset into the file at which the locking change MUST begin.

LengthInBytesHigh (4 bytes): The 32-bit unsigned integer value that is the high 32 bits of a 64-bit value specifying the number of bytes that MUST be locked or unlocked.

LengthInBytesLow (4 bytes): The 32-bit unsigned integer value that is the low 32 bits of a 64-bit value specifying the number of bytes that MUST be locked or unlocked.