Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3927 lines
159 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. smb.h
  5. Abstract:
  6. This file contains request and response structure definitions
  7. for the specific parameters of each SMB command, as well as codes
  8. for SMB commands and errors.
  9. Author:
  10. David R. Treadwell (davidtr) 27-Sept-1989 (from LanMan 1.2 code)
  11. Revision History:
  12. --*/
  13. #ifndef _SMB_
  14. #define _SMB_
  15. //#include <nt.h>
  16. //#include <smbtypes.h>
  17. /*
  18. Inclusion of SMB request/response structures in this file is
  19. conditionalized in the following way:
  20. If INCLUDE_SMB_ALL is defined, all of the structures are defined.
  21. Otherwise, the following names, if defined, cause inclusion of the
  22. corresponding SMB categories:
  23. INCLUDE_SMB_ADMIN Administrative requests:
  24. PROCESS_EXIT
  25. NEGOTIATE
  26. SESSION_SETUP_ANDX
  27. LOGOFF_ANDX
  28. INCLUDE_SMB_TREE Tree connect requests:
  29. TREE_CONNECT
  30. TREE_DISCONNECT
  31. TREE_CONNECT_ANDX
  32. INCLUDE_SMB_DIRECTORY Directory-related requests:
  33. CREATE_DIRECTORY
  34. DELETE_DIRECTORY
  35. CHECK_DIRECTORY
  36. INCLUDE_SMB_OPEN_CLOSE File open and close requests:
  37. OPEN
  38. CREATE
  39. CLOSE
  40. CREATE_TEMPORARY
  41. CREATE_NEW
  42. OPEN_ANDX
  43. CLOSE_AND_TREE_DISC
  44. INCLUDE_SMB_READ_WRITE Read and write requests:
  45. READ
  46. WRITE
  47. SEEK
  48. LOCK_AND_READ
  49. WRITE_AND_UNLOCK
  50. WRITE_AND_CLOSE
  51. READ_ANDX
  52. WRITE_ANDX
  53. INCLUDE_SMB_FILE_CONTROL File control requests:
  54. FLUSH
  55. DELETE
  56. RENAME
  57. COPY
  58. MOVE
  59. INCLUDE_SMB_QUERY_SET File query/set requests:
  60. QUERY_INFORMATION
  61. SET_INFORMATION
  62. QUERY_INFORMATION2
  63. SET_INFORMATION2
  64. QUERY_PATH_INFORMATION
  65. SET_PATH_INFORMATION
  66. QUERY_FILE_INFORMATION
  67. SET_FILE_INFORMATION
  68. INCLUDE_SMB_LOCK Lock requests (not LOCK_AND_READ)
  69. LOCK_BYTE_RANGE
  70. UNLOCK_BYTE_RANGE
  71. LOCKING_ANDX
  72. INCLUDE_SMB_RAW Raw read/write requests:
  73. READ_RAW
  74. WRITE_RAW
  75. INCLUDE_SMB_MPX Multiplexed requests:
  76. READ_MPX
  77. WRITE_MPX
  78. INCLUDE_SMB_SEARCH Search requests:
  79. FIND_CLOSE2
  80. FIND_NOTIFY_CLOSE
  81. SEARCH
  82. FIND
  83. FIND_UNIQUE
  84. FIND_CLOSE
  85. INCLUDE_SMB_TRANSACTION Transaction and IOCTL requests:
  86. TRANSACTION
  87. IOCTL
  88. TRANSACTION2
  89. NTTRANSACTION
  90. INCLUDE_SMB_PRINT Printer requests:
  91. OPEN_PRINT_FILE
  92. WRITE_PRINT_FILE
  93. CLOSE_PRINT_FILE
  94. GET_PRINT_QUEUE
  95. INCLUDE_SMB_MESSAGE Message requests:
  96. SEND_MESSAGE
  97. SEND_BROADCAST_MESSAGE
  98. FORWARD_USER_NAME
  99. CANCEL_FORWARD
  100. GET_MACHINE_NAME
  101. SEND_START_MB_MESSAGE
  102. SEND_END_MB_MESSAGE
  103. SEND_TEXT_MB_MESSAGE
  104. INCLUDE_SMB_MISC Miscellaneous requests:
  105. QUERY_INFORMATION_SRV
  106. ECHO
  107. QUERY_INFORMATION_DISK
  108. */
  109. #ifdef INCLUDE_SMB_ALL
  110. #define INCLUDE_SMB_ADMIN
  111. #define INCLUDE_SMB_TREE
  112. #define INCLUDE_SMB_DIRECTORY
  113. #define INCLUDE_SMB_OPEN_CLOSE
  114. #define INCLUDE_SMB_FILE_CONTROL
  115. #define INCLUDE_SMB_READ_WRITE
  116. #define INCLUDE_SMB_LOCK
  117. #define INCLUDE_SMB_RAW
  118. #define INCLUDE_SMB_MPX
  119. #define INCLUDE_SMB_QUERY_SET
  120. #define INCLUDE_SMB_SEARCH
  121. #define INCLUDE_SMB_TRANSACTION
  122. #define INCLUDE_SMB_PRINT
  123. #define INCLUDE_SMB_MESSAGE
  124. #define INCLUDE_SMB_MISC
  125. #endif // def INCLUDE_SMB_ALL
  126. //
  127. // Force misalignment of the following structures
  128. //
  129. #ifndef NO_PACKING
  130. #include <packon.h>
  131. #endif // ndef NO_PACKING
  132. //
  133. // SMB servers listen on two NETBIOS addresses to facilitate connections. The
  134. // first one is a name formulated from the computer name by padding it with
  135. // a number of blanks ( upto NETBIOS_NAME_LEN ). This name is registered and
  136. // resolved using the NETBIOS name registration/resolution mechanism. They also
  137. // register under a second name *SMBSERVER which is not a valuid netbios name
  138. // but provides a name which can be used in NETBT session setup. This eliminates
  139. // the need for querying the remote adapter status to obtain the name.
  140. //
  141. #define SMBSERVER_LOCAL_ENDPOINT_NAME "*SMBSERVER "
  142. #define SMBSERVER_LOCAL_ENDPOINT_NAME_UNICODE L"*SMBSERVER "
  143. //
  144. // SMB Command code definitions:
  145. //
  146. // *** Start of SMB commands
  147. #define SMB_COM_CREATE_DIRECTORY (UCHAR)0x00
  148. #define SMB_COM_DELETE_DIRECTORY (UCHAR)0x01
  149. #define SMB_COM_OPEN (UCHAR)0x02
  150. #define SMB_COM_CREATE (UCHAR)0x03
  151. #define SMB_COM_CLOSE (UCHAR)0x04
  152. #define SMB_COM_FLUSH (UCHAR)0x05
  153. #define SMB_COM_DELETE (UCHAR)0x06
  154. #define SMB_COM_RENAME (UCHAR)0x07
  155. #define SMB_COM_QUERY_INFORMATION (UCHAR)0x08
  156. #define SMB_COM_SET_INFORMATION (UCHAR)0x09
  157. #define SMB_COM_READ (UCHAR)0x0A
  158. #define SMB_COM_WRITE (UCHAR)0x0B
  159. #define SMB_COM_LOCK_BYTE_RANGE (UCHAR)0x0C
  160. #define SMB_COM_UNLOCK_BYTE_RANGE (UCHAR)0x0D
  161. #define SMB_COM_CREATE_TEMPORARY (UCHAR)0x0E
  162. #define SMB_COM_CREATE_NEW (UCHAR)0x0F
  163. #define SMB_COM_CHECK_DIRECTORY (UCHAR)0x10
  164. #define SMB_COM_PROCESS_EXIT (UCHAR)0x11
  165. #define SMB_COM_SEEK (UCHAR)0x12
  166. #define SMB_COM_LOCK_AND_READ (UCHAR)0x13
  167. #define SMB_COM_WRITE_AND_UNLOCK (UCHAR)0x14
  168. #define SMB_COM_READ_RAW (UCHAR)0x1A
  169. #define SMB_COM_READ_MPX (UCHAR)0x1B
  170. #define SMB_COM_READ_MPX_SECONDARY (UCHAR)0x1C // server to redir only
  171. #define SMB_COM_WRITE_RAW (UCHAR)0x1D
  172. #define SMB_COM_WRITE_MPX (UCHAR)0x1E
  173. #define SMB_COM_WRITE_MPX_SECONDARY (UCHAR)0x1F
  174. #define SMB_COM_WRITE_COMPLETE (UCHAR)0x20 // server to redir only
  175. #define SMB_COM_QUERY_INFORMATION_SRV (UCHAR)0x21
  176. #define SMB_COM_SET_INFORMATION2 (UCHAR)0x22
  177. #define SMB_COM_QUERY_INFORMATION2 (UCHAR)0x23
  178. #define SMB_COM_LOCKING_ANDX (UCHAR)0x24
  179. #define SMB_COM_TRANSACTION (UCHAR)0x25
  180. #define SMB_COM_TRANSACTION_SECONDARY (UCHAR)0x26
  181. #define SMB_COM_IOCTL (UCHAR)0x27
  182. #define SMB_COM_IOCTL_SECONDARY (UCHAR)0x28
  183. #define SMB_COM_COPY (UCHAR)0x29
  184. #define SMB_COM_MOVE (UCHAR)0x2A
  185. #define SMB_COM_ECHO (UCHAR)0x2B
  186. #define SMB_COM_WRITE_AND_CLOSE (UCHAR)0x2C
  187. #define SMB_COM_OPEN_ANDX (UCHAR)0x2D
  188. #define SMB_COM_READ_ANDX (UCHAR)0x2E
  189. #define SMB_COM_WRITE_ANDX (UCHAR)0x2F
  190. #define SMB_COM_CLOSE_AND_TREE_DISC (UCHAR)0x31
  191. #define SMB_COM_TRANSACTION2 (UCHAR)0x32
  192. #define SMB_COM_TRANSACTION2_SECONDARY (UCHAR)0x33
  193. #define SMB_COM_FIND_CLOSE2 (UCHAR)0x34
  194. #define SMB_COM_FIND_NOTIFY_CLOSE (UCHAR)0x35
  195. #define SMB_COM_TREE_CONNECT (UCHAR)0x70
  196. #define SMB_COM_TREE_DISCONNECT (UCHAR)0x71
  197. #define SMB_COM_NEGOTIATE (UCHAR)0x72
  198. #define SMB_COM_SESSION_SETUP_ANDX (UCHAR)0x73
  199. #define SMB_COM_LOGOFF_ANDX (UCHAR)0x74
  200. #define SMB_COM_TREE_CONNECT_ANDX (UCHAR)0x75
  201. #define SMB_COM_QUERY_INFORMATION_DISK (UCHAR)0x80
  202. #define SMB_COM_SEARCH (UCHAR)0x81
  203. #define SMB_COM_FIND (UCHAR)0x82
  204. #define SMB_COM_FIND_UNIQUE (UCHAR)0x83
  205. #define SMB_COM_FIND_CLOSE (UCHAR)0x84
  206. #define SMB_COM_NT_TRANSACT (UCHAR)0xA0
  207. #define SMB_COM_NT_TRANSACT_SECONDARY (UCHAR)0xA1
  208. #define SMB_COM_NT_CREATE_ANDX (UCHAR)0xA2
  209. #define SMB_COM_NT_CANCEL (UCHAR)0xA4
  210. #define SMB_COM_NT_RENAME (UCHAR)0xA5
  211. #define SMB_COM_OPEN_PRINT_FILE (UCHAR)0xC0
  212. #define SMB_COM_WRITE_PRINT_FILE (UCHAR)0xC1
  213. #define SMB_COM_CLOSE_PRINT_FILE (UCHAR)0xC2
  214. #define SMB_COM_GET_PRINT_QUEUE (UCHAR)0xC3
  215. #define SMB_COM_SEND_MESSAGE (UCHAR)0xD0
  216. #define SMB_COM_SEND_BROADCAST_MESSAGE (UCHAR)0xD1
  217. #define SMB_COM_FORWARD_USER_NAME (UCHAR)0xD2
  218. #define SMB_COM_CANCEL_FORWARD (UCHAR)0xD3
  219. #define SMB_COM_GET_MACHINE_NAME (UCHAR)0xD4
  220. #define SMB_COM_SEND_START_MB_MESSAGE (UCHAR)0xD5
  221. #define SMB_COM_SEND_END_MB_MESSAGE (UCHAR)0xD6
  222. #define SMB_COM_SEND_TEXT_MB_MESSAGE (UCHAR)0xD7
  223. // *** End of SMB commands
  224. #define SMB_COM_NO_ANDX_COMMAND (UCHAR)0xFF
  225. //
  226. // Header for SMBs, see #4 page 10
  227. //
  228. // *** Note that we do NOT define PSMB_HEADER as SMB_UNALIGNED! This is
  229. // done on the assumption that the SMB header, at least, will always
  230. // be properly aligned. If you need to access an unaligned header,
  231. // declare the pointer as SMB_UNALIGNED *SMB_HEADER.
  232. //
  233. #define SMB_SECURITY_SIGNATURE_LENGTH 8
  234. typedef struct _SMB_HEADER {
  235. UCHAR Protocol[4]; // Contains 0xFF,'SMB'
  236. UCHAR Command; // Command code
  237. UCHAR ErrorClass; // Error class
  238. UCHAR Reserved; // Reserved for future use
  239. _USHORT( Error ); // Error code
  240. UCHAR Flags; // Flags
  241. _USHORT( Flags2 ); // More flags
  242. union {
  243. _USHORT( Reserved2 )[6]; // Reserved for future use
  244. struct {
  245. _USHORT( PidHigh ); // High part of PID (NT Create And X)
  246. union {
  247. struct {
  248. _ULONG( Key ); // Encryption key (IPX)
  249. _USHORT( Sid ); // Session ID (IPX)
  250. _USHORT( SequenceNumber ); // Sequence number (IPX)
  251. _USHORT( Gid ); // Group ID (unused?)
  252. };
  253. UCHAR SecuritySignature[SMB_SECURITY_SIGNATURE_LENGTH];
  254. // Client must send the correct Signature
  255. // for this SMB to be accepted.
  256. };
  257. };
  258. };
  259. _USHORT( Tid ); // Authenticated user/group
  260. _USHORT( Pid ); // Caller's process id
  261. _USHORT( Uid ); // Unauthenticated user id
  262. _USHORT( Mid ); // multiplex id
  263. #ifdef NO_PACKING // ***
  264. _USHORT( Kludge ); // *** make sure parameter structs
  265. #endif // *** are longword aligned
  266. } SMB_HEADER;
  267. typedef SMB_HEADER *PSMB_HEADER;
  268. typedef struct _NT_SMB_HEADER {
  269. UCHAR Protocol[4]; // Contains 0xFF,'SMB'
  270. UCHAR Command; // Command code
  271. union {
  272. struct {
  273. UCHAR ErrorClass; // Error class
  274. UCHAR Reserved; // Reserved for future use
  275. _USHORT( Error ); // Error code
  276. } DosError;
  277. ULONG NtStatus; // NT-style 32-bit error code
  278. } Status;
  279. UCHAR Flags; // Flags
  280. _USHORT( Flags2 ); // More flags
  281. union {
  282. _USHORT( Reserved2 )[6]; // Reserved for future use
  283. struct {
  284. _USHORT( PidHigh ); // High part of PID (NT Create And X)
  285. union {
  286. struct {
  287. _ULONG( Key ); // Encryption key (IPX)
  288. _USHORT( Sid ); // Session ID (IPX)
  289. _USHORT( SequenceNumber ); // Sequence number (IPX)
  290. _USHORT( Gid ); // Group ID (unused?)
  291. };
  292. UCHAR SecuritySignature[SMB_SECURITY_SIGNATURE_LENGTH];
  293. // Client must send the correct Signature
  294. // for this SMB to be accepted.
  295. };
  296. };
  297. };
  298. _USHORT( Tid ); // Authenticated user/group
  299. _USHORT( Pid ); // Caller's process id
  300. _USHORT( Uid ); // Unauthenticated user id
  301. _USHORT( Mid ); // multiplex id
  302. #ifdef NO_PACKING // ***
  303. _USHORT( Kludge ); // *** make sure parameter structs
  304. #endif // *** are longword aligned
  305. } NT_SMB_HEADER;
  306. typedef NT_SMB_HEADER *PNT_SMB_HEADER;
  307. //
  308. // The SMB header, protocol field, as a long.
  309. //
  310. #define SMB_HEADER_PROTOCOL (0xFF + ('S' << 8) + ('M' << 16) + ('B' << 24))
  311. //
  312. // Minimum parameter structure that can be returned. Used in returning
  313. // error SMBs.
  314. //
  315. // *** Note that this structure does NOT have a Buffer field!
  316. //
  317. typedef struct _SMB_PARAMS {
  318. UCHAR WordCount; // Count of parameter words = 0
  319. _USHORT( ByteCount ); // Count of bytes that follow; min = 0
  320. } SMB_PARAMS;
  321. typedef SMB_PARAMS SMB_UNALIGNED *PSMB_PARAMS;
  322. //
  323. // Generic header for AndX commands.
  324. //
  325. typedef struct _GENERIC_ANDX {
  326. UCHAR WordCount; // Count of parameter words
  327. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  328. UCHAR AndXReserved; // Reserved
  329. _USHORT( AndXOffset ); // Offset (from SMB header start)
  330. } GENERIC_ANDX;
  331. typedef GENERIC_ANDX SMB_UNALIGNED *PGENERIC_ANDX;
  332. #ifdef INCLUDE_SMB_MESSAGE
  333. //
  334. // Cancel Forward SMB, see #1 page 35
  335. // Function is SrvSmbCancelForward()
  336. // SMB_COM_CANCEL_FORWARD 0xD3
  337. //
  338. typedef struct _REQ_CANCEL_FORWARD {
  339. UCHAR WordCount; // Count of parameter words = 0
  340. _USHORT( ByteCount ); // Count of data bytes; min = 2
  341. UCHAR Buffer[1]; // Buffer containing:
  342. //UCHAR BufferFormat; // 0x04 -- ASCII
  343. //UCHAR ForwardedName[]; // Forwarded name
  344. } REQ_CANCEL_FORWARD;
  345. typedef REQ_CANCEL_FORWARD SMB_UNALIGNED *PREQ_CANCEL_FORWARD;
  346. typedef struct _RESP_CANCEL_FORWARD {
  347. UCHAR WordCount; // Count of parameter words = 0
  348. _USHORT( ByteCount ); // Count of data bytes = 0
  349. UCHAR Buffer[1]; // empty
  350. } RESP_CANCEL_FORWARD;
  351. typedef RESP_CANCEL_FORWARD SMB_UNALIGNED *PRESP_CANCEL_FORWARD;
  352. #endif // def INCLUDE_SMB_MESSAGE
  353. #ifdef INCLUDE_SMB_DIRECTORY
  354. //
  355. // Check Directory SMB, see #1 page 23
  356. // Function is SrvSmbCheckDirectory()
  357. // SMB_COM_CHECK_DIRECTORY 0x10
  358. //
  359. typedef struct _REQ_CHECK_DIRECTORY {
  360. UCHAR WordCount; // Count of parameter words = 0
  361. _USHORT( ByteCount ); // Count of data bytes; min = 2
  362. UCHAR Buffer[1]; // Buffer containing:
  363. //UCHAR BufferFormat; // 0x04 -- ASCII
  364. //UCHAR DirectoryPath[]; // Directory path
  365. } REQ_CHECK_DIRECTORY;
  366. typedef REQ_CHECK_DIRECTORY SMB_UNALIGNED *PREQ_CHECK_DIRECTORY;
  367. typedef struct _RESP_CHECK_DIRECTORY {
  368. UCHAR WordCount; // Count of parameter words = 0
  369. _USHORT( ByteCount ); // Count of data bytes = 0
  370. UCHAR Buffer[1]; // empty
  371. } RESP_CHECK_DIRECTORY;
  372. typedef RESP_CHECK_DIRECTORY SMB_UNALIGNED *PRESP_CHECK_DIRECTORY;
  373. #endif // def INCLUDE_SMB_DIRECTORY
  374. #ifdef INCLUDE_SMB_OPEN_CLOSE
  375. //
  376. // Close SMB, see #1 page 10
  377. // Function is SrvSmbClose()
  378. // SMB_COM_CLOSE 0x04
  379. //
  380. typedef struct _REQ_CLOSE {
  381. UCHAR WordCount; // Count of parameter words = 3
  382. _USHORT( Fid ); // File handle
  383. _ULONG( LastWriteTimeInSeconds ); // Time of last write, low and high
  384. _USHORT( ByteCount ); // Count of data bytes = 0
  385. UCHAR Buffer[1]; // empty
  386. } REQ_CLOSE;
  387. typedef REQ_CLOSE SMB_UNALIGNED *PREQ_CLOSE;
  388. typedef struct _RESP_CLOSE {
  389. UCHAR WordCount; // Count of parameter words = 0
  390. _USHORT( ByteCount ); // Count of data bytes = 0
  391. UCHAR Buffer[1]; // empty
  392. } RESP_CLOSE;
  393. typedef RESP_CLOSE SMB_UNALIGNED *PRESP_CLOSE;
  394. #ifdef INCLUDE_SMB_IFMODIFIED
  395. typedef struct _REQ_EXTENDED_CLOSE {
  396. UCHAR WordCount; // Count of parameter words = 5
  397. _USHORT( Fid ); // File handle
  398. _ULONG( LastWriteTimeInSeconds ); // Time of last write, low and high
  399. _ULONG( Flags ); // NT_CREATE_xxx
  400. _USHORT( ByteCount ); // Count of data bytes = 0
  401. UCHAR Buffer[1]; // empty
  402. } REQ_EXTENDED_CLOSE;
  403. typedef REQ_EXTENDED_CLOSE SMB_UNALIGNED *PREQ_EXTENDED_CLOSE;
  404. #define SMB_RESP_EXTENDED_CLOSE_WORK_COUNT 32
  405. typedef struct _RESP_EXTENDED_CLOSE {
  406. UCHAR WordCount; // Count of parameter words = 32
  407. _ULONG( FileAttributes ); // File attributes for creation
  408. _ULONG( Flags ); // NT_CREATE_xxx
  409. TIME CreationTime; // The time the file was created
  410. TIME LastWriteTime; // The time the file was last written
  411. TIME ChangeTime; // The time the file was last changed
  412. LARGE_INTEGER AllocationSize; // Initial allocation size
  413. LARGE_INTEGER EndOfFile; // The end of file offset
  414. LARGE_INTEGER UsnValue; // The file's USN # in NTFS
  415. LARGE_INTEGER FileReferenceNumber; //
  416. _USHORT( ByteCount ); // Count of data bytes = 0
  417. UCHAR Buffer[1]; // empty
  418. } RESP_EXTENDED_CLOSE;
  419. typedef RESP_EXTENDED_CLOSE SMB_UNALIGNED *PRESP_EXTENDED_CLOSE;
  420. #endif // def INCLUDE_SMB_IFMODIFIED
  421. #endif // def INCLUDE_SMB_OPEN_CLOSE
  422. #ifdef INCLUDE_SMB_OPEN_CLOSE
  423. //
  424. // Close and Tree Disconnect SMB, see #? page ??
  425. // Function is SrvSmbCloseAndTreeDisc
  426. // SMB_COM_CLOSE_AND_TREE_DISC 0x31
  427. //
  428. typedef struct _REQ_CLOSE_AND_TREE_DISC {
  429. UCHAR WordCount; // Count of parameter words
  430. _USHORT( Fid ); // File handle
  431. _ULONG( LastWriteTimeInSeconds );
  432. _USHORT( ByteCount ); // Count of data bytes = 0
  433. UCHAR Buffer[1]; // empty
  434. } REQ_CLOSE_AND_TREE_DISC;
  435. typedef REQ_CLOSE_AND_TREE_DISC SMB_UNALIGNED *PREQ_CLOSE_AND_TREE_DISC;
  436. typedef struct _RESP_CLOSE_AND_TREE_DISC {
  437. UCHAR WordCount; // Count of parameter words = 0
  438. _USHORT( ByteCount ); // Count of data bytes = 0
  439. UCHAR Buffer[1]; // empty
  440. } RESP_CLOSE_AND_TREE_DISC;
  441. typedef RESP_CLOSE_AND_TREE_DISC SMB_UNALIGNED *PRESP_CLOSE_AND_TREE_DISC;
  442. #endif // def INCLUDE_SMB_OPEN_CLOSE
  443. #ifdef INCLUDE_SMB_PRINT
  444. //
  445. // Close Print Spool File SMB, see #1 page 29
  446. // Function is SrvSmbClosePrintSpoolFile()
  447. // SMB_COM_CLOSE_PRINT_FILE 0xC2
  448. //
  449. typedef struct _REQ_CLOSE_PRINT_FILE {
  450. UCHAR WordCount; // Count of parameter words = 1
  451. _USHORT( Fid ); // File handle
  452. _USHORT( ByteCount ); // Count of data bytes = 0
  453. UCHAR Buffer[1]; // empty
  454. } REQ_CLOSE_PRINT_FILE;
  455. typedef REQ_CLOSE_PRINT_FILE SMB_UNALIGNED *PREQ_CLOSE_PRINT_FILE;
  456. typedef struct _RESP_CLOSE_PRINT_FILE {
  457. UCHAR WordCount; // Count of parameter words = 0
  458. _USHORT( ByteCount ); // Count of data bytes = 0
  459. UCHAR Buffer[1]; // empty
  460. } RESP_CLOSE_PRINT_FILE;
  461. typedef RESP_CLOSE_PRINT_FILE SMB_UNALIGNED *PRESP_CLOSE_PRINT_FILE;
  462. #endif // def INCLUDE_SMB_PRINT
  463. #ifdef INCLUDE_SMB_FILE_CONTROL
  464. //
  465. // Copy SMB, see #2 page 23
  466. // Function is SrvSmbCopy()
  467. // SMB_COM_COPY 0x29
  468. //
  469. typedef struct _REQ_COPY {
  470. UCHAR WordCount; // Count of parameter words = 3
  471. _USHORT( Tid2 ); // Second (target) path TID
  472. _USHORT( OpenFunction ); // What to do if target file exists
  473. _USHORT( Flags ); // Flags to control copy operation:
  474. // bit 0 - target must be a file
  475. // bit 1 - target must ba a dir.
  476. // bit 2 - copy target mode:
  477. // 0 = binary, 1 = ASCII
  478. // bit 3 - copy source mode:
  479. // 0 = binary, 1 = ASCII
  480. // bit 4 - verify all writes
  481. // bit 5 - tree copy
  482. _USHORT( ByteCount ); // Count of data bytes; min = 2
  483. UCHAR Buffer[1]; // Buffer containing:
  484. //UCHAR SourceFileName[]; // pathname of source file
  485. //UCHAR TargetFileName[]; // pathname of target file
  486. } REQ_COPY;
  487. typedef REQ_COPY SMB_UNALIGNED *PREQ_COPY;
  488. typedef struct _RESP_COPY {
  489. UCHAR WordCount; // Count of parameter words = 1
  490. _USHORT( Count ); // Number of files copied
  491. _USHORT( ByteCount ); // Count of data bytes; min = 0
  492. UCHAR Buffer[1]; // ASCIIZ pathname of file with error
  493. } RESP_COPY;
  494. typedef RESP_COPY SMB_UNALIGNED *PRESP_COPY;
  495. #endif // def INCLUDE_SMB_FILE_CONTROL
  496. #ifdef INCLUDE_SMB_OPEN_CLOSE
  497. //
  498. // Create SMB, see #1 page 9
  499. // Create New SMB, see #1 page 23
  500. // Function is SrvSmbCreate()
  501. // SMB_COM_CREATE 0x03
  502. // SMB_COM_CREATE_NEW 0x0F
  503. //
  504. typedef struct _REQ_CREATE {
  505. UCHAR WordCount; // Count of parameter words = 3
  506. _USHORT( FileAttributes ); // New file attributes
  507. _ULONG( CreationTimeInSeconds ); // Creation time
  508. _USHORT( ByteCount ); // Count of data bytes; min = 2
  509. UCHAR Buffer[1]; // Buffer containing:
  510. //UCHAR BufferFormat; // 0x04 -- ASCII
  511. //UCHAR FileName[]; // File name
  512. } REQ_CREATE;
  513. typedef REQ_CREATE SMB_UNALIGNED *PREQ_CREATE;
  514. typedef struct _RESP_CREATE {
  515. UCHAR WordCount; // Count of parameter words = 1
  516. _USHORT( Fid ); // File handle
  517. _USHORT( ByteCount ); // Count of data bytes = 0
  518. UCHAR Buffer[1]; // empty
  519. } RESP_CREATE;
  520. typedef RESP_CREATE SMB_UNALIGNED *PRESP_CREATE;
  521. #endif // def INCLUDE_SMB_OPEN_CLOSE
  522. #ifdef INCLUDE_SMB_DIRECTORY
  523. //
  524. // Create Directory SMB, see #1 page 14
  525. // Function is SrvSmbCreateDirectory
  526. // SMB_COM_CREATE_DIRECTORY 0x00
  527. //
  528. typedef struct _REQ_CREATE_DIRECTORY {
  529. UCHAR WordCount; // Count of parameter words = 0
  530. _USHORT( ByteCount ); // Count of data bytes; min = 2
  531. UCHAR Buffer[1]; // Buffer containing:
  532. //UCHAR BufferFormat; // 0x04 -- ASCII
  533. //UCHAR DirectoryName[]; // Directory name
  534. } REQ_CREATE_DIRECTORY;
  535. typedef REQ_CREATE_DIRECTORY SMB_UNALIGNED *PREQ_CREATE_DIRECTORY;
  536. typedef struct _RESP_CREATE_DIRECTORY {
  537. UCHAR WordCount; // Count of parameter words = 0
  538. _USHORT( ByteCount ); // Count of data bytes = 0
  539. UCHAR Buffer[1]; // empty
  540. } RESP_CREATE_DIRECTORY;
  541. typedef RESP_CREATE_DIRECTORY SMB_UNALIGNED *PRESP_CREATE_DIRECTORY;
  542. #endif // def INCLUDE_SMB_DIRECTORY
  543. #ifdef INCLUDE_SMB_OPEN_CLOSE
  544. //
  545. // Create Temporary SMB, see #1 page 21
  546. // Function is SrvSmbCreateTemporary()
  547. // SMB_COM_CREATE_TEMPORARY 0x0E
  548. //
  549. typedef struct _REQ_CREATE_TEMPORARY {
  550. UCHAR WordCount; // Count of parameter words = 3
  551. _USHORT( FileAttributes );
  552. _ULONG( CreationTimeInSeconds );
  553. _USHORT( ByteCount ); // Count of data bytes; min = 2
  554. UCHAR Buffer[1]; // Buffer containing:
  555. //UCHAR BufferFormat; // 0x04 -- ASCII
  556. //UCHAR DirectoryName[]; // Directory name
  557. } REQ_CREATE_TEMPORARY;
  558. typedef REQ_CREATE_TEMPORARY SMB_UNALIGNED *PREQ_CREATE_TEMPORARY;
  559. typedef struct _RESP_CREATE_TEMPORARY {
  560. UCHAR WordCount; // Count of parameter words = 1
  561. _USHORT( Fid ); // File handle
  562. _USHORT( ByteCount ); // Count of data bytes; min = 2
  563. UCHAR Buffer[1]; // Buffer containing:
  564. //UCHAR BufferFormat; // 0x04 -- ASCII
  565. //UCHAR FileName[]; // File name
  566. } RESP_CREATE_TEMPORARY;
  567. typedef RESP_CREATE_TEMPORARY SMB_UNALIGNED *PRESP_CREATE_TEMPORARY;
  568. #endif // def INCLUDE_SMB_OPEN_CLOSE
  569. #ifdef INCLUDE_SMB_FILE_CONTROL
  570. //
  571. // Delete SMB, see #1 page 16
  572. // Function is SrvSmbDelete()
  573. // SMB_COM_DELETE 0x06
  574. //
  575. typedef struct _REQ_DELETE {
  576. UCHAR WordCount; // Count of parameter words = 1
  577. _USHORT( SearchAttributes );
  578. _USHORT( ByteCount ); // Count of data bytes; min = 2
  579. UCHAR Buffer[1]; // Buffer containing:
  580. //UCHAR BufferFormat; // 0x04 -- ASCII
  581. //UCHAR FileName[]; // File name
  582. } REQ_DELETE;
  583. typedef REQ_DELETE SMB_UNALIGNED *PREQ_DELETE;
  584. typedef struct _RESP_DELETE {
  585. UCHAR WordCount; // Count of parameter words = 0
  586. _USHORT( ByteCount ); // Count of data bytes = 0
  587. UCHAR Buffer[1]; // empty
  588. } RESP_DELETE;
  589. typedef RESP_DELETE SMB_UNALIGNED *PRESP_DELETE;
  590. #endif // def INCLUDE_SMB_FILE_CONTROL
  591. #ifdef INCLUDE_SMB_DIRECTORY
  592. //
  593. // Delete Directory SMB, see #1 page 15
  594. // Function is SrvSmbDeleteDirectory()
  595. // SMB_COM_DELETE_DIRECTORY 0x01
  596. //
  597. typedef struct _REQ_DELETE_DIRECTORY {
  598. UCHAR WordCount; // Count of parameter words = 0
  599. _USHORT( ByteCount ); // Count of data bytes; min = 2
  600. UCHAR Buffer[1]; // Buffer containing:
  601. //UCHAR BufferFormat; // 0x04 -- ASCII
  602. //UCHAR DirectoryName[]; // Directory name
  603. } REQ_DELETE_DIRECTORY;
  604. typedef REQ_DELETE_DIRECTORY SMB_UNALIGNED *PREQ_DELETE_DIRECTORY;
  605. typedef struct _RESP_DELETE_DIRECTORY {
  606. UCHAR WordCount; // Count of parameter words = 0
  607. _USHORT( ByteCount ); // Count of data bytes = 0
  608. UCHAR Buffer[1]; // empty
  609. } RESP_DELETE_DIRECTORY;
  610. typedef RESP_DELETE_DIRECTORY SMB_UNALIGNED *PRESP_DELETE_DIRECTORY;
  611. #endif // def INCLUDE_SMB_DIRECTORY
  612. #ifdef INCLUDE_SMB_MISC
  613. //
  614. // Echo SMB, see #2 page 25
  615. // Function is SrvSmbEcho()
  616. // SMB_COM_ECHO 0x2B
  617. //
  618. typedef struct _REQ_ECHO {
  619. UCHAR WordCount; // Count of parameter words = 1
  620. _USHORT( EchoCount ); // Number of times to echo data back
  621. _USHORT( ByteCount ); // Count of data bytes; min = 4
  622. UCHAR Buffer[1]; // Data to echo
  623. } REQ_ECHO;
  624. typedef REQ_ECHO SMB_UNALIGNED *PREQ_ECHO;
  625. typedef struct _RESP_ECHO {
  626. UCHAR WordCount; // Count of parameter words = 1
  627. _USHORT( SequenceNumber ); // Sequence number of this echo
  628. _USHORT( ByteCount ); // Count of data bytes; min = 4
  629. UCHAR Buffer[1]; // Echoed data
  630. } RESP_ECHO;
  631. typedef RESP_ECHO SMB_UNALIGNED *PRESP_ECHO;
  632. #endif // def INCLUDE_SMB_MISC
  633. #ifdef INCLUDE_SMB_SEARCH
  634. //
  635. // Find Close2 SMB, see #3 page 54
  636. // Function is SrvFindClose2()
  637. // SMB_COM_FIND_CLOSE2 0x34
  638. //
  639. typedef struct _REQ_FIND_CLOSE2 {
  640. UCHAR WordCount; // Count of parameter words = 1
  641. _USHORT( Sid ); // Find handle
  642. _USHORT( ByteCount ); // Count of data bytes = 0
  643. UCHAR Buffer[1]; // empty
  644. } REQ_FIND_CLOSE2;
  645. typedef REQ_FIND_CLOSE2 SMB_UNALIGNED *PREQ_FIND_CLOSE2;
  646. typedef struct _RESP_FIND_CLOSE2 {
  647. UCHAR WordCount; // Count of parameter words = 0
  648. _USHORT( ByteCount ); // Count of data bytes = 0
  649. UCHAR Buffer[1]; // empty
  650. } RESP_FIND_CLOSE2;
  651. typedef RESP_FIND_CLOSE2 SMB_UNALIGNED *PRESP_FIND_CLOSE2;
  652. #endif // def INCLUDE_SMB_SEARCH
  653. #ifdef INCLUDE_SMB_SEARCH
  654. //
  655. // Find Notify Close SMB, see #3 page 53
  656. // Function is SrvSmbFindNotifyClose()
  657. // SMB_COM_FIND_NOTIFY_CLOSE 0x35
  658. //
  659. typedef struct _REQ_FIND_NOTIFY_CLOSE {
  660. UCHAR WordCount; // Count of parameter words = 1
  661. _USHORT( Handle ); // Find notify handle
  662. _USHORT( ByteCount ); // Count of data bytes = 0
  663. UCHAR Buffer[1]; // empty
  664. } REQ_FIND_NOTIFY_CLOSE;
  665. typedef REQ_FIND_NOTIFY_CLOSE SMB_UNALIGNED *PREQ_FIND_NOTIFY_CLOSE;
  666. typedef struct _RESP_FIND_NOTIFY_CLOSE {
  667. UCHAR WordCount; // Count of parameter words = 0
  668. _USHORT( ByteCount ); // Count of data bytes = 0
  669. UCHAR Buffer[1]; // empty
  670. } RESP_FIND_NOTIFY_CLOSE;
  671. typedef RESP_FIND_NOTIFY_CLOSE SMB_UNALIGNED *PRESP_FIND_NOTIFY_CLOSE;
  672. #endif // def INCLUDE_SMB_SEARCH
  673. #ifdef INCLUDE_SMB_FILE_CONTROL
  674. //
  675. // Flush SMB, see #1 page 11
  676. // Function is SrvSmbFlush()
  677. // SMB_COM_FLUSH 0x05
  678. //
  679. typedef struct _REQ_FLUSH {
  680. UCHAR WordCount; // Count of parameter words = 1
  681. _USHORT( Fid ); // File handle
  682. _USHORT( ByteCount ); // Count of data bytes = 0
  683. UCHAR Buffer[1]; // empty
  684. } REQ_FLUSH;
  685. typedef REQ_FLUSH SMB_UNALIGNED *PREQ_FLUSH;
  686. typedef struct _RESP_FLUSH {
  687. UCHAR WordCount; // Count of parameter words = 0
  688. _USHORT( ByteCount ); // Count of data bytes = 0
  689. UCHAR Buffer[1]; // empty
  690. } RESP_FLUSH;
  691. typedef RESP_FLUSH SMB_UNALIGNED *PRESP_FLUSH;
  692. #endif // def INCLUDE_SMB_FILE_CONTROL
  693. #ifdef INCLUDE_SMB_MESSAGE
  694. //
  695. // Forward User Name SMB, see #1 page 34
  696. // Function is SrvSmbForwardUserName()
  697. // SMB_COM_FORWARD_USER_NAME 0xD2
  698. //
  699. typedef struct _REQ_FORWARD_USER_NAME {
  700. UCHAR WordCount; // Count of parameter words = 0
  701. _USHORT( ByteCount ); // Count of data bytes; min = 2
  702. UCHAR Buffer[1]; // Buffer containing:
  703. //UCHAR BufferFormat; // 0x04 -- ASCII
  704. //UCHAR ForwardedName[]; // Forwarded name
  705. } REQ_FORWARD_USER_NAME;
  706. typedef REQ_FORWARD_USER_NAME SMB_UNALIGNED *PREQ_FORWARD_USER_NAME;
  707. typedef struct _RESP_FORWARD_USER_NAME {
  708. UCHAR WordCount; // Count of parameter words = 0
  709. _USHORT( ByteCount ); // Count of data bytes = 0
  710. UCHAR Buffer[1]; // empty
  711. } RESP_FORWARD_USER_NAME;
  712. typedef RESP_FORWARD_USER_NAME SMB_UNALIGNED *PRESP_FORWARD_USER_NAME;
  713. #endif // def INCLUDE_SMB_MESSAGE
  714. #ifdef INCLUDE_SMB_MESSAGE
  715. //
  716. // Get Machine Name SMB, see #1 page 35
  717. // Function is SrvSmbGetMachineName()
  718. // SMB_COM_GET_MACHINE_NAME 0xD4
  719. //
  720. typedef struct _REQ_GET_MACHINE_NAME {
  721. UCHAR WordCount; // Count of parameter words = 0
  722. _USHORT( ByteCount ); // Count of data bytes = 0
  723. UCHAR Buffer[1]; // empty
  724. } REQ_GET_MACHINE_NAME;
  725. typedef REQ_GET_MACHINE_NAME SMB_UNALIGNED *PREQ_GET_MACHINE_NAME;
  726. typedef struct _RESP_GET_MACHINE_NAME {
  727. UCHAR WordCount; // Count of parameter words = 0
  728. _USHORT( ByteCount ); // Count of data bytes; min = 2
  729. UCHAR Buffer[1]; // Buffer containing:
  730. //UCHAR BufferFormat; // 0x04 -- ASCII
  731. //UCHAR MachineName[]; // Machine name
  732. } RESP_GET_MACHINE_NAME;
  733. typedef RESP_GET_MACHINE_NAME SMB_UNALIGNED *PRESP_GET_MACHINE_NAME;
  734. #endif // def INCLUDE_SMB_MESSAGE
  735. #ifdef INCLUDE_SMB_PRINT
  736. //
  737. // Get Print Queue SMB, see #1 page 29
  738. // Function is SrvSmbGetPrintQueue()
  739. // SMB_COM_GET_PRINT_QUEUE 0xC3
  740. //
  741. typedef struct _REQ_GET_PRINT_QUEUE {
  742. UCHAR WordCount; // Count of parameter words = 2
  743. _USHORT( MaxCount ); // Max number of entries to return
  744. _USHORT( StartIndex ); // First queue entry to return
  745. _USHORT( ByteCount ); // Count of data bytes = 0
  746. UCHAR Buffer[1]; // empty
  747. } REQ_GET_PRINT_QUEUE;
  748. typedef REQ_GET_PRINT_QUEUE SMB_UNALIGNED *PREQ_GET_PRINT_QUEUE;
  749. typedef struct _RESP_GET_PRINT_QUEUE {
  750. UCHAR WordCount; // Count of parameter words = 2
  751. _USHORT( Count ); // Number of entries returned
  752. _USHORT( RestartIndex ); // Index of entry after last returned
  753. _USHORT( ByteCount ); // Count of data bytes; min = 3
  754. UCHAR Buffer[1]; // Buffer containing:
  755. //UCHAR BufferFormat; // 0x01 -- Data block
  756. //USHORT DataLength; // Length of data
  757. //UCHAR Data[]; // Queue elements
  758. } RESP_GET_PRINT_QUEUE;
  759. typedef RESP_GET_PRINT_QUEUE SMB_UNALIGNED *PRESP_GET_PRINT_QUEUE;
  760. #endif // def INCLUDE_SMB_PRINT
  761. #ifdef INCLUDE_SMB_TRANSACTION
  762. //
  763. // Ioctl SMB, see #2 page 39
  764. // Function is SrvSmbIoctl()
  765. // SMB_COM_IOCTL 0x27
  766. // SMB_COM_IOCTL_SECONDARY 0x28
  767. //
  768. typedef struct _REQ_IOCTL {
  769. UCHAR WordCount; // Count of parameter words = 14
  770. _USHORT( Fid ); // File handle
  771. _USHORT( Category ); // Device category
  772. _USHORT( Function ); // Device function
  773. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  774. _USHORT( TotalDataCount ); // Total data bytes being sent
  775. _USHORT( MaxParameterCount ); // Max parameter bytes to return
  776. _USHORT( MaxDataCount ); // Max data bytes to return
  777. _ULONG( Timeout );
  778. _USHORT( Reserved );
  779. _USHORT( ParameterCount ); // Parameter bytes sent this buffer
  780. _USHORT( ParameterOffset ); // Offset (from header start) to params
  781. _USHORT( DataCount ); // Data bytes sent this buffer
  782. _USHORT( DataOffset ); // Offset (from header start) to data
  783. _USHORT( ByteCount ); // Count of data bytes
  784. UCHAR Buffer[1]; // Buffer containing:
  785. //UCHAR Pad[]; // Pad to SHORT or LONG
  786. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  787. //UCHAR Pad1[]; // Pad to SHORT or LONG
  788. //UCHAR Data[]; // Data bytes (# = DataCount)
  789. } REQ_IOCTL;
  790. typedef REQ_IOCTL SMB_UNALIGNED *PREQ_IOCTL;
  791. typedef struct _RESP_IOCTL_INTERIM {
  792. UCHAR WordCount; // Count of parameter words = 0
  793. _USHORT( ByteCount ); // Count of data bytes = 0
  794. UCHAR Buffer[1]; // empty
  795. } RESP_IOCTL_INTERIM;
  796. typedef RESP_IOCTL_INTERIM SMB_UNALIGNED *PRESP_IOCTL_INTERIM;
  797. typedef struct _REQ_IOCTL_SECONDARY {
  798. UCHAR WordCount; // Count of parameter words = 8
  799. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  800. _USHORT( TotalDataCount ); // Total data bytes being sent
  801. _USHORT( ParameterCount ); // Parameter bytes sent this buffer
  802. _USHORT( ParameterOffset ); // Offset (from header start) to params
  803. _USHORT( ParameterDisplacement ); // Displacement of these param bytes
  804. _USHORT( DataCount ); // Data bytes sent this buffer
  805. _USHORT( DataOffset ); // Offset (from header start) to data
  806. _USHORT( DataDisplacement ); // Displacement of these data bytes
  807. _USHORT( ByteCount ); // Count of data bytes
  808. UCHAR Buffer[1]; // Buffer containing:
  809. //UCHAR Pad[]; // Pad to SHORT or LONG
  810. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  811. //UCHAR Pad1[]; // Pad to SHORT or LONG
  812. //UCHAR Data[]; // Data bytes (# = DataCount)
  813. } REQ_IOCTL_SECONDARY;
  814. typedef REQ_IOCTL_SECONDARY SMB_UNALIGNED *PREQ_IOCTL_SECONDARY;
  815. typedef struct _RESP_IOCTL {
  816. UCHAR WordCount; // Count of parameter words = 8
  817. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  818. _USHORT( TotalDataCount ); // Total data bytes being sent
  819. _USHORT( ParameterCount ); // Parameter bytes sent this buffer
  820. _USHORT( ParameterOffset ); // Offset (from header start) to params
  821. _USHORT( ParameterDisplacement ); // Displacement of these param bytes
  822. _USHORT( DataCount ); // Data bytes sent this buffer
  823. _USHORT( DataOffset ); // Offset (from header start) to data
  824. _USHORT( DataDisplacement ); // Displacement of these data bytes
  825. _USHORT( ByteCount ); // Count of data bytes
  826. UCHAR Buffer[1]; // Buffer containing:
  827. //UCHAR Pad[]; // Pad to SHORT or LONG
  828. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  829. //UCHAR Pad1[]; // Pad to SHORT or LONG
  830. //UCHAR Data[]; // Data bytes (# = DataCount)
  831. } RESP_IOCTL;
  832. typedef RESP_IOCTL SMB_UNALIGNED *PRESP_IOCTL;
  833. #endif // def INCLUDE_SMB_TRANSACTION
  834. #ifdef INCLUDE_SMB_LOCK
  835. //
  836. // Lock Byte Range SMB, see #1 page 20
  837. // Function is SrvSmbLockByteRange()
  838. // SMB_COM_LOCK_BYTE_RANGE 0x0C
  839. //
  840. typedef struct _REQ_LOCK_BYTE_RANGE {
  841. UCHAR WordCount; // Count of parameter words = 5
  842. _USHORT( Fid ); // File handle
  843. _ULONG( Count ); // Count of bytes to lock
  844. _ULONG( Offset ); // Offset from start of file
  845. _USHORT( ByteCount ); // Count of data bytes = 0
  846. UCHAR Buffer[1]; // empty
  847. } REQ_LOCK_BYTE_RANGE;
  848. typedef REQ_LOCK_BYTE_RANGE SMB_UNALIGNED *PREQ_LOCK_BYTE_RANGE;
  849. typedef struct _RESP_LOCK_BYTE_RANGE {
  850. UCHAR WordCount; // Count of parameter words = 0
  851. _USHORT( ByteCount ); // Count of data bytes = 0
  852. UCHAR Buffer[1]; // empty
  853. } RESP_LOCK_BYTE_RANGE;
  854. typedef RESP_LOCK_BYTE_RANGE SMB_UNALIGNED *PRESP_LOCK_BYTE_RANGE;
  855. #endif // def INCLUDE_SMB_LOCK
  856. #ifdef INCLUDE_SMB_LOCK
  857. //
  858. // Locking and X SMB, see #2 page 46
  859. // Function is SrvLockingAndX()
  860. // SMB_COM_LOCKING_ANDX 0x24
  861. //
  862. typedef struct _REQ_LOCKING_ANDX {
  863. UCHAR WordCount; // Count of parameter words = 8
  864. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  865. UCHAR AndXReserved; // Reserved (must be 0)
  866. _USHORT( AndXOffset ); // Offset to next command WordCount
  867. _USHORT( Fid ); // File handle
  868. //
  869. // When NT protocol is not negotiated the OplockLevel field is
  870. // omitted, and LockType field is a full word. Since the upper
  871. // bits of LockType are never used, this definition works for
  872. // all protocols.
  873. //
  874. UCHAR( LockType ); // Locking mode:
  875. // bit 0: 0 = lock out all access
  876. // 1 = read OK while locked
  877. // bit 1: 1 = 1 user total file unlock
  878. UCHAR( OplockLevel ); // The new oplock level
  879. _ULONG( Timeout );
  880. _USHORT( NumberOfUnlocks ); // Num. unlock range structs following
  881. _USHORT( NumberOfLocks ); // Num. lock range structs following
  882. _USHORT( ByteCount ); // Count of data bytes
  883. UCHAR Buffer[1]; // Buffer containing:
  884. //LOCKING_ANDX_RANGE Unlocks[]; // Unlock ranges
  885. //LOCKING_ANDX_RANGE Locks[]; // Lock ranges
  886. } REQ_LOCKING_ANDX;
  887. typedef REQ_LOCKING_ANDX SMB_UNALIGNED *PREQ_LOCKING_ANDX;
  888. #define LOCKING_ANDX_SHARED_LOCK 0x01
  889. #define LOCKING_ANDX_OPLOCK_RELEASE 0x02
  890. #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
  891. #define LOCKING_ANDX_CANCEL_LOCK 0x08
  892. #define LOCKING_ANDX_LARGE_FILES 0x10
  893. #define OPLOCK_BROKEN_TO_NONE 0
  894. #define OPLOCK_BROKEN_TO_II 1
  895. typedef struct _LOCKING_ANDX_RANGE {
  896. _USHORT( Pid ); // PID of process "owning" lock
  897. _ULONG( Offset ); // Ofset to bytes to [un]lock
  898. _ULONG( Length ); // Number of bytes to [un]lock
  899. } LOCKING_ANDX_RANGE;
  900. typedef LOCKING_ANDX_RANGE SMB_UNALIGNED *PLOCKING_ANDX_RANGE;
  901. typedef struct _NT_LOCKING_ANDX_RANGE {
  902. _USHORT( Pid ); // PID of process "owning" lock
  903. _USHORT( Pad ); // Pad to DWORD align (mbz)
  904. _ULONG( OffsetHigh ); // Ofset to bytes to [un]lock (high)
  905. _ULONG( OffsetLow ); // Ofset to bytes to [un]lock (low)
  906. _ULONG( LengthHigh ); // Number of bytes to [un]lock (high)
  907. _ULONG( LengthLow ); // Number of bytes to [un]lock (low)
  908. } NTLOCKING_ANDX_RANGE;
  909. typedef NTLOCKING_ANDX_RANGE SMB_UNALIGNED *PNTLOCKING_ANDX_RANGE;
  910. //
  911. typedef struct _RESP_LOCKING_ANDX {
  912. UCHAR WordCount; // Count of parameter words = 2
  913. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  914. UCHAR AndXReserved; // Reserved (must be 0)
  915. _USHORT( AndXOffset ); // Offset to next command WordCount
  916. _USHORT( ByteCount ); // Count of data bytes = 0
  917. UCHAR Buffer[1]; // empty
  918. } RESP_LOCKING_ANDX;
  919. typedef RESP_LOCKING_ANDX SMB_UNALIGNED *PRESP_LOCKING_ANDX;
  920. #define LOCK_BROKEN_SIZE 51 // # of bytes in lock broken notify
  921. #endif // def INCLUDE_SMB_LOCK
  922. #ifdef INCLUDE_SMB_ADMIN
  923. //
  924. // Logoff and X SMB, see #3, page 55
  925. // SMB_COM_LOGOFF_ANDX 0x74
  926. //
  927. typedef struct _REQ_LOGOFF_ANDX {
  928. UCHAR WordCount; // Count of parameter words = 2
  929. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  930. UCHAR AndXReserved; // Reserved (must be 0)
  931. _USHORT( AndXOffset ); // Offset to next command WordCount
  932. _USHORT( ByteCount ); // Count of data bytes = 0
  933. UCHAR Buffer[1]; // empty
  934. } REQ_LOGOFF_ANDX;
  935. typedef REQ_LOGOFF_ANDX SMB_UNALIGNED *PREQ_LOGOFF_ANDX;
  936. typedef struct _RESP_LOGOFF_ANDX {
  937. UCHAR WordCount; // Count of parameter words = 2
  938. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  939. UCHAR AndXReserved; // Reserved (must be 0)
  940. _USHORT( AndXOffset ); // Offset to next command WordCount
  941. _USHORT( ByteCount ); // Count of data bytes = 0
  942. UCHAR Buffer[1]; // empty
  943. } RESP_LOGOFF_ANDX;
  944. typedef RESP_LOGOFF_ANDX SMB_UNALIGNED *PRESP_LOGOFF_ANDX;
  945. #endif // def INCLUDE_SMB_ADMIN
  946. #ifdef INCLUDE_SMB_FILE_CONTROL
  947. //
  948. // Move SMB, see #2 page 49
  949. // Funcion is SrvSmbMove()
  950. // SMB_COM_MOVE 0x2A
  951. //
  952. typedef struct _REQ_MOVE {
  953. UCHAR WordCount; // Count of parameter words = 3
  954. _USHORT( Tid2 ); // Second (target) file id
  955. _USHORT( OpenFunction ); // what to do if target file exists
  956. _USHORT( Flags ); // Flags to control move operations:
  957. // 0 - target must be a file
  958. // 1 - target must be a directory
  959. // 2 - reserved (must be 0)
  960. // 3 - reserved (must be 0)
  961. // 4 - verify all writes
  962. _USHORT( ByteCount ); // Count of data bytes; min = 2
  963. UCHAR Buffer[1]; // Buffer containing:
  964. //UCHAR OldFileName[]; // Old file name
  965. //UCHAR NewFileName[]; // New file name
  966. } REQ_MOVE;
  967. typedef REQ_MOVE SMB_UNALIGNED *PREQ_MOVE;
  968. typedef struct _RESP_MOVE {
  969. UCHAR WordCount; // Count of parameter words = 1
  970. _USHORT( Count ); // Number of files moved
  971. _USHORT( ByteCount ); // Count of data bytes; min = 0
  972. UCHAR Buffer[1]; // Pathname of file where error occurred
  973. } RESP_MOVE;
  974. typedef RESP_MOVE SMB_UNALIGNED *PRESP_MOVE;
  975. #endif // def INCLUDE_SMB_FILE_CONTROL
  976. #ifdef INCLUDE_SMB_ADMIN
  977. //
  978. // Negotiate SMB's for Net 1 and Net 3, see #1 page 25 and #2 page 20
  979. // Function is SrvSmbNegotiate()
  980. // SMB_COM_NEGOTIATE 0x72
  981. //
  982. typedef struct _REQ_NEGOTIATE {
  983. UCHAR WordCount; // Count of parameter words = 0
  984. _USHORT( ByteCount ); // Count of data bytes; min = 2
  985. UCHAR Buffer[1]; // Buffer containing:
  986. //struct {
  987. // UCHAR BufferFormat; // 0x02 -- Dialect
  988. // UCHAR DialectName[]; // ASCIIZ
  989. //} Dialects[];
  990. } REQ_NEGOTIATE;
  991. typedef REQ_NEGOTIATE *PREQ_NEGOTIATE; // *** NOT SMB_UNALIGNED!
  992. typedef struct _RESP_NEGOTIATE {
  993. UCHAR WordCount; // Count of parameter words = 13
  994. _USHORT( DialectIndex ); // Index of selected dialect
  995. _USHORT( SecurityMode ); // Security mode:
  996. // bit 0: 0 = share, 1 = user
  997. // bit 1: 1 = encrypt passwords
  998. // bit 2: 1 = SMB security signatures enabled
  999. // bit 3: 1 = SMB security signatures required
  1000. _USHORT( MaxBufferSize ); // Max transmit buffer size
  1001. _USHORT( MaxMpxCount ); // Max pending multiplexed requests
  1002. _USHORT( MaxNumberVcs ); // Max VCs between client and server
  1003. _USHORT( RawMode ); // Raw modes supported:
  1004. // bit 0: 1 = Read Raw supported
  1005. // bit 1: 1 = Write Raw supported
  1006. _ULONG( SessionKey );
  1007. SMB_TIME ServerTime; // Current time at server
  1008. SMB_DATE ServerDate; // Current date at server
  1009. _USHORT( ServerTimeZone ); // Current time zone at server
  1010. _USHORT( EncryptionKeyLength ); // MBZ if this is not LM2.1
  1011. _USHORT( Reserved ); // MBZ
  1012. _USHORT( ByteCount ); // Count of data bytes
  1013. UCHAR Buffer[1]; // Password encryption key
  1014. //UCHAR EncryptionKey[]; // The challenge encryption key
  1015. //UCHAR PrimaryDomain[]; // The server's primary domain (2.1 only)
  1016. } RESP_NEGOTIATE;
  1017. typedef RESP_NEGOTIATE *PRESP_NEGOTIATE; // *** NOT SMB_UNALIGNED!
  1018. // Macros for SecurityMode field, above
  1019. #define NEGOTIATE_USER_SECURITY 0x01
  1020. #define NEGOTIATE_ENCRYPT_PASSWORDS 0x02
  1021. #define NEGOTIATE_SECURITY_SIGNATURES_ENABLED 0x04
  1022. #define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 0x08
  1023. // Macros for RawMode field, above
  1024. #define NEGOTIATE_READ_RAW_SUPPORTED 1
  1025. #define NEGOTIATE_WRITE_RAW_SUPPORTED 2
  1026. typedef struct _RESP_OLD_NEGOTIATE {
  1027. UCHAR WordCount; // Count of parameter words = 1
  1028. _USHORT( DialectIndex ); // Index of selected dialect
  1029. _USHORT( ByteCount ); // Count of data bytes = 0
  1030. UCHAR Buffer[1]; // empty
  1031. } RESP_OLD_NEGOTIATE;
  1032. typedef RESP_OLD_NEGOTIATE *PRESP_OLD_NEGOTIATE; // *** NOT SMB_UNALIGNED!
  1033. typedef struct _RESP_NT_NEGOTIATE {
  1034. UCHAR WordCount; // Count of parameter words = 17
  1035. _USHORT( DialectIndex ); // Index of selected dialect
  1036. UCHAR( SecurityMode ); // Security mode:
  1037. // bit 0: 0 = share, 1 = user
  1038. // bit 1: 1 = encrypt passwords
  1039. // bit 2: 1 = SMB sequence numbers enabled
  1040. // bit 3: 1 = SMB sequence numbers required
  1041. _USHORT( MaxMpxCount ); // Max pending multiplexed requests
  1042. _USHORT( MaxNumberVcs ); // Max VCs between client and server
  1043. _ULONG( MaxBufferSize ); // Max transmit buffer size
  1044. _ULONG( MaxRawSize ); // Maximum raw buffer size
  1045. _ULONG( SessionKey );
  1046. _ULONG( Capabilities ); // Server capabilities
  1047. _ULONG( SystemTimeLow ); // System (UTC) time of the server (low).
  1048. _ULONG( SystemTimeHigh ); // System (UTC) time of the server (high).
  1049. _USHORT( ServerTimeZone ); // Time zone of server (min from UTC)
  1050. UCHAR( EncryptionKeyLength ); // Length of encryption key.
  1051. _USHORT( ByteCount ); // Count of data bytes
  1052. UCHAR Buffer[1]; // Password encryption key
  1053. //for nonExtendedSecurity...
  1054. //UCHAR EncryptionKey[]; // The challenge encryption key
  1055. //UCHAR OemDomainName[]; // The name of the domain (in OEM chars)
  1056. //for ExtendedSecurity...
  1057. //UCHAR GUID[16]; // The server's GUID
  1058. //UCHAR SecurityBlob[]; // The blob
  1059. } RESP_NT_NEGOTIATE;
  1060. typedef RESP_NT_NEGOTIATE *PRESP_NT_NEGOTIATE; // *** NOT SMB_UNALIGNED!
  1061. #endif // def INCLUDE_SMB_ADMIN
  1062. //
  1063. // Server / workstation capabilities
  1064. // N.B. Most messages use a ULONG for this, so there are many more
  1065. // bits available.
  1066. //
  1067. #define CAP_RAW_MODE 0x0001
  1068. #define CAP_MPX_MODE 0x0002
  1069. #define CAP_UNICODE 0x0004
  1070. #define CAP_LARGE_FILES 0x0008
  1071. #define CAP_NT_SMBS 0x0010
  1072. #define CAP_RPC_REMOTE_APIS 0x0020
  1073. #define CAP_NT_STATUS 0x0040
  1074. #define CAP_LEVEL_II_OPLOCKS 0x0080
  1075. #define CAP_LOCK_AND_READ 0x0100
  1076. #define CAP_NT_FIND 0x0200
  1077. #define CAP_DFS 0x1000 // This server is DFS aware
  1078. #define CAP_INFOLEVEL_PASSTHRU 0x2000 // NT information level requests can pass through
  1079. #define CAP_LARGE_READX 0x4000 // Server supports oversized READ&X on files
  1080. #define CAP_LARGE_WRITEX 0x8000
  1081. #define CAP_RESERVED1 0x00100000 // Reserved for third party SMB server
  1082. #define CAP_RESERVED2 0x00200000 // Reserved for third party SMB server
  1083. #define CAP_RESERVED3 0x00400000 // Reserved for third party SMB server
  1084. #define CAP_UNIX 0x00800000 // This is a Unix SMB server
  1085. #define CAP_COMPRESSED_DATA 0x02000000
  1086. #define CAP_DYNAMIC_REAUTH 0x20000000
  1087. #ifdef INCLUDE_SMB_PERSISTENT
  1088. #define CAP_PERSISTENT_HANDLES 0x40000000 // Server supports persistent handles
  1089. #endif
  1090. #define CAP_EXTENDED_SECURITY 0x80000000 // Server supports extended
  1091. // validation.
  1092. #ifdef INCLUDE_SMB_OPEN_CLOSE
  1093. //
  1094. // Open SMB, see #1, page 7
  1095. // Function is SrvSmbOpen()
  1096. // SMB_COM_OPEN 0x02
  1097. //
  1098. typedef struct _REQ_OPEN {
  1099. UCHAR WordCount; // Count of parameter words = 2
  1100. _USHORT( DesiredAccess ); // Mode - read/write/share
  1101. _USHORT( SearchAttributes );
  1102. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1103. UCHAR Buffer[1]; // Buffer containing:
  1104. //UCHAR BufferFormat; // 0x04 -- ASCII
  1105. //UCHAR FileName[]; // File name
  1106. } REQ_OPEN;
  1107. typedef REQ_OPEN SMB_UNALIGNED *PREQ_OPEN;
  1108. typedef struct _RESP_OPEN {
  1109. UCHAR WordCount; // Count of parameter words = 7
  1110. _USHORT( Fid ); // File handle
  1111. _USHORT( FileAttributes );
  1112. _ULONG( LastWriteTimeInSeconds );
  1113. _ULONG( DataSize ); // File size
  1114. _USHORT( GrantedAccess ); // Access allowed
  1115. _USHORT( ByteCount ); // Count of data bytes = 0
  1116. UCHAR Buffer[1]; // empty
  1117. } RESP_OPEN;
  1118. typedef RESP_OPEN SMB_UNALIGNED *PRESP_OPEN;
  1119. #endif // def INCLUDE_SMB_OPEN_CLOSE
  1120. #ifdef INCLUDE_SMB_OPEN_CLOSE
  1121. //
  1122. // Open and X SMB, see #2 page 51
  1123. // Function is SrvOpenAndX()
  1124. // SMB_COM_OPEN_ANDX 0x2D
  1125. //
  1126. typedef struct _REQ_OPEN_ANDX {
  1127. UCHAR WordCount; // Count of parameter words = 15
  1128. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1129. UCHAR AndXReserved; // Reserved (must be 0)
  1130. _USHORT( AndXOffset ); // Offset to next command WordCount
  1131. _USHORT( Flags ); // Additional information: bit set-
  1132. // 0 - return additional info
  1133. // 1 - set single user total file lock
  1134. // 2 - server notifies consumer of
  1135. // actions which may change file
  1136. // 4 - return extended response
  1137. _USHORT( DesiredAccess ); // File open mode
  1138. _USHORT( SearchAttributes );
  1139. _USHORT( FileAttributes );
  1140. _ULONG( CreationTimeInSeconds );
  1141. _USHORT( OpenFunction );
  1142. _ULONG( AllocationSize ); // Bytes to reserve on create or truncate
  1143. _ULONG( Timeout ); // Max milliseconds to wait for resource
  1144. _ULONG( Reserved ); // Reserved (must be 0)
  1145. _USHORT( ByteCount ); // Count of data bytes; min = 1
  1146. UCHAR Buffer[1]; // File name
  1147. } REQ_OPEN_ANDX;
  1148. typedef REQ_OPEN_ANDX SMB_UNALIGNED *PREQ_OPEN_ANDX;
  1149. typedef struct _RESP_OPEN_ANDX {
  1150. UCHAR WordCount; // Count of parameter words = 15
  1151. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1152. UCHAR AndXReserved; // Reserved (must be 0)
  1153. _USHORT( AndXOffset ); // Offset to next command WordCount
  1154. _USHORT( Fid ); // File handle
  1155. _USHORT( FileAttributes );
  1156. _ULONG( LastWriteTimeInSeconds );
  1157. _ULONG( DataSize ); // Current file size
  1158. _USHORT( GrantedAccess ); // Access permissions actually allowed
  1159. _USHORT( FileType );
  1160. _USHORT( DeviceState ); // state of IPC device (e.g. pipe)
  1161. _USHORT( Action ); // Action taken
  1162. _ULONG( ServerFid ); // Server unique file id
  1163. _USHORT( Reserved ); // Reserved (must be 0)
  1164. _USHORT( ByteCount ); // Count of data bytes = 0
  1165. UCHAR Buffer[1]; // empty
  1166. } RESP_OPEN_ANDX;
  1167. typedef RESP_OPEN_ANDX SMB_UNALIGNED *PRESP_OPEN_ANDX;
  1168. typedef struct _RESP_EXTENDED_OPEN_ANDX {
  1169. UCHAR WordCount; // Count of parameter words = 15
  1170. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1171. UCHAR AndXReserved; // Reserved (must be 0)
  1172. _USHORT( AndXOffset ); // Offset to next command WordCount
  1173. _USHORT( Fid ); // File handle
  1174. _USHORT( FileAttributes );
  1175. _ULONG( LastWriteTimeInSeconds );
  1176. _ULONG( DataSize ); // Current file size
  1177. _USHORT( GrantedAccess ); // Access permissions actually allowed
  1178. _USHORT( FileType );
  1179. _USHORT( DeviceState ); // state of IPC device (e.g. pipe)
  1180. _USHORT( Action ); // Action taken
  1181. _ULONG( ServerFid ); // Server unique file id
  1182. _USHORT( Reserved ); // Reserved (must be 0)
  1183. _ULONG( MaximalAccessRights ); // maximal access rights for user
  1184. _ULONG( GuestMaximalAccessRights ); // maximal access rights for guest
  1185. _USHORT( ByteCount ); // Count of data bytes = 0
  1186. UCHAR Buffer[1]; // empty
  1187. } RESP_EXTENDED_OPEN_ANDX;
  1188. typedef RESP_EXTENDED_OPEN_ANDX SMB_UNALIGNED *PRESP_EXTENDED_OPEN_ANDX;
  1189. typedef struct _REQ_NT_CREATE_ANDX {
  1190. UCHAR WordCount; // Count of parameter words = 24
  1191. UCHAR AndXCommand; // Secondary command; 0xFF = None
  1192. UCHAR AndXReserved; // MBZ
  1193. _USHORT( AndXOffset ); // Offset to next command wordcount
  1194. UCHAR Reserved; // MBZ
  1195. _USHORT( NameLength ); // Length of Name[] in bytes
  1196. _ULONG( Flags ); // Create flags NT_CREATE_xxx
  1197. _ULONG( RootDirectoryFid ); // If non-zero, open is relative to this directory
  1198. ACCESS_MASK DesiredAccess; // NT access desired
  1199. LARGE_INTEGER AllocationSize; // Initial allocation size
  1200. _ULONG( FileAttributes ); // File attributes for creation
  1201. _ULONG( ShareAccess ); // Type of share access
  1202. _ULONG( CreateDisposition ); // Action to take if file exists or not
  1203. _ULONG( CreateOptions ); // Options to use if creating a file
  1204. _ULONG( ImpersonationLevel ); // Security QOS information
  1205. UCHAR SecurityFlags; // Security QOS information
  1206. _USHORT( ByteCount ); // Length of byte parameters
  1207. UCHAR Buffer[1];
  1208. //UCHAR Name[]; // File to open or create
  1209. } REQ_NT_CREATE_ANDX;
  1210. typedef REQ_NT_CREATE_ANDX SMB_UNALIGNED *PREQ_NT_CREATE_ANDX;
  1211. // Flag bit for Security flags
  1212. #define SMB_SECURITY_DYNAMIC_TRACKING 0x01
  1213. #define SMB_SECURITY_EFFECTIVE_ONLY 0x02
  1214. typedef struct _RESP_NT_CREATE_ANDX {
  1215. UCHAR WordCount; // Count of parameter words = 26
  1216. UCHAR AndXCommand; // Secondary command; 0xFF = None
  1217. UCHAR AndXReserved; // MBZ
  1218. _USHORT( AndXOffset ); // Offset to next command wordcount
  1219. UCHAR OplockLevel; // The oplock level granted
  1220. _USHORT( Fid ); // The file ID
  1221. _ULONG( CreateAction ); // The action taken
  1222. TIME CreationTime; // The time the file was created
  1223. TIME LastAccessTime; // The time the file was accessed
  1224. TIME LastWriteTime; // The time the file was last written
  1225. TIME ChangeTime; // The time the file was last changed
  1226. _ULONG( FileAttributes ); // The file attributes
  1227. LARGE_INTEGER AllocationSize; // The number of byes allocated
  1228. LARGE_INTEGER EndOfFile; // The end of file offset
  1229. _USHORT( FileType );
  1230. union {
  1231. _USHORT( DeviceState ); // state of IPC device (e.g. pipe)
  1232. _USHORT( FileStatusFlags ); // if a file or directory. See below.
  1233. };
  1234. BOOLEAN Directory; // TRUE if this is a directory
  1235. _USHORT( ByteCount ); // = 0
  1236. UCHAR Buffer[1];
  1237. } RESP_NT_CREATE_ANDX;
  1238. typedef RESP_NT_CREATE_ANDX SMB_UNALIGNED *PRESP_NT_CREATE_ANDX;
  1239. typedef struct _RESP_EXTENDED_NT_CREATE_ANDX {
  1240. UCHAR WordCount; // Count of parameter words = 42
  1241. UCHAR AndXCommand; // Secondary command; 0xFF = None
  1242. UCHAR AndXReserved; // MBZ
  1243. _USHORT( AndXOffset ); // Offset to next command wordcount
  1244. UCHAR OplockLevel; // The oplock level granted
  1245. _USHORT( Fid ); // The file ID
  1246. _ULONG( CreateAction ); // The action taken
  1247. TIME CreationTime; // The time the file was created
  1248. TIME LastAccessTime; // The time the file was accessed
  1249. TIME LastWriteTime; // The time the file was last written
  1250. TIME ChangeTime; // The time the file was last changed
  1251. _ULONG( FileAttributes ); // The file attributes
  1252. LARGE_INTEGER AllocationSize; // The number of byes allocated
  1253. LARGE_INTEGER EndOfFile; // The end of file offset
  1254. _USHORT( FileType );
  1255. union {
  1256. _USHORT( DeviceState ); // state of the pipe
  1257. _USHORT( FileStatusFlags ); // if a file or directory. See below.
  1258. };
  1259. BOOLEAN Directory; // TRUE if this is a directory
  1260. UCHAR VolumeGuid[16]; // the volume GUID
  1261. UCHAR FileId[8]; // the file id
  1262. _ULONG ( MaximalAccessRights ); // the access rights for the session owner
  1263. _ULONG ( GuestMaximalAccessRights ); // the maximal access rights for guest
  1264. _USHORT( ByteCount ); // = 0
  1265. UCHAR Buffer[1];
  1266. } RESP_EXTENDED_NT_CREATE_ANDX;
  1267. typedef RESP_EXTENDED_NT_CREATE_ANDX SMB_UNALIGNED *PRESP_EXTENDED_NT_CREATE_ANDX;
  1268. //
  1269. // This request is identical to REQ_NT_CREATE_ANDX up to CreationTime.
  1270. // The SMB command code is the same, Flags has NT_CREATE_IFMODIFIED_REQUEST
  1271. // ORed in.
  1272. //
  1273. #ifdef INCLUDE_SMB_IFMODIFIED
  1274. #define SMB_REQ_EXTENDED_NT_CREATE_ANDX2_WORK_COUNT 48
  1275. typedef struct _REQ_NT_CREATE_IF_MODIFIED_ANDX {
  1276. UCHAR WordCount; // Count of parameter words = 48
  1277. UCHAR AndXCommand; // Secondary command; 0xFF = None
  1278. UCHAR AndXReserved; // MBZ
  1279. _USHORT( AndXOffset ); // Offset to next command wordcount
  1280. UCHAR Reserved; // MBZ
  1281. _USHORT( NameLength ); // Length of Name[] in bytes
  1282. _ULONG( Flags ); // Create flags NT_CREATE_xxx
  1283. _ULONG( RootDirectoryFid ); // If non-zero, open is relative to this directory
  1284. ACCESS_MASK DesiredAccess; // NT access desired
  1285. LARGE_INTEGER AllocationSize; // Initial allocation size
  1286. _ULONG( FileAttributes ); // File attributes for creation
  1287. _ULONG( ShareAccess ); // Type of share access
  1288. _ULONG( CreateDisposition ); // Action to take if file exists or not
  1289. _ULONG( CreateOptions ); // Options to use if creating a file
  1290. _ULONG( ImpersonationLevel ); // Security QOS information
  1291. UCHAR SecurityFlags; // Security QOS information
  1292. // the following fields are filled in by the client, if they all match the
  1293. // current file (and attributes also matches), the file is closed
  1294. // automatically and returns with status code of STATUS_FILE_CLOSED.
  1295. TIME CreationTime; // The time the file was created
  1296. TIME LastWriteTime; // The time the file was last written
  1297. TIME ChangeTime; // The time the file was last changed
  1298. LARGE_INTEGER EndOfFile; // The end of file offset
  1299. LARGE_INTEGER UsnValue; // The file's USN # in NTFS
  1300. LARGE_INTEGER FileReferenceNumber; //
  1301. _USHORT( ByteCount ); // Length of byte parameters
  1302. UCHAR Buffer[1];
  1303. //UCHAR Name[]; // File to open or create
  1304. } REQ_NT_CREATE_IF_MODIFIED_ANDX;
  1305. typedef REQ_NT_CREATE_IF_MODIFIED_ANDX SMB_UNALIGNED *PREQ_NT_CREATE_IF_MODIFIED_ANDX;
  1306. #define SMB_SHORT_NAME_LENGTH 13
  1307. #define SMB_RESP_EXTENDED_NT_CREATE_ANDX2_WORK_COUNT 71
  1308. typedef struct _RESP_EXTENDED_NT_CREATE_ANDX2 {
  1309. UCHAR WordCount; // Count of parameter words = 71
  1310. UCHAR AndXCommand; // Secondary command; 0xFF = None
  1311. UCHAR AndXReserved; // MBZ
  1312. _USHORT( AndXOffset ); // Offset to next command wordcount
  1313. UCHAR OplockLevel; // The oplock level granted
  1314. _USHORT( Fid ); // The file ID
  1315. _ULONG( CreateAction ); // The action taken
  1316. TIME CreationTime; // The time the file was created
  1317. TIME LastAccessTime; // The time the file was accessed
  1318. TIME LastWriteTime; // The time the file was last written
  1319. TIME ChangeTime; // The time the file was last changed
  1320. _ULONG( FileAttributes ); // The file attributes
  1321. LARGE_INTEGER AllocationSize; // The number of byes allocated
  1322. LARGE_INTEGER EndOfFile; // The end of file offset
  1323. _USHORT( FileType );
  1324. union {
  1325. _USHORT( DeviceState ); // state of the pipe
  1326. _USHORT( FileStatusFlags ); // if a file or directory. See below.
  1327. };
  1328. BOOLEAN Directory; // TRUE if this is a directory
  1329. UCHAR VolumeGuid[16]; // the volume GUID
  1330. UCHAR FileId[8]; // the file id
  1331. _ULONG ( MaximalAccessRights ); // the access rights for the session owner
  1332. _ULONG ( GuestMaximalAccessRights ); // the maximal access rights for guest
  1333. // below here is where it differs from RESP_EXTENDED_NT_CREATE_ANDX
  1334. LARGE_INTEGER UsnValue; // The file's USN # in NTFS
  1335. LARGE_INTEGER FileReferenceNumber; //
  1336. WCHAR ShortName[SMB_SHORT_NAME_LENGTH]; // null terminated. if not present, empty string.
  1337. _USHORT( ByteCount ); // length of long name
  1338. WCHAR Buffer[1]; // long name goes here in unicode
  1339. } RESP_EXTENDED_NT_CREATE_ANDX2;
  1340. typedef RESP_EXTENDED_NT_CREATE_ANDX2 SMB_UNALIGNED *PRESP_EXTENDED_NT_CREATE_ANDX2;
  1341. #endif // def INCLUDE_SMB_IFMODIFIED
  1342. //
  1343. // Values for FileStatusFlags, if the opened resource is a file or directory
  1344. //
  1345. #define SMB_FSF_NO_EAS 0x0001 // file/dir has no extended attributes
  1346. #define SMB_FSF_NO_SUBSTREAMS 0x0002 // file/dir has no substreams
  1347. #define SMB_FSF_NO_REPARSETAG 0x0004 // file/dir is not a reparse point
  1348. #define SMB_OPLOCK_LEVEL_NONE 0
  1349. #define SMB_OPLOCK_LEVEL_EXCLUSIVE 1
  1350. #define SMB_OPLOCK_LEVEL_BATCH 2
  1351. #define SMB_OPLOCK_LEVEL_II 3
  1352. #endif // def INCLUDE_SMB_OPEN_CLOSE
  1353. #ifdef INCLUDE_SMB_PRINT
  1354. //
  1355. // Open Print File SMB, see #1 page 27
  1356. // Function is SrvSmbOpenPrintFile()
  1357. // SMB_COM_OPEN_PRINT_FILE 0xC0
  1358. //
  1359. typedef struct _REQ_OPEN_PRINT_FILE {
  1360. UCHAR WordCount; // Count of parameter words = 2
  1361. _USHORT( SetupLength ); // Length of printer setup data
  1362. _USHORT( Mode ); // 0 = Text mode (DOS expands TABs)
  1363. // 1 = Graphics mode
  1364. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1365. UCHAR Buffer[1]; // Buffer containing:
  1366. //UCHAR BufferFormat; // 0x04 -- ASCII
  1367. //UCHAR IdentifierString[]; // Identifier string
  1368. } REQ_OPEN_PRINT_FILE;
  1369. typedef REQ_OPEN_PRINT_FILE SMB_UNALIGNED *PREQ_OPEN_PRINT_FILE;
  1370. typedef struct _RESP_OPEN_PRINT_FILE {
  1371. UCHAR WordCount; // Count of parameter words = 1
  1372. _USHORT( Fid ); // File handle
  1373. _USHORT( ByteCount ); // Count of data bytes = 0
  1374. UCHAR Buffer[1]; // empty
  1375. } RESP_OPEN_PRINT_FILE;
  1376. typedef RESP_OPEN_PRINT_FILE SMB_UNALIGNED *PRESP_OPEN_PRINT_FILE;
  1377. #endif // def INCLUDE_SMB_PRINT
  1378. #ifdef INCLUDE_SMB_ADMIN
  1379. //
  1380. // Process Exit SMB, see #1 page 22
  1381. // Function is SrvSmbProcessExit()
  1382. // SMB_COM_PROCESS_EXIT 0x11
  1383. //
  1384. typedef struct _REQ_PROCESS_EXIT {
  1385. UCHAR WordCount; // Count of parameter words = 0
  1386. _USHORT( ByteCount ); // Count of data bytes = 0
  1387. UCHAR Buffer[1]; // empty
  1388. } REQ_PROCESS_EXIT;
  1389. typedef REQ_PROCESS_EXIT SMB_UNALIGNED *PREQ_PROCESS_EXIT;
  1390. typedef struct _RESP_PROCESS_EXIT {
  1391. UCHAR WordCount; // Count of parameter words = 0
  1392. _USHORT( ByteCount ); // Count of data bytes = 0
  1393. UCHAR Buffer[1]; // empty
  1394. } RESP_PROCESS_EXIT;
  1395. typedef RESP_PROCESS_EXIT SMB_UNALIGNED *PRESP_PROCESS_EXIT;
  1396. #endif // def INCLUDE_SMB_ADMIN
  1397. #ifdef INCLUDE_SMB_QUERY_SET
  1398. //
  1399. // Query Information SMB, see #1 page 18
  1400. // Function is SrvSmbQueryInformation()
  1401. // SMB_COM_QUERY_INFORMATION 0x08
  1402. //
  1403. typedef struct _REQ_QUERY_INFORMATION {
  1404. UCHAR WordCount; // Count of parameter words = 0
  1405. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1406. UCHAR Buffer[1]; // Buffer containing:
  1407. //UCHAR BufferFormat; // 0x04 -- ASCII
  1408. //UCHAR FileName[]; // File name
  1409. } REQ_QUERY_INFORMATION;
  1410. typedef REQ_QUERY_INFORMATION SMB_UNALIGNED *PREQ_QUERY_INFORMATION;
  1411. typedef struct _RESP_QUERY_INFORMATION {
  1412. UCHAR WordCount; // Count of parameter words = 10
  1413. _USHORT( FileAttributes );
  1414. _ULONG( LastWriteTimeInSeconds );
  1415. _ULONG( FileSize ); // File size
  1416. _USHORT( Reserved )[5]; // Reserved (must be 0)
  1417. _USHORT( ByteCount ); // Count of data bytes = 0
  1418. UCHAR Buffer[1]; // empty
  1419. } RESP_QUERY_INFORMATION;
  1420. typedef RESP_QUERY_INFORMATION SMB_UNALIGNED *PRESP_QUERY_INFORMATION;
  1421. #endif // def INCLUDE_SMB_QUERY_SET
  1422. #ifdef INCLUDE_SMB_QUERY_SET
  1423. //
  1424. // Query Information2 SMB, see #2 page 37
  1425. // Function is SrvSmbQueryInformation2()
  1426. // SMB_COM_QUERY_INFORMATION2 0x23
  1427. //
  1428. typedef struct _REQ_QUERY_INFORMATION2 {
  1429. UCHAR WordCount; // Count of parameter words = 2
  1430. _USHORT( Fid ); // File handle
  1431. _USHORT( ByteCount ); // Count of data bytes = 0
  1432. UCHAR Buffer[1]; // empty
  1433. } REQ_QUERY_INFORMATION2;
  1434. typedef REQ_QUERY_INFORMATION2 SMB_UNALIGNED *PREQ_QUERY_INFORMATION2;
  1435. typedef struct _RESP_QUERY_INFORMATION2 {
  1436. UCHAR WordCount; // Count of parameter words = 11
  1437. SMB_DATE CreationDate;
  1438. SMB_TIME CreationTime;
  1439. SMB_DATE LastAccessDate;
  1440. SMB_TIME LastAccessTime;
  1441. SMB_DATE LastWriteDate;
  1442. SMB_TIME LastWriteTime;
  1443. _ULONG( FileDataSize ); // File end of data
  1444. _ULONG( FileAllocationSize ); // File allocation size
  1445. _USHORT( FileAttributes );
  1446. _USHORT( ByteCount ); // Count of data bytes; min = 0
  1447. UCHAR Buffer[1]; // Reserved buffer
  1448. } RESP_QUERY_INFORMATION2;
  1449. typedef RESP_QUERY_INFORMATION2 SMB_UNALIGNED *PRESP_QUERY_INFORMATION2;
  1450. #endif // def INCLUDE_SMB_QUERY_SET
  1451. #ifdef INCLUDE_SMB_MISC
  1452. //
  1453. // Query Information Disk SMB, see #1 page 24
  1454. // Function is SrvSmbQueryInformationDisk()
  1455. // SMB_COM_QUERY_INFORMATION_DISK 0x80
  1456. //
  1457. typedef struct _REQ_QUERY_INFORMATION_DISK {
  1458. UCHAR WordCount; // Count of parameter words = 0
  1459. _USHORT( ByteCount ); // Count of data bytes = 0
  1460. UCHAR Buffer[1]; // empty
  1461. } REQ_QUERY_INFORMATION_DISK;
  1462. typedef REQ_QUERY_INFORMATION_DISK SMB_UNALIGNED *PREQ_QUERY_INFORMATION_DISK;
  1463. typedef struct _RESP_QUERY_INFORMATION_DISK {
  1464. UCHAR WordCount; // Count of parameter words = 5
  1465. _USHORT( TotalUnits ); // Total allocation units per server
  1466. _USHORT( BlocksPerUnit ); // Blocks per allocation unit
  1467. _USHORT( BlockSize ); // Block size (in bytes)
  1468. _USHORT( FreeUnits ); // Number of free units
  1469. _USHORT( Reserved ); // Reserved (media identification code)
  1470. _USHORT( ByteCount ); // Count of data bytes = 0
  1471. UCHAR Buffer[1]; // empty
  1472. } RESP_QUERY_INFORMATION_DISK;
  1473. typedef RESP_QUERY_INFORMATION_DISK SMB_UNALIGNED *PRESP_QUERY_INFORMATION_DISK;
  1474. #endif // def INCLUDE_SMB_MISC
  1475. #ifdef INCLUDE_SMB_MISC
  1476. //
  1477. // Query Server Information SMB, see #? page ??
  1478. // Function is SrvSmbQueryInformationServer
  1479. // SMB_COM_QUERY_INFORMATION_SRV 0x21
  1480. //
  1481. typedef struct _REQ_QUERY_INFORMATION_SRV {
  1482. UCHAR WordCount; // Count of parameter words = 1
  1483. _USHORT( Mode );
  1484. _USHORT( ByteCount ); // Count of data bytes; min =
  1485. UCHAR Buffer[1]; //
  1486. } REQ_QUERY_INFORMATION_SRV;
  1487. typedef REQ_QUERY_INFORMATION_SRV SMB_UNALIGNED *PREQ_QUERY_INFORMATION_SRV;
  1488. typedef struct _RESP_QUERY_INFORMATION_SRV {
  1489. UCHAR WordCount; // Count of parameter words = 20
  1490. _ULONG( smb_fsid );
  1491. _ULONG( BlocksPerUnit );
  1492. _ULONG( smb_aunits );
  1493. _ULONG( smb_fau );
  1494. _USHORT( BlockSize );
  1495. SMB_DATE smb_vldate;
  1496. SMB_TIME smb_vltime;
  1497. UCHAR smb_vllen;
  1498. UCHAR Reserved; // Reserved (must be 0)
  1499. _USHORT( SecurityMode );
  1500. _USHORT( BlockMode );
  1501. _ULONG( Services );
  1502. _USHORT( MaxTransmitSize );
  1503. _USHORT( MaxMpxCount );
  1504. _USHORT( MaxNumberVcs );
  1505. SMB_TIME ServerTime;
  1506. SMB_DATE ServerDate;
  1507. _USHORT( ServerTimeZone );
  1508. _ULONG( Reserved2 );
  1509. _USHORT( ByteCount ); // Count of data bytes; min =
  1510. UCHAR Buffer[1]; //
  1511. } RESP_QUERY_INFORMATION_SRV;
  1512. typedef RESP_QUERY_INFORMATION_SRV SMB_UNALIGNED *PRESP_QUERY_INFORMATION_SRV;
  1513. #endif // def INCLUDE_SMB_MISC
  1514. #ifdef INCLUDE_SMB_READ_WRITE
  1515. //
  1516. // Read SMB, see #1 page 12
  1517. // Lock and Read SMB, see #2 page 44
  1518. // SMB_COM_READ 0x0A, Function is SrvSmbRead
  1519. // SMB_COM_LOCK_AND_READ 0x13, Function is SrvSmbLockAndRead
  1520. //
  1521. typedef struct _REQ_READ {
  1522. UCHAR WordCount; // Count of parameter words = 5
  1523. _USHORT( Fid ); // File handle
  1524. _USHORT( Count ); // Count of bytes being requested
  1525. _ULONG( Offset ); // Offset in file of first byte to read
  1526. _USHORT( Remaining ); // Estimate of bytes to read if nonzero
  1527. _USHORT( ByteCount ); // Count of data bytes = 0
  1528. UCHAR Buffer[1]; // empty
  1529. } REQ_READ;
  1530. typedef REQ_READ SMB_UNALIGNED *PREQ_READ;
  1531. //
  1532. // *** Warning: the following structure is defined the way it is to
  1533. // ensure longword alignment of the data buffer. (This only matters
  1534. // when packing is disabled; when packing is turned on, the right
  1535. // thing happens no matter what.)
  1536. //
  1537. typedef struct _RESP_READ {
  1538. UCHAR WordCount; // Count of parameter words = 5
  1539. _USHORT( Count ); // Count of bytes actually returned
  1540. _USHORT( Reserved )[4]; // Reserved (must be 0)
  1541. _USHORT( ByteCount ); // Count of data bytes
  1542. //UCHAR Buffer[1]; // Buffer containing:
  1543. UCHAR BufferFormat; // 0x01 -- Data block
  1544. _USHORT( DataLength ); // Length of data
  1545. ULONG Buffer[1]; // Data
  1546. } RESP_READ;
  1547. typedef RESP_READ SMB_UNALIGNED *PRESP_READ;
  1548. #endif // def INCLUDE_SMB_READ_WRITE
  1549. #ifdef INCLUDE_SMB_READ_WRITE
  1550. //
  1551. // Read and X SMB, see #2 page 56
  1552. // Function is SrvSmbReadAndX()
  1553. // SMB_COM_READ_ANDX 0x2E
  1554. //
  1555. typedef struct _REQ_READ_ANDX {
  1556. UCHAR WordCount; // Count of parameter words = 10
  1557. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1558. UCHAR AndXReserved; // Reserved (must be 0)
  1559. _USHORT( AndXOffset ); // Offset to next command WordCount
  1560. _USHORT( Fid ); // File handle
  1561. _ULONG( Offset ); // Offset in file to begin read
  1562. _USHORT( MaxCount ); // Max number of bytes to return
  1563. _USHORT( MinCount ); // Min number of bytes to return
  1564. _ULONG( Timeout );
  1565. _USHORT( Remaining ); // Bytes remaining to satisfy request
  1566. _USHORT( ByteCount ); // Count of data bytes = 0
  1567. UCHAR Buffer[1]; // empty
  1568. } REQ_READ_ANDX;
  1569. typedef REQ_READ_ANDX SMB_UNALIGNED *PREQ_READ_ANDX;
  1570. typedef struct _REQ_NT_READ_ANDX {
  1571. UCHAR WordCount; // Count of parameter words = 12
  1572. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1573. UCHAR AndXReserved; // Reserved (must be 0)
  1574. _USHORT( AndXOffset ); // Offset to next command WordCount
  1575. _USHORT( Fid ); // File handle
  1576. _ULONG( Offset ); // Offset in file to begin read
  1577. _USHORT( MaxCount ); // Max number of bytes to return
  1578. _USHORT( MinCount ); // Min number of bytes to return
  1579. union {
  1580. _ULONG( Timeout );
  1581. _USHORT( MaxCountHigh ); // upper 16 bits of MaxCount if NT request
  1582. };
  1583. _USHORT( Remaining ); // Bytes remaining to satisfy request
  1584. _ULONG( OffsetHigh ); // Used for NT Protocol only
  1585. // Upper 32 bits of offset
  1586. _USHORT( ByteCount ); // Count of data bytes = 0
  1587. UCHAR Buffer[1]; // empty
  1588. } REQ_NT_READ_ANDX;
  1589. typedef REQ_NT_READ_ANDX SMB_UNALIGNED *PREQ_NT_READ_ANDX;
  1590. typedef struct _RESP_READ_ANDX {
  1591. UCHAR WordCount; // Count of parameter words = 12
  1592. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1593. UCHAR AndXReserved; // Reserved (must be 0)
  1594. _USHORT( AndXOffset ); // Offset to next command WordCount
  1595. _USHORT( Remaining ); // Bytes remaining to be read
  1596. _USHORT( DataCompactionMode );
  1597. union {
  1598. _USHORT(CdiLength); // COMPRESSED_DATA_INFO length
  1599. _USHORT( Reserved ); // Reserved (must be 0)
  1600. };
  1601. _USHORT( DataLength ); // Number of data bytes (min = 0)
  1602. _USHORT( DataOffset ); // Offset (from header start) to data
  1603. union {
  1604. _USHORT( Reserved2 ); // Reserved (must be 0)
  1605. _USHORT( DataLengthHigh ); // upper 16 bits of DataLength if NT request
  1606. };
  1607. _ULONG( Reserved3 )[2]; // Reserved (must be 0)
  1608. _USHORT( ByteCount ); // Count of data bytes. Inaccurate if we
  1609. // are doing large Read&X's!
  1610. UCHAR Buffer[1]; // Buffer containing:
  1611. //UCHAR Pad[]; // Pad to SHORT or LONG
  1612. //UCHAR Data[]; // Data (size = DataLength)
  1613. } RESP_READ_ANDX;
  1614. typedef RESP_READ_ANDX SMB_UNALIGNED *PRESP_READ_ANDX;
  1615. #endif // def INCLUDE_SMB_READ_WRITE
  1616. #ifdef INCLUDE_SMB_MPX
  1617. //
  1618. // Read Block Multiplexed SMB, see #2 page 58
  1619. // Function is SrvSmbReadMpx()
  1620. // SMB_COM_READ_MPX 0x1B
  1621. // SMB_COM_READ_MPX_SECONDARY 0x1C
  1622. //
  1623. typedef struct _REQ_READ_MPX {
  1624. UCHAR WordCount; // Count of parameter words = 8
  1625. _USHORT( Fid ); // File handle
  1626. _ULONG( Offset ); // Offset in file to begin read
  1627. _USHORT( MaxCount ); // Max bytes to return (max 65535)
  1628. _USHORT( MinCount ); // Min bytes to return (normally 0)
  1629. _ULONG( Timeout );
  1630. _USHORT( Reserved );
  1631. _USHORT( ByteCount ); // Count of data bytes = 0
  1632. UCHAR Buffer[1]; // empty
  1633. } REQ_READ_MPX;
  1634. typedef REQ_READ_MPX SMB_UNALIGNED *PREQ_READ_MPX;
  1635. typedef struct _RESP_READ_MPX {
  1636. UCHAR WordCount; // Count of parameter words = 8
  1637. _ULONG( Offset ); // Offset in file where data read
  1638. _USHORT( Count ); // Total bytes being returned
  1639. _USHORT( Remaining ); // Bytes remaining to be read (pipe/dev)
  1640. _USHORT( DataCompactionMode );
  1641. _USHORT( Reserved );
  1642. _USHORT( DataLength ); // Number of data bytes this buffer
  1643. _USHORT( DataOffset ); // Offset (from header start) to data
  1644. _USHORT( ByteCount ); // Count of data bytes
  1645. UCHAR Buffer[1]; // Buffer containing:
  1646. //UCHAR Pad[]; // Pad to SHORT or LONG
  1647. //UCHAR Data[]; // Data (size = DataLength)
  1648. } RESP_READ_MPX;
  1649. typedef RESP_READ_MPX SMB_UNALIGNED *PRESP_READ_MPX;
  1650. #endif // def INCLUDE_SMB_MPX
  1651. #ifdef INCLUDE_SMB_RAW
  1652. //
  1653. // Read Block Raw SMB, see #2 page 61
  1654. // Function is SrvSmbReadRaw()
  1655. // SMB_COM_READ_RAW 0x1A
  1656. //
  1657. typedef struct _REQ_READ_RAW {
  1658. UCHAR WordCount; // Count of parameter words = 8
  1659. _USHORT( Fid ); // File handle
  1660. _ULONG( Offset ); // Offset in file to begin read
  1661. _USHORT( MaxCount ); // Max bytes to return (max 65535)
  1662. _USHORT( MinCount ); // Min bytes to return (normally 0)
  1663. _ULONG( Timeout );
  1664. _USHORT( Reserved );
  1665. _USHORT( ByteCount ); // Count of data bytes = 0
  1666. UCHAR Buffer[1]; // empty
  1667. } REQ_READ_RAW;
  1668. typedef REQ_READ_RAW SMB_UNALIGNED *PREQ_READ_RAW;
  1669. typedef struct _REQ_NT_READ_RAW {
  1670. UCHAR WordCount; // Count of parameter words = 10
  1671. _USHORT( Fid ); // File handle
  1672. _ULONG( Offset ); // Offset in file to begin read
  1673. _USHORT( MaxCount ); // Max bytes to return (max 65535)
  1674. _USHORT( MinCount ); // Min bytes to return (normally 0)
  1675. _ULONG( Timeout );
  1676. _USHORT( Reserved );
  1677. _ULONG( OffsetHigh ); // Used for NT Protocol only
  1678. // Upper 32 bits of offset
  1679. _USHORT( ByteCount ); // Count of data bytes = 0
  1680. UCHAR Buffer[1]; // empty
  1681. } REQ_NT_READ_RAW;
  1682. typedef REQ_NT_READ_RAW SMB_UNALIGNED *PREQ_NT_READ_RAW;
  1683. // No response params for raw read--the response is the raw data.
  1684. #endif // def INCLUDE_SMB_RAW
  1685. #ifdef INCLUDE_SMB_FILE_CONTROL
  1686. //
  1687. // Rename SMB, see #1 page 17
  1688. // Function is SrvSmbRename()
  1689. // SMB_COM_RENAME 0x07
  1690. //
  1691. typedef struct _REQ_RENAME {
  1692. UCHAR WordCount; // Count of parameter words = 1
  1693. _USHORT( SearchAttributes );
  1694. _USHORT( ByteCount ); // Count of data bytes; min = 4
  1695. UCHAR Buffer[1]; // Buffer containing:
  1696. //UCHAR BufferFormat1; // 0x04 -- ASCII
  1697. //UCHAR OldFileName[]; // Old file name
  1698. //UCHAR BufferFormat2; // 0x04 -- ASCII
  1699. //UCHAR NewFileName[]; // New file name
  1700. } REQ_RENAME;
  1701. typedef REQ_RENAME SMB_UNALIGNED *PREQ_RENAME;
  1702. //
  1703. // Extended NT rename SMB
  1704. // Function is SrvSmbRename()
  1705. // SMB_COM_NT_RENAME 0xA5
  1706. //
  1707. typedef struct _REQ_NTRENAME {
  1708. UCHAR WordCount; // Count of parameter words = 4
  1709. _USHORT( SearchAttributes );
  1710. _USHORT( InformationLevel );
  1711. _ULONG( ClusterCount );
  1712. _USHORT( ByteCount ); // Count of data bytes; min = 4
  1713. UCHAR Buffer[1]; // Buffer containing:
  1714. //UCHAR BufferFormat1; // 0x04 -- ASCII
  1715. //UCHAR OldFileName[]; // Old file name
  1716. //UCHAR BufferFormat2; // 0x04 -- ASCII
  1717. //UCHAR NewFileName[]; // New file name
  1718. } REQ_NTRENAME;
  1719. typedef REQ_NTRENAME SMB_UNALIGNED *PREQ_NTRENAME;
  1720. typedef struct _RESP_RENAME {
  1721. UCHAR WordCount; // Count of parameter words = 0
  1722. _USHORT( ByteCount ); // Count of data bytes = 0
  1723. UCHAR Buffer[1]; // empty
  1724. } RESP_RENAME;
  1725. typedef RESP_RENAME SMB_UNALIGNED *PRESP_RENAME;
  1726. #endif // def INCLUDE_SMB_FILE_CONTROL
  1727. #ifdef INCLUDE_SMB_SEARCH
  1728. //
  1729. // Search SMBs. One structure is common for both the core Search and the
  1730. // LAN Manager 1.0 Find First/Next/Close.
  1731. //
  1732. // Function is SrvSmbSearch()
  1733. //
  1734. // Search, see #1 page 26
  1735. // SMB_COM_SEARCH 0x81
  1736. // FindFirst and FindNext, see #2 page 27
  1737. // SMB_COM_FIND 0x82
  1738. // FindUnique, see #2 page 33
  1739. // SMB_COM_FIND_UNIQUE 0x83
  1740. // FindClose, see #2 page 31
  1741. // SMB_COM_FIND_CLOSE 0x84
  1742. //
  1743. typedef struct _REQ_SEARCH {
  1744. UCHAR WordCount; // Count of parameter words = 2
  1745. _USHORT( MaxCount ); // Number of dir. entries to return
  1746. _USHORT( SearchAttributes );
  1747. _USHORT( ByteCount ); // Count of data bytes; min = 5
  1748. UCHAR Buffer[1]; // Buffer containing:
  1749. //UCHAR BufferFormat1; // 0x04 -- ASCII
  1750. //UCHAR FileName[]; // File name, may be null
  1751. //UCHAR BufferFormat2; // 0x05 -- Variable block
  1752. //USHORT ResumeKeyLength; // Length of resume key, may be 0
  1753. //UCHAR SearchStatus[]; // Resume key
  1754. } REQ_SEARCH;
  1755. typedef REQ_SEARCH SMB_UNALIGNED *PREQ_SEARCH;
  1756. typedef struct _RESP_SEARCH {
  1757. UCHAR WordCount; // Count of parameter words = 1
  1758. _USHORT( Count ); // Number of entries returned
  1759. _USHORT( ByteCount ); // Count of data bytes; min = 3
  1760. UCHAR Buffer[1]; // Buffer containing:
  1761. //UCHAR BufferFormat; // 0x05 -- Variable block
  1762. //USHORT DataLength; // Length of data
  1763. //UCHAR Data[]; // Data
  1764. } RESP_SEARCH;
  1765. typedef RESP_SEARCH SMB_UNALIGNED *PRESP_SEARCH;
  1766. //
  1767. // These two structures are use to return information in the Search SMBs.
  1768. // SMB_DIRECTORY_INFORMATION is used to return information about a file
  1769. // that was found. In addition to the usual information about the file,
  1770. // each of these structures contains an SMB_RESUME_KEY, which is used to
  1771. // continue or rewind a search.
  1772. //
  1773. // These structures must be packed, so turn on packing if it isn't
  1774. // already on.
  1775. //
  1776. #ifdef NO_PACKING
  1777. #include <packon.h>
  1778. #endif // def NO_PACKING
  1779. typedef struct _SMB_RESUME_KEY {
  1780. UCHAR Reserved; // bit 7 - comsumer use
  1781. // bits 5,6 - system use (must preserve)
  1782. // bits 0-4 - server use (must preserve)
  1783. UCHAR FileName[11];
  1784. UCHAR Sid; // Uniquely identifies Find through Close
  1785. _ULONG( FileIndex ); // Reserved for server use
  1786. UCHAR Consumer[4]; // Reserved for comsumer use
  1787. } SMB_RESUME_KEY;
  1788. typedef SMB_RESUME_KEY SMB_UNALIGNED *PSMB_RESUME_KEY;
  1789. typedef struct _SMB_DIRECTORY_INFORMATION {
  1790. SMB_RESUME_KEY ResumeKey;
  1791. UCHAR FileAttributes;
  1792. SMB_TIME LastWriteTime;
  1793. SMB_DATE LastWriteDate;
  1794. _ULONG( FileSize );
  1795. UCHAR FileName[13]; // ASCII, space-filled null terminated
  1796. } SMB_DIRECTORY_INFORMATION;
  1797. typedef SMB_DIRECTORY_INFORMATION SMB_UNALIGNED *PSMB_DIRECTORY_INFORMATION;
  1798. #ifdef NO_PACKING
  1799. #include <packoff.h>
  1800. #endif // def NO_PACKING
  1801. #endif // def INCLUDE_SMB_SEARCH
  1802. #ifdef INCLUDE_SMB_READ_WRITE
  1803. //
  1804. // Seek SMB, see #1 page 14
  1805. // Function is SrvSmbSeek
  1806. // SMB_COM_SEEK 0x12
  1807. //
  1808. typedef struct _REQ_SEEK {
  1809. UCHAR WordCount; // Count of parameter words = 4
  1810. _USHORT( Fid ); // File handle
  1811. _USHORT( Mode ); // Seek mode:
  1812. // 0 = from start of file
  1813. // 1 = from current position
  1814. // 2 = from end of file
  1815. _ULONG( Offset ); // Relative offset
  1816. _USHORT( ByteCount ); // Count of data bytes = 0
  1817. UCHAR Buffer[1]; // empty
  1818. } REQ_SEEK;
  1819. typedef REQ_SEEK SMB_UNALIGNED *PREQ_SEEK;
  1820. typedef struct _RESP_SEEK {
  1821. UCHAR WordCount; // Count of parameter words = 2
  1822. _ULONG( Offset ); // Offset from start of file
  1823. _USHORT( ByteCount ); // Count of data bytes = 0
  1824. UCHAR Buffer[1]; // empty
  1825. } RESP_SEEK;
  1826. typedef RESP_SEEK SMB_UNALIGNED *PRESP_SEEK;
  1827. #endif // def INCLUDE_SMB_READ_WRITE
  1828. #ifdef INCLUDE_SMB_MESSAGE
  1829. //
  1830. // Send Broadcast Message SMB, see #1 page 32
  1831. // Function is SrvSmbSendBroadcastMessage()
  1832. // SMB_COM_SEND_BROADCAST_MESSAGE 0xD1
  1833. //
  1834. typedef struct _REQ_SEND_BROADCAST_MESSAGE {
  1835. UCHAR WordCount; // Count of parameter words = 0
  1836. _USHORT( ByteCount ); // Count of data bytes; min = 8
  1837. UCHAR Buffer[1]; // Buffer containing:
  1838. //UCHAR BufferFormat1; // 0x04 -- ASCII
  1839. //UCHAR OriginatorName[]; // Originator name (max = 15)
  1840. //UCHAR BufferFormat2; // 0x04 -- ASCII
  1841. //UCHAR DestinationName[]; // "*"
  1842. //UCHAR BufferFormat3; // 0x01 -- Data block
  1843. //USHORT DataLength; // Length of message; max = 128
  1844. //UCHAR Data[]; // Message
  1845. } REQ_SEND_BROADCAST_MESSAGE;
  1846. typedef REQ_SEND_BROADCAST_MESSAGE SMB_UNALIGNED *PREQ_SEND_BROADCAST_MESSAGE;
  1847. // No response for Send Broadcast Message
  1848. #endif // def INCLUDE_SMB_MESSAGE
  1849. #ifdef INCLUDE_SMB_MESSAGE
  1850. //
  1851. // Send End of Multi-block Message SMB, see #1 page 33
  1852. // Function is SrvSmbSendEndMbMessage()
  1853. // SMB_COM_SEND_END_MB_MESSAGE 0xD6
  1854. //
  1855. typedef struct _REQ_SEND_END_MB_MESSAGE {
  1856. UCHAR WordCount; // Count of parameter words = 1
  1857. _USHORT( MessageGroupId );
  1858. _USHORT( ByteCount ); // Count of data bytes = 0
  1859. UCHAR Buffer[1]; // empty
  1860. } REQ_SEND_END_MB_MESSAGE;
  1861. typedef REQ_SEND_END_MB_MESSAGE SMB_UNALIGNED *PREQ_SEND_END_MB_MESSAGE;
  1862. typedef struct _RESP_SEND_END_MB_MESSAGE {
  1863. UCHAR WordCount; // Count of parameter words = 0
  1864. _USHORT( ByteCount ); // Count of data bytes = 0
  1865. UCHAR Buffer[1]; // empty
  1866. } RESP_SEND_END_MB_MESSAGE;
  1867. typedef RESP_SEND_END_MB_MESSAGE SMB_UNALIGNED *PRESP_SEND_END_MB_MESSAGE;
  1868. #endif // def INCLUDE_SMB_MESSAGE
  1869. #ifdef INCLUDE_SMB_MESSAGE
  1870. //
  1871. // Send Single Block Message SMB, see #1 page 31
  1872. // Function is SrvSmbSendMessage()
  1873. // SMB_COM_SEND_MESSAGE 0xD0
  1874. //
  1875. typedef struct _REQ_SEND_MESSAGE {
  1876. UCHAR WordCount; // Count of parameter words = 0
  1877. _USHORT( ByteCount ); // Count of data bytes; min = 7
  1878. UCHAR Buffer[1]; // Buffer containing:
  1879. //UCHAR BufferFormat1; // 0x04 -- ASCII
  1880. //UCHAR OriginatorName[]; // Originator name (max = 15)
  1881. //UCHAR BufferFormat2; // 0x04 -- ASCII
  1882. //UCHAR DestinationName[]; // Destination name (max = 15)
  1883. //UCHAR BufferFormat3; // 0x01 -- Data block
  1884. //USHORT DataLength; // Length of message; max = 128
  1885. //UCHAR Data[]; // Message
  1886. } REQ_SEND_MESSAGE;
  1887. typedef REQ_SEND_MESSAGE SMB_UNALIGNED *PREQ_SEND_MESSAGE;
  1888. typedef struct _RESP_SEND_MESSAGE {
  1889. UCHAR WordCount; // Count of parameter words = 0
  1890. _USHORT( ByteCount ); // Count of data bytes = 0
  1891. UCHAR Buffer[1]; // empty
  1892. } RESP_SEND_MESSAGE;
  1893. typedef RESP_SEND_MESSAGE SMB_UNALIGNED *PRESP_SEND_MESSAGE;
  1894. #endif // def INCLUDE_SMB_MESSAGE
  1895. #ifdef INCLUDE_SMB_MESSAGE
  1896. //
  1897. // Send Start of Multi-block Message SMB, see #1 page 32
  1898. // Function is SrvSmbSendStartMbMessage()
  1899. // SMB_COM_SEND_START_MB_MESSAGE 0xD5
  1900. //
  1901. typedef struct _REQ_SEND_START_MB_MESSAGE {
  1902. UCHAR WordCount; // Count of parameter words = 0
  1903. _USHORT( ByteCount ); // Count of data bytes; min = 0
  1904. UCHAR Buffer[1]; // Buffer containing:
  1905. //UCHAR BufferFormat1; // 0x04 -- ASCII
  1906. //UCHAR OriginatorName[]; // Originator name (max = 15)
  1907. //UCHAR BufferFormat2; // 0x04 -- ASCII
  1908. //UCHAR DestinationName[]; // Destination name (max = 15)
  1909. } REQ_SEND_START_MB_MESSAGE;
  1910. typedef REQ_SEND_START_MB_MESSAGE SMB_UNALIGNED *PREQ_SEND_START_MB_MESSAGE;
  1911. typedef struct _RESP_SEND_START_MB_MESSAGE {
  1912. UCHAR WordCount; // Count of parameter words = 1
  1913. _USHORT( MessageGroupId );
  1914. _USHORT( ByteCount ); // Count of data bytes = 0
  1915. UCHAR Buffer[1]; // empty
  1916. } RESP_SEND_START_MB_MESSAGE;
  1917. typedef RESP_SEND_START_MB_MESSAGE SMB_UNALIGNED *PSEND_START_MB_MESSAGE;
  1918. #endif // def INCLUDE_SMB_MESSAGE
  1919. #ifdef INCLUDE_SMB_MESSAGE
  1920. //
  1921. // Send Text of Multi-block Message SMB, see #1 page 33
  1922. // Function is SrvSmbSendTextMbMessage()
  1923. // SMB_COM_SEND_TEXT_MB_MESSAGE 0xD7
  1924. //
  1925. typedef struct _REQ_SEND_TEXT_MB_MESSAGE {
  1926. UCHAR WordCount; // Count of parameter words = 1
  1927. _USHORT( MessageGroupId );
  1928. _USHORT( ByteCount ); // Count of data bytes; min = 3
  1929. UCHAR Buffer[1]; // Buffer containing:
  1930. //UCHAR BufferFormat; // 0x01 -- Data block
  1931. //USHORT DataLength; // Length of message; max = 128
  1932. //UCHAR Data[]; // Message
  1933. } REQ_SEND_TEXT_MB_MESSAGE;
  1934. typedef REQ_SEND_TEXT_MB_MESSAGE SMB_UNALIGNED *PREQ_SEND_TEXT_MB_MESSAGE;
  1935. typedef struct _RESP_SEND_TEXT_MB_MESSAGE {
  1936. UCHAR WordCount; // Count of aprameter words = 0
  1937. _USHORT( ByteCount ); // Count of data bytes = 0
  1938. UCHAR Buffer[1]; // empty
  1939. } RESP_SEND_TEXT_MB_MESSAGE;
  1940. typedef RESP_SEND_TEXT_MB_MESSAGE SMB_UNALIGNED *PRESP_SEND_TEXT_MB_MESSAGE;
  1941. #endif // def INCLUDE_SMB_MESSAGE
  1942. #ifdef INCLUDE_SMB_ADMIN
  1943. //
  1944. // Session Setup and X SMB, see #2 page 63 and #3 page 10
  1945. // Function is SrvSmbSessionSetupAndX()
  1946. // SMB_COM_SESSION_SETUP_ANDX 0x73
  1947. //
  1948. typedef struct _REQ_SESSION_SETUP_ANDX {
  1949. UCHAR WordCount; // Count of parameter words = 10
  1950. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1951. UCHAR AndXReserved; // Reserved (must be 0)
  1952. _USHORT( AndXOffset ); // Offset to next command WordCount
  1953. _USHORT( MaxBufferSize ); // Consumer's maximum buffer size
  1954. _USHORT( MaxMpxCount ); // Actual maximum multiplexed pending requests
  1955. _USHORT( VcNumber ); // 0 = first (only), nonzero=additional VC number
  1956. _ULONG( SessionKey ); // Session key (valid iff VcNumber != 0)
  1957. _USHORT( PasswordLength ); // Account password size
  1958. _ULONG( Reserved );
  1959. _USHORT( ByteCount ); // Count of data bytes; min = 0
  1960. UCHAR Buffer[1]; // Buffer containing:
  1961. //UCHAR AccountPassword[]; // Account Password
  1962. //UCHAR AccountName[]; // Account Name
  1963. //UCHAR PrimaryDomain[]; // Client's primary domain
  1964. //UCHAR NativeOS[]; // Client's native operating system
  1965. //UCHAR NativeLanMan[]; // Client's native LAN Manager type
  1966. } REQ_SESSION_SETUP_ANDX;
  1967. typedef REQ_SESSION_SETUP_ANDX SMB_UNALIGNED *PREQ_SESSION_SETUP_ANDX;
  1968. typedef struct _REQ_NT_SESSION_SETUP_ANDX {
  1969. UCHAR WordCount; // Count of parameter words = 13
  1970. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1971. UCHAR AndXReserved; // Reserved (must be 0)
  1972. _USHORT( AndXOffset ); // Offset to next command WordCount
  1973. _USHORT( MaxBufferSize ); // Consumer's maximum buffer size
  1974. _USHORT( MaxMpxCount ); // Actual maximum multiplexed pending requests
  1975. _USHORT( VcNumber ); // 0 = first (only), nonzero=additional VC number
  1976. _ULONG( SessionKey ); // Session key (valid iff VcNumber != 0)
  1977. _USHORT( CaseInsensitivePasswordLength ); // Account password size, ANSI
  1978. _USHORT( CaseSensitivePasswordLength ); // Account password size, Unicode
  1979. _ULONG( Reserved);
  1980. _ULONG( Capabilities ); // Client capabilities
  1981. _USHORT( ByteCount ); // Count of data bytes; min = 0
  1982. UCHAR Buffer[1]; // Buffer containing:
  1983. //UCHAR CaseInsensitivePassword[]; // Account Password, ANSI
  1984. //UCHAR CaseSensitivePassword[]; // Account Password, Unicode
  1985. //UCHAR AccountName[]; // Account Name
  1986. //UCHAR PrimaryDomain[]; // Client's primary domain
  1987. //UCHAR NativeOS[]; // Client's native operating system
  1988. //UCHAR NativeLanMan[]; // Client's native LAN Manager type
  1989. } REQ_NT_SESSION_SETUP_ANDX;
  1990. typedef REQ_NT_SESSION_SETUP_ANDX SMB_UNALIGNED *PREQ_NT_SESSION_SETUP_ANDX;
  1991. //
  1992. // Action flags in the response
  1993. //
  1994. #define SMB_SETUP_GUEST 0x0001 // Session setup as a guest
  1995. #define SMB_SETUP_USE_LANMAN_KEY 0x0002 // Use the Lan Manager setup key.
  1996. typedef struct _REQ_NT_EXTENDED_SESSION_SETUP_ANDX {
  1997. UCHAR WordCount; // Count of parameter words = 12
  1998. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1999. UCHAR AndXReserved; // Reserved (must be 0)
  2000. _USHORT( AndXOffset ); // Offset to next command WordCount
  2001. _USHORT( MaxBufferSize ); // Consumer's maximum buffer size
  2002. _USHORT( MaxMpxCount ); // Actual maximum multiplexed pending requests
  2003. _USHORT( VcNumber ); // 0 = first (only), nonzero=additional VC number
  2004. _ULONG( SessionKey ); // Session key (valid iff VcNumber != 0)
  2005. _USHORT( SecurityBlobLength ); // Account password size, Unicode
  2006. _ULONG( Reserved);
  2007. _ULONG( Capabilities ); // Client capabilities
  2008. _USHORT( ByteCount ); // Count of data bytes; min = 0
  2009. UCHAR Buffer[1]; // Buffer containing:
  2010. //UCHAR SecurityBlob[]; // opaque security byte array.
  2011. //UCHAR NativeOS[]; // Client's native operating system
  2012. //UCHAR NativeLanMan[]; // Client's native LAN Manager type
  2013. } REQ_NT_EXTENDED_SESSION_SETUP_ANDX;
  2014. typedef REQ_NT_EXTENDED_SESSION_SETUP_ANDX SMB_UNALIGNED *PREQ_NT_EXTENDED_SESSION_SETUP_ANDX;
  2015. typedef struct _RESP_SESSION_SETUP_ANDX {
  2016. UCHAR WordCount; // Count of parameter words = 3
  2017. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2018. UCHAR AndXReserved; // Reserved (must be 0)
  2019. _USHORT( AndXOffset ); // Offset to next command WordCount
  2020. _USHORT( Action ); // Request mode:
  2021. // bit0 = logged in as GUEST
  2022. _USHORT( ByteCount ); // Count of data bytes
  2023. UCHAR Buffer[1]; // Buffer containing:
  2024. //UCHAR NativeOS[]; // Server's native operating system
  2025. //UCHAR NativeLanMan[]; // Server's native LAN Manager type
  2026. //UCHAR PrimaryDomain[]; // Server's primary domain
  2027. } RESP_SESSION_SETUP_ANDX;
  2028. typedef RESP_SESSION_SETUP_ANDX SMB_UNALIGNED *PRESP_SESSION_SETUP_ANDX;
  2029. typedef struct _RESP_NT_EXTENDED_SESSION_SETUP_ANDX {
  2030. UCHAR WordCount; // Count of parameter words = 4
  2031. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2032. UCHAR AndXReserved; // Reserved (must be 0)
  2033. _USHORT( AndXOffset ); // Offset to next command WordCount
  2034. _USHORT( Action ); // Request mode:
  2035. // bit0 = logged in as GUEST
  2036. _USHORT( SecurityBlobLength ); // Length of opaque security blob.
  2037. _USHORT( ByteCount ); // Count of data bytes
  2038. UCHAR Buffer[1]; // Buffer containing:
  2039. //UCHAR SecurityBlob[]; // SecurityBlob length message
  2040. //UCHAR NativeOS[]; // Server's native operating system
  2041. //UCHAR NativeLanMan[]; // Server's native LAN Manager type
  2042. //UCHAR PrimaryDomain[]; // Server's primary domain
  2043. } RESP_NT_EXTENDED_SESSION_SETUP_ANDX;
  2044. typedef RESP_NT_EXTENDED_SESSION_SETUP_ANDX SMB_UNALIGNED *PRESP_NT_EXTENDED_SESSION_SETUP_ANDX;
  2045. #endif // def INCLUDE_SMB_ADMIN
  2046. #ifdef INCLUDE_SMB_QUERY_SET
  2047. //
  2048. // Set Information SMB, see #1 page 19
  2049. // Function is SrvSmbSetInformation()
  2050. // SMB_COM_SET_INFORMATION 0x09
  2051. //
  2052. typedef struct _REQ_SET_INFORMATION {
  2053. UCHAR WordCount; // Count of parameter words = 8
  2054. _USHORT( FileAttributes );
  2055. _ULONG( LastWriteTimeInSeconds );
  2056. _USHORT( Reserved )[5]; // Reserved (must be 0)
  2057. _USHORT( ByteCount ); // Count of data bytes; min = 2
  2058. UCHAR Buffer[1]; // Buffer containing:
  2059. //UCHAR BufferFormat; // 0x04 -- ASCII
  2060. //UCHAR FileName[]; // File name
  2061. } REQ_SET_INFORMATION;
  2062. typedef REQ_SET_INFORMATION SMB_UNALIGNED *PREQ_SET_INFORMATION;
  2063. typedef struct _RESP_SET_INFORMATION {
  2064. UCHAR WordCount; // Count of parameter words = 0
  2065. _USHORT( ByteCount ); // Count of data bytes = 0
  2066. UCHAR Buffer[1]; // empty
  2067. } RESP_SET_INFORMATION;
  2068. typedef RESP_SET_INFORMATION SMB_UNALIGNED *PRESP_SET_INFORMATION;
  2069. #endif // def INCLUDE_SMB_QUERY_SET
  2070. #ifdef INCLUDE_SMB_QUERY_SET
  2071. //
  2072. // Set Information2 SMB, see #2 page 66
  2073. // Function is SrvSmbSetInformation2
  2074. // SMB_COM_SET_INFORMATION2 0x22
  2075. //
  2076. typedef struct _REQ_SET_INFORMATION2 {
  2077. UCHAR WordCount; // Count of parameter words = 7
  2078. _USHORT( Fid ); // File handle
  2079. SMB_DATE CreationDate;
  2080. SMB_TIME CreationTime;
  2081. SMB_DATE LastAccessDate;
  2082. SMB_TIME LastAccessTime;
  2083. SMB_DATE LastWriteDate;
  2084. SMB_TIME LastWriteTime;
  2085. _USHORT( ByteCount ); // Count of data bytes; min = 0
  2086. UCHAR Buffer[1]; // Reserved buffer
  2087. } REQ_SET_INFORMATION2;
  2088. typedef REQ_SET_INFORMATION2 SMB_UNALIGNED *PREQ_SET_INFORMATION2;
  2089. typedef struct _RESP_SET_INFORMATION2 {
  2090. UCHAR WordCount; // Count of parameter words = 0
  2091. _USHORT( ByteCount ); // Count of data bytes = 0
  2092. UCHAR Buffer[1]; // empty
  2093. } RESP_SET_INFORMATION2;
  2094. typedef RESP_SET_INFORMATION2 SMB_UNALIGNED *PRESP_SET_INFORMATION2;
  2095. #endif // def INCLUDE_SMB_QUERY_SET
  2096. #ifdef INCLUDE_SMB_TRANSACTION
  2097. //
  2098. // Transaction and Transaction2 SMBs, see #2 page 68 and #3 page 13
  2099. // Function is SrvSmbTransaction()
  2100. // SMB_COM_TRANSACTION 0x25
  2101. // SMB_COM_TRANSACTION_SECONDARY 0x26
  2102. // SMB_COM_TRANSACTION2 0x32
  2103. // SMB_COM_TRANSACTION2_SECONDARY 0x33
  2104. //
  2105. // Structures for specific transaction types are defined in smbtrans.h.
  2106. //
  2107. // *** The Transaction2 secondary request format includes a USHORT Fid
  2108. // field that we ignore. We can do this because the Fid field
  2109. // occurs at the end of the word parameters part of the request, and
  2110. // because the rest of the request (parameter and data bytes) is
  2111. // pointed by offset fields occurring prior to the Fid field. (The
  2112. // Fid field was added to speed up dispatching in the OS/2 server,
  2113. // in which different worker processes handle each Fid. The NT
  2114. // server has only one process.)
  2115. //
  2116. typedef struct _REQ_TRANSACTION {
  2117. UCHAR WordCount; // Count of parameter words; value = (14 + SetupCount)
  2118. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  2119. _USHORT( TotalDataCount ); // Total data bytes being sent
  2120. _USHORT( MaxParameterCount ); // Max parameter bytes to return
  2121. _USHORT( MaxDataCount ); // Max data bytes to return
  2122. UCHAR MaxSetupCount; // Max setup words to return
  2123. UCHAR Reserved;
  2124. _USHORT( Flags ); // Additional information:
  2125. // bit 0 - also disconnect TID in Tid
  2126. // bit 1 - one-way transacion (no resp)
  2127. _ULONG( Timeout );
  2128. _USHORT( Reserved2 );
  2129. _USHORT( ParameterCount ); // Parameter bytes sent this buffer
  2130. _USHORT( ParameterOffset ); // Offset (from header start) to params
  2131. _USHORT( DataCount ); // Data bytes sent this buffer
  2132. _USHORT( DataOffset ); // Offset (from header start) to data
  2133. UCHAR SetupCount; // Count of setup words
  2134. UCHAR Reserved3; // Reserved (pad above to word)
  2135. UCHAR Buffer[1]; // Buffer containing:
  2136. //USHORT Setup[]; // Setup words (# = SetupWordCount)
  2137. //USHORT ByteCount; // Count of data bytes
  2138. //UCHAR Name[]; // Name of transaction (NULL if Transact2)
  2139. //UCHAR Pad[]; // Pad to SHORT or LONG
  2140. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  2141. //UCHAR Pad1[]; // Pad to SHORT or LONG
  2142. //UCHAR Data[]; // Data bytes (# = DataCount)
  2143. } REQ_TRANSACTION;
  2144. typedef REQ_TRANSACTION SMB_UNALIGNED *PREQ_TRANSACTION;
  2145. #define SMB_TRANSACTION_DISCONNECT 1
  2146. #define SMB_TRANSACTION_NO_RESPONSE 2
  2147. #define SMB_TRANSACTION_RECONNECTING 4
  2148. #define SMB_TRANSACTION_DFSFILE 8
  2149. typedef struct _RESP_TRANSACTION_INTERIM {
  2150. UCHAR WordCount; // Count of parameter words = 0
  2151. _USHORT( ByteCount ); // Count of data bytes = 0
  2152. UCHAR Buffer[1]; // empty
  2153. } RESP_TRANSACTION_INTERIM;
  2154. typedef RESP_TRANSACTION_INTERIM SMB_UNALIGNED *PRESP_TRANSACTION_INTERIM;
  2155. typedef struct _REQ_TRANSACTION_SECONDARY {
  2156. UCHAR WordCount; // Count of parameter words = 8
  2157. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  2158. _USHORT( TotalDataCount ); // Total data bytes being sent
  2159. _USHORT( ParameterCount ); // Parameter bytes sent this buffer
  2160. _USHORT( ParameterOffset ); // Offset (from header start) to params
  2161. _USHORT( ParameterDisplacement ); // Displacement of these param bytes
  2162. _USHORT( DataCount ); // Data bytes sent this buffer
  2163. _USHORT( DataOffset ); // Offset (from header start) to data
  2164. _USHORT( DataDisplacement ); // Displacement of these data bytes
  2165. _USHORT( ByteCount ); // Count of data bytes
  2166. UCHAR Buffer[1]; // Buffer containing:
  2167. //UCHAR Pad[]; // Pad to SHORT or LONG
  2168. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  2169. //UCHAR Pad1[]; // Pad to SHORT or LONG
  2170. //UCHAR Data[]; // Data bytes (# = DataCount)
  2171. } REQ_TRANSACTION_SECONDARY;
  2172. typedef REQ_TRANSACTION_SECONDARY SMB_UNALIGNED *PREQ_TRANSACTION_SECONDARY;
  2173. typedef struct _RESP_TRANSACTION {
  2174. UCHAR WordCount; // Count of data bytes; value = 10 + SetupCount
  2175. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  2176. _USHORT( TotalDataCount ); // Total data bytes being sent
  2177. _USHORT( Reserved );
  2178. _USHORT( ParameterCount ); // Parameter bytes sent this buffer
  2179. _USHORT( ParameterOffset ); // Offset (from header start) to params
  2180. _USHORT( ParameterDisplacement ); // Displacement of these param bytes
  2181. _USHORT( DataCount ); // Data bytes sent this buffer
  2182. _USHORT( DataOffset ); // Offset (from header start) to data
  2183. _USHORT( DataDisplacement ); // Displacement of these data bytes
  2184. UCHAR SetupCount; // Count of setup words
  2185. UCHAR Reserved2; // Reserved (pad above to word)
  2186. UCHAR Buffer[1]; // Buffer containing:
  2187. //USHORT Setup[]; // Setup words (# = SetupWordCount)
  2188. //USHORT ByteCount; // Count of data bytes
  2189. //UCHAR Pad[]; // Pad to SHORT or LONG
  2190. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  2191. //UCHAR Pad1[]; // Pad to SHORT or LONG
  2192. //UCHAR Data[]; // Data bytes (# = DataCount)
  2193. } RESP_TRANSACTION;
  2194. typedef RESP_TRANSACTION SMB_UNALIGNED *PRESP_TRANSACTION;
  2195. typedef struct _REQ_NT_TRANSACTION {
  2196. UCHAR WordCount; // Count of parameter words; value = (19 + SetupCount)
  2197. UCHAR MaxSetupCount; // Max setup words to return
  2198. _USHORT( Flags ); // Currently unused
  2199. _ULONG( TotalParameterCount ); // Total parameter bytes being sent
  2200. _ULONG( TotalDataCount ); // Total data bytes being sent
  2201. _ULONG( MaxParameterCount ); // Max parameter bytes to return
  2202. _ULONG( MaxDataCount ); // Max data bytes to return
  2203. _ULONG( ParameterCount ); // Parameter bytes sent this buffer
  2204. _ULONG( ParameterOffset ); // Offset (from header start) to params
  2205. _ULONG( DataCount ); // Data bytes sent this buffer
  2206. _ULONG( DataOffset ); // Offset (from header start) to data
  2207. UCHAR SetupCount; // Count of setup words
  2208. _USHORT( Function ); // The transaction function code
  2209. UCHAR Buffer[1];
  2210. //USHORT Setup[]; // Setup words (# = SetupWordCount)
  2211. //USHORT ByteCount; // Count of data bytes
  2212. //UCHAR Pad1[]; // Pad to LONG
  2213. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  2214. //UCHAR Pad2[]; // Pad to LONG
  2215. //UCHAR Data[]; // Data bytes (# = DataCount)
  2216. } REQ_NT_TRANSACTION;
  2217. typedef REQ_NT_TRANSACTION SMB_UNALIGNED *PREQ_NT_TRANSACTION;
  2218. #define SMB_TRANSACTION_DISCONNECT 1
  2219. #define SMB_TRANSACTION_NO_RESPONSE 2
  2220. typedef struct _RESP_NT_TRANSACTION_INTERIM {
  2221. UCHAR WordCount; // Count of parameter words = 0
  2222. _USHORT( ByteCount ); // Count of data bytes = 0
  2223. UCHAR Buffer[1];
  2224. } RESP_NT_TRANSACTION_INTERIM;
  2225. typedef RESP_NT_TRANSACTION_INTERIM SMB_UNALIGNED *PRESP_NT_TRANSACTION_INTERIM;
  2226. typedef struct _REQ_NT_TRANSACTION_SECONDARY {
  2227. UCHAR WordCount; // Count of parameter words = 18
  2228. UCHAR Reserved1; // MBZ
  2229. _USHORT( Reserved2 ); // MBZ
  2230. _ULONG( TotalParameterCount ); // Total parameter bytes being sent
  2231. _ULONG( TotalDataCount ); // Total data bytes being sent
  2232. _ULONG( ParameterCount ); // Parameter bytes sent this buffer
  2233. _ULONG( ParameterOffset ); // Offset (from header start) to params
  2234. _ULONG( ParameterDisplacement ); // Displacement of these param bytes
  2235. _ULONG( DataCount ); // Data bytes sent this buffer
  2236. _ULONG( DataOffset ); // Offset (from header start) to data
  2237. _ULONG( DataDisplacement ); // Displacement of these data bytes
  2238. UCHAR Reserved3;
  2239. _USHORT( ByteCount ); // Count of data bytes
  2240. UCHAR Buffer[1];
  2241. //UCHAR Pad1[]; // Pad to LONG
  2242. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  2243. //UCHAR Pad2[]; // Pad to LONG
  2244. //UCHAR Data[]; // Data bytes (# = DataCount)
  2245. } REQ_NT_TRANSACTION_SECONDARY;
  2246. typedef REQ_NT_TRANSACTION_SECONDARY SMB_UNALIGNED *PREQ_NT_TRANSACTION_SECONDARY;
  2247. typedef struct _RESP_NT_TRANSACTION {
  2248. UCHAR WordCount; // Count of data bytes; value = 18 + SetupCount
  2249. UCHAR Reserved1;
  2250. _USHORT( Reserved2 );
  2251. _ULONG( TotalParameterCount ); // Total parameter bytes being sent
  2252. _ULONG( TotalDataCount ); // Total data bytes being sent
  2253. _ULONG( ParameterCount ); // Parameter bytes sent this buffer
  2254. _ULONG( ParameterOffset ); // Offset (from header start) to params
  2255. _ULONG( ParameterDisplacement ); // Displacement of these param bytes
  2256. _ULONG( DataCount ); // Data bytes sent this buffer
  2257. _ULONG( DataOffset ); // Offset (from header start) to data
  2258. _ULONG( DataDisplacement ); // Displacement of these data bytes
  2259. UCHAR SetupCount; // Count of setup words
  2260. UCHAR Buffer[1];
  2261. //USHORT Setup[]; // Setup words (# = SetupWordCount)
  2262. //USHORT ByteCount; // Count of data bytes
  2263. //UCHAR Pad1[]; // Pad to LONG
  2264. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  2265. //UCHAR Pad2[]; // Pad to SHORT or LONG
  2266. //UCHAR Data[]; // Data bytes (# = DataCount)
  2267. } RESP_NT_TRANSACTION;
  2268. typedef RESP_NT_TRANSACTION SMB_UNALIGNED *PRESP_NT_TRANSACTION;
  2269. #endif // def INCLUDE_SMB_TRANSACTION
  2270. #ifdef INCLUDE_SMB_TREE
  2271. //
  2272. // Tree Connect SMB, see #1, page 6
  2273. // Function is SrvSmbTreeConnect()
  2274. // SMB_COM_TREE_CONNECT 0x70
  2275. //
  2276. typedef struct _REQ_TREE_CONNECT {
  2277. UCHAR WordCount; // Count of parameter words = 0
  2278. _USHORT( ByteCount ); // Count of data bytes; min = 4
  2279. UCHAR Buffer[1]; // Buffer containing:
  2280. //UCHAR BufferFormat1; // 0x04 -- ASCII
  2281. //UCHAR Path[]; // Server name and share name
  2282. //UCHAR BufferFormat2; // 0x04 -- ASCII
  2283. //UCHAR Password[]; // Password
  2284. //UCHAR BufferFormat3; // 0x04 -- ASCII
  2285. //UCHAR Service[]; // Service name
  2286. } REQ_TREE_CONNECT;
  2287. typedef REQ_TREE_CONNECT SMB_UNALIGNED *PREQ_TREE_CONNECT;
  2288. typedef struct _RESP_TREE_CONNECT {
  2289. UCHAR WordCount; // Count of parameter words = 2
  2290. _USHORT( MaxBufferSize ); // Max size message the server handles
  2291. _USHORT( Tid ); // Tree ID
  2292. _USHORT( ByteCount ); // Count of data bytes = 0
  2293. UCHAR Buffer[1]; // empty
  2294. } RESP_TREE_CONNECT;
  2295. typedef RESP_TREE_CONNECT SMB_UNALIGNED *PRESP_TREE_CONNECT;
  2296. #endif // def INCLUDE_SMB_TREE
  2297. #ifdef INCLUDE_SMB_TREE
  2298. //
  2299. // Tree Connect and X SMB, see #2, page 88
  2300. // Function is SrvSmbTreeConnectAndX()
  2301. // SMB_COM_TREE_CONNECT_ANDX 0x75
  2302. //
  2303. // TREE_CONNECT_ANDX flags
  2304. #define TREE_CONNECT_ANDX_DISCONNECT_TID (0x1)
  2305. // #define TREE_CONNECT_ANDX_W95 (0x2) -- W95 sets this flag. Don't know why.
  2306. #define TREE_CONNECT_ANDX_EXTENDED_RESPONSE (0x8)
  2307. typedef struct _REQ_TREE_CONNECT_ANDX {
  2308. UCHAR WordCount; // Count of parameter words = 4
  2309. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2310. UCHAR AndXReserved; // Reserved (must be 0)
  2311. _USHORT( AndXOffset ); // Offset to next command WordCount
  2312. _USHORT( Flags ); // Additional information
  2313. // bit 0 set = disconnect Tid
  2314. // bit 7 set = extended response
  2315. _USHORT( PasswordLength ); // Length of Password[]
  2316. _USHORT( ByteCount ); // Count of data bytes; min = 3
  2317. UCHAR Buffer[1]; // Buffer containing:
  2318. //UCHAR Password[]; // Password
  2319. //UCHAR Path[]; // Server name and share name
  2320. //UCHAR Service[]; // Service name
  2321. } REQ_TREE_CONNECT_ANDX;
  2322. typedef REQ_TREE_CONNECT_ANDX SMB_UNALIGNED *PREQ_TREE_CONNECT_ANDX;
  2323. typedef struct _RESP_TREE_CONNECT_ANDX {
  2324. UCHAR WordCount; // Count of parameter words = 2
  2325. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2326. UCHAR AndXReserved; // Reserved (must be 0)
  2327. _USHORT( AndXOffset ); // Offset to next command WordCount
  2328. _USHORT( ByteCount ); // Count of data bytes; min = 3
  2329. UCHAR Buffer[1]; // Service type connected to
  2330. } RESP_TREE_CONNECT_ANDX;
  2331. typedef RESP_TREE_CONNECT_ANDX SMB_UNALIGNED *PRESP_TREE_CONNECT_ANDX;
  2332. //
  2333. // The response for clients that are LAN Manager 2.1 or better.
  2334. //
  2335. typedef struct _RESP_21_TREE_CONNECT_ANDX {
  2336. UCHAR WordCount; // Count of parameter words = 3
  2337. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2338. UCHAR AndXReserved; // Reserved (must be 0)
  2339. _USHORT( AndXOffset ); // Offset to next command WordCount
  2340. _USHORT( OptionalSupport ); // Optional support bits
  2341. _USHORT( ByteCount ); // Count of data bytes; min = 3
  2342. UCHAR Buffer[1]; // Buffer containing:
  2343. //UCHAR Service[]; // Service type connected to
  2344. //UCHAR NativeFileSystem[]; // Native file system for this tree
  2345. } RESP_21_TREE_CONNECT_ANDX;
  2346. typedef RESP_21_TREE_CONNECT_ANDX SMB_UNALIGNED *PRESP_21_TREE_CONNECT_ANDX;
  2347. typedef struct _RESP_EXTENDED_TREE_CONNECT_ANDX {
  2348. UCHAR WordCount; // Count of parameter words = 7
  2349. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2350. UCHAR AndXReserved; // Reserved (must be 0)
  2351. _USHORT( AndXOffset ); // Offset to next command WordCount
  2352. _USHORT( OptionalSupport); // optional support bits
  2353. _ULONG( MaximalShareAccessRights ); // maximal share access rights
  2354. _ULONG( GuestMaximalShareAccessRights); // maximal guest access rights
  2355. _USHORT( ByteCount ); // Count of data bytes; min = 3
  2356. UCHAR Buffer[1]; // Service type connected to
  2357. } RESP_EXTENDED_TREE_CONNECT_ANDX;
  2358. typedef RESP_EXTENDED_TREE_CONNECT_ANDX SMB_UNALIGNED *PRESP_EXTENDED_TREE_CONNECT_ANDX;
  2359. //
  2360. // Optional Support bit definitions
  2361. //
  2362. #define SMB_SUPPORT_SEARCH_BITS 0x0001
  2363. #define SMB_SHARE_IS_IN_DFS 0x0002
  2364. #define SMB_UNIQUE_FILE_NAME 0x0010
  2365. #define SMB_CSC_MASK 0x000C // see below
  2366. //
  2367. // Bits under SMB_CSC_MASK decode like this:
  2368. //
  2369. #define SMB_CSC_CACHE_MANUAL_REINT 0x0000 // No automatic file by file reint
  2370. #define SMB_CSC_CACHE_AUTO_REINT 0x0004 // File by file reint is OK
  2371. #define SMB_CSC_CACHE_VDO 0x0008 // no need to flow opens
  2372. #define SMB_CSC_NO_CACHING 0x000C // client should not cache this share
  2373. #endif // def INCLUDE_SMB_TREE
  2374. #ifdef INCLUDE_SMB_TREE
  2375. //
  2376. // Tree Disconnect SMB, see #1 page 7
  2377. // Function is SrvSmbTreeDisconnect()
  2378. // SMB_COM_TREE_DISCONNECT 0x71
  2379. //
  2380. typedef struct _REQ_TREE_DISCONNECT {
  2381. UCHAR WordCount; // Count of parameter words = 0
  2382. _USHORT( ByteCount ); // Count of data bytes = 0
  2383. UCHAR Buffer[1]; // empty
  2384. } REQ_TREE_DISCONNECT;
  2385. typedef REQ_TREE_DISCONNECT SMB_UNALIGNED *PREQ_TREE_DISCONNECT;
  2386. typedef struct _RESP_TREE_DISCONNECT {
  2387. UCHAR WordCount; // Count of parameter words = 0
  2388. _USHORT( ByteCount ); // Count of data bytes = 0
  2389. UCHAR Buffer[1]; // empty
  2390. } RESP_TREE_DISCONNECT;
  2391. typedef RESP_TREE_DISCONNECT SMB_UNALIGNED *PRESP_TREE_DISCONNECT;
  2392. #endif // def INCLUDE_SMB_TREE
  2393. #ifdef INCLUDE_SMB_LOCK
  2394. //
  2395. // Unlock Byte Range SMB, see #1 page 20
  2396. // Function is SrvSmbUnlockByteRange()
  2397. // SMB_COM_UNLOCK_BYTE_RANGE 0x0D
  2398. //
  2399. typedef struct _REQ_UNLOCK_BYTE_RANGE {
  2400. UCHAR WordCount; // Count of parameter words = 5
  2401. _USHORT( Fid ); // File handle
  2402. _ULONG( Count ); // Count of bytes to unlock
  2403. _ULONG( Offset ); // Offset from start of file
  2404. _USHORT( ByteCount ); // Count of data bytes = 0
  2405. UCHAR Buffer[1]; // empty
  2406. } REQ_UNLOCK_BYTE_RANGE;
  2407. typedef REQ_UNLOCK_BYTE_RANGE SMB_UNALIGNED *PREQ_UNLOCK_BYTE_RANGE;
  2408. typedef struct _RESP_UNLOCK_BYTE_RANGE {
  2409. UCHAR WordCount; // Count of parameter words = 0
  2410. _USHORT( ByteCount ); // Count of data bytes = 0
  2411. UCHAR Buffer[1]; // empty
  2412. } RESP_UNLOCK_BYTE_RANGE;
  2413. typedef RESP_UNLOCK_BYTE_RANGE SMB_UNALIGNED *PRESP_UNLOCK_BYTE_RANGE;
  2414. #endif // def INCLUDE_SMB_LOCK
  2415. #ifdef INCLUDE_SMB_READ_WRITE
  2416. //
  2417. // Write SMB, see #1 page 12
  2418. // Write and Unlock SMB, see #2 page 92
  2419. // Function is SrvSmbWrite()
  2420. // SMB_COM_WRITE 0x0B
  2421. // SMB_COM_WRITE_AND_UNLOCK 0x14
  2422. //
  2423. //
  2424. // *** Warning: the following structure is defined the way it is to
  2425. // ensure longword alignment of the data buffer. (This only matters
  2426. // when packing is disabled; when packing is turned on, the right
  2427. // thing happens no matter what.)
  2428. //
  2429. typedef struct _REQ_WRITE {
  2430. UCHAR WordCount; // Count of parameter words = 5
  2431. _USHORT( Fid ); // File handle
  2432. _USHORT( Count ); // Number of bytes to be written
  2433. _ULONG( Offset ); // Offset in file to begin write
  2434. _USHORT( Remaining ); // Bytes remaining to satisfy request
  2435. _USHORT( ByteCount ); // Count of data bytes
  2436. //UCHAR Buffer[1]; // Buffer containing:
  2437. UCHAR BufferFormat; // 0x01 -- Data block
  2438. _USHORT( DataLength ); // Length of data
  2439. ULONG Buffer[1]; // Data
  2440. } REQ_WRITE;
  2441. typedef REQ_WRITE SMB_UNALIGNED *PREQ_WRITE;
  2442. typedef struct _RESP_WRITE {
  2443. UCHAR WordCount; // Count of parameter words = 1
  2444. _USHORT( Count ); // Count of bytes actually written
  2445. _USHORT( ByteCount ); // Count of data bytes = 0
  2446. UCHAR Buffer[1]; // empty
  2447. } RESP_WRITE;
  2448. typedef RESP_WRITE SMB_UNALIGNED *PRESP_WRITE;
  2449. #endif // def INCLUDE_SMB_READ_WRITE
  2450. #ifdef INCLUDE_SMB_READ_WRITE
  2451. //
  2452. // Write and Close SMB, see #2 page 90
  2453. // Function is SrvSmbWriteAndClose()
  2454. // SMB_COM_WRITE_AND_CLOSE 0x2C
  2455. //
  2456. //
  2457. // The Write and Close parameters can be 6 words long or 12 words long,
  2458. // depending on whether it's supposed to look like a Write SMB or a
  2459. // Write and X SMB. So we define two different structures here.
  2460. //
  2461. // *** Warning: the following structures are defined the way they are to
  2462. // ensure longword alignment of the data buffer. (This only matters
  2463. // when packing is disabled; when packing is turned on, the right
  2464. // thing happens no matter what.)
  2465. //
  2466. typedef struct _REQ_WRITE_AND_CLOSE {
  2467. UCHAR WordCount; // Count of parameter words = 6
  2468. _USHORT( Fid ); // File handle
  2469. _USHORT( Count ); // Number of bytes to write
  2470. _ULONG( Offset ); // Offset in file of first byte to write
  2471. _ULONG( LastWriteTimeInSeconds ); // Time of last write
  2472. _USHORT( ByteCount ); // 1 (for pad) + value of Count
  2473. UCHAR Pad; // To force to doubleword boundary
  2474. ULONG Buffer[1]; // Data
  2475. } REQ_WRITE_AND_CLOSE;
  2476. typedef REQ_WRITE_AND_CLOSE SMB_UNALIGNED *PREQ_WRITE_AND_CLOSE;
  2477. typedef struct _REQ_WRITE_AND_CLOSE_LONG {
  2478. UCHAR WordCount; // Count of parameter words = 12
  2479. _USHORT( Fid ); // File handle
  2480. _USHORT( Count ); // Number of bytes to write
  2481. _ULONG( Offset ); // Offset in file of first byte to write
  2482. _ULONG( LastWriteTimeInSeconds ); // Time of last write
  2483. _ULONG( Reserved )[3]; // Reserved, must be 0
  2484. _USHORT( ByteCount ); // 1 (for pad) + value of Count
  2485. UCHAR Pad; // To force to doubleword boundary
  2486. ULONG Buffer[1]; // Data
  2487. } REQ_WRITE_AND_CLOSE_LONG;
  2488. typedef REQ_WRITE_AND_CLOSE_LONG SMB_UNALIGNED *PREQ_WRITE_AND_CLOSE_LONG;
  2489. typedef struct _RESP_WRITE_AND_CLOSE {
  2490. UCHAR WordCount; // Count of parameter words = 1
  2491. _USHORT( Count ); // Count of bytes actually written
  2492. _USHORT( ByteCount ); // Count of data bytes = 0
  2493. UCHAR Buffer[1]; // empty
  2494. } RESP_WRITE_AND_CLOSE;
  2495. typedef RESP_WRITE_AND_CLOSE SMB_UNALIGNED *PRESP_WRITE_AND_CLOSE;
  2496. #endif // def INCLUDE_SMB_READ_WRITE
  2497. #ifdef INCLUDE_SMB_READ_WRITE
  2498. //
  2499. // Write and X SMB, see #2 page 94
  2500. // Function is SrvSmbWriteAndX()
  2501. // SMB_COM_WRITE_ANDX 0x2F
  2502. //
  2503. typedef struct _REQ_WRITE_ANDX {
  2504. UCHAR WordCount; // Count of parameter words = 12
  2505. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2506. UCHAR AndXReserved; // Reserved (must be 0)
  2507. _USHORT( AndXOffset ); // Offset to next command WordCount
  2508. _USHORT( Fid ); // File handle
  2509. _ULONG( Offset ); // Offset in file to begin write
  2510. _ULONG( Timeout );
  2511. _USHORT( WriteMode ); // Write mode:
  2512. // 0 - write through
  2513. // 1 - return Remaining
  2514. // 2 - use WriteRawNamedPipe (n. pipes)
  2515. // 3 - "this is the start of the msg"
  2516. _USHORT( Remaining ); // Bytes remaining to satisfy request
  2517. _USHORT( Reserved );
  2518. _USHORT( DataLength ); // Number of data bytes in buffer (>=0)
  2519. _USHORT( DataOffset ); // Offset to data bytes
  2520. _USHORT( ByteCount ); // Count of data bytes
  2521. UCHAR Buffer[1]; // Buffer containing:
  2522. //UCHAR Pad[]; // Pad to SHORT or LONG
  2523. //UCHAR Data[]; // Data (# = DataLength)
  2524. } REQ_WRITE_ANDX;
  2525. typedef REQ_WRITE_ANDX SMB_UNALIGNED *PREQ_WRITE_ANDX;
  2526. typedef struct _REQ_NT_WRITE_ANDX {
  2527. UCHAR WordCount; // Count of parameter words = 14
  2528. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2529. UCHAR AndXReserved; // Reserved (must be 0)
  2530. _USHORT( AndXOffset ); // Offset to next command WordCount
  2531. _USHORT( Fid ); // File handle
  2532. _ULONG( Offset ); // Offset in file to begin write
  2533. _ULONG( Timeout );
  2534. _USHORT( WriteMode ); // Write mode:
  2535. // 0 - write through
  2536. // 1 - return Remaining
  2537. // 2 - use WriteRawNamedPipe (n. pipes)
  2538. // 3 - "this is the start of the msg"
  2539. union {
  2540. _USHORT( Remaining ); // Bytes remaining to satisfy request
  2541. _USHORT( CdiLength ); // if SMB_FLAGS2_COMPRESSED
  2542. };
  2543. _USHORT( DataLengthHigh );
  2544. _USHORT( DataLength ); // Number of data bytes in buffer (>=0)
  2545. _USHORT( DataOffset ); // Offset to data bytes
  2546. _ULONG( OffsetHigh ); // Used for NT Protocol only
  2547. // Upper 32 bits of offset
  2548. _USHORT( ByteCount ); // Count of data bytes
  2549. UCHAR Buffer[1]; // Buffer containing:
  2550. //UCHAR Pad[]; // Pad to SHORT or LONG
  2551. //UCHAR Data[]; // Data (# = DataLength)
  2552. } REQ_NT_WRITE_ANDX;
  2553. typedef REQ_NT_WRITE_ANDX SMB_UNALIGNED *PREQ_NT_WRITE_ANDX;
  2554. typedef struct _RESP_WRITE_ANDX {
  2555. UCHAR WordCount; // Count of parameter words = 6
  2556. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2557. UCHAR AndXReserved; // Reserved (must be 0)
  2558. _USHORT( AndXOffset ); // Offset to next command WordCount
  2559. _USHORT( Count ); // Number of bytes written
  2560. _USHORT( Remaining ); // Bytes remaining to be read (pipe/dev)
  2561. union {
  2562. _ULONG( Reserved );
  2563. _USHORT( CountHigh ); // if large write&x
  2564. };
  2565. _USHORT( ByteCount ); // Count of data bytes. Inaccurate if
  2566. // large writes
  2567. UCHAR Buffer[1]; // empty
  2568. } RESP_WRITE_ANDX;
  2569. typedef RESP_WRITE_ANDX SMB_UNALIGNED *PRESP_WRITE_ANDX;
  2570. #endif // def INCLUDE_SMB_READ_WRITE
  2571. #ifdef INCLUDE_SMB_MPX
  2572. //
  2573. // Write Block Multiplexed SMB, see #2 page 97
  2574. // Function is SrvSmbWriteMpx()
  2575. // SMB_COM_WRITE_MPX 0x1E
  2576. // SMB_COM_WRITE_MPX_SECONDARY 0x1F
  2577. // SMB_COM_WRITE_MPX_COMPLETE 0x20
  2578. //
  2579. typedef struct _REQ_WRITE_MPX {
  2580. UCHAR WordCount; // Count of parameter words = 12
  2581. _USHORT( Fid ); // File handle
  2582. _USHORT( Count ); // Total bytes, including this buffer
  2583. _USHORT( Reserved );
  2584. _ULONG( Offset ); // Offset in file to begin write
  2585. _ULONG( Timeout );
  2586. _USHORT( WriteMode ); // Write mode:
  2587. // bit 0 - complete write to disk and
  2588. // send final result response
  2589. // bit 1 - return Remaining (pipe/dev)
  2590. // bit 7 - IPX datagram mode
  2591. union {
  2592. struct {
  2593. _USHORT( DataCompactionMode );
  2594. _USHORT( Reserved2 );
  2595. } ;
  2596. _ULONG( Mask ); // IPX datagram mode mask
  2597. } ;
  2598. _USHORT( DataLength ); // Number of data bytes this buffer
  2599. _USHORT( DataOffset ); // Offset (from header start) to data
  2600. _USHORT( ByteCount ); // Count of data bytes
  2601. UCHAR Buffer[1]; // Buffer containing:
  2602. //UCHAR Pad[]; // Pad to SHORT or LONG
  2603. //UCHAR Data[]; // Data (# = DataLength)
  2604. } REQ_WRITE_MPX;
  2605. typedef REQ_WRITE_MPX SMB_UNALIGNED *PREQ_WRITE_MPX;
  2606. typedef struct _RESP_WRITE_MPX_INTERIM { // First response
  2607. UCHAR WordCount; // Count of parameter words = 1
  2608. _USHORT( Remaining ); // Bytes ramaining to be read (pipe/dev)
  2609. _USHORT( ByteCount ); // Count of data bytes = 0
  2610. UCHAR Buffer[1]; // empty
  2611. } RESP_WRITE_MPX_INTERIM;
  2612. typedef RESP_WRITE_MPX_INTERIM SMB_UNALIGNED *PRESP_WRITE_MPX_INTERIM;
  2613. typedef struct _RESP_WRITE_MPX_DATAGRAM { // Response to sequenced request
  2614. UCHAR WordCount; // Count of parameter words = 2
  2615. _ULONG( Mask ); // OR of all masks received
  2616. _USHORT( ByteCount ); // Count of data bytes = 0
  2617. UCHAR Buffer[1]; // empty
  2618. } RESP_WRITE_MPX_DATAGRAM;
  2619. typedef RESP_WRITE_MPX_DATAGRAM SMB_UNALIGNED *PRESP_WRITE_MPX_DATAGRAM;
  2620. // Secondary request format, 0 to N of these.
  2621. typedef struct _REQ_WRITE_MPX_SECONDARY {
  2622. UCHAR WordCount; // Count of parameter words = 8
  2623. _USHORT( Fid ); // File handle
  2624. _USHORT( Count ); // Total bytes to be sent
  2625. _ULONG( Offset ); // Offset in file to begin write
  2626. _ULONG( Reserved );
  2627. _USHORT( DataLength ); // Number of data bytes this buffer
  2628. _USHORT( DataOffset ); // Offset (from header start) to data
  2629. _USHORT( ByteCount ); // Count of data bytes
  2630. UCHAR Buffer[1]; // Buffer containing:
  2631. //UCHAR Pad[]; // Pad to SHORT or LONG
  2632. //UCHAR Data[]; // Data (# = DataLength)
  2633. } REQ_WRITE_MPX_SECONDARY;
  2634. typedef REQ_WRITE_MPX_SECONDARY SMB_UNALIGNED *PREQ_WRITE_MPX_SECONDARY;
  2635. #endif // def INCLUDE_SMB_MPX
  2636. #ifndef INCLUDE_SMB_WRITE_COMPLETE
  2637. #ifdef INCLUDE_SMB_MPX
  2638. #define INCLUDE_SMB_WRITE_COMPLETE
  2639. #else
  2640. #ifdef INCLUDE_SMB_RAW
  2641. #define INCLUDE_SMB_WRITE_COMPLETE
  2642. #endif
  2643. #endif
  2644. #endif
  2645. #ifdef INCLUDE_SMB_WRITE_COMPLETE
  2646. //
  2647. // The following structure is used as the final response to both Write
  2648. // Block Multiplexed and Write Block Raw.
  2649. //
  2650. typedef struct _RESP_WRITE_COMPLETE { // Final response; command is
  2651. // SMB_COM_WRITE_COMPLETE
  2652. UCHAR WordCount; // Count of parameter words = 1
  2653. _USHORT( Count ); // Total number of bytes written
  2654. _USHORT( ByteCount ); // Count of data bytes = 0
  2655. UCHAR Buffer[1]; // empty
  2656. } RESP_WRITE_COMPLETE;
  2657. typedef RESP_WRITE_COMPLETE SMB_UNALIGNED *PRESP_WRITE_COMPLETE;
  2658. #endif // def INCLUDE_SMB_WRITE_COMPLETE
  2659. #ifdef INCLUDE_SMB_READ_WRITE
  2660. //
  2661. // Write Print File SMB, see #1 page 29
  2662. // Function is SrvSmbWritePrintFile()
  2663. // SMB_COM_WRITE_PRINT_FILE 0xC1
  2664. //
  2665. typedef struct _REQ_WRITE_PRINT_FILE {
  2666. UCHAR WordCount; // Count of parameter words = 1
  2667. _USHORT( Fid ); // File handle
  2668. _USHORT( ByteCount ); // Count of data bytes; min = 4
  2669. UCHAR Buffer[1]; // Buffer containing:
  2670. //UCHAR BufferFormat; // 0x01 -- Data block
  2671. //USHORT DataLength; // Length of data
  2672. //UCHAR Data[]; // Data
  2673. } REQ_WRITE_PRINT_FILE;
  2674. typedef REQ_WRITE_PRINT_FILE SMB_UNALIGNED *PREQ_WRITE_PRINT_FILE;
  2675. typedef struct _RESP_WRITE_PRINT_FILE {
  2676. UCHAR WordCount; // Count of parameter words = 0
  2677. _USHORT( ByteCount ); // Count of data bytes = 0
  2678. UCHAR Buffer[1]; // empty
  2679. } RESP_WRITE_PRINT_FILE;
  2680. typedef RESP_WRITE_PRINT_FILE SMB_UNALIGNED *PRESP_WRITE_PRINT_FILE;
  2681. #endif // def INCLUDE_SMB_READ_WRITE
  2682. #ifdef INCLUDE_SMB_RAW
  2683. //
  2684. // Write Block Raw SMB, see #2 page 100
  2685. // Function is SrvSmbWriteRaw()
  2686. // SMB_COM_WRITE_RAW 0x1D
  2687. //
  2688. typedef struct _REQ_WRITE_RAW {
  2689. UCHAR WordCount; // Count of parameter words = 12
  2690. _USHORT( Fid ); // File handle
  2691. _USHORT( Count ); // Total bytes, including this buffer
  2692. _USHORT( Reserved );
  2693. _ULONG( Offset ); // Offset in file to begin write
  2694. _ULONG( Timeout );
  2695. _USHORT( WriteMode ); // Write mode:
  2696. // bit 0 - complete write to disk and
  2697. // send final result response
  2698. // bit 1 - return Remaining (pipe/dev)
  2699. // (see WriteAndX for #defines)
  2700. _ULONG( Reserved2 );
  2701. _USHORT( DataLength ); // Number of data bytes this buffer
  2702. _USHORT( DataOffset ); // Offset (from header start) to data
  2703. _USHORT( ByteCount ); // Count of data bytes
  2704. UCHAR Buffer[1]; // Buffer containing:
  2705. //UCHAR Pad[]; // Pad to SHORT or LONG
  2706. //UCHAR Data[]; // Data (# = DataLength)
  2707. } REQ_WRITE_RAW;
  2708. typedef REQ_WRITE_RAW SMB_UNALIGNED *PREQ_WRITE_RAW;
  2709. typedef struct _REQ_NT_WRITE_RAW {
  2710. UCHAR WordCount; // Count of parameter words = 14
  2711. _USHORT( Fid ); // File handle
  2712. _USHORT( Count ); // Total bytes, including this buffer
  2713. _USHORT( Reserved );
  2714. _ULONG( Offset ); // Offset in file to begin write
  2715. _ULONG( Timeout );
  2716. _USHORT( WriteMode ); // Write mode:
  2717. // bit 0 - complete write to disk and
  2718. // send final result response
  2719. // bit 1 - return Remaining (pipe/dev)
  2720. // (see WriteAndX for #defines)
  2721. _ULONG( Reserved2 );
  2722. _USHORT( DataLength ); // Number of data bytes this buffer
  2723. _USHORT( DataOffset ); // Offset (from header start) to data
  2724. _ULONG( OffsetHigh ); // Used for NT Protocol only
  2725. // Upper 32 bits of offset
  2726. _USHORT( ByteCount ); // Count of data bytes
  2727. UCHAR Buffer[1]; // Buffer containing:
  2728. //UCHAR Pad[]; // Pad to SHORT or LONG
  2729. //UCHAR Data[]; // Data (# = DataLength)
  2730. } REQ_NT_WRITE_RAW;
  2731. typedef REQ_NT_WRITE_RAW SMB_UNALIGNED *PREQ_NT_WRITE_RAW;
  2732. typedef struct _RESP_WRITE_RAW_INTERIM { // First response
  2733. UCHAR WordCount; // Count of parameter words = 1
  2734. _USHORT( Remaining ); // Bytes remaining to be read (pipe/dev)
  2735. _USHORT( ByteCount ); // Count of data bytes = 0
  2736. UCHAR Buffer[1]; // empty
  2737. } RESP_WRITE_RAW_INTERIM;
  2738. typedef RESP_WRITE_RAW_INTERIM SMB_UNALIGNED *PRESP_WRITE_RAW_INTERIM;
  2739. typedef struct _RESP_WRITE_RAW_SECONDARY { // Second (final) response
  2740. UCHAR WordCount; // Count of parameter words = 1
  2741. _USHORT( Count ); // Total number of bytes written
  2742. _USHORT( ByteCount ); // Count of data bytes = 0
  2743. UCHAR Buffer[1]; // empty
  2744. } RESP_WRITE_RAW_SECONDARY;
  2745. typedef RESP_WRITE_RAW_SECONDARY SMB_UNALIGNED *PRESP_WRITE_RAW_SECONDARY;
  2746. typedef struct _REQ_103_WRITE_RAW {
  2747. UCHAR WordCount; // Count of parameter words
  2748. _USHORT( Fid ); // File handle
  2749. _USHORT( Count );
  2750. _USHORT( Reserved );
  2751. _ULONG( Offset );
  2752. _ULONG( Timeout );
  2753. _USHORT( WriteMode );
  2754. _ULONG( Reserved2 );
  2755. _USHORT( ByteCount ); // Count of data bytes; min =
  2756. UCHAR Buffer[1]; //
  2757. } REQ_103_WRITE_RAW;
  2758. typedef REQ_103_WRITE_RAW SMB_UNALIGNED *PREQ_103_WRITE_RAW;
  2759. typedef struct _RESP_103_WRITE_RAW {
  2760. UCHAR WordCount; // Count of parameter words
  2761. _USHORT( ByteCount ); // Count of data bytes; min =
  2762. UCHAR Buffer[1]; //
  2763. } RESP_103_WRITE_RAW;
  2764. typedef RESP_103_WRITE_RAW SMB_UNALIGNED *PRESP_103_WRITE_RAW;
  2765. #endif // def INCLUDE_SMB_RAW
  2766. typedef struct _REQ_NT_CANCEL {
  2767. UCHAR WordCount; // = 0
  2768. _USHORT( ByteCount ); // = 0
  2769. UCHAR Buffer[1];
  2770. } REQ_NT_CANCEL;
  2771. typedef REQ_NT_CANCEL SMB_UNALIGNED *PREQ_NT_CANCEL;
  2772. typedef struct _RESP_NT_CANCEL {
  2773. UCHAR WordCount; // = 0
  2774. _USHORT( ByteCount ); // = 0
  2775. UCHAR Buffer[1];
  2776. } RESP_NT_CANCEL;
  2777. typedef RESP_NT_CANCEL SMB_UNALIGNED *PRESP_NT_CANCEL;
  2778. //
  2779. // File open modes
  2780. //
  2781. #define SMB_ACCESS_READ_ONLY 0
  2782. #define SMB_ACCESS_WRITE_ONLY 1
  2783. #define SMB_ACCESS_READ_WRITE 2
  2784. #define SMB_ACCESS_EXECUTE 3
  2785. //
  2786. // Open flags
  2787. //
  2788. #define SMB_OPEN_QUERY_INFORMATION 0x01
  2789. #define SMB_OPEN_OPLOCK 0x02
  2790. #define SMB_OPEN_OPBATCH 0x04
  2791. #define SMB_OPEN_QUERY_EA_LENGTH 0x08
  2792. #define SMB_OPEN_EXTENDED_RESPONSE 0x10
  2793. //
  2794. // NT open manifests
  2795. //
  2796. #define NT_CREATE_REQUEST_OPLOCK 0x02
  2797. #define NT_CREATE_REQUEST_OPBATCH 0x04
  2798. #define NT_CREATE_OPEN_TARGET_DIR 0x08
  2799. #define NT_CREATE_REQUEST_EXTENDED_RESPONSE 0x10
  2800. // these options are post NT 5
  2801. #ifdef INCLUDE_SMB_IFMODIFIED
  2802. #define NT_CREATE_IFMODIFIED_REQUEST 0x20
  2803. #define NT_CREATE_REQUEST_EXTENDED_RESPONSE2 0x80
  2804. #endif
  2805. #ifdef INCLUDE_SMB_PERSISTENT
  2806. #define NT_CREATE_PERSISTANT_HANDLE 0x100
  2807. #endif
  2808. #define Added 0
  2809. #define Removed 1
  2810. #define Modified 2
  2811. #define RenamedOldName 3
  2812. #define RenamedNewName 4
  2813. //
  2814. // Lockrange for use with OS/2 DosFileLocks call
  2815. //
  2816. // *** Where is this used?
  2817. //typedef struct lockrange {
  2818. // ULONG offset;
  2819. // ULONG range;
  2820. // };
  2821. //#define LOCK 0x1
  2822. //#define UNLOCK 0x2
  2823. //
  2824. // Data buffer format codes, from the core protocol.
  2825. //
  2826. #define SMB_FORMAT_DATA 1
  2827. #define SMB_FORMAT_DIALECT 2
  2828. #define SMB_FORMAT_PATHNAME 3
  2829. #define SMB_FORMAT_ASCII 4
  2830. #define SMB_FORMAT_VARIABLE 5
  2831. //
  2832. // WriteMode flags
  2833. //
  2834. #define SMB_WMODE_WRITE_THROUGH 0x0001 // complete write before responding
  2835. #define SMB_WMODE_SET_REMAINING 0x0002 // returning amt remaining in pipe
  2836. #define SMB_WMODE_WRITE_RAW_NAMED_PIPE 0x0004 // write named pipe in raw mode
  2837. #define SMB_WMODE_START_OF_MESSAGE 0x0008 // start of pipe message
  2838. #define SMB_WMODE_DATAGRAM 0x0080 // start of pipe message
  2839. //
  2840. // Various SMB flags:
  2841. //
  2842. //
  2843. // If the server supports LockAndRead and WriteAndUnlock, it sets this
  2844. // bit the Negotiate response.
  2845. //
  2846. #define SMB_FLAGS_LOCK_AND_READ_OK 0x01
  2847. //
  2848. // When on, the consumer guarantees that there is a receive buffer posted
  2849. // such that a "Send.No.Ack" can be used by the server to respond to
  2850. // the consumer's request.
  2851. //
  2852. #define SMB_FLAGS_SEND_NO_ACK 0x2
  2853. //
  2854. // This is part of the Flags field of every SMB header. If this bit
  2855. // is set, then all pathnames in the SMB should be treated as case-
  2856. // insensitive.
  2857. //
  2858. #define SMB_FLAGS_CASE_INSENSITIVE 0x8
  2859. //
  2860. // When on in session setup, this bit indicates that all paths sent to
  2861. // the server are already in OS/2 canonicalized format.
  2862. //
  2863. #define SMB_FLAGS_CANONICALIZED_PATHS 0x10
  2864. //
  2865. // When on in a open file request SMBs (open, create, openX, etc.) this
  2866. // bit indicates a request for an oplock on the file. When on in the
  2867. // response, this bit indicates that the oplock was granted.
  2868. //
  2869. #define SMB_FLAGS_OPLOCK 0x20
  2870. //
  2871. // When on, this bit indicates that the server should notify the client
  2872. // on any request that could cause the file to be changed. If not set,
  2873. // the server only notifies the client on other open requests on the
  2874. // file.
  2875. //
  2876. #define SMB_FLAGS_OPLOCK_NOTIFY_ANY 0x40
  2877. //
  2878. // This bit indicates that the SMB is being sent from server to redir.
  2879. //
  2880. #define SMB_FLAGS_SERVER_TO_REDIR 0x80
  2881. //
  2882. // Valid bits for Flags on an incoming SMB
  2883. //
  2884. #define INCOMING_SMB_FLAGS \
  2885. (SMB_FLAGS_LOCK_AND_READ_OK | \
  2886. SMB_FLAGS_SEND_NO_ACK | \
  2887. SMB_FLAGS_CASE_INSENSITIVE | \
  2888. SMB_FLAGS_CANONICALIZED_PATHS | \
  2889. SMB_FLAGS_OPLOCK_NOTIFY_ANY | \
  2890. SMB_FLAGS_OPLOCK)
  2891. //
  2892. // Names for bits in Flags2 field of SMB header that indicate what the
  2893. // client app is aware of.
  2894. //
  2895. #define SMB_FLAGS2_KNOWS_LONG_NAMES 0x0001
  2896. #define SMB_FLAGS2_KNOWS_EAS 0x0002
  2897. #define SMB_FLAGS2_SMB_SECURITY_SIGNATURE 0x0004
  2898. #define SMB_FLAGS2_COMPRESSED 0x0008
  2899. // Unused 0x0010
  2900. // Unused 0x0020
  2901. #define SMB_FLAGS2_IS_LONG_NAME 0x0040
  2902. // Unused 0x0080
  2903. // Unused 0x0100
  2904. // Unused 0x0200
  2905. #define SMB_FLAGS2_REPARSE_PATH 0x0400
  2906. #define SMB_FLAGS2_EXTENDED_SECURITY 0x0800
  2907. #define SMB_FLAGS2_DFS 0x1000
  2908. #define SMB_FLAGS2_PAGING_IO 0x2000
  2909. #define SMB_FLAGS2_NT_STATUS 0x4000
  2910. #define SMB_FLAGS2_UNICODE 0x8000
  2911. //
  2912. // Valid bits for Flags2 on an incoming SMB
  2913. //
  2914. #define INCOMING_SMB_FLAGS2 \
  2915. (SMB_FLAGS2_KNOWS_LONG_NAMES | \
  2916. SMB_FLAGS2_KNOWS_EAS | \
  2917. SMB_FLAGS2_SMB_SECURITY_SIGNATURE | \
  2918. SMB_FLAGS2_EXTENDED_SECURITY| \
  2919. SMB_FLAGS2_DFS | \
  2920. SMB_FLAGS2_PAGING_IO | \
  2921. SMB_FLAGS2_IS_LONG_NAME | \
  2922. SMB_FLAGS2_NT_STATUS | \
  2923. SMB_FLAGS2_COMPRESSED | \
  2924. SMB_FLAGS2_UNICODE | \
  2925. SMB_FLAGS2_REPARSE_PATH)
  2926. //
  2927. // The SMB open function determines what action should be taken depending
  2928. // on the existence or lack thereof of files used in the operation. It
  2929. // has the following mapping:
  2930. //
  2931. // 1111 1
  2932. // 5432 1098 7654 3210
  2933. // rrrr rrrr rrrC rrOO
  2934. //
  2935. // where:
  2936. //
  2937. // O - Open (action to be taken if the target file exists)
  2938. // 0 - Fail
  2939. // 1 - Open or Append file
  2940. // 2 - Truncate file
  2941. //
  2942. // C - Create (action to be taken if the target file does not exist)
  2943. // 0 - Fail
  2944. // 1 - Create file
  2945. //
  2946. #define SMB_OFUN_OPEN_MASK 0x3
  2947. #define SMB_OFUN_CREATE_MASK 0x10
  2948. #define SMB_OFUN_OPEN_FAIL 0
  2949. #define SMB_OFUN_OPEN_APPEND 1
  2950. #define SMB_OFUN_OPEN_OPEN 1
  2951. #define SMB_OFUN_OPEN_TRUNCATE 2
  2952. #define SMB_OFUN_CREATE_FAIL 0x00
  2953. #define SMB_OFUN_CREATE_CREATE 0x10
  2954. //++
  2955. //
  2956. // BOOLEAN
  2957. // SmbOfunCreate(
  2958. // IN USHORT SmbOpenFunction
  2959. // )
  2960. //
  2961. //--
  2962. #define SmbOfunCreate(SmbOpenFunction) \
  2963. (BOOLEAN)((SmbOpenFunction & SMB_OFUN_CREATE_MASK) == SMB_OFUN_CREATE_CREATE)
  2964. //++
  2965. //
  2966. // BOOLEAN
  2967. // SmbOfunAppend(
  2968. // IN USHORT SmbOpenFunction
  2969. // )
  2970. //
  2971. //--
  2972. #define SmbOfunAppend(SmbOpenFunction) \
  2973. (BOOLEAN)((SmbOpenFunction & SMB_OFUN_OPEN_MASK) == SMB_OFUN_OPEN_APPEND)
  2974. //++
  2975. //
  2976. // BOOLEAN
  2977. // SmbOfunTruncate(
  2978. // IN USHORT SmbOpenFunction
  2979. // )
  2980. //
  2981. //--
  2982. #define SmbOfunTruncate(SmbOpenFunction) \
  2983. (BOOLEAN)((SmbOpenFunction & SMB_OFUN_OPEN_MASK) == SMB_OFUN_OPEN_TRUNCATE)
  2984. //
  2985. // The desired access mode passed in Open and Open and X has the following
  2986. // mapping:
  2987. //
  2988. // 1111 11
  2989. // 5432 1098 7654 3210
  2990. // rWrC rLLL rSSS rAAA
  2991. //
  2992. // where:
  2993. //
  2994. // W - Write through mode. No read ahead or write behind allowed on
  2995. // this file or device. When protocol is returned, data is expected
  2996. // to be on the disk or device.
  2997. //
  2998. // S - Sharing mode:
  2999. // 0 - Compatibility mode (as in core open)
  3000. // 1 - Deny read/write/execute (exclusive)
  3001. // 2 - Deny write
  3002. // 3 - Deny read/execute
  3003. // 4 - Deny none
  3004. //
  3005. // A - Access mode
  3006. // 0 - Open for reading
  3007. // 1 - Open for writing
  3008. // 2 - Open for reading and writing
  3009. // 3 - Open for execute
  3010. //
  3011. // rSSSrAAA = 11111111 (hex FF) indicates FCB open (as in core protocol)
  3012. //
  3013. // C - Cache mode
  3014. // 0 - Normal file
  3015. // 1 - Do not cache this file
  3016. //
  3017. // L - Locality of reference
  3018. // 0 - Locality of reference is unknown
  3019. // 1 - Mainly sequential access
  3020. // 2 - Mainly random access
  3021. // 3 - Random access with some locality
  3022. // 4 to 7 - Currently undefined
  3023. //
  3024. #define SMB_DA_SHARE_MASK 0x70
  3025. #define SMB_DA_ACCESS_MASK 0x07
  3026. #define SMB_DA_FCB_MASK (UCHAR)0xFF
  3027. #define SMB_DA_ACCESS_READ 0x00
  3028. #define SMB_DA_ACCESS_WRITE 0x01
  3029. #define SMB_DA_ACCESS_READ_WRITE 0x02
  3030. #define SMB_DA_ACCESS_EXECUTE 0x03
  3031. #define SMB_DA_SHARE_COMPATIBILITY 0x00
  3032. #define SMB_DA_SHARE_EXCLUSIVE 0x10
  3033. #define SMB_DA_SHARE_DENY_WRITE 0x20
  3034. #define SMB_DA_SHARE_DENY_READ 0x30
  3035. #define SMB_DA_SHARE_DENY_NONE 0x40
  3036. #define SMB_DA_FCB (UCHAR)0xFF
  3037. #define SMB_CACHE_NORMAL 0x0000
  3038. #define SMB_DO_NOT_CACHE 0x1000
  3039. #define SMB_LR_UNKNOWN 0x0000
  3040. #define SMB_LR_SEQUENTIAL 0x0100
  3041. #define SMB_LR_RANDOM 0x0200
  3042. #define SMB_LR_RANDOM_WITH_LOCALITY 0x0300
  3043. #define SMB_LR_MASK 0x0F00
  3044. #define SMB_DA_WRITE_THROUGH 0x4000
  3045. //
  3046. // The Action field of OpenAndX has the following format:
  3047. //
  3048. // 1111 11
  3049. // 5432 1098 7654 3210
  3050. // Lrrr rrrr rrrr rrOO
  3051. //
  3052. // where:
  3053. //
  3054. // L - Opportunistic lock. 1 if lock granted, else 0.
  3055. //
  3056. // O - Open action:
  3057. // 1 - The file existed and was opened
  3058. // 2 - The file did not exist but was created
  3059. // 3 - The file existed and was truncated
  3060. //
  3061. #define SMB_OACT_OPENED 0x01
  3062. #define SMB_OACT_CREATED 0x02
  3063. #define SMB_OACT_TRUNCATED 0x03
  3064. #define SMB_OACT_OPLOCK 0x8000
  3065. //
  3066. // These flags are passed in the Flags field of the copy and extended rename
  3067. // SMBs.
  3068. //
  3069. //
  3070. // If set, the target must be a file or directory.
  3071. //
  3072. #define SMB_TARGET_IS_FILE 0x1
  3073. #define SMB_TARGET_IS_DIRECTORY 0x2
  3074. //
  3075. // The copy mode--if set, ASCII copying should be done, otherwise binary.
  3076. //
  3077. #define SMB_COPY_TARGET_ASCII 0x4
  3078. #define SMB_COPY_SOURCE_ASCII 0x8
  3079. #define SMB_COPY_TREE 0x20
  3080. //
  3081. // If set, verify all writes.
  3082. //
  3083. #define SMB_VERIFY_WRITES
  3084. //
  3085. // Define file attribute bits as used in the SMB protocol. The specific
  3086. // bit positions are, for the most part, identical to those used in NT.
  3087. // However, NT does not define Volume and Directory bits. It also has
  3088. // an explicit Normal bit; this bit is implied in SMB attributes by
  3089. // Hidden, System, and Directory being off.
  3090. //
  3091. #define SMB_FILE_ATTRIBUTE_READONLY 0x01
  3092. #define SMB_FILE_ATTRIBUTE_HIDDEN 0x02
  3093. #define SMB_FILE_ATTRIBUTE_SYSTEM 0x04
  3094. #define SMB_FILE_ATTRIBUTE_VOLUME 0x08
  3095. #define SMB_FILE_ATTRIBUTE_DIRECTORY 0x10
  3096. #define SMB_FILE_ATTRIBUTE_ARCHIVE 0x20
  3097. //
  3098. // Share type strings are passed in SMBs to indicate what type of shared
  3099. // resource is being or has been connected to.
  3100. //
  3101. #define SHARE_TYPE_NAME_DISK "A:"
  3102. #define SHARE_TYPE_NAME_PIPE "IPC"
  3103. #define SHARE_TYPE_NAME_COMM "COMM"
  3104. #define SHARE_TYPE_NAME_PRINT "LPT1:"
  3105. #define SHARE_TYPE_NAME_WILD "?????"
  3106. //
  3107. // SMB Error codes:
  3108. //
  3109. //
  3110. // Success Class:
  3111. //
  3112. #define SMB_ERR_SUCCESS (UCHAR)0x00
  3113. //
  3114. // DOS Error Class:
  3115. //
  3116. #define SMB_ERR_CLASS_DOS (UCHAR)0x01
  3117. #define SMB_ERR_BAD_FUNCTION 1 // Invalid function
  3118. #define SMB_ERR_BAD_FILE 2 // File not found
  3119. #define SMB_ERR_BAD_PATH 3 // Invalid directory
  3120. #define SMB_ERR_NO_FIDS 4 // Too many open files
  3121. #define SMB_ERR_ACCESS_DENIED 5 // Access not allowed for req. func.
  3122. #define SMB_ERR_BAD_FID 6 // Invalid file handle
  3123. #define SMB_ERR_BAD_MCB 7 // Memory control blocks destroyed
  3124. #define SMB_ERR_INSUFFICIENT_MEMORY 8 // For the desired function
  3125. #define SMB_ERR_BAD_MEMORY 9 // Invalid memory block address
  3126. #define SMB_ERR_BAD_ENVIRONMENT 10 // Invalid environment
  3127. #define SMB_ERR_BAD_FORMAT 11 // Invalid format
  3128. #define SMB_ERR_BAD_ACCESS 12 // Invalid open mode
  3129. #define SMB_ERR_BAD_DATA 13 // Invalid data (only from IOCTL)
  3130. #define SMB_ERR_RESERVED 14
  3131. #define SMB_ERR_BAD_DRIVE 15 // Invalid drive specified
  3132. #define SMB_ERR_CURRENT_DIRECTORY 16 // Attempted to remove currect directory
  3133. #define SMB_ERR_DIFFERENT_DEVICE 17 // Not the same device
  3134. #define SMB_ERR_NO_FILES 18 // File search can't find more files
  3135. #define SMB_ERR_BAD_SHARE 32 // An open conflicts with FIDs on file
  3136. #define SMB_ERR_LOCK 33 // Conflict with existing lock
  3137. #define SMB_ERR_FILE_EXISTS 80 // Tried to overwrite existing file
  3138. #define SMB_ERR_BAD_PIPE 230 // Invalie pipe
  3139. #define SMB_ERR_PIPE_BUSY 231 // All instances of the pipe are busy
  3140. #define SMB_ERR_PIPE_CLOSING 232 // Pipe close in progress
  3141. #define SMB_ERR_PIPE_NOT_CONNECTED 233 // No process on other end of pipe
  3142. #define SMB_ERR_MORE_DATA 234 // There is more data to return
  3143. //
  3144. // SERVER Error Class:
  3145. //
  3146. #define SMB_ERR_CLASS_SERVER (UCHAR)0x02
  3147. #define SMB_ERR_ERROR 1 // Non-specific error code
  3148. #define SMB_ERR_BAD_PASSWORD 2 // Bad name/password pair
  3149. #define SMB_ERR_BAD_TYPE 3 // Reserved
  3150. #define SMB_ERR_ACCESS 4 // Requester lacks necessary access
  3151. #define SMB_ERR_BAD_TID 5 // Invalid TID
  3152. #define SMB_ERR_BAD_NET_NAME 6 // Invalid network name in tree connect
  3153. #define SMB_ERR_BAD_DEVICE 7 // Invalid device request
  3154. #define SMB_ERR_QUEUE_FULL 49 // Print queue full--returned print file
  3155. #define SMB_ERR_QUEUE_TOO_BIG 50 // Print queue full--no space
  3156. #define SMB_ERR_QUEUE_EOF 51 // EOF on print queue dump
  3157. #define SMB_ERR_BAD_PRINT_FID 52 // Invalid print file FID
  3158. #define SMB_ERR_BAD_SMB_COMMAND 64 // SMB command not recognized
  3159. #define SMB_ERR_SERVER_ERROR 65 // Internal server error
  3160. #define SMB_ERR_FILE_SPECS 67 // FID and pathname were incompatible
  3161. #define SMB_ERR_RESERVED2 68
  3162. #define SMB_ERR_BAD_PERMITS 69 // Access permissions invalid
  3163. #define SMB_ERR_RESERVED3 70
  3164. #define SMB_ERR_BAD_ATTRIBUTE_MODE 71 // Invalid attribute mode specified
  3165. #define SMB_ERR_SERVER_PAUSED 81 // Server is paused
  3166. #define SMB_ERR_MESSAGE_OFF 82 // Server not receiving messages
  3167. #define SMB_ERR_NO_ROOM 83 // No room for buffer message
  3168. #define SMB_ERR_TOO_MANY_NAMES 87 // Too many remote user names
  3169. #define SMB_ERR_TIMEOUT 88 // Operation was timed out
  3170. #define SMB_ERR_NO_RESOURCE 89 // No resources available for request
  3171. #define SMB_ERR_TOO_MANY_UIDS 90 // Too many UIDs active in session
  3172. #define SMB_ERR_BAD_UID 91 // UID not known as a valid UID
  3173. #define SMB_ERR_INVALID_NAME 123 // Invalid name returned from FAT.
  3174. #define SMB_ERR_INVALID_NAME_RANGE 206 // Non 8.3 name passed to FAT (or non 255 name to HPFS)
  3175. #define SMB_ERR_USE_MPX 250 // Can't support Raw; use MPX
  3176. #define SMB_ERR_USE_STANDARD 251 // Can't support Raw, use standard r/w
  3177. #define SMB_ERR_CONTINUE_MPX 252 // Reserved
  3178. #define SMB_ERR_RESERVED4 253
  3179. #define SMB_ERR_RESERVED5 254
  3180. #define SMB_ERR_NO_SUPPORT_INTERNAL 255 // Internal code for NO_SUPPORT--
  3181. // allows codes to be stored in a byte
  3182. #define SMB_ERR_NO_SUPPORT (USHORT)0xFFFF // Function not supported
  3183. //
  3184. // HARDWARE Error Class:
  3185. //
  3186. #define SMB_ERR_CLASS_HARDWARE (UCHAR)0x03
  3187. #define SMB_ERR_NO_WRITE 19 // Write attempted to write-prot. disk
  3188. #define SMB_ERR_BAD_UNIT 20 // Unknown unit
  3189. #define SMB_ERR_DRIVE_NOT_READY 21 // Disk drive not ready
  3190. #define SMB_ERR_BAD_COMMAND 22 // Unknown command
  3191. #define SMB_ERR_DATA 23 // Data error (CRC)
  3192. #define SMB_ERR_BAD_REQUEST 24 // Bad request structure length
  3193. #define SMB_ERR_SEEK 25 // Seek error
  3194. #define SMB_ERR_BAD_MEDIA 26 // Unknown media type
  3195. #define SMB_ERR_BAD_SECTOR 27 // Sector not found
  3196. #define SMB_ERR_NO_PAPER 28 // Printer out of paper
  3197. #define SMB_ERR_WRITE_FAULT 29 // Write fault
  3198. #define SMB_ERR_READ_FAULT 30 // Read fault
  3199. #define SMB_ERR_GENERAL 31 // General failure
  3200. #define SMB_ERR_LOCK_CONFLICT 33 // Lock conflicts with existing lock
  3201. #define SMB_ERR_WRONG_DISK 34 // Wrong disk was found in a drive
  3202. #define SMB_ERR_FCB_UNAVAILABLE 35 // No FCBs available to process request
  3203. #define SMB_ERR_SHARE_BUFFER_EXCEEDED 36
  3204. #define SMB_ERR_DISK_FULL 39 // !!! Undocumented, but in LM2.0
  3205. //
  3206. // Other Error Classes:
  3207. //
  3208. #define SMB_ERR_CLASS_XOS (UCHAR)0x04 // Reserved for XENIX
  3209. #define SMB_ERR_CLASS_RMX1 (UCHAR)0xE1 // Reserved for iRMX
  3210. #define SMB_ERR_CLASS_RMX2 (UCHAR)0xE2 // Reserved for iRMX
  3211. #define SMB_ERR_CLASS_RMX3 (UCHAR)0xE3 // Reserved for iRMX
  3212. #define SMB_ERR_CLASS_COMMAND (UCHAR)0xFF // Command was not in the SMB format
  3213. //
  3214. // Turn structure packing back off
  3215. //
  3216. #ifndef NO_PACKING
  3217. #include <packoff.h>
  3218. #endif // ndef NO_PACKING
  3219. #endif // _SMB_
  3220. // Old (LanMan 1.2) and new (NT) field names:
  3221. // (Undocumented fields have corresponding structure in parenthesis)
  3222. // smb_access Access
  3223. // smb_action Action
  3224. // smb_adate AccessDate
  3225. // smb_allocsize AllocationSize
  3226. // smb_aname AccountName
  3227. // smb_apasslen PasswordSize
  3228. // smb_apasswd AccountPassword
  3229. // smb_atime AccessTime
  3230. // smb_attr Attribute
  3231. // smb_attribute Attribute
  3232. // smb_aunits (RESP_QUERY_INFORMATION_SERVER)
  3233. // smb_bcc BufferSize
  3234. // smb_blkmode BlockMode
  3235. // smb_blksize BlockSize
  3236. // smb_blksperunit BlocksPerUnit
  3237. // smb_bpu BlocksPerUnit
  3238. // smb_bs BlockSize
  3239. // smb_bufsize MaxBufferSize
  3240. // smb_buf[1] Buffer[1]
  3241. // smb_bytes[*] Bytes[*]
  3242. // smb_cat Category
  3243. // smb_cct FilesCopied
  3244. // smb_cdate CreateDate
  3245. // smb_cert CertificateOffset
  3246. // smb_com Command
  3247. // smb_com2 AndXCommand
  3248. // smb_count Count
  3249. // smb_count_left Remaining
  3250. // smb_cryptkey[*] CryptKey
  3251. // smb_ctime CreateTime
  3252. // smb_datablock DataBlock
  3253. // smb_datalen DataSize
  3254. // smb_datasize DataSize
  3255. // smb_data[*] Data[*]
  3256. // smb_dcmode DataCompactMode
  3257. // smb_dev DeviceName
  3258. // smb_doff DataOffset
  3259. // smb_drcnt DataCount
  3260. // smb_drdisp DataDisplacement
  3261. // smb_droff DataOffset
  3262. // smb_dscnt DataCount
  3263. // smb_dsdisp DataDisplacement
  3264. // smb_dsize DataSize
  3265. // smb_dsoff DataOffset
  3266. // smb_encrypt EncryptKey
  3267. // smb_encryptlen EncryptKeySize
  3268. // smb_encryptoff EncryptKeyOffset
  3269. // smb_eos EndOfSearch
  3270. // smb_err Error
  3271. // smb_errmsg[1] ErrorMessage[1]
  3272. // smb_fau (RESP_QUERY_INFORMATION_SERVER)
  3273. // smb_fid Fid
  3274. // smb_fileid ServerFid
  3275. // smb_flag Flag
  3276. // smb_flag2 Flag2
  3277. // smb_flags Flag
  3278. // smb_flg Flag
  3279. // smb_freeunits FreeUnits
  3280. // smb_fsid (RESP_QUERY_INFORMATION_SERVER)
  3281. // smb_fsize FileSize
  3282. // smb_fun Function
  3283. // smb_gid Gid
  3284. // smb_handle Handle
  3285. // smb_ident1 Identifier
  3286. // smb_idf[4] Protocol[4]
  3287. // smb_index Index
  3288. // smb_info Info
  3289. // smb_left Remaining
  3290. // smb_len SetupLength
  3291. // smb_locknum NumberOfLocks
  3292. // smb_lockrng[*] LockRange
  3293. // smb_locktype LockType
  3294. // smb_lpid OwnerPid
  3295. // smb_maxbytes MaxBytes
  3296. // smb_maxcnt MaxCount
  3297. // smb_maxcount MaxCount
  3298. // smb_maxmux (RESP_NEGOTIATE)
  3299. // smb_maxvcs MaxNumberVcs
  3300. // smb_maxxmitsz MaxTransmitSize
  3301. // smb_maxxmt MaxTransmitSize
  3302. // smb_mdate ModificationDate
  3303. // smb_mdrcnt MaxDataCount
  3304. // smb_mid Mid
  3305. // smb_mincnt MinCount
  3306. // smb_mode Mode
  3307. // smb_mprcnt MaxParameterCount
  3308. // smb_mpxmax MaxMpxCount
  3309. // smb_msrcnt MaxSetupCount
  3310. // smb_mtime ModificationTime
  3311. // smb_name[*] Name[*]
  3312. // smb_off2 AndXOffset
  3313. // smb_offset Offset
  3314. // smb_ofun OpenFunction
  3315. // smb_pad Pad
  3316. // smb_pad1[] Pad1
  3317. // smb_pad[] Pad[]
  3318. // smb_param[*] Parameter[*]
  3319. // smb_path ServerName
  3320. // smb_pathname PathName
  3321. // smb_pid Pid
  3322. // smb_prcnt ParameterCount
  3323. // smb_prdisp ParameterDisplacement
  3324. // smb_proff ParameterCount
  3325. // smb_pscnt ParameterCount
  3326. // smb_psdisp ParameterDisplacement
  3327. // smb_psoff ParameterOffset
  3328. // smb_range LockLength or UnlockLength
  3329. // smb_rcls ErrorClass
  3330. // smb_reh ReservedH
  3331. // smb_reh2 ReservedH2
  3332. // smb_remaining Remaining
  3333. // smb_remcnt Remaining
  3334. // smb_res1 Reserved
  3335. // smb_res2 Reserved2
  3336. // smb_res3 Reserved3
  3337. // smb_res4 Reserved4
  3338. // smb_res5 Reserved5
  3339. // smb_reserved Reserved
  3340. // smb_restart Restart
  3341. // smb_resumekey ResumeKey
  3342. // smb_res[5] Reserved[]
  3343. // smb_reverb ReverbCount
  3344. // smb_rsvd Reserved
  3345. // smb_rsvd1 Reserved
  3346. // smb_rsvd2 Reserved2
  3347. // smb_rsvd3 Reserved3
  3348. // smb_rsvd4 Reserved4
  3349. // smb_sattr SearchAttribute
  3350. // smb_secmode SecurityMode
  3351. // smb_seq SequenceNumber
  3352. // smb_services Services
  3353. // smb_sesskey SessionKey
  3354. // smb_setup[*] Setup[*]
  3355. // smb_size Size
  3356. // smb_spasslen ServerPasswordSize
  3357. // smb_spasswd ServerPassword
  3358. // smb_srv_date ServerDate
  3359. // smb_srv_time ServerTime
  3360. // smb_srv_tzone ServerTimeZone
  3361. // smb_start StartIndex
  3362. // smb_state DeviceState
  3363. // smb_suwcnt SetupWordCount
  3364. // smb_su_class SetupClass
  3365. // smb_su_com SetupCommand
  3366. // smb_su_handle SetupFid
  3367. // smb_su_opcode SetupOpcode
  3368. // smb_su_priority SetupPriority
  3369. // smb_tcount Count
  3370. // smb_tdis TreeDisconnect
  3371. // smb_tdrcnt TotalDataCount
  3372. // smb_tdscnt TotalDataCount
  3373. // smb_tid Tid
  3374. // smb_tid2 Tid2
  3375. // smb_time Time
  3376. // smb_timeout Timeout
  3377. // smb_totalunits TotalUnits
  3378. // smb_tprcnt TotalParameterCount
  3379. // smb_tpscnt TotalParameterCount
  3380. // smb_type FileType
  3381. // smb_uid Uid
  3382. // smb_unlkrng[*] UnlockRange
  3383. // smb_unlocknum NumberOfUnlocks
  3384. // smb_vblen DataLength
  3385. // smb_vcnum VcNumber
  3386. // smb_vldate (RESP_QUERY_INFORMATION_SERVER)
  3387. // smb_vllen (RESP_QUERY_INFORMATION_SERVER)
  3388. // smb_vltime (RESP_QUERY_INFORMATION_SERVER)
  3389. // smb_vwv[1] Param
  3390. // smb_wct WordCount
  3391. // smb_wmode WriteMode
  3392. // smb_xchain EncryptChainOffset