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.

6339 lines
220 KiB

  1. /*++
  2. Copyright (c) 1989 - 1999 Microsoft Corporation
  3. Module Name:
  4. cifs.h
  5. Abstract:
  6. This module defines structures and constants for the Common Internet File System
  7. commands, request and response protocol.
  8. --*/
  9. #ifndef _CIFS_
  10. #define _CIFS_
  11. //
  12. // The server has 16 bits available to it in each 32-bit status code.
  13. // See \nt\sdk\inc\ntstatus.h for a description of the use of the
  14. // high 16 bits of the status.
  15. //
  16. // The layout of the bits is:
  17. //
  18. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  19. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  20. // +---+-+-------------------------+-------+-----------------------+
  21. // |Sev|C| Facility--Server | Class | Code |
  22. // +---+-+-------------------------+-------+-----------------------+
  23. //
  24. // Class values:
  25. // 0 - a server-specific error code, not put directly on the wire.
  26. // 1 - SMB error class DOS. This includes those OS/2 errors
  27. // that share code values and meanings with the SMB protocol.
  28. // 2 - SMB error class SERVER.
  29. // 3 - SMB error class HARDWARE.
  30. // 4 - other SMB error classes
  31. // 5-E - undefined
  32. // F - an OS/2-specific error. If the client is OS/2, then the
  33. // SMB error class is set to DOS and the code is set to
  34. // the actual OS/2 error code contained in the Code field.
  35. //
  36. // The meaning of the Code field depends on the Class value. If the
  37. // class is 00, then the code value is arbitrary. For other classes,
  38. // the code is the actual code of the error in the SMB or OS/2
  39. // protocols.
  40. //
  41. #define SRV_STATUS_FACILITY_CODE 0x00980000L
  42. #define SRV_SRV_STATUS (0xC0000000L | SRV_STATUS_FACILITY_CODE)
  43. #define SRV_DOS_STATUS (0xC0001000L | SRV_STATUS_FACILITY_CODE)
  44. #define SRV_SERVER_STATUS (0xC0002000L | SRV_STATUS_FACILITY_CODE)
  45. #define SRV_HARDWARE_STATUS (0xC0003000L | SRV_STATUS_FACILITY_CODE)
  46. #define SRV_WIN32_STATUS (0xC000E000L | SRV_STATUS_FACILITY_CODE)
  47. #define SRV_OS2_STATUS (0xC000F000L | SRV_STATUS_FACILITY_CODE)
  48. //++
  49. //
  50. // BOOLEAN
  51. // SmbIsSrvStatus (
  52. // IN NTSTATUS Status
  53. // )
  54. //
  55. // Routine Description:
  56. //
  57. // Macro to determine whether a status code is one defined by the
  58. // server (has the server facility code).
  59. //
  60. // Arguments:
  61. //
  62. // Status - the status code to check.
  63. //
  64. // Return Value:
  65. //
  66. // BOOLEAN - TRUE if the facility code is the servers, FALSE
  67. // otherwise.
  68. //
  69. //--
  70. #define SrvIsSrvStatus(Status) \
  71. ( ((Status) & 0x1FFF0000) == SRV_STATUS_FACILITY_CODE ? TRUE : FALSE )
  72. //++
  73. //
  74. // UCHAR
  75. // SmbErrorClass (
  76. // IN NTSTATUS Status
  77. // )
  78. //
  79. // Routine Description:
  80. //
  81. // This macro extracts the error class field from a server status
  82. // code.
  83. //
  84. // Arguments:
  85. //
  86. // Status - the status code from which to get the error class.
  87. //
  88. // Return Value:
  89. //
  90. // UCHAR - the server error class of the status code.
  91. //
  92. //--
  93. #define SrvErrorClass(Status) ((UCHAR)( ((Status) & 0x0000F000) >> 12 ))
  94. //++
  95. //
  96. // UCHAR
  97. // SmbErrorCode (
  98. // IN NTSTATUS Status
  99. // )
  100. //
  101. // Routine Description:
  102. //
  103. // This macro extracts the error code field from a server status
  104. // code.
  105. //
  106. // Arguments:
  107. //
  108. // Status - the status code from which to get the error code.
  109. //
  110. // Return Value:
  111. //
  112. // UCHAR - the server error code of the status code.
  113. //
  114. //--
  115. #define SrvErrorCode(Status) ((USHORT)( (Status) & 0xFFF) )
  116. //
  117. // Status codes unique to the server. These error codes are used
  118. // internally only.
  119. //
  120. #define STATUS_ENDPOINT_CLOSED (SRV_SRV_STATUS | 0x01)
  121. #define STATUS_DISCONNECTED (SRV_SRV_STATUS | 0x02)
  122. #define STATUS_SERVER_ALREADY_STARTED (SRV_SRV_STATUS | 0x04)
  123. #define STATUS_SERVER_NOT_STARTED (SRV_SRV_STATUS | 0x05)
  124. #define STATUS_OPLOCK_BREAK_UNDERWAY (SRV_SRV_STATUS | 0x06)
  125. #define STATUS_NONEXISTENT_NET_NAME (SRV_SRV_STATUS | 0x08)
  126. //
  127. // Error codes that exist in both the SMB protocol and OS/2 but not NT.
  128. // Note that all SMB DOS-class error codes are defined in OS/2.
  129. //
  130. #define STATUS_OS2_INVALID_FUNCTION (SRV_DOS_STATUS | ERROR_INVALID_FUNCTION)
  131. #define STATUS_OS2_TOO_MANY_OPEN_FILES \
  132. (SRV_DOS_STATUS | ERROR_TOO_MANY_OPEN_FILES)
  133. #define STATUS_OS2_INVALID_ACCESS (SRV_DOS_STATUS | ERROR_INVALID_ACCESS)
  134. //
  135. // SMB SERVER-class error codes that lack an NT or OS/2 equivalent.
  136. //
  137. #define STATUS_INVALID_SMB (SRV_SERVER_STATUS | SMB_ERR_ERROR)
  138. #define STATUS_SMB_BAD_NET_NAME (SRV_SERVER_STATUS | SMB_ERR_BAD_NET_NAME)
  139. #define STATUS_SMB_BAD_TID (SRV_SERVER_STATUS | SMB_ERR_BAD_TID)
  140. #define STATUS_SMB_BAD_UID (SRV_SERVER_STATUS | SMB_ERR_BAD_UID)
  141. #define STATUS_SMB_TOO_MANY_UIDS (SRV_SERVER_STATUS | SMB_ERR_TOO_MANY_UIDS)
  142. #define STATUS_SMB_USE_MPX (SRV_SERVER_STATUS | SMB_ERR_USE_MPX)
  143. #define STATUS_SMB_USE_STANDARD (SRV_SERVER_STATUS | SMB_ERR_USE_STANDARD)
  144. #define STATUS_SMB_CONTINUE_MPX (SRV_SERVER_STATUS | SMB_ERR_CONTINUE_MPX)
  145. #define STATUS_SMB_BAD_COMMAND (SRV_SERVER_STATUS | SMB_ERR_BAD_COMMAND)
  146. #define STATUS_SMB_NO_SUPPORT (SRV_SERVER_STATUS | SMB_ERR_NO_SUPPORT_INTERNAL)
  147. // *** because SMB_ERR_NO_SUPPORT uses 16 bits, but we have only 12 bits
  148. // available for error codes, it must be special-cased in the code.
  149. //
  150. // SMB HARDWARE-class error codes that lack an NT or OS/2 equivalent.
  151. //
  152. #define STATUS_SMB_DATA (SRV_HARDWARE_STATUS | SMB_ERR_DATA)
  153. //
  154. // OS/2 error codes that lack an NT or SMB equivalent.
  155. //
  156. #include <winerror.h>
  157. #define STATUS_OS2_INVALID_LEVEL \
  158. (NTSTATUS)(SRV_OS2_STATUS | ERROR_INVALID_LEVEL)
  159. #define STATUS_OS2_EA_LIST_INCONSISTENT \
  160. (NTSTATUS)(SRV_OS2_STATUS | ERROR_EA_LIST_INCONSISTENT)
  161. #define STATUS_OS2_NEGATIVE_SEEK \
  162. (NTSTATUS)(SRV_OS2_STATUS | ERROR_NEGATIVE_SEEK)
  163. #define STATUS_OS2_NO_MORE_SIDS \
  164. (NTSTATUS)(SRV_OS2_STATUS | ERROR_NO_MORE_SEARCH_HANDLES)
  165. #define STATUS_OS2_EAS_DIDNT_FIT \
  166. (NTSTATUS)(SRV_OS2_STATUS | ERROR_EAS_DIDNT_FIT)
  167. #define STATUS_OS2_EA_ACCESS_DENIED \
  168. (NTSTATUS)(SRV_OS2_STATUS | ERROR_EA_ACCESS_DENIED)
  169. #define STATUS_OS2_CANCEL_VIOLATION \
  170. (NTSTATUS)(SRV_OS2_STATUS | ERROR_CANCEL_VIOLATION)
  171. #define STATUS_OS2_ATOMIC_LOCKS_NOT_SUPPORTED \
  172. (NTSTATUS)(SRV_OS2_STATUS | ERROR_ATOMIC_LOCKS_NOT_SUPPORTED)
  173. #define STATUS_OS2_CANNOT_COPY \
  174. (NTSTATUS)(SRV_OS2_STATUS | ERROR_CANNOT_COPY)
  175. //
  176. // SMBDBG determines whether the get/put macros are instead defined as
  177. // function calls. (This is used to more reliablyfind char/short/long
  178. // mismatches).
  179. //
  180. #ifndef SMBDBG
  181. #define SMBDBG 0
  182. #endif
  183. //
  184. // SMBDBG1 determines whether the names of short and long fields in SMB
  185. // structures have an extra character appended. This is used to ensure
  186. // that these fields are only accessed via the get/put macros. SMBDBG1
  187. // must be disabled when SMBDBG is enabled.
  188. //
  189. #ifndef SMBDBG1
  190. #define SMBDBG1 0
  191. #endif
  192. #if SMBDBG && SMBDBG1
  193. #undef SMBDBG1
  194. #define SMBDBG1 0
  195. #endif
  196. //
  197. // If __unaligned support is available, or if we're compiling for a
  198. // machine that handles unaligned accesses in hardware, then define
  199. // SMB_USE_UNALIGNED as 1 (TRUE). Otherwise, define it as 0 (FALSE).
  200. // If SMB_USE_UNALIGNED is FALSE, then the macros below use byte
  201. // accesses to build up word and longword accesses to unaligned fields.
  202. //
  203. // Currently, the machines we build for all have SMB_USE_UNALIGNED as
  204. // TRUE. x86 supports unaligned accesses in hardware, while the MIPS
  205. // compiler supports the __unaligned keyword.
  206. //
  207. // Note that if SMB_USE_UNALIGNED is predefined, we use that definition.
  208. // Also, if SMB_NO_UNALIGNED is defined as TRUE, it forces
  209. // SMB_USE_ALIGNED off. This allows us to force, for testing purposes,
  210. // use of byte accesses in the macros.
  211. //
  212. #ifndef SMB_NO_UNALIGNED
  213. #define SMB_NO_UNALIGNED 0
  214. #endif
  215. #ifndef SMB_USE_UNALIGNED
  216. #if SMB_NO_UNALIGNED
  217. #define SMB_USE_UNALIGNED 0
  218. #else
  219. #define SMB_USE_UNALIGNED 1
  220. #endif
  221. #endif
  222. //
  223. // ntdef.h defines UNALIGNED as "__unaligned" or "", depending on
  224. // whether we're building for MIPS or x86, respectively. Because we
  225. // want to be able to disable use of __unaligned, we define
  226. // SMB_UNALIGNED as "UNALIGNED" or "", depending on whether
  227. // SMB_USE_UNALIGNED is TRUE or FALSE, respectively.
  228. //
  229. #if SMB_USE_UNALIGNED
  230. #define SMB_UNALIGNED UNALIGNED
  231. #else
  232. #define SMB_UNALIGNED
  233. #endif
  234. //
  235. // For ease of use, we define types for unaligned pointers to shorts
  236. // and longs in SMBs. Note that "PUSHORT UNALIGNED" doesn't work.
  237. //
  238. typedef unsigned short SMB_UNALIGNED *PSMB_USHORT;
  239. typedef unsigned long SMB_UNALIGNED *PSMB_ULONG;
  240. //
  241. // Macros for renaming short and long SMB fields.
  242. //
  243. #if SMBDBG1
  244. #define _USHORT( field ) USHORT field ## S
  245. #define _ULONG( field ) ULONG field ## L
  246. #else
  247. #define _USHORT( field ) USHORT field
  248. #define _ULONG( field ) ULONG field
  249. #endif
  250. //
  251. // Force misalignment of the following structures
  252. //
  253. #ifndef NO_PACKING
  254. #include <packon.h>
  255. #endif // ndef NO_PACKING
  256. //
  257. // The SMB_DIALECT type corresponds to the different SMB dialects
  258. // that the server can speak. Associated with it is the DialectStrings[]
  259. // array that holds information about the ASCIIZ strings that are passed
  260. // in the Negotiate SMB.s
  261. //
  262. // These are listed in order from highest preference to lowest preference.
  263. // The assigned numbers correspond to the array SrvClientTypes[] in the
  264. // server module srvdata.c.
  265. //
  266. typedef enum _SMB_DIALECT {
  267. SmbDialectNtLanMan, // NT LAN Man
  268. SmbDialectLanMan21, // OS/2 Lanman 2.1
  269. SmbDialectDosLanMan21, // DOS Lanman 2.1
  270. SmbDialectLanMan20, // OS/2 1.2 LanMan 2.0
  271. SmbDialectDosLanMan20, // DOS LanMan 2.0
  272. SmbDialectLanMan10, // 1st version of full LanMan extensions
  273. SmbDialectMsNet30, // Larger subset of LanMan extensions
  274. SmbDialectMsNet103, // Limited subset of LanMan extensions
  275. SmbDialectPcLan10, // Alternate original protocol
  276. SmbDialectPcNet10, // Original protocol
  277. SmbDialectIllegal,
  278. } SMB_DIALECT, *PSMB_DIALECT;
  279. #define FIRST_DIALECT SmbDialectNtLanMan
  280. #define FIRST_DIALECT_EMULATED SmbDialectNtLanMan
  281. #define LAST_DIALECT SmbDialectIllegal
  282. #define IS_DOS_DIALECT(dialect) \
  283. ( (BOOLEAN)( (dialect) == SmbDialectDosLanMan21 || \
  284. (dialect) == SmbDialectDosLanMan20 || \
  285. (dialect) > SmbDialectLanMan10 ) )
  286. #define IS_OS2_DIALECT(dialect) ( (BOOLEAN)!IS_DOS_DIALECT(dialect) )
  287. #define IS_NT_DIALECT(dialect) (dialect) == SmbDialectNtLanMan
  288. #define DIALECT_HONORS_UID(dialect) \
  289. ( (BOOLEAN)(dialect <= SmbDialectDosLanMan20 ) )
  290. //
  291. // Date and time structures that conform to MS-DOS standard used in
  292. // some SMBs.
  293. //
  294. // !!! These structures are not portable--they depend on a little-endian
  295. // machine (TwoSeconds in lowest bits, etc.)
  296. //
  297. typedef union _SMB_DATE {
  298. USHORT Ushort;
  299. struct {
  300. USHORT Day : 5;
  301. USHORT Month : 4;
  302. USHORT Year : 7;
  303. } Struct;
  304. } SMB_DATE;
  305. typedef SMB_DATE SMB_UNALIGNED *PSMB_DATE;
  306. typedef union _SMB_TIME {
  307. USHORT Ushort;
  308. struct {
  309. USHORT TwoSeconds : 5;
  310. USHORT Minutes : 6;
  311. USHORT Hours : 5;
  312. } Struct;
  313. } SMB_TIME;
  314. typedef SMB_TIME SMB_UNALIGNED *PSMB_TIME;
  315. //
  316. // The SMB_FIND_BUFFER and SMB_FIND_BUFFER2 structures are used in the
  317. // Transaction2 Find protocols to return files matching the requested
  318. // specifications. They are identical except for the EaSize field
  319. // in SMB_FIND_BUFFER2.
  320. //
  321. typedef struct _SMB_FIND_BUFFER {
  322. SMB_DATE CreationDate;
  323. SMB_TIME CreationTime;
  324. SMB_DATE LastAccessDate;
  325. SMB_TIME LastAccessTime;
  326. SMB_DATE LastWriteDate;
  327. SMB_TIME LastWriteTime;
  328. _ULONG( DataSize );
  329. _ULONG( AllocationSize );
  330. _USHORT( Attributes );
  331. UCHAR FileNameLength;
  332. CHAR FileName[1];
  333. } SMB_FIND_BUFFER;
  334. typedef SMB_FIND_BUFFER SMB_UNALIGNED *PSMB_FIND_BUFFER;
  335. typedef struct _SMB_FIND_BUFFER2 {
  336. SMB_DATE CreationDate;
  337. SMB_TIME CreationTime;
  338. SMB_DATE LastAccessDate;
  339. SMB_TIME LastAccessTime;
  340. SMB_DATE LastWriteDate;
  341. SMB_TIME LastWriteTime;
  342. _ULONG( DataSize );
  343. _ULONG( AllocationSize );
  344. _USHORT( Attributes );
  345. _ULONG( EaSize ); // this field intentionally misaligned!
  346. UCHAR FileNameLength;
  347. CHAR FileName[1];
  348. } SMB_FIND_BUFFER2;
  349. typedef SMB_FIND_BUFFER2 SMB_UNALIGNED *PSMB_FIND_BUFFER2;
  350. //
  351. // The following structures are used in OS/2 1.2 for extended attributes
  352. // (EAs). OS/2 2.0 uses the same structures as NT. See the OS/2
  353. // Programmer's Reference, Volume 4, Chapter 4 for more information.
  354. //
  355. // The FEA structure holds a single EA's name and value and is the
  356. // equivalent ofthe NT structure FILE_FULL_EA_INFORMATION.
  357. //
  358. typedef struct _FEA {
  359. UCHAR fEA;
  360. UCHAR cbName;
  361. _USHORT( cbValue );
  362. } FEA;
  363. typedef FEA SMB_UNALIGNED *PFEA;
  364. //
  365. // The only legal bit in fEA is FEA_NEEDEA.
  366. //
  367. #define FEA_NEEDEA 0x80
  368. //
  369. // The FEALIST structure holds the names and values of multiple EAs
  370. // NT has no direct equivalent but rather strings together
  371. // FILE_FULL_EA_INFORMATION structures.
  372. //
  373. typedef struct _FEALIST {
  374. _ULONG( cbList );
  375. FEA list[1];
  376. } FEALIST;
  377. typedef FEALIST SMB_UNALIGNED *PFEALIST;
  378. //
  379. // The GEA structure holds the name of a single EA. It is used to
  380. // request the value of that EA in OS/2 API functions. The NT
  381. // equivalent is FILE_GET_EA_INFORMATION.
  382. //
  383. typedef struct _GEA {
  384. UCHAR cbName;
  385. CHAR szName[1];
  386. } GEA;
  387. typedef GEA SMB_UNALIGNED *PGEA;
  388. //
  389. // The GEALIST structure holds the names of multiple EAs. NT has no
  390. // direct equivalent but rather strings together FILE_GET_EA_INFORMATION
  391. // structures.
  392. //
  393. typedef struct _GEALIST {
  394. _ULONG( cbList );
  395. GEA list[1];
  396. } GEALIST;
  397. typedef GEALIST SMB_UNALIGNED *PGEALIST;
  398. //
  399. // The EAOP structure holds EA information needed by API calls. It has
  400. // no NT equivalent.
  401. //
  402. typedef struct _EAOP {
  403. PGEALIST fpGEAList;
  404. PFEALIST fpFEAList;
  405. ULONG oError;
  406. } EAOP;
  407. typedef EAOP SMB_UNALIGNED *PEAOP;
  408. //
  409. // FSALLOCATE contains information about a disk returned by
  410. // SrvSmbQueryFsInfo.
  411. //
  412. typedef struct _FSALLOCATE {
  413. _ULONG( idFileSystem );
  414. _ULONG( cSectorUnit );
  415. _ULONG( cUnit );
  416. _ULONG( cUnitAvail );
  417. _USHORT( cbSector );
  418. } FSALLOCATE, *PFSALLOCATE; // *** NOT SMB_UNALIGNED!
  419. //
  420. // VOLUMELABEL contains information about a volume label returned by
  421. // SrvSmbQueryFsInformation.
  422. //
  423. typedef struct _VOLUMELABEL {
  424. UCHAR cch;
  425. CHAR szVolLabel[12];
  426. } VOLUMELABEL, *PVOLUMELABEL; // *** NOT SMB_UNALIGNED!
  427. //
  428. // FSINFO holds information about a volume returned by
  429. // SrvSmbQueryFsInformation.
  430. //
  431. typedef struct _FSINFO {
  432. _ULONG( ulVsn );
  433. VOLUMELABEL vol;
  434. } FSINFO, *PFSINFO; // *** NOT SMB_UNALIGNED!
  435. //
  436. // File types (returned by OpenAndX and Transact2_Open)
  437. // FileTypeIPC is a private definition for the NT redirector and
  438. // is not in the smb protocol.
  439. //
  440. typedef enum _FILE_TYPE {
  441. FileTypeDisk = 0,
  442. FileTypeByteModePipe = 1,
  443. FileTypeMessageModePipe = 2,
  444. FileTypePrinter = 3,
  445. FileTypeCommDevice = 4,
  446. FileTypeIPC = 0xFFFE,
  447. FileTypeUnknown = 0xFFFF
  448. } FILE_TYPE;
  449. //
  450. // Turn structure packing back off
  451. //
  452. #ifndef NO_PACKING
  453. #include <packoff.h>
  454. #endif // ndef NO_PACKING
  455. //
  456. // PVOID
  457. // ALIGN_SMB_WSTR(
  458. // IN PVOID Pointer
  459. // )
  460. //
  461. // Routine description:
  462. //
  463. // This macro aligns the input pointer to the next 2-byte boundary.
  464. // Used to align Unicode strings in SMBs.
  465. //
  466. // Arguments:
  467. //
  468. // Pointer - A pointer
  469. //
  470. // Return Value:
  471. //
  472. // PVOID - Pointer aligned to next 2-byte boundary.
  473. //
  474. #define ALIGN_SMB_WSTR( Pointer ) \
  475. (PVOID)( ((ULONG_PTR)Pointer + 1) & ~1 )
  476. //
  477. // Macro to find the size of an SMB parameter block. This macro takes
  478. // as input the type of a parameter block and a byte count. It finds
  479. // the offset of the Buffer field, which appears at the end of all
  480. // parameter blocks, and adds the byte count to find the total size.
  481. // The type of the returned offset is USHORT.
  482. //
  483. // Note that this macro does NOT pad to a word or longword boundary.
  484. //
  485. #define SIZEOF_SMB_PARAMS(type,byteCount) \
  486. (USHORT)( (ULONG_PTR)&((type *)0)->Buffer[0] + (byteCount) )
  487. //
  488. // Macro to find the next location after an SMB parameter block. This
  489. // macro takes as input the address of the current parameter block, its
  490. // type, and a byte count. It finds the address of the Buffer field,
  491. // which appears at the end of all parameter blocks, and adds the byte
  492. // count to find the next available location. The type of the returned
  493. // pointer is PVOID.
  494. //
  495. // The byte count is passed in even though it is available through
  496. // base->ByteCount. The reason for this is that this number will be a
  497. // compile-time constant in most cases, so the resulting code will be
  498. // simpler and faster.
  499. //
  500. // !!! This macro does not round to a longword boundary when packing
  501. // is turned off. Pre-LM 2.0 DOS redirectors cannot handle having
  502. // too much data sent to them; the exact amount must be sent.
  503. // We may want to make this macro such that the first location
  504. // AFTER the returned value (WordCount field of the SMB) is aligned,
  505. // since most of the fields are misaligned USHORTs. This would
  506. // result in a minor performance win on the 386 and other CISC
  507. // machines.
  508. //
  509. #ifndef NO_PACKING
  510. #define NEXT_LOCATION(base,type,byteCount) \
  511. (PVOID)( (ULONG_PTR)( (PUCHAR)( &((type *)(base))->Buffer[0] ) ) + \
  512. (byteCount) )
  513. #else
  514. #define NEXT_LOCATION(base,type,byteCount) \
  515. (PVOID)(( (ULONG_PTR)( (PUCHAR)( &((type *)(base))->Buffer[0] ) ) + \
  516. (byteCount) + 3) & ~3)
  517. #endif
  518. //
  519. // Macro to find the offset of a followon command to an and X command.
  520. // This offset is the number of bytes from the start of the SMB header
  521. // to where the followon command's parameters should start.
  522. //
  523. #define GET_ANDX_OFFSET(header,params,type,byteCount) \
  524. (USHORT)( (PCHAR)(params) - (PCHAR)(header) + \
  525. SIZEOF_SMB_PARAMS( type,(byteCount) ) )
  526. //
  527. // The following are macros to assist in converting OS/2 1.2 EAs to
  528. // NT style and vice-versa.
  529. //
  530. //++
  531. //
  532. // ULONG
  533. // SmbGetNtSizeOfFea (
  534. // IN PFEA Fea
  535. // )
  536. //
  537. // Routine Description:
  538. //
  539. // This macro gets the size that would be required to hold the FEA
  540. // in NT format. The length is padded to account for the fact that
  541. // each FILE_FULL_EA_INFORMATION structure must start on a
  542. // longword boundary.
  543. //
  544. // Arguments:
  545. //
  546. // Fea - a pointer to the OS/2 1.2 FEA structure to evaluate.
  547. //
  548. // Return Value:
  549. //
  550. // ULONG - number of bytes the FEA would require in NT format.
  551. //
  552. //--
  553. //
  554. // The +1 is for the zero terminator on the name, the +3 is for padding.
  555. //
  556. #define SmbGetNtSizeOfFea( Fea ) \
  557. (ULONG)(( FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]) + \
  558. (Fea)->cbName + 1 + SmbGetUshort( &(Fea)->cbValue ) + \
  559. 3 ) & ~3 )
  560. //++
  561. //
  562. // ULONG
  563. // SmbGetNtSizeOfGea (
  564. // IN PFEA Gea
  565. // )
  566. //
  567. // Routine Description:
  568. //
  569. // This macro gets the size that would be required to hold the GEA
  570. // in NT format. The length is padded to account for the fact that
  571. // each FILE_FULL_EA_INFORMATION structure must start on a
  572. // longword boundary.
  573. //
  574. // Arguments:
  575. //
  576. // Gea - a pointer to the OS/2 1.2 GEA structure to evaluate.
  577. //
  578. // Return Value:
  579. //
  580. // ULONG - number of bytes the GEA would require in NT format.
  581. //
  582. //--
  583. //
  584. // The +1 is for the zero terminator on the name, the +3 is for padding.
  585. //
  586. #define SmbGetNtSizeOfGea( Gea ) \
  587. (ULONG)(( FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]) + \
  588. (Gea)->cbName + 1 + 3 ) & ~3 )
  589. //++
  590. //
  591. // ULONG
  592. // SmbGetOs2SizeOfNtFullEa (
  593. // IN PFILE_FULL_EA_INFORMATION NtFullEa;
  594. // )
  595. //
  596. // Routine Description:
  597. //
  598. // This macro gets the size a FILE_FULL_EA_INFORMATION structure would
  599. // require to be represented in a OS/2 1.2 style FEA.
  600. //
  601. // Arguments:
  602. //
  603. // NtFullEa - a pointer to the NT FILE_FULL_EA_INFORMATION structure
  604. // to evaluate.
  605. //
  606. // Return Value:
  607. //
  608. // ULONG - number of bytes requires for the FEA.
  609. //
  610. //--
  611. #define SmbGetOs2SizeOfNtFullEa( NtFullEa ) \
  612. (ULONG)( sizeof(FEA) + (NtFullEa)->EaNameLength + 1 + \
  613. (NtFullEa)->EaValueLength )
  614. //++
  615. //
  616. // ULONG
  617. // SmbGetOs2SizeOfNtGetEa (
  618. // IN PFILE_GET_EA_INFORMATION NtGetEa;
  619. // )
  620. //
  621. // Routine Description:
  622. //
  623. // This macro gets the size a FILE_GET_EA_INFORMATION structure would
  624. // require to be represented in a OS/2 1.2 style GEA.
  625. //
  626. // Arguments:
  627. //
  628. // NtGetEa - a pointer to the NT FILE_GET_EA_INFORMATION structure
  629. // to evaluate.
  630. //
  631. // Return Value:
  632. //
  633. // ULONG - number of bytes requires for the GEA.
  634. //
  635. //--
  636. //
  637. // The zero terminator on the name is accounted for by the szName[0]
  638. // field in the GEA definition.
  639. //
  640. #define SmbGetOs2SizeOfNtGetEa( NtGetEa ) \
  641. (ULONG)( sizeof(GEA) + (NtGetEa)->EaNameLength )
  642. /*
  643. Inclusion of SMB request/response structures in this file is
  644. conditionalized in the following way:
  645. If INCLUDE_SMB_ALL is defined, all of the structures are defined.
  646. Otherwise, the following names, if defined, cause inclusion of the
  647. corresponding SMB categories:
  648. INCLUDE_SMB_ADMIN Administrative requests:
  649. PROCESS_EXIT
  650. NEGOTIATE
  651. SESSION_SETUP_ANDX
  652. LOGOFF_ANDX
  653. INCLUDE_SMB_TREE Tree connect requests:
  654. TREE_CONNECT
  655. TREE_DISCONNECT
  656. TREE_CONNECT_ANDX
  657. INCLUDE_SMB_DIRECTORY Directory-related requests:
  658. CREATE_DIRECTORY
  659. DELETE_DIRECTORY
  660. CHECK_DIRECTORY
  661. INCLUDE_SMB_OPEN_CLOSE File open and close requests:
  662. OPEN
  663. CREATE
  664. CLOSE
  665. CREATE_TEMPORARY
  666. CREATE_NEW
  667. OPEN_ANDX
  668. CLOSE_AND_TREE_DISC
  669. INCLUDE_SMB_READ_WRITE Read and write requests:
  670. READ
  671. WRITE
  672. SEEK
  673. LOCK_AND_READ
  674. WRITE_AND_UNLOCK
  675. WRITE_AND_CLOSE
  676. READ_ANDX
  677. WRITE_ANDX
  678. INCLUDE_SMB_FILE_CONTROL File control requests:
  679. FLUSH
  680. DELETE
  681. RENAME
  682. COPY
  683. MOVE
  684. INCLUDE_SMB_QUERY_SET File query/set requests:
  685. QUERY_INFORMATION
  686. SET_INFORMATION
  687. QUERY_INFORMATION2
  688. SET_INFORMATION2
  689. QUERY_PATH_INFORMATION
  690. SET_PATH_INFORMATION
  691. QUERY_FILE_INFORMATION
  692. SET_FILE_INFORMATION
  693. INCLUDE_SMB_LOCK Lock requests (not LOCK_AND_READ)
  694. LOCK_BYTE_RANGE
  695. UNLOCK_BYTE_RANGE
  696. LOCKING_ANDX
  697. INCLUDE_SMB_RAW Raw read/write requests:
  698. READ_RAW
  699. WRITE_RAW
  700. INCLUDE_SMB_MPX Multiplexed requests:
  701. READ_MPX
  702. WRITE_MPX
  703. INCLUDE_SMB_SEARCH Search requests:
  704. FIND_CLOSE2
  705. FIND_NOTIFY_CLOSE
  706. SEARCH
  707. FIND
  708. FIND_UNIQUE
  709. FIND_CLOSE
  710. INCLUDE_SMB_TRANSACTION Transaction and IOCTL requests:
  711. TRANSACTION
  712. IOCTL
  713. TRANSACTION2
  714. NTTRANSACTION
  715. INCLUDE_SMB_PRINT Printer requests:
  716. OPEN_PRINT_FILE
  717. WRITE_PRINT_FILE
  718. CLOSE_PRINT_FILE
  719. GET_PRINT_QUEUE
  720. INCLUDE_SMB_MESSAGE Message requests:
  721. SEND_MESSAGE
  722. SEND_BROADCAST_MESSAGE
  723. FORWARD_USER_NAME
  724. CANCEL_FORWARD
  725. GET_MACHINE_NAME
  726. SEND_START_MB_MESSAGE
  727. SEND_END_MB_MESSAGE
  728. SEND_TEXT_MB_MESSAGE
  729. INCLUDE_SMB_MISC Miscellaneous requests:
  730. QUERY_INFORMATION_SRV
  731. ECHO
  732. QUERY_INFORMATION_DISK
  733. */
  734. #ifdef INCLUDE_SMB_ALL
  735. #define INCLUDE_SMB_ADMIN
  736. #define INCLUDE_SMB_TREE
  737. #define INCLUDE_SMB_DIRECTORY
  738. #define INCLUDE_SMB_OPEN_CLOSE
  739. #define INCLUDE_SMB_FILE_CONTROL
  740. #define INCLUDE_SMB_READ_WRITE
  741. #define INCLUDE_SMB_LOCK
  742. #define INCLUDE_SMB_RAW
  743. #define INCLUDE_SMB_MPX
  744. #define INCLUDE_SMB_QUERY_SET
  745. #define INCLUDE_SMB_SEARCH
  746. #define INCLUDE_SMB_TRANSACTION
  747. #define INCLUDE_SMB_PRINT
  748. #define INCLUDE_SMB_MESSAGE
  749. #define INCLUDE_SMB_MISC
  750. #endif // def INCLUDE_SMB_ALL
  751. //
  752. // Force misalignment of the following structures
  753. //
  754. #ifndef NO_PACKING
  755. #include <packon.h>
  756. #endif // ndef NO_PACKING
  757. //
  758. // SMB servers listen on two NETBIOS addresses to facilitate connections. The
  759. // first one is a name formulated from the computer name by padding it with
  760. // a number of blanks ( upto NETBIOS_NAME_LEN ). This name is registered and
  761. // resolved using the NETBIOS name registration/resolution mechanism. They also
  762. // register under a second name *SMBSERVER which is not a valuid netbios name
  763. // but provides a name which can be used in NETBT session setup. This eliminates
  764. // the need for querying the remote adapter status to obtain the name.
  765. //
  766. #define SMBSERVER_LOCAL_ENDPOINT_NAME "*SMBSERVER "
  767. //
  768. // SMB Command code definitions:
  769. //
  770. // *** Start of SMB commands
  771. #define SMB_COM_CREATE_DIRECTORY (UCHAR)0x00
  772. #define SMB_COM_DELETE_DIRECTORY (UCHAR)0x01
  773. #define SMB_COM_OPEN (UCHAR)0x02
  774. #define SMB_COM_CREATE (UCHAR)0x03
  775. #define SMB_COM_CLOSE (UCHAR)0x04
  776. #define SMB_COM_FLUSH (UCHAR)0x05
  777. #define SMB_COM_DELETE (UCHAR)0x06
  778. #define SMB_COM_RENAME (UCHAR)0x07
  779. #define SMB_COM_QUERY_INFORMATION (UCHAR)0x08
  780. #define SMB_COM_SET_INFORMATION (UCHAR)0x09
  781. #define SMB_COM_READ (UCHAR)0x0A
  782. #define SMB_COM_WRITE (UCHAR)0x0B
  783. #define SMB_COM_LOCK_BYTE_RANGE (UCHAR)0x0C
  784. #define SMB_COM_UNLOCK_BYTE_RANGE (UCHAR)0x0D
  785. #define SMB_COM_CREATE_TEMPORARY (UCHAR)0x0E
  786. #define SMB_COM_CREATE_NEW (UCHAR)0x0F
  787. #define SMB_COM_CHECK_DIRECTORY (UCHAR)0x10
  788. #define SMB_COM_PROCESS_EXIT (UCHAR)0x11
  789. #define SMB_COM_SEEK (UCHAR)0x12
  790. #define SMB_COM_LOCK_AND_READ (UCHAR)0x13
  791. #define SMB_COM_WRITE_AND_UNLOCK (UCHAR)0x14
  792. #define SMB_COM_READ_RAW (UCHAR)0x1A
  793. #define SMB_COM_READ_MPX (UCHAR)0x1B
  794. #define SMB_COM_READ_MPX_SECONDARY (UCHAR)0x1C // server to redir only
  795. #define SMB_COM_WRITE_RAW (UCHAR)0x1D
  796. #define SMB_COM_WRITE_MPX (UCHAR)0x1E
  797. #define SMB_COM_WRITE_MPX_SECONDARY (UCHAR)0x1F
  798. #define SMB_COM_WRITE_COMPLETE (UCHAR)0x20 // server to redir only
  799. #define SMB_COM_QUERY_INFORMATION_SRV (UCHAR)0x21
  800. #define SMB_COM_SET_INFORMATION2 (UCHAR)0x22
  801. #define SMB_COM_QUERY_INFORMATION2 (UCHAR)0x23
  802. #define SMB_COM_LOCKING_ANDX (UCHAR)0x24
  803. #define SMB_COM_TRANSACTION (UCHAR)0x25
  804. #define SMB_COM_TRANSACTION_SECONDARY (UCHAR)0x26
  805. #define SMB_COM_IOCTL (UCHAR)0x27
  806. #define SMB_COM_IOCTL_SECONDARY (UCHAR)0x28
  807. #define SMB_COM_COPY (UCHAR)0x29
  808. #define SMB_COM_MOVE (UCHAR)0x2A
  809. #define SMB_COM_ECHO (UCHAR)0x2B
  810. #define SMB_COM_WRITE_AND_CLOSE (UCHAR)0x2C
  811. #define SMB_COM_OPEN_ANDX (UCHAR)0x2D
  812. #define SMB_COM_READ_ANDX (UCHAR)0x2E
  813. #define SMB_COM_WRITE_ANDX (UCHAR)0x2F
  814. #define SMB_COM_CLOSE_AND_TREE_DISC (UCHAR)0x31
  815. #define SMB_COM_TRANSACTION2 (UCHAR)0x32
  816. #define SMB_COM_TRANSACTION2_SECONDARY (UCHAR)0x33
  817. #define SMB_COM_FIND_CLOSE2 (UCHAR)0x34
  818. #define SMB_COM_FIND_NOTIFY_CLOSE (UCHAR)0x35
  819. #define SMB_COM_TREE_CONNECT (UCHAR)0x70
  820. #define SMB_COM_TREE_DISCONNECT (UCHAR)0x71
  821. #define SMB_COM_NEGOTIATE (UCHAR)0x72
  822. #define SMB_COM_SESSION_SETUP_ANDX (UCHAR)0x73
  823. #define SMB_COM_LOGOFF_ANDX (UCHAR)0x74
  824. #define SMB_COM_TREE_CONNECT_ANDX (UCHAR)0x75
  825. #define SMB_COM_QUERY_INFORMATION_DISK (UCHAR)0x80
  826. #define SMB_COM_SEARCH (UCHAR)0x81
  827. #define SMB_COM_FIND (UCHAR)0x82
  828. #define SMB_COM_FIND_UNIQUE (UCHAR)0x83
  829. #define SMB_COM_FIND_CLOSE (UCHAR)0x84
  830. #define SMB_COM_NT_TRANSACT (UCHAR)0xA0
  831. #define SMB_COM_NT_TRANSACT_SECONDARY (UCHAR)0xA1
  832. #define SMB_COM_NT_CREATE_ANDX (UCHAR)0xA2
  833. #define SMB_COM_NT_CANCEL (UCHAR)0xA4
  834. #define SMB_COM_NT_RENAME (UCHAR)0xA5
  835. #define SMB_COM_OPEN_PRINT_FILE (UCHAR)0xC0
  836. #define SMB_COM_WRITE_PRINT_FILE (UCHAR)0xC1
  837. #define SMB_COM_CLOSE_PRINT_FILE (UCHAR)0xC2
  838. #define SMB_COM_GET_PRINT_QUEUE (UCHAR)0xC3
  839. #define SMB_COM_SEND_MESSAGE (UCHAR)0xD0
  840. #define SMB_COM_SEND_BROADCAST_MESSAGE (UCHAR)0xD1
  841. #define SMB_COM_FORWARD_USER_NAME (UCHAR)0xD2
  842. #define SMB_COM_CANCEL_FORWARD (UCHAR)0xD3
  843. #define SMB_COM_GET_MACHINE_NAME (UCHAR)0xD4
  844. #define SMB_COM_SEND_START_MB_MESSAGE (UCHAR)0xD5
  845. #define SMB_COM_SEND_END_MB_MESSAGE (UCHAR)0xD6
  846. #define SMB_COM_SEND_TEXT_MB_MESSAGE (UCHAR)0xD7
  847. // *** End of SMB commands
  848. #define SMB_COM_NO_ANDX_COMMAND (UCHAR)0xFF
  849. //
  850. // Header for SMBs, see #4 page 10
  851. //
  852. // *** Note that we do NOT define PSMB_HEADER as SMB_UNALIGNED! This is
  853. // done on the assumption that the SMB header, at least, will always
  854. // be properly aligned. If you need to access an unaligned header,
  855. // declare the pointer as SMB_UNALIGNED *SMB_HEADER.
  856. //
  857. #define SMB_SECURITY_SIGNATURE_LENGTH 8
  858. typedef struct _SMB_HEADER {
  859. UCHAR Protocol[4]; // Contains 0xFF,'SMB'
  860. UCHAR Command; // Command code
  861. UCHAR ErrorClass; // Error class
  862. UCHAR Reserved; // Reserved for future use
  863. _USHORT( Error ); // Error code
  864. UCHAR Flags; // Flags
  865. _USHORT( Flags2 ); // More flags
  866. union {
  867. _USHORT( Reserved2 )[6]; // Reserved for future use
  868. struct {
  869. _USHORT( PidHigh ); // High part of PID (NT Create And X)
  870. union {
  871. struct {
  872. _ULONG( Key ); // Encryption key (IPX)
  873. _USHORT( Sid ); // Session ID (IPX)
  874. _USHORT( SequenceNumber ); // Sequence number (IPX)
  875. _USHORT( Gid ); // Group ID (unused?)
  876. };
  877. UCHAR SecuritySignature[SMB_SECURITY_SIGNATURE_LENGTH];
  878. // Client must send the correct Signature
  879. // for this SMB to be accepted.
  880. };
  881. };
  882. };
  883. _USHORT( Tid ); // Authenticated user/group
  884. _USHORT( Pid ); // Caller's process id
  885. _USHORT( Uid ); // Unauthenticated user id
  886. _USHORT( Mid ); // multiplex id
  887. #ifdef NO_PACKING // ***
  888. _USHORT( Kludge ); // *** make sure parameter structs
  889. #endif // *** are longword aligned
  890. } SMB_HEADER;
  891. typedef SMB_HEADER *PSMB_HEADER;
  892. typedef struct _NT_SMB_HEADER {
  893. UCHAR Protocol[4]; // Contains 0xFF,'SMB'
  894. UCHAR Command; // Command code
  895. union {
  896. struct {
  897. UCHAR ErrorClass; // Error class
  898. UCHAR Reserved; // Reserved for future use
  899. _USHORT( Error ); // Error code
  900. } DosError;
  901. ULONG NtStatus; // NT-style 32-bit error code
  902. } Status;
  903. UCHAR Flags; // Flags
  904. _USHORT( Flags2 ); // More flags
  905. union {
  906. _USHORT( Reserved2 )[6]; // Reserved for future use
  907. struct {
  908. _USHORT( PidHigh ); // High part of PID (NT Create And X)
  909. union {
  910. struct {
  911. _ULONG( Key ); // Encryption key (IPX)
  912. _USHORT( Sid ); // Session ID (IPX)
  913. _USHORT( SequenceNumber ); // Sequence number (IPX)
  914. _USHORT( Gid ); // Group ID (unused?)
  915. };
  916. UCHAR SecuritySignature[SMB_SECURITY_SIGNATURE_LENGTH];
  917. // Client must send the correct Signature
  918. // for this SMB to be accepted.
  919. };
  920. };
  921. };
  922. _USHORT( Tid ); // Authenticated user/group
  923. _USHORT( Pid ); // Caller's process id
  924. _USHORT( Uid ); // Unauthenticated user id
  925. _USHORT( Mid ); // multiplex id
  926. #ifdef NO_PACKING // ***
  927. _USHORT( Kludge ); // *** make sure parameter structs
  928. #endif // *** are longword aligned
  929. } NT_SMB_HEADER;
  930. typedef NT_SMB_HEADER *PNT_SMB_HEADER;
  931. //
  932. // The SMB header, protocol field, as a long.
  933. //
  934. #define SMB_HEADER_PROTOCOL (0xFF + ('S' << 8) + ('M' << 16) + ('B' << 24))
  935. //
  936. // Minimum parameter structure that can be returned. Used in returning
  937. // error SMBs.
  938. //
  939. // *** Note that this structure does NOT have a Buffer field!
  940. //
  941. typedef struct _SMB_PARAMS {
  942. UCHAR WordCount; // Count of parameter words = 0
  943. _USHORT( ByteCount ); // Count of bytes that follow; min = 0
  944. } SMB_PARAMS;
  945. typedef SMB_PARAMS SMB_UNALIGNED *PSMB_PARAMS;
  946. //
  947. // Generic header for AndX commands.
  948. //
  949. typedef struct _GENERIC_ANDX {
  950. UCHAR WordCount; // Count of parameter words
  951. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  952. UCHAR AndXReserved; // Reserved
  953. _USHORT( AndXOffset ); // Offset (from SMB header start)
  954. } GENERIC_ANDX;
  955. typedef GENERIC_ANDX SMB_UNALIGNED *PGENERIC_ANDX;
  956. #ifdef INCLUDE_SMB_MESSAGE
  957. //
  958. // Cancel Forward SMB, see #1 page 35
  959. // Function is SrvSmbCancelForward()
  960. // SMB_COM_CANCEL_FORWARD 0xD3
  961. //
  962. typedef struct _REQ_CANCEL_FORWARD {
  963. UCHAR WordCount; // Count of parameter words = 0
  964. _USHORT( ByteCount ); // Count of data bytes; min = 2
  965. UCHAR Buffer[1]; // Buffer containing:
  966. //UCHAR BufferFormat; // 0x04 -- ASCII
  967. //UCHAR ForwardedName[]; // Forwarded name
  968. } REQ_CANCEL_FORWARD;
  969. typedef REQ_CANCEL_FORWARD SMB_UNALIGNED *PREQ_CANCEL_FORWARD;
  970. typedef struct _RESP_CANCEL_FORWARD {
  971. UCHAR WordCount; // Count of parameter words = 0
  972. _USHORT( ByteCount ); // Count of data bytes = 0
  973. UCHAR Buffer[1]; // empty
  974. } RESP_CANCEL_FORWARD;
  975. typedef RESP_CANCEL_FORWARD SMB_UNALIGNED *PRESP_CANCEL_FORWARD;
  976. #endif // def INCLUDE_SMB_MESSAGE
  977. #ifdef INCLUDE_SMB_DIRECTORY
  978. //
  979. // Check Directory SMB, see #1 page 23
  980. // Function is SrvSmbCheckDirectory()
  981. // SMB_COM_CHECK_DIRECTORY 0x10
  982. //
  983. typedef struct _REQ_CHECK_DIRECTORY {
  984. UCHAR WordCount; // Count of parameter words = 0
  985. _USHORT( ByteCount ); // Count of data bytes; min = 2
  986. UCHAR Buffer[1]; // Buffer containing:
  987. //UCHAR BufferFormat; // 0x04 -- ASCII
  988. //UCHAR DirectoryPath[]; // Directory path
  989. } REQ_CHECK_DIRECTORY;
  990. typedef REQ_CHECK_DIRECTORY SMB_UNALIGNED *PREQ_CHECK_DIRECTORY;
  991. typedef struct _RESP_CHECK_DIRECTORY {
  992. UCHAR WordCount; // Count of parameter words = 0
  993. _USHORT( ByteCount ); // Count of data bytes = 0
  994. UCHAR Buffer[1]; // empty
  995. } RESP_CHECK_DIRECTORY;
  996. typedef RESP_CHECK_DIRECTORY SMB_UNALIGNED *PRESP_CHECK_DIRECTORY;
  997. #endif // def INCLUDE_SMB_DIRECTORY
  998. #ifdef INCLUDE_SMB_OPEN_CLOSE
  999. //
  1000. // Close SMB, see #1 page 10
  1001. // Function is SrvSmbClose()
  1002. // SMB_COM_CLOSE 0x04
  1003. //
  1004. typedef struct _REQ_CLOSE {
  1005. UCHAR WordCount; // Count of parameter words = 3
  1006. _USHORT( Fid ); // File handle
  1007. _ULONG( LastWriteTimeInSeconds ); // Time of last write, low and high
  1008. _USHORT( ByteCount ); // Count of data bytes = 0
  1009. UCHAR Buffer[1]; // empty
  1010. } REQ_CLOSE;
  1011. typedef REQ_CLOSE SMB_UNALIGNED *PREQ_CLOSE;
  1012. typedef struct _RESP_CLOSE {
  1013. UCHAR WordCount; // Count of parameter words = 0
  1014. _USHORT( ByteCount ); // Count of data bytes = 0
  1015. UCHAR Buffer[1]; // empty
  1016. } RESP_CLOSE;
  1017. typedef RESP_CLOSE SMB_UNALIGNED *PRESP_CLOSE;
  1018. #endif // def INCLUDE_SMB_OPEN_CLOSE
  1019. #ifdef INCLUDE_SMB_OPEN_CLOSE
  1020. //
  1021. // Close and Tree Disconnect SMB, see #? page ??
  1022. // Function is SrvSmbCloseAndTreeDisc
  1023. // SMB_COM_CLOSE_AND_TREE_DISC 0x31
  1024. //
  1025. typedef struct _REQ_CLOSE_AND_TREE_DISC {
  1026. UCHAR WordCount; // Count of parameter words
  1027. _USHORT( Fid ); // File handle
  1028. _ULONG( LastWriteTimeInSeconds );
  1029. _USHORT( ByteCount ); // Count of data bytes = 0
  1030. UCHAR Buffer[1]; // empty
  1031. } REQ_CLOSE_AND_TREE_DISC;
  1032. typedef REQ_CLOSE_AND_TREE_DISC SMB_UNALIGNED *PREQ_CLOSE_AND_TREE_DISC;
  1033. typedef struct _RESP_CLOSE_AND_TREE_DISC {
  1034. UCHAR WordCount; // Count of parameter words = 0
  1035. _USHORT( ByteCount ); // Count of data bytes = 0
  1036. UCHAR Buffer[1]; // empty
  1037. } RESP_CLOSE_AND_TREE_DISC;
  1038. typedef RESP_CLOSE_AND_TREE_DISC SMB_UNALIGNED *PRESP_CLOSE_AND_TREE_DISC;
  1039. #endif // def INCLUDE_SMB_OPEN_CLOSE
  1040. #ifdef INCLUDE_SMB_PRINT
  1041. //
  1042. // Close Print Spool File SMB, see #1 page 29
  1043. // Function is SrvSmbClosePrintSpoolFile()
  1044. // SMB_COM_CLOSE_PRINT_FILE 0xC2
  1045. //
  1046. typedef struct _REQ_CLOSE_PRINT_FILE {
  1047. UCHAR WordCount; // Count of parameter words = 1
  1048. _USHORT( Fid ); // File handle
  1049. _USHORT( ByteCount ); // Count of data bytes = 0
  1050. UCHAR Buffer[1]; // empty
  1051. } REQ_CLOSE_PRINT_FILE;
  1052. typedef REQ_CLOSE_PRINT_FILE SMB_UNALIGNED *PREQ_CLOSE_PRINT_FILE;
  1053. typedef struct _RESP_CLOSE_PRINT_FILE {
  1054. UCHAR WordCount; // Count of parameter words = 0
  1055. _USHORT( ByteCount ); // Count of data bytes = 0
  1056. UCHAR Buffer[1]; // empty
  1057. } RESP_CLOSE_PRINT_FILE;
  1058. typedef RESP_CLOSE_PRINT_FILE SMB_UNALIGNED *PRESP_CLOSE_PRINT_FILE;
  1059. #endif // def INCLUDE_SMB_PRINT
  1060. #ifdef INCLUDE_SMB_FILE_CONTROL
  1061. //
  1062. // Copy SMB, see #2 page 23
  1063. // Function is SrvSmbCopy()
  1064. // SMB_COM_COPY 0x29
  1065. //
  1066. typedef struct _REQ_COPY {
  1067. UCHAR WordCount; // Count of parameter words = 3
  1068. _USHORT( Tid2 ); // Second (target) path TID
  1069. _USHORT( OpenFunction ); // What to do if target file exists
  1070. _USHORT( Flags ); // Flags to control copy operation:
  1071. // bit 0 - target must be a file
  1072. // bit 1 - target must ba a dir.
  1073. // bit 2 - copy target mode:
  1074. // 0 = binary, 1 = ASCII
  1075. // bit 3 - copy source mode:
  1076. // 0 = binary, 1 = ASCII
  1077. // bit 4 - verify all writes
  1078. // bit 5 - tree copy
  1079. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1080. UCHAR Buffer[1]; // Buffer containing:
  1081. //UCHAR SourceFileName[]; // pathname of source file
  1082. //UCHAR TargetFileName[]; // pathname of target file
  1083. } REQ_COPY;
  1084. typedef REQ_COPY SMB_UNALIGNED *PREQ_COPY;
  1085. typedef struct _RESP_COPY {
  1086. UCHAR WordCount; // Count of parameter words = 1
  1087. _USHORT( Count ); // Number of files copied
  1088. _USHORT( ByteCount ); // Count of data bytes; min = 0
  1089. UCHAR Buffer[1]; // ASCIIZ pathname of file with error
  1090. } RESP_COPY;
  1091. typedef RESP_COPY SMB_UNALIGNED *PRESP_COPY;
  1092. #endif // def INCLUDE_SMB_FILE_CONTROL
  1093. #ifdef INCLUDE_SMB_OPEN_CLOSE
  1094. //
  1095. // Create SMB, see #1 page 9
  1096. // Create New SMB, see #1 page 23
  1097. // Function is SrvSmbCreate()
  1098. // SMB_COM_CREATE 0x03
  1099. // SMB_COM_CREATE_NEW 0x0F
  1100. //
  1101. typedef struct _REQ_CREATE {
  1102. UCHAR WordCount; // Count of parameter words = 3
  1103. _USHORT( FileAttributes ); // New file attributes
  1104. _ULONG( CreationTimeInSeconds ); // Creation time
  1105. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1106. UCHAR Buffer[1]; // Buffer containing:
  1107. //UCHAR BufferFormat; // 0x04 -- ASCII
  1108. //UCHAR FileName[]; // File name
  1109. } REQ_CREATE;
  1110. typedef REQ_CREATE SMB_UNALIGNED *PREQ_CREATE;
  1111. typedef struct _RESP_CREATE {
  1112. UCHAR WordCount; // Count of parameter words = 1
  1113. _USHORT( Fid ); // File handle
  1114. _USHORT( ByteCount ); // Count of data bytes = 0
  1115. UCHAR Buffer[1]; // empty
  1116. } RESP_CREATE;
  1117. typedef RESP_CREATE SMB_UNALIGNED *PRESP_CREATE;
  1118. #endif // def INCLUDE_SMB_OPEN_CLOSE
  1119. #ifdef INCLUDE_SMB_DIRECTORY
  1120. //
  1121. // Create Directory SMB, see #1 page 14
  1122. // Function is SrvSmbCreateDirectory
  1123. // SMB_COM_CREATE_DIRECTORY 0x00
  1124. //
  1125. typedef struct _REQ_CREATE_DIRECTORY {
  1126. UCHAR WordCount; // Count of parameter words = 0
  1127. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1128. UCHAR Buffer[1]; // Buffer containing:
  1129. //UCHAR BufferFormat; // 0x04 -- ASCII
  1130. //UCHAR DirectoryName[]; // Directory name
  1131. } REQ_CREATE_DIRECTORY;
  1132. typedef REQ_CREATE_DIRECTORY SMB_UNALIGNED *PREQ_CREATE_DIRECTORY;
  1133. typedef struct _RESP_CREATE_DIRECTORY {
  1134. UCHAR WordCount; // Count of parameter words = 0
  1135. _USHORT( ByteCount ); // Count of data bytes = 0
  1136. UCHAR Buffer[1]; // empty
  1137. } RESP_CREATE_DIRECTORY;
  1138. typedef RESP_CREATE_DIRECTORY SMB_UNALIGNED *PRESP_CREATE_DIRECTORY;
  1139. #endif // def INCLUDE_SMB_DIRECTORY
  1140. #ifdef INCLUDE_SMB_OPEN_CLOSE
  1141. //
  1142. // Create Temporary SMB, see #1 page 21
  1143. // Function is SrvSmbCreateTemporary()
  1144. // SMB_COM_CREATE_TEMPORARY 0x0E
  1145. //
  1146. typedef struct _REQ_CREATE_TEMPORARY {
  1147. UCHAR WordCount; // Count of parameter words = 3
  1148. _USHORT( FileAttributes );
  1149. _ULONG( CreationTimeInSeconds );
  1150. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1151. UCHAR Buffer[1]; // Buffer containing:
  1152. //UCHAR BufferFormat; // 0x04 -- ASCII
  1153. //UCHAR DirectoryName[]; // Directory name
  1154. } REQ_CREATE_TEMPORARY;
  1155. typedef REQ_CREATE_TEMPORARY SMB_UNALIGNED *PREQ_CREATE_TEMPORARY;
  1156. typedef struct _RESP_CREATE_TEMPORARY {
  1157. UCHAR WordCount; // Count of parameter words = 1
  1158. _USHORT( Fid ); // File handle
  1159. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1160. UCHAR Buffer[1]; // Buffer containing:
  1161. //UCHAR BufferFormat; // 0x04 -- ASCII
  1162. //UCHAR FileName[]; // File name
  1163. } RESP_CREATE_TEMPORARY;
  1164. typedef RESP_CREATE_TEMPORARY SMB_UNALIGNED *PRESP_CREATE_TEMPORARY;
  1165. #endif // def INCLUDE_SMB_OPEN_CLOSE
  1166. #ifdef INCLUDE_SMB_FILE_CONTROL
  1167. //
  1168. // Delete SMB, see #1 page 16
  1169. // Function is SrvSmbDelete()
  1170. // SMB_COM_DELETE 0x06
  1171. //
  1172. typedef struct _REQ_DELETE {
  1173. UCHAR WordCount; // Count of parameter words = 1
  1174. _USHORT( SearchAttributes );
  1175. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1176. UCHAR Buffer[1]; // Buffer containing:
  1177. //UCHAR BufferFormat; // 0x04 -- ASCII
  1178. //UCHAR FileName[]; // File name
  1179. } REQ_DELETE;
  1180. typedef REQ_DELETE SMB_UNALIGNED *PREQ_DELETE;
  1181. typedef struct _RESP_DELETE {
  1182. UCHAR WordCount; // Count of parameter words = 0
  1183. _USHORT( ByteCount ); // Count of data bytes = 0
  1184. UCHAR Buffer[1]; // empty
  1185. } RESP_DELETE;
  1186. typedef RESP_DELETE SMB_UNALIGNED *PRESP_DELETE;
  1187. #endif // def INCLUDE_SMB_FILE_CONTROL
  1188. #ifdef INCLUDE_SMB_DIRECTORY
  1189. //
  1190. // Delete Directory SMB, see #1 page 15
  1191. // Function is SrvSmbDeleteDirectory()
  1192. // SMB_COM_DELETE_DIRECTORY 0x01
  1193. //
  1194. typedef struct _REQ_DELETE_DIRECTORY {
  1195. UCHAR WordCount; // Count of parameter words = 0
  1196. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1197. UCHAR Buffer[1]; // Buffer containing:
  1198. //UCHAR BufferFormat; // 0x04 -- ASCII
  1199. //UCHAR DirectoryName[]; // Directory name
  1200. } REQ_DELETE_DIRECTORY;
  1201. typedef REQ_DELETE_DIRECTORY SMB_UNALIGNED *PREQ_DELETE_DIRECTORY;
  1202. typedef struct _RESP_DELETE_DIRECTORY {
  1203. UCHAR WordCount; // Count of parameter words = 0
  1204. _USHORT( ByteCount ); // Count of data bytes = 0
  1205. UCHAR Buffer[1]; // empty
  1206. } RESP_DELETE_DIRECTORY;
  1207. typedef RESP_DELETE_DIRECTORY SMB_UNALIGNED *PRESP_DELETE_DIRECTORY;
  1208. #endif // def INCLUDE_SMB_DIRECTORY
  1209. #ifdef INCLUDE_SMB_MISC
  1210. //
  1211. // Echo SMB, see #2 page 25
  1212. // Function is SrvSmbEcho()
  1213. // SMB_COM_ECHO 0x2B
  1214. //
  1215. typedef struct _REQ_ECHO {
  1216. UCHAR WordCount; // Count of parameter words = 1
  1217. _USHORT( EchoCount ); // Number of times to echo data back
  1218. _USHORT( ByteCount ); // Count of data bytes; min = 4
  1219. UCHAR Buffer[1]; // Data to echo
  1220. } REQ_ECHO;
  1221. typedef REQ_ECHO SMB_UNALIGNED *PREQ_ECHO;
  1222. typedef struct _RESP_ECHO {
  1223. UCHAR WordCount; // Count of parameter words = 1
  1224. _USHORT( SequenceNumber ); // Sequence number of this echo
  1225. _USHORT( ByteCount ); // Count of data bytes; min = 4
  1226. UCHAR Buffer[1]; // Echoed data
  1227. } RESP_ECHO;
  1228. typedef RESP_ECHO SMB_UNALIGNED *PRESP_ECHO;
  1229. #endif // def INCLUDE_SMB_MISC
  1230. #ifdef INCLUDE_SMB_SEARCH
  1231. //
  1232. // Find Close2 SMB, see #3 page 54
  1233. // Function is SrvFindClose2()
  1234. // SMB_COM_FIND_CLOSE2 0x34
  1235. //
  1236. typedef struct _REQ_FIND_CLOSE2 {
  1237. UCHAR WordCount; // Count of parameter words = 1
  1238. _USHORT( Sid ); // Find handle
  1239. _USHORT( ByteCount ); // Count of data bytes = 0
  1240. UCHAR Buffer[1]; // empty
  1241. } REQ_FIND_CLOSE2;
  1242. typedef REQ_FIND_CLOSE2 SMB_UNALIGNED *PREQ_FIND_CLOSE2;
  1243. typedef struct _RESP_FIND_CLOSE2 {
  1244. UCHAR WordCount; // Count of parameter words = 0
  1245. _USHORT( ByteCount ); // Count of data bytes = 0
  1246. UCHAR Buffer[1]; // empty
  1247. } RESP_FIND_CLOSE2;
  1248. typedef RESP_FIND_CLOSE2 SMB_UNALIGNED *PRESP_FIND_CLOSE2;
  1249. #endif // def INCLUDE_SMB_SEARCH
  1250. #ifdef INCLUDE_SMB_SEARCH
  1251. //
  1252. // Find Notify Close SMB, see #3 page 53
  1253. // Function is SrvSmbFindNotifyClose()
  1254. // SMB_COM_FIND_NOTIFY_CLOSE 0x35
  1255. //
  1256. typedef struct _REQ_FIND_NOTIFY_CLOSE {
  1257. UCHAR WordCount; // Count of parameter words = 1
  1258. _USHORT( Handle ); // Find notify handle
  1259. _USHORT( ByteCount ); // Count of data bytes = 0
  1260. UCHAR Buffer[1]; // empty
  1261. } REQ_FIND_NOTIFY_CLOSE;
  1262. typedef REQ_FIND_NOTIFY_CLOSE SMB_UNALIGNED *PREQ_FIND_NOTIFY_CLOSE;
  1263. typedef struct _RESP_FIND_NOTIFY_CLOSE {
  1264. UCHAR WordCount; // Count of parameter words = 0
  1265. _USHORT( ByteCount ); // Count of data bytes = 0
  1266. UCHAR Buffer[1]; // empty
  1267. } RESP_FIND_NOTIFY_CLOSE;
  1268. typedef RESP_FIND_NOTIFY_CLOSE SMB_UNALIGNED *PRESP_FIND_NOTIFY_CLOSE;
  1269. #endif // def INCLUDE_SMB_SEARCH
  1270. #ifdef INCLUDE_SMB_FILE_CONTROL
  1271. //
  1272. // Flush SMB, see #1 page 11
  1273. // Function is SrvSmbFlush()
  1274. // SMB_COM_FLUSH 0x05
  1275. //
  1276. typedef struct _REQ_FLUSH {
  1277. UCHAR WordCount; // Count of parameter words = 1
  1278. _USHORT( Fid ); // File handle
  1279. _USHORT( ByteCount ); // Count of data bytes = 0
  1280. UCHAR Buffer[1]; // empty
  1281. } REQ_FLUSH;
  1282. typedef REQ_FLUSH SMB_UNALIGNED *PREQ_FLUSH;
  1283. typedef struct _RESP_FLUSH {
  1284. UCHAR WordCount; // Count of parameter words = 0
  1285. _USHORT( ByteCount ); // Count of data bytes = 0
  1286. UCHAR Buffer[1]; // empty
  1287. } RESP_FLUSH;
  1288. typedef RESP_FLUSH SMB_UNALIGNED *PRESP_FLUSH;
  1289. #endif // def INCLUDE_SMB_FILE_CONTROL
  1290. #ifdef INCLUDE_SMB_MESSAGE
  1291. //
  1292. // Forward User Name SMB, see #1 page 34
  1293. // Function is SrvSmbForwardUserName()
  1294. // SMB_COM_FORWARD_USER_NAME 0xD2
  1295. //
  1296. typedef struct _REQ_FORWARD_USER_NAME {
  1297. UCHAR WordCount; // Count of parameter words = 0
  1298. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1299. UCHAR Buffer[1]; // Buffer containing:
  1300. //UCHAR BufferFormat; // 0x04 -- ASCII
  1301. //UCHAR ForwardedName[]; // Forwarded name
  1302. } REQ_FORWARD_USER_NAME;
  1303. typedef REQ_FORWARD_USER_NAME SMB_UNALIGNED *PREQ_FORWARD_USER_NAME;
  1304. typedef struct _RESP_FORWARD_USER_NAME {
  1305. UCHAR WordCount; // Count of parameter words = 0
  1306. _USHORT( ByteCount ); // Count of data bytes = 0
  1307. UCHAR Buffer[1]; // empty
  1308. } RESP_FORWARD_USER_NAME;
  1309. typedef RESP_FORWARD_USER_NAME SMB_UNALIGNED *PRESP_FORWARD_USER_NAME;
  1310. #endif // def INCLUDE_SMB_MESSAGE
  1311. #ifdef INCLUDE_SMB_MESSAGE
  1312. //
  1313. // Get Machine Name SMB, see #1 page 35
  1314. // Function is SrvSmbGetMachineName()
  1315. // SMB_COM_GET_MACHINE_NAME 0xD4
  1316. //
  1317. typedef struct _REQ_GET_MACHINE_NAME {
  1318. UCHAR WordCount; // Count of parameter words = 0
  1319. _USHORT( ByteCount ); // Count of data bytes = 0
  1320. UCHAR Buffer[1]; // empty
  1321. } REQ_GET_MACHINE_NAME;
  1322. typedef REQ_GET_MACHINE_NAME SMB_UNALIGNED *PREQ_GET_MACHINE_NAME;
  1323. typedef struct _RESP_GET_MACHINE_NAME {
  1324. UCHAR WordCount; // Count of parameter words = 0
  1325. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1326. UCHAR Buffer[1]; // Buffer containing:
  1327. //UCHAR BufferFormat; // 0x04 -- ASCII
  1328. //UCHAR MachineName[]; // Machine name
  1329. } RESP_GET_MACHINE_NAME;
  1330. typedef RESP_GET_MACHINE_NAME SMB_UNALIGNED *PRESP_GET_MACHINE_NAME;
  1331. #endif // def INCLUDE_SMB_MESSAGE
  1332. #ifdef INCLUDE_SMB_PRINT
  1333. //
  1334. // Get Print Queue SMB, see #1 page 29
  1335. // Function is SrvSmbGetPrintQueue()
  1336. // SMB_COM_GET_PRINT_QUEUE 0xC3
  1337. //
  1338. typedef struct _REQ_GET_PRINT_QUEUE {
  1339. UCHAR WordCount; // Count of parameter words = 2
  1340. _USHORT( MaxCount ); // Max number of entries to return
  1341. _USHORT( StartIndex ); // First queue entry to return
  1342. _USHORT( ByteCount ); // Count of data bytes = 0
  1343. UCHAR Buffer[1]; // empty
  1344. } REQ_GET_PRINT_QUEUE;
  1345. typedef REQ_GET_PRINT_QUEUE SMB_UNALIGNED *PREQ_GET_PRINT_QUEUE;
  1346. typedef struct _RESP_GET_PRINT_QUEUE {
  1347. UCHAR WordCount; // Count of parameter words = 2
  1348. _USHORT( Count ); // Number of entries returned
  1349. _USHORT( RestartIndex ); // Index of entry after last returned
  1350. _USHORT( ByteCount ); // Count of data bytes; min = 3
  1351. UCHAR Buffer[1]; // Buffer containing:
  1352. //UCHAR BufferFormat; // 0x01 -- Data block
  1353. //USHORT DataLength; // Length of data
  1354. //UCHAR Data[]; // Queue elements
  1355. } RESP_GET_PRINT_QUEUE;
  1356. typedef RESP_GET_PRINT_QUEUE SMB_UNALIGNED *PRESP_GET_PRINT_QUEUE;
  1357. #endif // def INCLUDE_SMB_PRINT
  1358. #ifdef INCLUDE_SMB_TRANSACTION
  1359. //
  1360. // Ioctl SMB, see #2 page 39
  1361. // Function is SrvSmbIoctl()
  1362. // SMB_COM_IOCTL 0x27
  1363. // SMB_COM_IOCTL_SECONDARY 0x28
  1364. //
  1365. typedef struct _REQ_IOCTL {
  1366. UCHAR WordCount; // Count of parameter words = 14
  1367. _USHORT( Fid ); // File handle
  1368. _USHORT( Category ); // Device category
  1369. _USHORT( Function ); // Device function
  1370. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  1371. _USHORT( TotalDataCount ); // Total data bytes being sent
  1372. _USHORT( MaxParameterCount ); // Max parameter bytes to return
  1373. _USHORT( MaxDataCount ); // Max data bytes to return
  1374. _ULONG( Timeout );
  1375. _USHORT( Reserved );
  1376. _USHORT( ParameterCount ); // Parameter bytes sent this buffer
  1377. _USHORT( ParameterOffset ); // Offset (from header start) to params
  1378. _USHORT( DataCount ); // Data bytes sent this buffer
  1379. _USHORT( DataOffset ); // Offset (from header start) to data
  1380. _USHORT( ByteCount ); // Count of data bytes
  1381. UCHAR Buffer[1]; // Buffer containing:
  1382. //UCHAR Pad[]; // Pad to SHORT or LONG
  1383. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  1384. //UCHAR Pad1[]; // Pad to SHORT or LONG
  1385. //UCHAR Data[]; // Data bytes (# = DataCount)
  1386. } REQ_IOCTL;
  1387. typedef REQ_IOCTL SMB_UNALIGNED *PREQ_IOCTL;
  1388. typedef struct _RESP_IOCTL_INTERIM {
  1389. UCHAR WordCount; // Count of parameter words = 0
  1390. _USHORT( ByteCount ); // Count of data bytes = 0
  1391. UCHAR Buffer[1]; // empty
  1392. } RESP_IOCTL_INTERIM;
  1393. typedef RESP_IOCTL_INTERIM SMB_UNALIGNED *PRESP_IOCTL_INTERIM;
  1394. typedef struct _REQ_IOCTL_SECONDARY {
  1395. UCHAR WordCount; // Count of parameter words = 8
  1396. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  1397. _USHORT( TotalDataCount ); // Total data bytes being sent
  1398. _USHORT( ParameterCount ); // Parameter bytes sent this buffer
  1399. _USHORT( ParameterOffset ); // Offset (from header start) to params
  1400. _USHORT( ParameterDisplacement ); // Displacement of these param bytes
  1401. _USHORT( DataCount ); // Data bytes sent this buffer
  1402. _USHORT( DataOffset ); // Offset (from header start) to data
  1403. _USHORT( DataDisplacement ); // Displacement of these data bytes
  1404. _USHORT( ByteCount ); // Count of data bytes
  1405. UCHAR Buffer[1]; // Buffer containing:
  1406. //UCHAR Pad[]; // Pad to SHORT or LONG
  1407. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  1408. //UCHAR Pad1[]; // Pad to SHORT or LONG
  1409. //UCHAR Data[]; // Data bytes (# = DataCount)
  1410. } REQ_IOCTL_SECONDARY;
  1411. typedef REQ_IOCTL_SECONDARY SMB_UNALIGNED *PREQ_IOCTL_SECONDARY;
  1412. typedef struct _RESP_IOCTL {
  1413. UCHAR WordCount; // Count of parameter words = 8
  1414. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  1415. _USHORT( TotalDataCount ); // Total data bytes being sent
  1416. _USHORT( ParameterCount ); // Parameter bytes sent this buffer
  1417. _USHORT( ParameterOffset ); // Offset (from header start) to params
  1418. _USHORT( ParameterDisplacement ); // Displacement of these param bytes
  1419. _USHORT( DataCount ); // Data bytes sent this buffer
  1420. _USHORT( DataOffset ); // Offset (from header start) to data
  1421. _USHORT( DataDisplacement ); // Displacement of these data bytes
  1422. _USHORT( ByteCount ); // Count of data bytes
  1423. UCHAR Buffer[1]; // Buffer containing:
  1424. //UCHAR Pad[]; // Pad to SHORT or LONG
  1425. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  1426. //UCHAR Pad1[]; // Pad to SHORT or LONG
  1427. //UCHAR Data[]; // Data bytes (# = DataCount)
  1428. } RESP_IOCTL;
  1429. typedef RESP_IOCTL SMB_UNALIGNED *PRESP_IOCTL;
  1430. #endif // def INCLUDE_SMB_TRANSACTION
  1431. #ifdef INCLUDE_SMB_LOCK
  1432. //
  1433. // Lock Byte Range SMB, see #1 page 20
  1434. // Function is SrvSmbLockByteRange()
  1435. // SMB_COM_LOCK_BYTE_RANGE 0x0C
  1436. //
  1437. typedef struct _REQ_LOCK_BYTE_RANGE {
  1438. UCHAR WordCount; // Count of parameter words = 5
  1439. _USHORT( Fid ); // File handle
  1440. _ULONG( Count ); // Count of bytes to lock
  1441. _ULONG( Offset ); // Offset from start of file
  1442. _USHORT( ByteCount ); // Count of data bytes = 0
  1443. UCHAR Buffer[1]; // empty
  1444. } REQ_LOCK_BYTE_RANGE;
  1445. typedef REQ_LOCK_BYTE_RANGE SMB_UNALIGNED *PREQ_LOCK_BYTE_RANGE;
  1446. typedef struct _RESP_LOCK_BYTE_RANGE {
  1447. UCHAR WordCount; // Count of parameter words = 0
  1448. _USHORT( ByteCount ); // Count of data bytes = 0
  1449. UCHAR Buffer[1]; // empty
  1450. } RESP_LOCK_BYTE_RANGE;
  1451. typedef RESP_LOCK_BYTE_RANGE SMB_UNALIGNED *PRESP_LOCK_BYTE_RANGE;
  1452. #endif // def INCLUDE_SMB_LOCK
  1453. #ifdef INCLUDE_SMB_LOCK
  1454. //
  1455. // Locking and X SMB, see #2 page 46
  1456. // Function is SrvLockingAndX()
  1457. // SMB_COM_LOCKING_ANDX 0x24
  1458. //
  1459. typedef struct _REQ_LOCKING_ANDX {
  1460. UCHAR WordCount; // Count of parameter words = 8
  1461. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1462. UCHAR AndXReserved; // Reserved (must be 0)
  1463. _USHORT( AndXOffset ); // Offset to next command WordCount
  1464. _USHORT( Fid ); // File handle
  1465. //
  1466. // When NT protocol is not negotiated the OplockLevel field is
  1467. // omitted, and LockType field is a full word. Since the upper
  1468. // bits of LockType are never used, this definition works for
  1469. // all protocols.
  1470. //
  1471. UCHAR( LockType ); // Locking mode:
  1472. // bit 0: 0 = lock out all access
  1473. // 1 = read OK while locked
  1474. // bit 1: 1 = 1 user total file unlock
  1475. UCHAR( OplockLevel ); // The new oplock level
  1476. _ULONG( Timeout );
  1477. _USHORT( NumberOfUnlocks ); // Num. unlock range structs following
  1478. _USHORT( NumberOfLocks ); // Num. lock range structs following
  1479. _USHORT( ByteCount ); // Count of data bytes
  1480. UCHAR Buffer[1]; // Buffer containing:
  1481. //LOCKING_ANDX_RANGE Unlocks[]; // Unlock ranges
  1482. //LOCKING_ANDX_RANGE Locks[]; // Lock ranges
  1483. } REQ_LOCKING_ANDX;
  1484. typedef REQ_LOCKING_ANDX SMB_UNALIGNED *PREQ_LOCKING_ANDX;
  1485. #define LOCKING_ANDX_SHARED_LOCK 0x01
  1486. #define LOCKING_ANDX_OPLOCK_RELEASE 0x02
  1487. #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
  1488. #define LOCKING_ANDX_CANCEL_LOCK 0x08
  1489. #define LOCKING_ANDX_LARGE_FILES 0x10
  1490. #define OPLOCK_BROKEN_TO_NONE 0
  1491. #define OPLOCK_BROKEN_TO_II 1
  1492. typedef struct _LOCKING_ANDX_RANGE {
  1493. _USHORT( Pid ); // PID of process "owning" lock
  1494. _ULONG( Offset ); // Ofset to bytes to [un]lock
  1495. _ULONG( Length ); // Number of bytes to [un]lock
  1496. } LOCKING_ANDX_RANGE;
  1497. typedef LOCKING_ANDX_RANGE SMB_UNALIGNED *PLOCKING_ANDX_RANGE;
  1498. typedef struct _NT_LOCKING_ANDX_RANGE {
  1499. _USHORT( Pid ); // PID of process "owning" lock
  1500. _USHORT( Pad ); // Pad to DWORD align (mbz)
  1501. _ULONG( OffsetHigh ); // Ofset to bytes to [un]lock (high)
  1502. _ULONG( OffsetLow ); // Ofset to bytes to [un]lock (low)
  1503. _ULONG( LengthHigh ); // Number of bytes to [un]lock (high)
  1504. _ULONG( LengthLow ); // Number of bytes to [un]lock (low)
  1505. } NTLOCKING_ANDX_RANGE;
  1506. typedef NTLOCKING_ANDX_RANGE SMB_UNALIGNED *PNTLOCKING_ANDX_RANGE;
  1507. //
  1508. typedef struct _RESP_LOCKING_ANDX {
  1509. UCHAR WordCount; // Count of parameter words = 2
  1510. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1511. UCHAR AndXReserved; // Reserved (must be 0)
  1512. _USHORT( AndXOffset ); // Offset to next command WordCount
  1513. _USHORT( ByteCount ); // Count of data bytes = 0
  1514. UCHAR Buffer[1]; // empty
  1515. } RESP_LOCKING_ANDX;
  1516. typedef RESP_LOCKING_ANDX SMB_UNALIGNED *PRESP_LOCKING_ANDX;
  1517. #define LOCK_BROKEN_SIZE 51 // # of bytes in lock broken notify
  1518. #endif // def INCLUDE_SMB_LOCK
  1519. #ifdef INCLUDE_SMB_ADMIN
  1520. //
  1521. // Logoff and X SMB, see #3, page 55
  1522. // SMB_COM_LOGOFF_ANDX 0x74
  1523. //
  1524. typedef struct _REQ_LOGOFF_ANDX {
  1525. UCHAR WordCount; // Count of parameter words = 2
  1526. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1527. UCHAR AndXReserved; // Reserved (must be 0)
  1528. _USHORT( AndXOffset ); // Offset to next command WordCount
  1529. _USHORT( ByteCount ); // Count of data bytes = 0
  1530. UCHAR Buffer[1]; // empty
  1531. } REQ_LOGOFF_ANDX;
  1532. typedef REQ_LOGOFF_ANDX SMB_UNALIGNED *PREQ_LOGOFF_ANDX;
  1533. typedef struct _RESP_LOGOFF_ANDX {
  1534. UCHAR WordCount; // Count of parameter words = 2
  1535. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1536. UCHAR AndXReserved; // Reserved (must be 0)
  1537. _USHORT( AndXOffset ); // Offset to next command WordCount
  1538. _USHORT( ByteCount ); // Count of data bytes = 0
  1539. UCHAR Buffer[1]; // empty
  1540. } RESP_LOGOFF_ANDX;
  1541. typedef RESP_LOGOFF_ANDX SMB_UNALIGNED *PRESP_LOGOFF_ANDX;
  1542. #endif // def INCLUDE_SMB_ADMIN
  1543. #ifdef INCLUDE_SMB_FILE_CONTROL
  1544. //
  1545. // Move SMB, see #2 page 49
  1546. // Funcion is SrvSmbMove()
  1547. // SMB_COM_MOVE 0x2A
  1548. //
  1549. typedef struct _REQ_MOVE {
  1550. UCHAR WordCount; // Count of parameter words = 3
  1551. _USHORT( Tid2 ); // Second (target) file id
  1552. _USHORT( OpenFunction ); // what to do if target file exists
  1553. _USHORT( Flags ); // Flags to control move operations:
  1554. // 0 - target must be a file
  1555. // 1 - target must be a directory
  1556. // 2 - reserved (must be 0)
  1557. // 3 - reserved (must be 0)
  1558. // 4 - verify all writes
  1559. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1560. UCHAR Buffer[1]; // Buffer containing:
  1561. //UCHAR OldFileName[]; // Old file name
  1562. //UCHAR NewFileName[]; // New file name
  1563. } REQ_MOVE;
  1564. typedef REQ_MOVE SMB_UNALIGNED *PREQ_MOVE;
  1565. typedef struct _RESP_MOVE {
  1566. UCHAR WordCount; // Count of parameter words = 1
  1567. _USHORT( Count ); // Number of files moved
  1568. _USHORT( ByteCount ); // Count of data bytes; min = 0
  1569. UCHAR Buffer[1]; // Pathname of file where error occurred
  1570. } RESP_MOVE;
  1571. typedef RESP_MOVE SMB_UNALIGNED *PRESP_MOVE;
  1572. #endif // def INCLUDE_SMB_FILE_CONTROL
  1573. #ifdef INCLUDE_SMB_ADMIN
  1574. //
  1575. // Negotiate SMB's for Net 1 and Net 3, see #1 page 25 and #2 page 20
  1576. // Function is SrvSmbNegotiate()
  1577. // SMB_COM_NEGOTIATE 0x72
  1578. //
  1579. typedef struct _REQ_NEGOTIATE {
  1580. UCHAR WordCount; // Count of parameter words = 0
  1581. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1582. UCHAR Buffer[1]; // Buffer containing:
  1583. //struct {
  1584. // UCHAR BufferFormat; // 0x02 -- Dialect
  1585. // UCHAR DialectName[]; // ASCIIZ
  1586. //} Dialects[];
  1587. } REQ_NEGOTIATE;
  1588. typedef REQ_NEGOTIATE *PREQ_NEGOTIATE; // *** NOT SMB_UNALIGNED!
  1589. typedef struct _RESP_NEGOTIATE {
  1590. UCHAR WordCount; // Count of parameter words = 13
  1591. _USHORT( DialectIndex ); // Index of selected dialect
  1592. _USHORT( SecurityMode ); // Security mode:
  1593. // bit 0: 0 = share, 1 = user
  1594. // bit 1: 1 = encrypt passwords
  1595. // bit 2: 1 = SMB security signatures enabled
  1596. // bit 3: 1 = SMB security signatures required
  1597. _USHORT( MaxBufferSize ); // Max transmit buffer size
  1598. _USHORT( MaxMpxCount ); // Max pending multiplexed requests
  1599. _USHORT( MaxNumberVcs ); // Max VCs between client and server
  1600. _USHORT( RawMode ); // Raw modes supported:
  1601. // bit 0: 1 = Read Raw supported
  1602. // bit 1: 1 = Write Raw supported
  1603. _ULONG( SessionKey );
  1604. SMB_TIME ServerTime; // Current time at server
  1605. SMB_DATE ServerDate; // Current date at server
  1606. _USHORT( ServerTimeZone ); // Current time zone at server
  1607. _USHORT( EncryptionKeyLength ); // MBZ if this is not LM2.1
  1608. _USHORT( Reserved ); // MBZ
  1609. _USHORT( ByteCount ); // Count of data bytes
  1610. UCHAR Buffer[1]; // Password encryption key
  1611. //UCHAR EncryptionKey[]; // The challenge encryption key
  1612. //UCHAR PrimaryDomain[]; // The server's primary domain (2.1 only)
  1613. } RESP_NEGOTIATE;
  1614. typedef RESP_NEGOTIATE *PRESP_NEGOTIATE; // *** NOT SMB_UNALIGNED!
  1615. // Macros for SecurityMode field, above
  1616. #define NEGOTIATE_USER_SECURITY 0x01
  1617. #define NEGOTIATE_ENCRYPT_PASSWORDS 0x02
  1618. #define NEGOTIATE_SECURITY_SIGNATURES_ENABLED 0x04
  1619. #define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 0x08
  1620. // Macros for RawMode field, above
  1621. #define NEGOTIATE_READ_RAW_SUPPORTED 1
  1622. #define NEGOTIATE_WRITE_RAW_SUPPORTED 2
  1623. typedef struct _RESP_OLD_NEGOTIATE {
  1624. UCHAR WordCount; // Count of parameter words = 1
  1625. _USHORT( DialectIndex ); // Index of selected dialect
  1626. _USHORT( ByteCount ); // Count of data bytes = 0
  1627. UCHAR Buffer[1]; // empty
  1628. } RESP_OLD_NEGOTIATE;
  1629. typedef RESP_OLD_NEGOTIATE *PRESP_OLD_NEGOTIATE; // *** NOT SMB_UNALIGNED!
  1630. typedef struct _RESP_NT_NEGOTIATE {
  1631. UCHAR WordCount; // Count of parameter words = 17
  1632. _USHORT( DialectIndex ); // Index of selected dialect
  1633. UCHAR( SecurityMode ); // Security mode:
  1634. // bit 0: 0 = share, 1 = user
  1635. // bit 1: 1 = encrypt passwords
  1636. // bit 2: 1 = SMB sequence numbers enabled
  1637. // bit 3: 1 = SMB sequence numbers required
  1638. _USHORT( MaxMpxCount ); // Max pending multiplexed requests
  1639. _USHORT( MaxNumberVcs ); // Max VCs between client and server
  1640. _ULONG( MaxBufferSize ); // Max transmit buffer size
  1641. _ULONG( MaxRawSize ); // Maximum raw buffer size
  1642. _ULONG( SessionKey );
  1643. _ULONG( Capabilities ); // Server capabilities
  1644. _ULONG( SystemTimeLow ); // System (UTC) time of the server (low).
  1645. _ULONG( SystemTimeHigh ); // System (UTC) time of the server (high).
  1646. _USHORT( ServerTimeZone ); // Time zone of server (min from UTC)
  1647. UCHAR( EncryptionKeyLength ); // Length of encryption key.
  1648. _USHORT( ByteCount ); // Count of data bytes
  1649. UCHAR Buffer[1]; // Password encryption key
  1650. //UCHAR EncryptionKey[]; // The challenge encryption key
  1651. //UCHAR OemDomainName[]; // The name of the domain (in OEM chars)
  1652. } RESP_NT_NEGOTIATE;
  1653. typedef RESP_NT_NEGOTIATE *PRESP_NT_NEGOTIATE; // *** NOT SMB_UNALIGNED!
  1654. #endif // def INCLUDE_SMB_ADMIN
  1655. //
  1656. // Server / workstation capabilities
  1657. // N.B. Most messages use a ULONG for this, so there are many more
  1658. // bits available.
  1659. //
  1660. #define CAP_RAW_MODE 0x0001
  1661. #define CAP_MPX_MODE 0x0002
  1662. #define CAP_UNICODE 0x0004
  1663. #define CAP_LARGE_FILES 0x0008
  1664. #define CAP_NT_SMBS 0x0010
  1665. #define CAP_RPC_REMOTE_APIS 0x0020
  1666. #define CAP_NT_STATUS 0x0040
  1667. #define CAP_LEVEL_II_OPLOCKS 0x0080
  1668. #define CAP_LOCK_AND_READ 0x0100
  1669. #define CAP_NT_FIND 0x0200
  1670. #define CAP_DFS 0x1000 // This server is DFS aware
  1671. #define CAP_INFOLEVEL_PASSTHRU 0x2000 // NT information level requests can pass through
  1672. #define CAP_LARGE_READX 0x4000 // Server supports oversized READ&X on files
  1673. #define CAP_LARGE_WRITEX 0x8000
  1674. #ifdef INCLUDE_SMB_OPEN_CLOSE
  1675. //
  1676. // Open SMB, see #1, page 7
  1677. // Function is SrvSmbOpen()
  1678. // SMB_COM_OPEN 0x02
  1679. //
  1680. typedef struct _REQ_OPEN {
  1681. UCHAR WordCount; // Count of parameter words = 2
  1682. _USHORT( DesiredAccess ); // Mode - read/write/share
  1683. _USHORT( SearchAttributes );
  1684. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1685. UCHAR Buffer[1]; // Buffer containing:
  1686. //UCHAR BufferFormat; // 0x04 -- ASCII
  1687. //UCHAR FileName[]; // File name
  1688. } REQ_OPEN;
  1689. typedef REQ_OPEN SMB_UNALIGNED *PREQ_OPEN;
  1690. typedef struct _RESP_OPEN {
  1691. UCHAR WordCount; // Count of parameter words = 7
  1692. _USHORT( Fid ); // File handle
  1693. _USHORT( FileAttributes );
  1694. _ULONG( LastWriteTimeInSeconds );
  1695. _ULONG( DataSize ); // File size
  1696. _USHORT( GrantedAccess ); // Access allowed
  1697. _USHORT( ByteCount ); // Count of data bytes = 0
  1698. UCHAR Buffer[1]; // empty
  1699. } RESP_OPEN;
  1700. typedef RESP_OPEN SMB_UNALIGNED *PRESP_OPEN;
  1701. #endif // def INCLUDE_SMB_OPEN_CLOSE
  1702. #ifdef INCLUDE_SMB_OPEN_CLOSE
  1703. //
  1704. // Open and X SMB, see #2 page 51
  1705. // Function is SrvOpenAndX()
  1706. // SMB_COM_OPEN_ANDX 0x2D
  1707. //
  1708. typedef struct _REQ_OPEN_ANDX {
  1709. UCHAR WordCount; // Count of parameter words = 15
  1710. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1711. UCHAR AndXReserved; // Reserved (must be 0)
  1712. _USHORT( AndXOffset ); // Offset to next command WordCount
  1713. _USHORT( Flags ); // Additional information: bit set-
  1714. // 0 - return additional info
  1715. // 1 - set single user total file lock
  1716. // 2 - server notifies consumer of
  1717. // actions which may change file
  1718. // 4 - return extended response
  1719. _USHORT( DesiredAccess ); // File open mode
  1720. _USHORT( SearchAttributes );
  1721. _USHORT( FileAttributes );
  1722. _ULONG( CreationTimeInSeconds );
  1723. _USHORT( OpenFunction );
  1724. _ULONG( AllocationSize ); // Bytes to reserve on create or truncate
  1725. _ULONG( Timeout ); // Max milliseconds to wait for resource
  1726. _ULONG( Reserved ); // Reserved (must be 0)
  1727. _USHORT( ByteCount ); // Count of data bytes; min = 1
  1728. UCHAR Buffer[1]; // File name
  1729. } REQ_OPEN_ANDX;
  1730. typedef REQ_OPEN_ANDX SMB_UNALIGNED *PREQ_OPEN_ANDX;
  1731. typedef struct _RESP_OPEN_ANDX {
  1732. UCHAR WordCount; // Count of parameter words = 15
  1733. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  1734. UCHAR AndXReserved; // Reserved (must be 0)
  1735. _USHORT( AndXOffset ); // Offset to next command WordCount
  1736. _USHORT( Fid ); // File handle
  1737. _USHORT( FileAttributes );
  1738. _ULONG( LastWriteTimeInSeconds );
  1739. _ULONG( DataSize ); // Current file size
  1740. _USHORT( GrantedAccess ); // Access permissions actually allowed
  1741. _USHORT( FileType );
  1742. _USHORT( DeviceState ); // state of IPC device (e.g. pipe)
  1743. _USHORT( Action ); // Action taken
  1744. _ULONG( ServerFid ); // Server unique file id
  1745. _USHORT( Reserved ); // Reserved (must be 0)
  1746. _USHORT( ByteCount ); // Count of data bytes = 0
  1747. UCHAR Buffer[1]; // empty
  1748. } RESP_OPEN_ANDX;
  1749. typedef RESP_OPEN_ANDX SMB_UNALIGNED *PRESP_OPEN_ANDX;
  1750. typedef struct _REQ_NT_CREATE_ANDX {
  1751. UCHAR WordCount; // Count of parameter words = 24
  1752. UCHAR AndXCommand; // Secondary command; 0xFF = None
  1753. UCHAR AndXReserved; // MBZ
  1754. _USHORT( AndXOffset ); // Offset to next command wordcount
  1755. UCHAR Reserved; // MBZ
  1756. _USHORT( NameLength ); // Length of Name[] in bytes
  1757. _ULONG( Flags ); // Create flags
  1758. _ULONG( RootDirectoryFid ); // If non-zero, open is relative to this directory
  1759. ACCESS_MASK DesiredAccess; // NT access desired
  1760. LARGE_INTEGER AllocationSize; // Initial allocation size
  1761. _ULONG( FileAttributes ); // File attributes for creation
  1762. _ULONG( ShareAccess ); // Type of share access
  1763. _ULONG( CreateDisposition ); // Action to take if file exists or not
  1764. _ULONG( CreateOptions ); // Options to use if creating a file
  1765. _ULONG( ImpersonationLevel ); // Security QOS information
  1766. UCHAR SecurityFlags; // Security QOS information
  1767. _USHORT( ByteCount ); // Length of byte parameters
  1768. UCHAR Buffer[1];
  1769. //UCHAR Name[]; // File to open or create
  1770. } REQ_NT_CREATE_ANDX;
  1771. typedef REQ_NT_CREATE_ANDX SMB_UNALIGNED *PREQ_NT_CREATE_ANDX;
  1772. // Flag bit for Security flags
  1773. #define SMB_SECURITY_DYNAMIC_TRACKING 0x01
  1774. #define SMB_SECURITY_EFFECTIVE_ONLY 0x02
  1775. typedef struct _RESP_NT_CREATE_ANDX {
  1776. UCHAR WordCount; // Count of parameter words = 26
  1777. UCHAR AndXCommand; // Secondary command; 0xFF = None
  1778. UCHAR AndXReserved; // MBZ
  1779. _USHORT( AndXOffset ); // Offset to next command wordcount
  1780. UCHAR OplockLevel; // The oplock level granted
  1781. _USHORT( Fid ); // The file ID
  1782. _ULONG( CreateAction ); // The action taken
  1783. TIME CreationTime; // The time the file was created
  1784. TIME LastAccessTime; // The time the file was accessed
  1785. TIME LastWriteTime; // The time the file was last written
  1786. TIME ChangeTime; // The time the file was last changed
  1787. _ULONG( FileAttributes ); // The file attributes
  1788. LARGE_INTEGER AllocationSize; // The number of byes allocated
  1789. LARGE_INTEGER EndOfFile; // The end of file offset
  1790. _USHORT( FileType );
  1791. union {
  1792. _USHORT( DeviceState ); // state of IPC device (e.g. pipe)
  1793. _USHORT( FileStatusFlags ); // if a file or directory. See below.
  1794. };
  1795. BOOLEAN Directory; // TRUE if this is a directory
  1796. _USHORT( ByteCount ); // = 0
  1797. UCHAR Buffer[1];
  1798. } RESP_NT_CREATE_ANDX;
  1799. typedef RESP_NT_CREATE_ANDX SMB_UNALIGNED *PRESP_NT_CREATE_ANDX;
  1800. //
  1801. // Values for FileStatusFlags, if the opened resource is a file or directory
  1802. //
  1803. #define SMB_FSF_NO_EAS 0x0001 // file/dir has no extended attributes
  1804. #define SMB_FSF_NO_SUBSTREAMS 0x0002 // file/dir has no substreams
  1805. #define SMB_FSF_NO_REPARSETAG 0x0004 // file/dir is not a reparse point
  1806. #define SMB_OPLOCK_LEVEL_NONE 0
  1807. #define SMB_OPLOCK_LEVEL_EXCLUSIVE 1
  1808. #define SMB_OPLOCK_LEVEL_BATCH 2
  1809. #define SMB_OPLOCK_LEVEL_II 3
  1810. #endif // def INCLUDE_SMB_OPEN_CLOSE
  1811. #ifdef INCLUDE_SMB_PRINT
  1812. //
  1813. // Open Print File SMB, see #1 page 27
  1814. // Function is SrvSmbOpenPrintFile()
  1815. // SMB_COM_OPEN_PRINT_FILE 0xC0
  1816. //
  1817. typedef struct _REQ_OPEN_PRINT_FILE {
  1818. UCHAR WordCount; // Count of parameter words = 2
  1819. _USHORT( SetupLength ); // Length of printer setup data
  1820. _USHORT( Mode ); // 0 = Text mode (DOS expands TABs)
  1821. // 1 = Graphics mode
  1822. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1823. UCHAR Buffer[1]; // Buffer containing:
  1824. //UCHAR BufferFormat; // 0x04 -- ASCII
  1825. //UCHAR IdentifierString[]; // Identifier string
  1826. } REQ_OPEN_PRINT_FILE;
  1827. typedef REQ_OPEN_PRINT_FILE SMB_UNALIGNED *PREQ_OPEN_PRINT_FILE;
  1828. typedef struct _RESP_OPEN_PRINT_FILE {
  1829. UCHAR WordCount; // Count of parameter words = 1
  1830. _USHORT( Fid ); // File handle
  1831. _USHORT( ByteCount ); // Count of data bytes = 0
  1832. UCHAR Buffer[1]; // empty
  1833. } RESP_OPEN_PRINT_FILE;
  1834. typedef RESP_OPEN_PRINT_FILE SMB_UNALIGNED *PRESP_OPEN_PRINT_FILE;
  1835. #endif // def INCLUDE_SMB_PRINT
  1836. #ifdef INCLUDE_SMB_ADMIN
  1837. //
  1838. // Process Exit SMB, see #1 page 22
  1839. // Function is SrvSmbProcessExit()
  1840. // SMB_COM_PROCESS_EXIT 0x11
  1841. //
  1842. typedef struct _REQ_PROCESS_EXIT {
  1843. UCHAR WordCount; // Count of parameter words = 0
  1844. _USHORT( ByteCount ); // Count of data bytes = 0
  1845. UCHAR Buffer[1]; // empty
  1846. } REQ_PROCESS_EXIT;
  1847. typedef REQ_PROCESS_EXIT SMB_UNALIGNED *PREQ_PROCESS_EXIT;
  1848. typedef struct _RESP_PROCESS_EXIT {
  1849. UCHAR WordCount; // Count of parameter words = 0
  1850. _USHORT( ByteCount ); // Count of data bytes = 0
  1851. UCHAR Buffer[1]; // empty
  1852. } RESP_PROCESS_EXIT;
  1853. typedef RESP_PROCESS_EXIT SMB_UNALIGNED *PRESP_PROCESS_EXIT;
  1854. #endif // def INCLUDE_SMB_ADMIN
  1855. #ifdef INCLUDE_SMB_QUERY_SET
  1856. //
  1857. // Query Information SMB, see #1 page 18
  1858. // Function is SrvSmbQueryInformation()
  1859. // SMB_COM_QUERY_INFORMATION 0x08
  1860. //
  1861. typedef struct _REQ_QUERY_INFORMATION {
  1862. UCHAR WordCount; // Count of parameter words = 0
  1863. _USHORT( ByteCount ); // Count of data bytes; min = 2
  1864. UCHAR Buffer[1]; // Buffer containing:
  1865. //UCHAR BufferFormat; // 0x04 -- ASCII
  1866. //UCHAR FileName[]; // File name
  1867. } REQ_QUERY_INFORMATION;
  1868. typedef REQ_QUERY_INFORMATION SMB_UNALIGNED *PREQ_QUERY_INFORMATION;
  1869. typedef struct _RESP_QUERY_INFORMATION {
  1870. UCHAR WordCount; // Count of parameter words = 10
  1871. _USHORT( FileAttributes );
  1872. _ULONG( LastWriteTimeInSeconds );
  1873. _ULONG( FileSize ); // File size
  1874. _USHORT( Reserved )[5]; // Reserved (must be 0)
  1875. _USHORT( ByteCount ); // Count of data bytes = 0
  1876. UCHAR Buffer[1]; // empty
  1877. } RESP_QUERY_INFORMATION;
  1878. typedef RESP_QUERY_INFORMATION SMB_UNALIGNED *PRESP_QUERY_INFORMATION;
  1879. #endif // def INCLUDE_SMB_QUERY_SET
  1880. #ifdef INCLUDE_SMB_QUERY_SET
  1881. //
  1882. // Query Information2 SMB, see #2 page 37
  1883. // Function is SrvSmbQueryInformation2()
  1884. // SMB_COM_QUERY_INFORMATION2 0x23
  1885. //
  1886. typedef struct _REQ_QUERY_INFORMATION2 {
  1887. UCHAR WordCount; // Count of parameter words = 2
  1888. _USHORT( Fid ); // File handle
  1889. _USHORT( ByteCount ); // Count of data bytes = 0
  1890. UCHAR Buffer[1]; // empty
  1891. } REQ_QUERY_INFORMATION2;
  1892. typedef REQ_QUERY_INFORMATION2 SMB_UNALIGNED *PREQ_QUERY_INFORMATION2;
  1893. typedef struct _RESP_QUERY_INFORMATION2 {
  1894. UCHAR WordCount; // Count of parameter words = 11
  1895. SMB_DATE CreationDate;
  1896. SMB_TIME CreationTime;
  1897. SMB_DATE LastAccessDate;
  1898. SMB_TIME LastAccessTime;
  1899. SMB_DATE LastWriteDate;
  1900. SMB_TIME LastWriteTime;
  1901. _ULONG( FileDataSize ); // File end of data
  1902. _ULONG( FileAllocationSize ); // File allocation size
  1903. _USHORT( FileAttributes );
  1904. _USHORT( ByteCount ); // Count of data bytes; min = 0
  1905. UCHAR Buffer[1]; // Reserved buffer
  1906. } RESP_QUERY_INFORMATION2;
  1907. typedef RESP_QUERY_INFORMATION2 SMB_UNALIGNED *PRESP_QUERY_INFORMATION2;
  1908. #endif // def INCLUDE_SMB_QUERY_SET
  1909. #ifdef INCLUDE_SMB_MISC
  1910. //
  1911. // Query Information Disk SMB, see #1 page 24
  1912. // Function is SrvSmbQueryInformationDisk()
  1913. // SMB_COM_QUERY_INFORMATION_DISK 0x80
  1914. //
  1915. typedef struct _REQ_QUERY_INFORMATION_DISK {
  1916. UCHAR WordCount; // Count of parameter words = 0
  1917. _USHORT( ByteCount ); // Count of data bytes = 0
  1918. UCHAR Buffer[1]; // empty
  1919. } REQ_QUERY_INFORMATION_DISK;
  1920. typedef REQ_QUERY_INFORMATION_DISK SMB_UNALIGNED *PREQ_QUERY_INFORMATION_DISK;
  1921. typedef struct _RESP_QUERY_INFORMATION_DISK {
  1922. UCHAR WordCount; // Count of parameter words = 5
  1923. _USHORT( TotalUnits ); // Total allocation units per server
  1924. _USHORT( BlocksPerUnit ); // Blocks per allocation unit
  1925. _USHORT( BlockSize ); // Block size (in bytes)
  1926. _USHORT( FreeUnits ); // Number of free units
  1927. _USHORT( Reserved ); // Reserved (media identification code)
  1928. _USHORT( ByteCount ); // Count of data bytes = 0
  1929. UCHAR Buffer[1]; // empty
  1930. } RESP_QUERY_INFORMATION_DISK;
  1931. typedef RESP_QUERY_INFORMATION_DISK SMB_UNALIGNED *PRESP_QUERY_INFORMATION_DISK;
  1932. #endif // def INCLUDE_SMB_MISC
  1933. #ifdef INCLUDE_SMB_MISC
  1934. //
  1935. // Query Server Information SMB, see #? page ??
  1936. // Function is SrvSmbQueryInformationServer
  1937. // SMB_COM_QUERY_INFORMATION_SRV 0x21
  1938. //
  1939. typedef struct _REQ_QUERY_INFORMATION_SRV {
  1940. UCHAR WordCount; // Count of parameter words = 1
  1941. _USHORT( Mode );
  1942. _USHORT( ByteCount ); // Count of data bytes; min =
  1943. UCHAR Buffer[1]; //
  1944. } REQ_QUERY_INFORMATION_SRV;
  1945. typedef REQ_QUERY_INFORMATION_SRV SMB_UNALIGNED *PREQ_QUERY_INFORMATION_SRV;
  1946. typedef struct _RESP_QUERY_INFORMATION_SRV {
  1947. UCHAR WordCount; // Count of parameter words = 20
  1948. _ULONG( smb_fsid );
  1949. _ULONG( BlocksPerUnit );
  1950. _ULONG( smb_aunits );
  1951. _ULONG( smb_fau );
  1952. _USHORT( BlockSize );
  1953. SMB_DATE smb_vldate;
  1954. SMB_TIME smb_vltime;
  1955. UCHAR smb_vllen;
  1956. UCHAR Reserved; // Reserved (must be 0)
  1957. _USHORT( SecurityMode );
  1958. _USHORT( BlockMode );
  1959. _ULONG( Services );
  1960. _USHORT( MaxTransmitSize );
  1961. _USHORT( MaxMpxCount );
  1962. _USHORT( MaxNumberVcs );
  1963. SMB_TIME ServerTime;
  1964. SMB_DATE ServerDate;
  1965. _USHORT( ServerTimeZone );
  1966. _ULONG( Reserved2 );
  1967. _USHORT( ByteCount ); // Count of data bytes; min =
  1968. UCHAR Buffer[1]; //
  1969. } RESP_QUERY_INFORMATION_SRV;
  1970. typedef RESP_QUERY_INFORMATION_SRV SMB_UNALIGNED *PRESP_QUERY_INFORMATION_SRV;
  1971. #endif // def INCLUDE_SMB_MISC
  1972. #ifdef INCLUDE_SMB_READ_WRITE
  1973. //
  1974. // Read SMB, see #1 page 12
  1975. // Lock and Read SMB, see #2 page 44
  1976. // SMB_COM_READ 0x0A, Function is SrvSmbRead
  1977. // SMB_COM_LOCK_AND_READ 0x13, Function is SrvSmbLockAndRead
  1978. //
  1979. typedef struct _REQ_READ {
  1980. UCHAR WordCount; // Count of parameter words = 5
  1981. _USHORT( Fid ); // File handle
  1982. _USHORT( Count ); // Count of bytes being requested
  1983. _ULONG( Offset ); // Offset in file of first byte to read
  1984. _USHORT( Remaining ); // Estimate of bytes to read if nonzero
  1985. _USHORT( ByteCount ); // Count of data bytes = 0
  1986. UCHAR Buffer[1]; // empty
  1987. } REQ_READ;
  1988. typedef REQ_READ SMB_UNALIGNED *PREQ_READ;
  1989. //
  1990. // *** Warning: the following structure is defined the way it is to
  1991. // ensure longword alignment of the data buffer. (This only matters
  1992. // when packing is disabled; when packing is turned on, the right
  1993. // thing happens no matter what.)
  1994. //
  1995. typedef struct _RESP_READ {
  1996. UCHAR WordCount; // Count of parameter words = 5
  1997. _USHORT( Count ); // Count of bytes actually returned
  1998. _USHORT( Reserved )[4]; // Reserved (must be 0)
  1999. _USHORT( ByteCount ); // Count of data bytes
  2000. //UCHAR Buffer[1]; // Buffer containing:
  2001. UCHAR BufferFormat; // 0x01 -- Data block
  2002. _USHORT( DataLength ); // Length of data
  2003. ULONG Buffer[1]; // Data
  2004. } RESP_READ;
  2005. typedef RESP_READ SMB_UNALIGNED *PRESP_READ;
  2006. #endif // def INCLUDE_SMB_READ_WRITE
  2007. #ifdef INCLUDE_SMB_READ_WRITE
  2008. //
  2009. // Read and X SMB, see #2 page 56
  2010. // Function is SrvSmbReadAndX()
  2011. // SMB_COM_READ_ANDX 0x2E
  2012. //
  2013. typedef struct _REQ_READ_ANDX {
  2014. UCHAR WordCount; // Count of parameter words = 10
  2015. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2016. UCHAR AndXReserved; // Reserved (must be 0)
  2017. _USHORT( AndXOffset ); // Offset to next command WordCount
  2018. _USHORT( Fid ); // File handle
  2019. _ULONG( Offset ); // Offset in file to begin read
  2020. _USHORT( MaxCount ); // Max number of bytes to return
  2021. _USHORT( MinCount ); // Min number of bytes to return
  2022. _ULONG( Timeout );
  2023. _USHORT( Remaining ); // Bytes remaining to satisfy request
  2024. _USHORT( ByteCount ); // Count of data bytes = 0
  2025. UCHAR Buffer[1]; // empty
  2026. } REQ_READ_ANDX;
  2027. typedef REQ_READ_ANDX SMB_UNALIGNED *PREQ_READ_ANDX;
  2028. typedef struct _REQ_NT_READ_ANDX {
  2029. UCHAR WordCount; // Count of parameter words = 12
  2030. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2031. UCHAR AndXReserved; // Reserved (must be 0)
  2032. _USHORT( AndXOffset ); // Offset to next command WordCount
  2033. _USHORT( Fid ); // File handle
  2034. _ULONG( Offset ); // Offset in file to begin read
  2035. _USHORT( MaxCount ); // Max number of bytes to return
  2036. _USHORT( MinCount ); // Min number of bytes to return
  2037. union {
  2038. _ULONG( Timeout );
  2039. _USHORT( MaxCountHigh ); // upper 16 bits of MaxCount if NT request
  2040. };
  2041. _USHORT( Remaining ); // Bytes remaining to satisfy request
  2042. _ULONG( OffsetHigh ); // Used for NT Protocol only
  2043. // Upper 32 bits of offset
  2044. _USHORT( ByteCount ); // Count of data bytes = 0
  2045. UCHAR Buffer[1]; // empty
  2046. } REQ_NT_READ_ANDX;
  2047. typedef REQ_NT_READ_ANDX SMB_UNALIGNED *PREQ_NT_READ_ANDX;
  2048. typedef struct _RESP_READ_ANDX {
  2049. UCHAR WordCount; // Count of parameter words = 12
  2050. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2051. UCHAR AndXReserved; // Reserved (must be 0)
  2052. _USHORT( AndXOffset ); // Offset to next command WordCount
  2053. _USHORT( Remaining ); // Bytes remaining to be read
  2054. _USHORT( DataCompactionMode );
  2055. _USHORT( Reserved ); // Reserved (must be 0)
  2056. _USHORT( DataLength ); // Number of data bytes (min = 0)
  2057. _USHORT( DataOffset ); // Offset (from header start) to data
  2058. union {
  2059. _USHORT( Reserved2 ); // Reserved (must be 0)
  2060. _USHORT( DataLengthHigh ); // upper 16 bits of DataLength if NT request
  2061. };
  2062. _ULONG( Reserved3 )[2]; // Reserved (must be 0)
  2063. _USHORT( ByteCount ); // Count of data bytes. Inaccurate if we
  2064. // are doing large Read&X's!
  2065. UCHAR Buffer[1]; // Buffer containing:
  2066. //UCHAR Pad[]; // Pad to SHORT or LONG
  2067. //UCHAR Data[]; // Data (size = DataLength)
  2068. } RESP_READ_ANDX;
  2069. typedef RESP_READ_ANDX SMB_UNALIGNED *PRESP_READ_ANDX;
  2070. #endif // def INCLUDE_SMB_READ_WRITE
  2071. #ifdef INCLUDE_SMB_MPX
  2072. //
  2073. // Read Block Multiplexed SMB, see #2 page 58
  2074. // Function is SrvSmbReadMpx()
  2075. // SMB_COM_READ_MPX 0x1B
  2076. // SMB_COM_READ_MPX_SECONDARY 0x1C
  2077. //
  2078. typedef struct _REQ_READ_MPX {
  2079. UCHAR WordCount; // Count of parameter words = 8
  2080. _USHORT( Fid ); // File handle
  2081. _ULONG( Offset ); // Offset in file to begin read
  2082. _USHORT( MaxCount ); // Max bytes to return (max 65535)
  2083. _USHORT( MinCount ); // Min bytes to return (normally 0)
  2084. _ULONG( Timeout );
  2085. _USHORT( Reserved );
  2086. _USHORT( ByteCount ); // Count of data bytes = 0
  2087. UCHAR Buffer[1]; // empty
  2088. } REQ_READ_MPX;
  2089. typedef REQ_READ_MPX SMB_UNALIGNED *PREQ_READ_MPX;
  2090. typedef struct _RESP_READ_MPX {
  2091. UCHAR WordCount; // Count of parameter words = 8
  2092. _ULONG( Offset ); // Offset in file where data read
  2093. _USHORT( Count ); // Total bytes being returned
  2094. _USHORT( Remaining ); // Bytes remaining to be read (pipe/dev)
  2095. _USHORT( DataCompactionMode );
  2096. _USHORT( Reserved );
  2097. _USHORT( DataLength ); // Number of data bytes this buffer
  2098. _USHORT( DataOffset ); // Offset (from header start) to data
  2099. _USHORT( ByteCount ); // Count of data bytes
  2100. UCHAR Buffer[1]; // Buffer containing:
  2101. //UCHAR Pad[]; // Pad to SHORT or LONG
  2102. //UCHAR Data[]; // Data (size = DataLength)
  2103. } RESP_READ_MPX;
  2104. typedef RESP_READ_MPX SMB_UNALIGNED *PRESP_READ_MPX;
  2105. #endif // def INCLUDE_SMB_MPX
  2106. #ifdef INCLUDE_SMB_RAW
  2107. //
  2108. // Read Block Raw SMB, see #2 page 61
  2109. // Function is SrvSmbReadRaw()
  2110. // SMB_COM_READ_RAW 0x1A
  2111. //
  2112. typedef struct _REQ_READ_RAW {
  2113. UCHAR WordCount; // Count of parameter words = 8
  2114. _USHORT( Fid ); // File handle
  2115. _ULONG( Offset ); // Offset in file to begin read
  2116. _USHORT( MaxCount ); // Max bytes to return (max 65535)
  2117. _USHORT( MinCount ); // Min bytes to return (normally 0)
  2118. _ULONG( Timeout );
  2119. _USHORT( Reserved );
  2120. _USHORT( ByteCount ); // Count of data bytes = 0
  2121. UCHAR Buffer[1]; // empty
  2122. } REQ_READ_RAW;
  2123. typedef REQ_READ_RAW SMB_UNALIGNED *PREQ_READ_RAW;
  2124. typedef struct _REQ_NT_READ_RAW {
  2125. UCHAR WordCount; // Count of parameter words = 10
  2126. _USHORT( Fid ); // File handle
  2127. _ULONG( Offset ); // Offset in file to begin read
  2128. _USHORT( MaxCount ); // Max bytes to return (max 65535)
  2129. _USHORT( MinCount ); // Min bytes to return (normally 0)
  2130. _ULONG( Timeout );
  2131. _USHORT( Reserved );
  2132. _ULONG( OffsetHigh ); // Used for NT Protocol only
  2133. // Upper 32 bits of offset
  2134. _USHORT( ByteCount ); // Count of data bytes = 0
  2135. UCHAR Buffer[1]; // empty
  2136. } REQ_NT_READ_RAW;
  2137. typedef REQ_NT_READ_RAW SMB_UNALIGNED *PREQ_NT_READ_RAW;
  2138. // No response params for raw read--the response is the raw data.
  2139. #endif // def INCLUDE_SMB_RAW
  2140. #ifdef INCLUDE_SMB_FILE_CONTROL
  2141. //
  2142. // Rename SMB, see #1 page 17
  2143. // Function is SrvSmbRename()
  2144. // SMB_COM_RENAME 0x07
  2145. //
  2146. typedef struct _REQ_RENAME {
  2147. UCHAR WordCount; // Count of parameter words = 1
  2148. _USHORT( SearchAttributes );
  2149. _USHORT( ByteCount ); // Count of data bytes; min = 4
  2150. UCHAR Buffer[1]; // Buffer containing:
  2151. //UCHAR BufferFormat1; // 0x04 -- ASCII
  2152. //UCHAR OldFileName[]; // Old file name
  2153. //UCHAR BufferFormat2; // 0x04 -- ASCII
  2154. //UCHAR NewFileName[]; // New file name
  2155. } REQ_RENAME;
  2156. typedef REQ_RENAME SMB_UNALIGNED *PREQ_RENAME;
  2157. //
  2158. // Extended NT rename SMB
  2159. // Function is SrvSmbRename()
  2160. // SMB_COM_NT_RENAME 0xA5
  2161. //
  2162. typedef struct _REQ_NTRENAME {
  2163. UCHAR WordCount; // Count of parameter words = 4
  2164. _USHORT( SearchAttributes );
  2165. _USHORT( InformationLevel );
  2166. _ULONG( ClusterCount );
  2167. _USHORT( ByteCount ); // Count of data bytes; min = 4
  2168. UCHAR Buffer[1]; // Buffer containing:
  2169. //UCHAR BufferFormat1; // 0x04 -- ASCII
  2170. //UCHAR OldFileName[]; // Old file name
  2171. //UCHAR BufferFormat2; // 0x04 -- ASCII
  2172. //UCHAR NewFileName[]; // New file name
  2173. } REQ_NTRENAME;
  2174. typedef REQ_NTRENAME SMB_UNALIGNED *PREQ_NTRENAME;
  2175. typedef struct _RESP_RENAME {
  2176. UCHAR WordCount; // Count of parameter words = 0
  2177. _USHORT( ByteCount ); // Count of data bytes = 0
  2178. UCHAR Buffer[1]; // empty
  2179. } RESP_RENAME;
  2180. typedef RESP_RENAME SMB_UNALIGNED *PRESP_RENAME;
  2181. #endif // def INCLUDE_SMB_FILE_CONTROL
  2182. #ifdef INCLUDE_SMB_SEARCH
  2183. //
  2184. // Search SMBs. One structure is common for both the core Search and the
  2185. // LAN Manager 1.0 Find First/Next/Close.
  2186. //
  2187. // Function is SrvSmbSearch()
  2188. //
  2189. // Search, see #1 page 26
  2190. // SMB_COM_SEARCH 0x81
  2191. // FindFirst and FindNext, see #2 page 27
  2192. // SMB_COM_FIND 0x82
  2193. // FindUnique, see #2 page 33
  2194. // SMB_COM_FIND_UNIQUE 0x83
  2195. // FindClose, see #2 page 31
  2196. // SMB_COM_FIND_CLOSE 0x84
  2197. //
  2198. typedef struct _REQ_SEARCH {
  2199. UCHAR WordCount; // Count of parameter words = 2
  2200. _USHORT( MaxCount ); // Number of dir. entries to return
  2201. _USHORT( SearchAttributes );
  2202. _USHORT( ByteCount ); // Count of data bytes; min = 5
  2203. UCHAR Buffer[1]; // Buffer containing:
  2204. //UCHAR BufferFormat1; // 0x04 -- ASCII
  2205. //UCHAR FileName[]; // File name, may be null
  2206. //UCHAR BufferFormat2; // 0x05 -- Variable block
  2207. //USHORT ResumeKeyLength; // Length of resume key, may be 0
  2208. //UCHAR SearchStatus[]; // Resume key
  2209. } REQ_SEARCH;
  2210. typedef REQ_SEARCH SMB_UNALIGNED *PREQ_SEARCH;
  2211. typedef struct _RESP_SEARCH {
  2212. UCHAR WordCount; // Count of parameter words = 1
  2213. _USHORT( Count ); // Number of entries returned
  2214. _USHORT( ByteCount ); // Count of data bytes; min = 3
  2215. UCHAR Buffer[1]; // Buffer containing:
  2216. //UCHAR BufferFormat; // 0x05 -- Variable block
  2217. //USHORT DataLength; // Length of data
  2218. //UCHAR Data[]; // Data
  2219. } RESP_SEARCH;
  2220. typedef RESP_SEARCH SMB_UNALIGNED *PRESP_SEARCH;
  2221. //
  2222. // These two structures are use to return information in the Search SMBs.
  2223. // SMB_DIRECTORY_INFORMATION is used to return information about a file
  2224. // that was found. In addition to the usual information about the file,
  2225. // each of these structures contains an SMB_RESUME_KEY, which is used to
  2226. // continue or rewind a search.
  2227. //
  2228. // These structures must be packed, so turn on packing if it isn't
  2229. // already on.
  2230. //
  2231. #ifdef NO_PACKING
  2232. #include <packon.h>
  2233. #endif // def NO_PACKING
  2234. typedef struct _SMB_RESUME_KEY {
  2235. UCHAR Reserved; // bit 7 - comsumer use
  2236. // bits 5,6 - system use (must preserve)
  2237. // bits 0-4 - server use (must preserve)
  2238. UCHAR FileName[11];
  2239. UCHAR Sid; // Uniquely identifies Find through Close
  2240. _ULONG( FileIndex ); // Reserved for server use
  2241. UCHAR Consumer[4]; // Reserved for comsumer use
  2242. } SMB_RESUME_KEY;
  2243. typedef SMB_RESUME_KEY SMB_UNALIGNED *PSMB_RESUME_KEY;
  2244. typedef struct _SMB_DIRECTORY_INFORMATION {
  2245. SMB_RESUME_KEY ResumeKey;
  2246. UCHAR FileAttributes;
  2247. SMB_TIME LastWriteTime;
  2248. SMB_DATE LastWriteDate;
  2249. _ULONG( FileSize );
  2250. UCHAR FileName[13]; // ASCII, space-filled null terminated
  2251. } SMB_DIRECTORY_INFORMATION;
  2252. typedef SMB_DIRECTORY_INFORMATION SMB_UNALIGNED *PSMB_DIRECTORY_INFORMATION;
  2253. #ifdef NO_PACKING
  2254. #include <packoff.h>
  2255. #endif // def NO_PACKING
  2256. #endif // def INCLUDE_SMB_SEARCH
  2257. #ifdef INCLUDE_SMB_READ_WRITE
  2258. //
  2259. // Seek SMB, see #1 page 14
  2260. // Function is SrvSmbSeek
  2261. // SMB_COM_SEEK 0x12
  2262. //
  2263. typedef struct _REQ_SEEK {
  2264. UCHAR WordCount; // Count of parameter words = 4
  2265. _USHORT( Fid ); // File handle
  2266. _USHORT( Mode ); // Seek mode:
  2267. // 0 = from start of file
  2268. // 1 = from current position
  2269. // 2 = from end of file
  2270. _ULONG( Offset ); // Relative offset
  2271. _USHORT( ByteCount ); // Count of data bytes = 0
  2272. UCHAR Buffer[1]; // empty
  2273. } REQ_SEEK;
  2274. typedef REQ_SEEK SMB_UNALIGNED *PREQ_SEEK;
  2275. typedef struct _RESP_SEEK {
  2276. UCHAR WordCount; // Count of parameter words = 2
  2277. _ULONG( Offset ); // Offset from start of file
  2278. _USHORT( ByteCount ); // Count of data bytes = 0
  2279. UCHAR Buffer[1]; // empty
  2280. } RESP_SEEK;
  2281. typedef RESP_SEEK SMB_UNALIGNED *PRESP_SEEK;
  2282. #endif // def INCLUDE_SMB_READ_WRITE
  2283. #ifdef INCLUDE_SMB_MESSAGE
  2284. //
  2285. // Send Broadcast Message SMB, see #1 page 32
  2286. // Function is SrvSmbSendBroadcastMessage()
  2287. // SMB_COM_SEND_BROADCAST_MESSAGE 0xD1
  2288. //
  2289. typedef struct _REQ_SEND_BROADCAST_MESSAGE {
  2290. UCHAR WordCount; // Count of parameter words = 0
  2291. _USHORT( ByteCount ); // Count of data bytes; min = 8
  2292. UCHAR Buffer[1]; // Buffer containing:
  2293. //UCHAR BufferFormat1; // 0x04 -- ASCII
  2294. //UCHAR OriginatorName[]; // Originator name (max = 15)
  2295. //UCHAR BufferFormat2; // 0x04 -- ASCII
  2296. //UCHAR DestinationName[]; // "*"
  2297. //UCHAR BufferFormat3; // 0x01 -- Data block
  2298. //USHORT DataLength; // Length of message; max = 128
  2299. //UCHAR Data[]; // Message
  2300. } REQ_SEND_BROADCAST_MESSAGE;
  2301. typedef REQ_SEND_BROADCAST_MESSAGE SMB_UNALIGNED *PREQ_SEND_BROADCAST_MESSAGE;
  2302. // No response for Send Broadcast Message
  2303. #endif // def INCLUDE_SMB_MESSAGE
  2304. #ifdef INCLUDE_SMB_MESSAGE
  2305. //
  2306. // Send End of Multi-block Message SMB, see #1 page 33
  2307. // Function is SrvSmbSendEndMbMessage()
  2308. // SMB_COM_SEND_END_MB_MESSAGE 0xD6
  2309. //
  2310. typedef struct _REQ_SEND_END_MB_MESSAGE {
  2311. UCHAR WordCount; // Count of parameter words = 1
  2312. _USHORT( MessageGroupId );
  2313. _USHORT( ByteCount ); // Count of data bytes = 0
  2314. UCHAR Buffer[1]; // empty
  2315. } REQ_SEND_END_MB_MESSAGE;
  2316. typedef REQ_SEND_END_MB_MESSAGE SMB_UNALIGNED *PREQ_SEND_END_MB_MESSAGE;
  2317. typedef struct _RESP_SEND_END_MB_MESSAGE {
  2318. UCHAR WordCount; // Count of parameter words = 0
  2319. _USHORT( ByteCount ); // Count of data bytes = 0
  2320. UCHAR Buffer[1]; // empty
  2321. } RESP_SEND_END_MB_MESSAGE;
  2322. typedef RESP_SEND_END_MB_MESSAGE SMB_UNALIGNED *PRESP_SEND_END_MB_MESSAGE;
  2323. #endif // def INCLUDE_SMB_MESSAGE
  2324. #ifdef INCLUDE_SMB_MESSAGE
  2325. //
  2326. // Send Single Block Message SMB, see #1 page 31
  2327. // Function is SrvSmbSendMessage()
  2328. // SMB_COM_SEND_MESSAGE 0xD0
  2329. //
  2330. typedef struct _REQ_SEND_MESSAGE {
  2331. UCHAR WordCount; // Count of parameter words = 0
  2332. _USHORT( ByteCount ); // Count of data bytes; min = 7
  2333. UCHAR Buffer[1]; // Buffer containing:
  2334. //UCHAR BufferFormat1; // 0x04 -- ASCII
  2335. //UCHAR OriginatorName[]; // Originator name (max = 15)
  2336. //UCHAR BufferFormat2; // 0x04 -- ASCII
  2337. //UCHAR DestinationName[]; // Destination name (max = 15)
  2338. //UCHAR BufferFormat3; // 0x01 -- Data block
  2339. //USHORT DataLength; // Length of message; max = 128
  2340. //UCHAR Data[]; // Message
  2341. } REQ_SEND_MESSAGE;
  2342. typedef REQ_SEND_MESSAGE SMB_UNALIGNED *PREQ_SEND_MESSAGE;
  2343. typedef struct _RESP_SEND_MESSAGE {
  2344. UCHAR WordCount; // Count of parameter words = 0
  2345. _USHORT( ByteCount ); // Count of data bytes = 0
  2346. UCHAR Buffer[1]; // empty
  2347. } RESP_SEND_MESSAGE;
  2348. typedef RESP_SEND_MESSAGE SMB_UNALIGNED *PRESP_SEND_MESSAGE;
  2349. #endif // def INCLUDE_SMB_MESSAGE
  2350. #ifdef INCLUDE_SMB_MESSAGE
  2351. //
  2352. // Send Start of Multi-block Message SMB, see #1 page 32
  2353. // Function is SrvSmbSendStartMbMessage()
  2354. // SMB_COM_SEND_START_MB_MESSAGE 0xD5
  2355. //
  2356. typedef struct _REQ_SEND_START_MB_MESSAGE {
  2357. UCHAR WordCount; // Count of parameter words = 0
  2358. _USHORT( ByteCount ); // Count of data bytes; min = 0
  2359. UCHAR Buffer[1]; // Buffer containing:
  2360. //UCHAR BufferFormat1; // 0x04 -- ASCII
  2361. //UCHAR OriginatorName[]; // Originator name (max = 15)
  2362. //UCHAR BufferFormat2; // 0x04 -- ASCII
  2363. //UCHAR DestinationName[]; // Destination name (max = 15)
  2364. } REQ_SEND_START_MB_MESSAGE;
  2365. typedef REQ_SEND_START_MB_MESSAGE SMB_UNALIGNED *PREQ_SEND_START_MB_MESSAGE;
  2366. typedef struct _RESP_SEND_START_MB_MESSAGE {
  2367. UCHAR WordCount; // Count of parameter words = 1
  2368. _USHORT( MessageGroupId );
  2369. _USHORT( ByteCount ); // Count of data bytes = 0
  2370. UCHAR Buffer[1]; // empty
  2371. } RESP_SEND_START_MB_MESSAGE;
  2372. typedef RESP_SEND_START_MB_MESSAGE SMB_UNALIGNED *PSEND_START_MB_MESSAGE;
  2373. #endif // def INCLUDE_SMB_MESSAGE
  2374. #ifdef INCLUDE_SMB_MESSAGE
  2375. //
  2376. // Send Text of Multi-block Message SMB, see #1 page 33
  2377. // Function is SrvSmbSendTextMbMessage()
  2378. // SMB_COM_SEND_TEXT_MB_MESSAGE 0xD7
  2379. //
  2380. typedef struct _REQ_SEND_TEXT_MB_MESSAGE {
  2381. UCHAR WordCount; // Count of parameter words = 1
  2382. _USHORT( MessageGroupId );
  2383. _USHORT( ByteCount ); // Count of data bytes; min = 3
  2384. UCHAR Buffer[1]; // Buffer containing:
  2385. //UCHAR BufferFormat; // 0x01 -- Data block
  2386. //USHORT DataLength; // Length of message; max = 128
  2387. //UCHAR Data[]; // Message
  2388. } REQ_SEND_TEXT_MB_MESSAGE;
  2389. typedef REQ_SEND_TEXT_MB_MESSAGE SMB_UNALIGNED *PREQ_SEND_TEXT_MB_MESSAGE;
  2390. typedef struct _RESP_SEND_TEXT_MB_MESSAGE {
  2391. UCHAR WordCount; // Count of aprameter words = 0
  2392. _USHORT( ByteCount ); // Count of data bytes = 0
  2393. UCHAR Buffer[1]; // empty
  2394. } RESP_SEND_TEXT_MB_MESSAGE;
  2395. typedef RESP_SEND_TEXT_MB_MESSAGE SMB_UNALIGNED *PRESP_SEND_TEXT_MB_MESSAGE;
  2396. #endif // def INCLUDE_SMB_MESSAGE
  2397. #ifdef INCLUDE_SMB_ADMIN
  2398. //
  2399. // Session Setup and X SMB, see #2 page 63 and #3 page 10
  2400. // Function is SrvSmbSessionSetupAndX()
  2401. // SMB_COM_SESSION_SETUP_ANDX 0x73
  2402. //
  2403. typedef struct _REQ_SESSION_SETUP_ANDX {
  2404. UCHAR WordCount; // Count of parameter words = 10
  2405. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2406. UCHAR AndXReserved; // Reserved (must be 0)
  2407. _USHORT( AndXOffset ); // Offset to next command WordCount
  2408. _USHORT( MaxBufferSize ); // Consumer's maximum buffer size
  2409. _USHORT( MaxMpxCount ); // Actual maximum multiplexed pending requests
  2410. _USHORT( VcNumber ); // 0 = first (only), nonzero=additional VC number
  2411. _ULONG( SessionKey ); // Session key (valid iff VcNumber != 0)
  2412. _USHORT( PasswordLength ); // Account password size
  2413. _ULONG( Reserved );
  2414. _USHORT( ByteCount ); // Count of data bytes; min = 0
  2415. UCHAR Buffer[1]; // Buffer containing:
  2416. //UCHAR AccountPassword[]; // Account Password
  2417. //UCHAR AccountName[]; // Account Name
  2418. //UCHAR PrimaryDomain[]; // Client's primary domain
  2419. //UCHAR NativeOS[]; // Client's native operating system
  2420. //UCHAR NativeLanMan[]; // Client's native LAN Manager type
  2421. } REQ_SESSION_SETUP_ANDX;
  2422. typedef REQ_SESSION_SETUP_ANDX SMB_UNALIGNED *PREQ_SESSION_SETUP_ANDX;
  2423. typedef struct _REQ_NT_SESSION_SETUP_ANDX {
  2424. UCHAR WordCount; // Count of parameter words = 13
  2425. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2426. UCHAR AndXReserved; // Reserved (must be 0)
  2427. _USHORT( AndXOffset ); // Offset to next command WordCount
  2428. _USHORT( MaxBufferSize ); // Consumer's maximum buffer size
  2429. _USHORT( MaxMpxCount ); // Actual maximum multiplexed pending requests
  2430. _USHORT( VcNumber ); // 0 = first (only), nonzero=additional VC number
  2431. _ULONG( SessionKey ); // Session key (valid iff VcNumber != 0)
  2432. _USHORT( CaseInsensitivePasswordLength ); // Account password size, ANSI
  2433. _USHORT( CaseSensitivePasswordLength ); // Account password size, Unicode
  2434. _ULONG( Reserved);
  2435. _ULONG( Capabilities ); // Client capabilities
  2436. _USHORT( ByteCount ); // Count of data bytes; min = 0
  2437. UCHAR Buffer[1]; // Buffer containing:
  2438. //UCHAR CaseInsensitivePassword[]; // Account Password, ANSI
  2439. //UCHAR CaseSensitivePassword[]; // Account Password, Unicode
  2440. //UCHAR AccountName[]; // Account Name
  2441. //UCHAR PrimaryDomain[]; // Client's primary domain
  2442. //UCHAR NativeOS[]; // Client's native operating system
  2443. //UCHAR NativeLanMan[]; // Client's native LAN Manager type
  2444. } REQ_NT_SESSION_SETUP_ANDX;
  2445. typedef REQ_NT_SESSION_SETUP_ANDX SMB_UNALIGNED *PREQ_NT_SESSION_SETUP_ANDX;
  2446. //
  2447. // Action flags in the response
  2448. //
  2449. #define SMB_SETUP_GUEST 0x0001 // Session setup as a guest
  2450. #define SMB_SETUP_USE_LANMAN_KEY 0x0002 // Use the Lan Manager setup key.
  2451. typedef struct _RESP_SESSION_SETUP_ANDX {
  2452. UCHAR WordCount; // Count of parameter words = 3
  2453. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2454. UCHAR AndXReserved; // Reserved (must be 0)
  2455. _USHORT( AndXOffset ); // Offset to next command WordCount
  2456. _USHORT( Action ); // Request mode:
  2457. // bit0 = logged in as GUEST
  2458. _USHORT( ByteCount ); // Count of data bytes
  2459. UCHAR Buffer[1]; // Buffer containing:
  2460. //UCHAR NativeOS[]; // Server's native operating system
  2461. //UCHAR NativeLanMan[]; // Server's native LAN Manager type
  2462. //UCHAR PrimaryDomain[]; // Server's primary domain
  2463. } RESP_SESSION_SETUP_ANDX;
  2464. typedef RESP_SESSION_SETUP_ANDX SMB_UNALIGNED *PRESP_SESSION_SETUP_ANDX;
  2465. #endif // def INCLUDE_SMB_ADMIN
  2466. #ifdef INCLUDE_SMB_QUERY_SET
  2467. //
  2468. // Set Information SMB, see #1 page 19
  2469. // Function is SrvSmbSetInformation()
  2470. // SMB_COM_SET_INFORMATION 0x09
  2471. //
  2472. typedef struct _REQ_SET_INFORMATION {
  2473. UCHAR WordCount; // Count of parameter words = 8
  2474. _USHORT( FileAttributes );
  2475. _ULONG( LastWriteTimeInSeconds );
  2476. _USHORT( Reserved )[5]; // Reserved (must be 0)
  2477. _USHORT( ByteCount ); // Count of data bytes; min = 2
  2478. UCHAR Buffer[1]; // Buffer containing:
  2479. //UCHAR BufferFormat; // 0x04 -- ASCII
  2480. //UCHAR FileName[]; // File name
  2481. } REQ_SET_INFORMATION;
  2482. typedef REQ_SET_INFORMATION SMB_UNALIGNED *PREQ_SET_INFORMATION;
  2483. typedef struct _RESP_SET_INFORMATION {
  2484. UCHAR WordCount; // Count of parameter words = 0
  2485. _USHORT( ByteCount ); // Count of data bytes = 0
  2486. UCHAR Buffer[1]; // empty
  2487. } RESP_SET_INFORMATION;
  2488. typedef RESP_SET_INFORMATION SMB_UNALIGNED *PRESP_SET_INFORMATION;
  2489. #endif // def INCLUDE_SMB_QUERY_SET
  2490. #ifdef INCLUDE_SMB_QUERY_SET
  2491. //
  2492. // Set Information2 SMB, see #2 page 66
  2493. // Function is SrvSmbSetInformation2
  2494. // SMB_COM_SET_INFORMATION2 0x22
  2495. //
  2496. typedef struct _REQ_SET_INFORMATION2 {
  2497. UCHAR WordCount; // Count of parameter words = 7
  2498. _USHORT( Fid ); // File handle
  2499. SMB_DATE CreationDate;
  2500. SMB_TIME CreationTime;
  2501. SMB_DATE LastAccessDate;
  2502. SMB_TIME LastAccessTime;
  2503. SMB_DATE LastWriteDate;
  2504. SMB_TIME LastWriteTime;
  2505. _USHORT( ByteCount ); // Count of data bytes; min = 0
  2506. UCHAR Buffer[1]; // Reserved buffer
  2507. } REQ_SET_INFORMATION2;
  2508. typedef REQ_SET_INFORMATION2 SMB_UNALIGNED *PREQ_SET_INFORMATION2;
  2509. typedef struct _RESP_SET_INFORMATION2 {
  2510. UCHAR WordCount; // Count of parameter words = 0
  2511. _USHORT( ByteCount ); // Count of data bytes = 0
  2512. UCHAR Buffer[1]; // empty
  2513. } RESP_SET_INFORMATION2;
  2514. typedef RESP_SET_INFORMATION2 SMB_UNALIGNED *PRESP_SET_INFORMATION2;
  2515. #endif // def INCLUDE_SMB_QUERY_SET
  2516. #ifdef INCLUDE_SMB_TRANSACTION
  2517. //
  2518. // Transaction and Transaction2 SMBs, see #2 page 68 and #3 page 13
  2519. // Function is SrvSmbTransaction()
  2520. // SMB_COM_TRANSACTION 0x25
  2521. // SMB_COM_TRANSACTION_SECONDARY 0x26
  2522. // SMB_COM_TRANSACTION2 0x32
  2523. // SMB_COM_TRANSACTION2_SECONDARY 0x33
  2524. //
  2525. // Structures for specific transaction types are defined in smbtrans.h.
  2526. //
  2527. // *** The Transaction2 secondary request format includes a USHORT Fid
  2528. // field that we ignore. We can do this because the Fid field
  2529. // occurs at the end of the word parameters part of the request, and
  2530. // because the rest of the request (parameter and data bytes) is
  2531. // pointed by offset fields occurring prior to the Fid field. (The
  2532. // Fid field was added to speed up dispatching in the OS/2 server,
  2533. // in which different worker processes handle each Fid. The NT
  2534. // server has only one process.)
  2535. //
  2536. typedef struct _REQ_TRANSACTION {
  2537. UCHAR WordCount; // Count of parameter words; value = (14 + SetupCount)
  2538. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  2539. _USHORT( TotalDataCount ); // Total data bytes being sent
  2540. _USHORT( MaxParameterCount ); // Max parameter bytes to return
  2541. _USHORT( MaxDataCount ); // Max data bytes to return
  2542. UCHAR MaxSetupCount; // Max setup words to return
  2543. UCHAR Reserved;
  2544. _USHORT( Flags ); // Additional information:
  2545. // bit 0 - also disconnect TID in Tid
  2546. // bit 1 - one-way transacion (no resp)
  2547. _ULONG( Timeout );
  2548. _USHORT( Reserved2 );
  2549. _USHORT( ParameterCount ); // Parameter bytes sent this buffer
  2550. _USHORT( ParameterOffset ); // Offset (from header start) to params
  2551. _USHORT( DataCount ); // Data bytes sent this buffer
  2552. _USHORT( DataOffset ); // Offset (from header start) to data
  2553. UCHAR SetupCount; // Count of setup words
  2554. UCHAR Reserved3; // Reserved (pad above to word)
  2555. UCHAR Buffer[1]; // Buffer containing:
  2556. //USHORT Setup[]; // Setup words (# = SetupWordCount)
  2557. //USHORT ByteCount; // Count of data bytes
  2558. //UCHAR Name[]; // Name of transaction (NULL if Transact2)
  2559. //UCHAR Pad[]; // Pad to SHORT or LONG
  2560. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  2561. //UCHAR Pad1[]; // Pad to SHORT or LONG
  2562. //UCHAR Data[]; // Data bytes (# = DataCount)
  2563. } REQ_TRANSACTION;
  2564. typedef REQ_TRANSACTION SMB_UNALIGNED *PREQ_TRANSACTION;
  2565. #define SMB_TRANSACTION_DISCONNECT 1
  2566. #define SMB_TRANSACTION_NO_RESPONSE 2
  2567. #define SMB_TRANSACTION_RECONNECTING 4
  2568. #define SMB_TRANSACTION_DFSFILE 8
  2569. typedef struct _RESP_TRANSACTION_INTERIM {
  2570. UCHAR WordCount; // Count of parameter words = 0
  2571. _USHORT( ByteCount ); // Count of data bytes = 0
  2572. UCHAR Buffer[1]; // empty
  2573. } RESP_TRANSACTION_INTERIM;
  2574. typedef RESP_TRANSACTION_INTERIM SMB_UNALIGNED *PRESP_TRANSACTION_INTERIM;
  2575. typedef struct _REQ_TRANSACTION_SECONDARY {
  2576. UCHAR WordCount; // Count of parameter words = 8
  2577. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  2578. _USHORT( TotalDataCount ); // Total data bytes being sent
  2579. _USHORT( ParameterCount ); // Parameter bytes sent this buffer
  2580. _USHORT( ParameterOffset ); // Offset (from header start) to params
  2581. _USHORT( ParameterDisplacement ); // Displacement of these param bytes
  2582. _USHORT( DataCount ); // Data bytes sent this buffer
  2583. _USHORT( DataOffset ); // Offset (from header start) to data
  2584. _USHORT( DataDisplacement ); // Displacement of these data bytes
  2585. _USHORT( ByteCount ); // Count of data bytes
  2586. UCHAR Buffer[1]; // Buffer containing:
  2587. //UCHAR Pad[]; // Pad to SHORT or LONG
  2588. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  2589. //UCHAR Pad1[]; // Pad to SHORT or LONG
  2590. //UCHAR Data[]; // Data bytes (# = DataCount)
  2591. } REQ_TRANSACTION_SECONDARY;
  2592. typedef REQ_TRANSACTION_SECONDARY SMB_UNALIGNED *PREQ_TRANSACTION_SECONDARY;
  2593. typedef struct _RESP_TRANSACTION {
  2594. UCHAR WordCount; // Count of data bytes; value = 10 + SetupCount
  2595. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  2596. _USHORT( TotalDataCount ); // Total data bytes being sent
  2597. _USHORT( Reserved );
  2598. _USHORT( ParameterCount ); // Parameter bytes sent this buffer
  2599. _USHORT( ParameterOffset ); // Offset (from header start) to params
  2600. _USHORT( ParameterDisplacement ); // Displacement of these param bytes
  2601. _USHORT( DataCount ); // Data bytes sent this buffer
  2602. _USHORT( DataOffset ); // Offset (from header start) to data
  2603. _USHORT( DataDisplacement ); // Displacement of these data bytes
  2604. UCHAR SetupCount; // Count of setup words
  2605. UCHAR Reserved2; // Reserved (pad above to word)
  2606. UCHAR Buffer[1]; // Buffer containing:
  2607. //USHORT Setup[]; // Setup words (# = SetupWordCount)
  2608. //USHORT ByteCount; // Count of data bytes
  2609. //UCHAR Pad[]; // Pad to SHORT or LONG
  2610. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  2611. //UCHAR Pad1[]; // Pad to SHORT or LONG
  2612. //UCHAR Data[]; // Data bytes (# = DataCount)
  2613. } RESP_TRANSACTION;
  2614. typedef RESP_TRANSACTION SMB_UNALIGNED *PRESP_TRANSACTION;
  2615. typedef struct _REQ_NT_TRANSACTION {
  2616. UCHAR WordCount; // Count of parameter words; value = (19 + SetupCount)
  2617. UCHAR MaxSetupCount; // Max setup words to return
  2618. _USHORT( Flags ); // Currently unused
  2619. _ULONG( TotalParameterCount ); // Total parameter bytes being sent
  2620. _ULONG( TotalDataCount ); // Total data bytes being sent
  2621. _ULONG( MaxParameterCount ); // Max parameter bytes to return
  2622. _ULONG( MaxDataCount ); // Max data bytes to return
  2623. _ULONG( ParameterCount ); // Parameter bytes sent this buffer
  2624. _ULONG( ParameterOffset ); // Offset (from header start) to params
  2625. _ULONG( DataCount ); // Data bytes sent this buffer
  2626. _ULONG( DataOffset ); // Offset (from header start) to data
  2627. UCHAR SetupCount; // Count of setup words
  2628. _USHORT( Function ); // The transaction function code
  2629. UCHAR Buffer[1];
  2630. //USHORT Setup[]; // Setup words (# = SetupWordCount)
  2631. //USHORT ByteCount; // Count of data bytes
  2632. //UCHAR Pad1[]; // Pad to LONG
  2633. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  2634. //UCHAR Pad2[]; // Pad to LONG
  2635. //UCHAR Data[]; // Data bytes (# = DataCount)
  2636. } REQ_NT_TRANSACTION;
  2637. typedef REQ_NT_TRANSACTION SMB_UNALIGNED *PREQ_NT_TRANSACTION;
  2638. #define SMB_TRANSACTION_DISCONNECT 1
  2639. #define SMB_TRANSACTION_NO_RESPONSE 2
  2640. typedef struct _RESP_NT_TRANSACTION_INTERIM {
  2641. UCHAR WordCount; // Count of parameter words = 0
  2642. _USHORT( ByteCount ); // Count of data bytes = 0
  2643. UCHAR Buffer[1];
  2644. } RESP_NT_TRANSACTION_INTERIM;
  2645. typedef RESP_NT_TRANSACTION_INTERIM SMB_UNALIGNED *PRESP_NT_TRANSACTION_INTERIM;
  2646. typedef struct _REQ_NT_TRANSACTION_SECONDARY {
  2647. UCHAR WordCount; // Count of parameter words = 18
  2648. UCHAR Reserved1; // MBZ
  2649. _USHORT( Reserved2 ); // MBZ
  2650. _ULONG( TotalParameterCount ); // Total parameter bytes being sent
  2651. _ULONG( TotalDataCount ); // Total data bytes being sent
  2652. _ULONG( ParameterCount ); // Parameter bytes sent this buffer
  2653. _ULONG( ParameterOffset ); // Offset (from header start) to params
  2654. _ULONG( ParameterDisplacement ); // Displacement of these param bytes
  2655. _ULONG( DataCount ); // Data bytes sent this buffer
  2656. _ULONG( DataOffset ); // Offset (from header start) to data
  2657. _ULONG( DataDisplacement ); // Displacement of these data bytes
  2658. UCHAR Reserved3;
  2659. _USHORT( ByteCount ); // Count of data bytes
  2660. UCHAR Buffer[1];
  2661. //UCHAR Pad1[]; // Pad to LONG
  2662. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  2663. //UCHAR Pad2[]; // Pad to LONG
  2664. //UCHAR Data[]; // Data bytes (# = DataCount)
  2665. } REQ_NT_TRANSACTION_SECONDARY;
  2666. typedef REQ_NT_TRANSACTION_SECONDARY SMB_UNALIGNED *PREQ_NT_TRANSACTION_SECONDARY;
  2667. typedef struct _RESP_NT_TRANSACTION {
  2668. UCHAR WordCount; // Count of data bytes; value = 18 + SetupCount
  2669. UCHAR Reserved1;
  2670. _USHORT( Reserved2 );
  2671. _ULONG( TotalParameterCount ); // Total parameter bytes being sent
  2672. _ULONG( TotalDataCount ); // Total data bytes being sent
  2673. _ULONG( ParameterCount ); // Parameter bytes sent this buffer
  2674. _ULONG( ParameterOffset ); // Offset (from header start) to params
  2675. _ULONG( ParameterDisplacement ); // Displacement of these param bytes
  2676. _ULONG( DataCount ); // Data bytes sent this buffer
  2677. _ULONG( DataOffset ); // Offset (from header start) to data
  2678. _ULONG( DataDisplacement ); // Displacement of these data bytes
  2679. UCHAR SetupCount; // Count of setup words
  2680. UCHAR Buffer[1];
  2681. //USHORT Setup[]; // Setup words (# = SetupWordCount)
  2682. //USHORT ByteCount; // Count of data bytes
  2683. //UCHAR Pad1[]; // Pad to LONG
  2684. //UCHAR Parameters[]; // Parameter bytes (# = ParameterCount)
  2685. //UCHAR Pad2[]; // Pad to SHORT or LONG
  2686. //UCHAR Data[]; // Data bytes (# = DataCount)
  2687. } RESP_NT_TRANSACTION;
  2688. typedef RESP_NT_TRANSACTION SMB_UNALIGNED *PRESP_NT_TRANSACTION;
  2689. #endif // def INCLUDE_SMB_TRANSACTION
  2690. #ifdef INCLUDE_SMB_TREE
  2691. //
  2692. // Tree Connect SMB, see #1, page 6
  2693. // Function is SrvSmbTreeConnect()
  2694. // SMB_COM_TREE_CONNECT 0x70
  2695. //
  2696. typedef struct _REQ_TREE_CONNECT {
  2697. UCHAR WordCount; // Count of parameter words = 0
  2698. _USHORT( ByteCount ); // Count of data bytes; min = 4
  2699. UCHAR Buffer[1]; // Buffer containing:
  2700. //UCHAR BufferFormat1; // 0x04 -- ASCII
  2701. //UCHAR Path[]; // Server name and share name
  2702. //UCHAR BufferFormat2; // 0x04 -- ASCII
  2703. //UCHAR Password[]; // Password
  2704. //UCHAR BufferFormat3; // 0x04 -- ASCII
  2705. //UCHAR Service[]; // Service name
  2706. } REQ_TREE_CONNECT;
  2707. typedef REQ_TREE_CONNECT SMB_UNALIGNED *PREQ_TREE_CONNECT;
  2708. typedef struct _RESP_TREE_CONNECT {
  2709. UCHAR WordCount; // Count of parameter words = 2
  2710. _USHORT( MaxBufferSize ); // Max size message the server handles
  2711. _USHORT( Tid ); // Tree ID
  2712. _USHORT( ByteCount ); // Count of data bytes = 0
  2713. UCHAR Buffer[1]; // empty
  2714. } RESP_TREE_CONNECT;
  2715. typedef RESP_TREE_CONNECT SMB_UNALIGNED *PRESP_TREE_CONNECT;
  2716. #endif // def INCLUDE_SMB_TREE
  2717. #ifdef INCLUDE_SMB_TREE
  2718. //
  2719. // Tree Connect and X SMB, see #2, page 88
  2720. // Function is SrvSmbTreeConnectAndX()
  2721. // SMB_COM_TREE_CONNECT_ANDX 0x75
  2722. //
  2723. // TREE_CONNECT_ANDX flags
  2724. #define TREE_CONNECT_ANDX_DISCONNECT_TID (0x1)
  2725. // #define TREE_CONNECT_ANDX_W95 (0x2) -- W95 sets this flag. Don't know why.
  2726. typedef struct _REQ_TREE_CONNECT_ANDX {
  2727. UCHAR WordCount; // Count of parameter words = 4
  2728. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2729. UCHAR AndXReserved; // Reserved (must be 0)
  2730. _USHORT( AndXOffset ); // Offset to next command WordCount
  2731. _USHORT( Flags ); // Additional information
  2732. // bit 0 set = disconnect Tid
  2733. // bit 7 set = extended response
  2734. _USHORT( PasswordLength ); // Length of Password[]
  2735. _USHORT( ByteCount ); // Count of data bytes; min = 3
  2736. UCHAR Buffer[1]; // Buffer containing:
  2737. //UCHAR Password[]; // Password
  2738. //UCHAR Path[]; // Server name and share name
  2739. //UCHAR Service[]; // Service name
  2740. } REQ_TREE_CONNECT_ANDX;
  2741. typedef REQ_TREE_CONNECT_ANDX SMB_UNALIGNED *PREQ_TREE_CONNECT_ANDX;
  2742. typedef struct _RESP_TREE_CONNECT_ANDX {
  2743. UCHAR WordCount; // Count of parameter words = 2
  2744. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2745. UCHAR AndXReserved; // Reserved (must be 0)
  2746. _USHORT( AndXOffset ); // Offset to next command WordCount
  2747. _USHORT( ByteCount ); // Count of data bytes; min = 3
  2748. UCHAR Buffer[1]; // Service type connected to
  2749. } RESP_TREE_CONNECT_ANDX;
  2750. typedef RESP_TREE_CONNECT_ANDX SMB_UNALIGNED *PRESP_TREE_CONNECT_ANDX;
  2751. //
  2752. // The response for clients that are LAN Manager 2.1 or better.
  2753. //
  2754. typedef struct _RESP_21_TREE_CONNECT_ANDX {
  2755. UCHAR WordCount; // Count of parameter words = 3
  2756. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2757. UCHAR AndXReserved; // Reserved (must be 0)
  2758. _USHORT( AndXOffset ); // Offset to next command WordCount
  2759. _USHORT( OptionalSupport ); // Optional support bits
  2760. _USHORT( ByteCount ); // Count of data bytes; min = 3
  2761. UCHAR Buffer[1]; // Buffer containing:
  2762. //UCHAR Service[]; // Service type connected to
  2763. //UCHAR NativeFileSystem[]; // Native file system for this tree
  2764. } RESP_21_TREE_CONNECT_ANDX;
  2765. typedef RESP_21_TREE_CONNECT_ANDX SMB_UNALIGNED *PRESP_21_TREE_CONNECT_ANDX;
  2766. //
  2767. // Optional Support bit definitions
  2768. //
  2769. #define SMB_SUPPORT_SEARCH_BITS 0x0001
  2770. #define SMB_SHARE_IS_IN_DFS 0x0002
  2771. #endif // def INCLUDE_SMB_TREE
  2772. #ifdef INCLUDE_SMB_TREE
  2773. //
  2774. // Tree Disconnect SMB, see #1 page 7
  2775. // Function is SrvSmbTreeDisconnect()
  2776. // SMB_COM_TREE_DISCONNECT 0x71
  2777. //
  2778. typedef struct _REQ_TREE_DISCONNECT {
  2779. UCHAR WordCount; // Count of parameter words = 0
  2780. _USHORT( ByteCount ); // Count of data bytes = 0
  2781. UCHAR Buffer[1]; // empty
  2782. } REQ_TREE_DISCONNECT;
  2783. typedef REQ_TREE_DISCONNECT SMB_UNALIGNED *PREQ_TREE_DISCONNECT;
  2784. typedef struct _RESP_TREE_DISCONNECT {
  2785. UCHAR WordCount; // Count of parameter words = 0
  2786. _USHORT( ByteCount ); // Count of data bytes = 0
  2787. UCHAR Buffer[1]; // empty
  2788. } RESP_TREE_DISCONNECT;
  2789. typedef RESP_TREE_DISCONNECT SMB_UNALIGNED *PRESP_TREE_DISCONNECT;
  2790. #endif // def INCLUDE_SMB_TREE
  2791. #ifdef INCLUDE_SMB_LOCK
  2792. //
  2793. // Unlock Byte Range SMB, see #1 page 20
  2794. // Function is SrvSmbUnlockByteRange()
  2795. // SMB_COM_UNLOCK_BYTE_RANGE 0x0D
  2796. //
  2797. typedef struct _REQ_UNLOCK_BYTE_RANGE {
  2798. UCHAR WordCount; // Count of parameter words = 5
  2799. _USHORT( Fid ); // File handle
  2800. _ULONG( Count ); // Count of bytes to unlock
  2801. _ULONG( Offset ); // Offset from start of file
  2802. _USHORT( ByteCount ); // Count of data bytes = 0
  2803. UCHAR Buffer[1]; // empty
  2804. } REQ_UNLOCK_BYTE_RANGE;
  2805. typedef REQ_UNLOCK_BYTE_RANGE SMB_UNALIGNED *PREQ_UNLOCK_BYTE_RANGE;
  2806. typedef struct _RESP_UNLOCK_BYTE_RANGE {
  2807. UCHAR WordCount; // Count of parameter words = 0
  2808. _USHORT( ByteCount ); // Count of data bytes = 0
  2809. UCHAR Buffer[1]; // empty
  2810. } RESP_UNLOCK_BYTE_RANGE;
  2811. typedef RESP_UNLOCK_BYTE_RANGE SMB_UNALIGNED *PRESP_UNLOCK_BYTE_RANGE;
  2812. #endif // def INCLUDE_SMB_LOCK
  2813. #ifdef INCLUDE_SMB_READ_WRITE
  2814. //
  2815. // Write SMB, see #1 page 12
  2816. // Write and Unlock SMB, see #2 page 92
  2817. // Function is SrvSmbWrite()
  2818. // SMB_COM_WRITE 0x0B
  2819. // SMB_COM_WRITE_AND_UNLOCK 0x14
  2820. //
  2821. //
  2822. // *** Warning: the following structure is defined the way it is to
  2823. // ensure longword alignment of the data buffer. (This only matters
  2824. // when packing is disabled; when packing is turned on, the right
  2825. // thing happens no matter what.)
  2826. //
  2827. typedef struct _REQ_WRITE {
  2828. UCHAR WordCount; // Count of parameter words = 5
  2829. _USHORT( Fid ); // File handle
  2830. _USHORT( Count ); // Number of bytes to be written
  2831. _ULONG( Offset ); // Offset in file to begin write
  2832. _USHORT( Remaining ); // Bytes remaining to satisfy request
  2833. _USHORT( ByteCount ); // Count of data bytes
  2834. //UCHAR Buffer[1]; // Buffer containing:
  2835. UCHAR BufferFormat; // 0x01 -- Data block
  2836. _USHORT( DataLength ); // Length of data
  2837. ULONG Buffer[1]; // Data
  2838. } REQ_WRITE;
  2839. typedef REQ_WRITE SMB_UNALIGNED *PREQ_WRITE;
  2840. typedef struct _RESP_WRITE {
  2841. UCHAR WordCount; // Count of parameter words = 1
  2842. _USHORT( Count ); // Count of bytes actually written
  2843. _USHORT( ByteCount ); // Count of data bytes = 0
  2844. UCHAR Buffer[1]; // empty
  2845. } RESP_WRITE;
  2846. typedef RESP_WRITE SMB_UNALIGNED *PRESP_WRITE;
  2847. #endif // def INCLUDE_SMB_READ_WRITE
  2848. #ifdef INCLUDE_SMB_READ_WRITE
  2849. //
  2850. // Write and Close SMB, see #2 page 90
  2851. // Function is SrvSmbWriteAndClose()
  2852. // SMB_COM_WRITE_AND_CLOSE 0x2C
  2853. //
  2854. //
  2855. // The Write and Close parameters can be 6 words long or 12 words long,
  2856. // depending on whether it's supposed to look like a Write SMB or a
  2857. // Write and X SMB. So we define two different structures here.
  2858. //
  2859. // *** Warning: the following structures are defined the way they are to
  2860. // ensure longword alignment of the data buffer. (This only matters
  2861. // when packing is disabled; when packing is turned on, the right
  2862. // thing happens no matter what.)
  2863. //
  2864. typedef struct _REQ_WRITE_AND_CLOSE {
  2865. UCHAR WordCount; // Count of parameter words = 6
  2866. _USHORT( Fid ); // File handle
  2867. _USHORT( Count ); // Number of bytes to write
  2868. _ULONG( Offset ); // Offset in file of first byte to write
  2869. _ULONG( LastWriteTimeInSeconds ); // Time of last write
  2870. _USHORT( ByteCount ); // 1 (for pad) + value of Count
  2871. UCHAR Pad; // To force to doubleword boundary
  2872. ULONG Buffer[1]; // Data
  2873. } REQ_WRITE_AND_CLOSE;
  2874. typedef REQ_WRITE_AND_CLOSE SMB_UNALIGNED *PREQ_WRITE_AND_CLOSE;
  2875. typedef struct _REQ_WRITE_AND_CLOSE_LONG {
  2876. UCHAR WordCount; // Count of parameter words = 12
  2877. _USHORT( Fid ); // File handle
  2878. _USHORT( Count ); // Number of bytes to write
  2879. _ULONG( Offset ); // Offset in file of first byte to write
  2880. _ULONG( LastWriteTimeInSeconds ); // Time of last write
  2881. _ULONG( Reserved )[3]; // Reserved, must be 0
  2882. _USHORT( ByteCount ); // 1 (for pad) + value of Count
  2883. UCHAR Pad; // To force to doubleword boundary
  2884. ULONG Buffer[1]; // Data
  2885. } REQ_WRITE_AND_CLOSE_LONG;
  2886. typedef REQ_WRITE_AND_CLOSE_LONG SMB_UNALIGNED *PREQ_WRITE_AND_CLOSE_LONG;
  2887. typedef struct _RESP_WRITE_AND_CLOSE {
  2888. UCHAR WordCount; // Count of parameter words = 1
  2889. _USHORT( Count ); // Count of bytes actually written
  2890. _USHORT( ByteCount ); // Count of data bytes = 0
  2891. UCHAR Buffer[1]; // empty
  2892. } RESP_WRITE_AND_CLOSE;
  2893. typedef RESP_WRITE_AND_CLOSE SMB_UNALIGNED *PRESP_WRITE_AND_CLOSE;
  2894. #endif // def INCLUDE_SMB_READ_WRITE
  2895. #ifdef INCLUDE_SMB_READ_WRITE
  2896. //
  2897. // Write and X SMB, see #2 page 94
  2898. // Function is SrvSmbWriteAndX()
  2899. // SMB_COM_WRITE_ANDX 0x2F
  2900. //
  2901. typedef struct _REQ_WRITE_ANDX {
  2902. UCHAR WordCount; // Count of parameter words = 12
  2903. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2904. UCHAR AndXReserved; // Reserved (must be 0)
  2905. _USHORT( AndXOffset ); // Offset to next command WordCount
  2906. _USHORT( Fid ); // File handle
  2907. _ULONG( Offset ); // Offset in file to begin write
  2908. _ULONG( Timeout );
  2909. _USHORT( WriteMode ); // Write mode:
  2910. // 0 - write through
  2911. // 1 - return Remaining
  2912. // 2 - use WriteRawNamedPipe (n. pipes)
  2913. // 3 - "this is the start of the msg"
  2914. _USHORT( Remaining ); // Bytes remaining to satisfy request
  2915. _USHORT( Reserved );
  2916. _USHORT( DataLength ); // Number of data bytes in buffer (>=0)
  2917. _USHORT( DataOffset ); // Offset to data bytes
  2918. _USHORT( ByteCount ); // Count of data bytes
  2919. UCHAR Buffer[1]; // Buffer containing:
  2920. //UCHAR Pad[]; // Pad to SHORT or LONG
  2921. //UCHAR Data[]; // Data (# = DataLength)
  2922. } REQ_WRITE_ANDX;
  2923. typedef REQ_WRITE_ANDX SMB_UNALIGNED *PREQ_WRITE_ANDX;
  2924. typedef struct _REQ_NT_WRITE_ANDX {
  2925. UCHAR WordCount; // Count of parameter words = 14
  2926. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2927. UCHAR AndXReserved; // Reserved (must be 0)
  2928. _USHORT( AndXOffset ); // Offset to next command WordCount
  2929. _USHORT( Fid ); // File handle
  2930. _ULONG( Offset ); // Offset in file to begin write
  2931. _ULONG( Timeout );
  2932. _USHORT( WriteMode ); // Write mode:
  2933. // 0 - write through
  2934. // 1 - return Remaining
  2935. // 2 - use WriteRawNamedPipe (n. pipes)
  2936. // 3 - "this is the start of the msg"
  2937. _USHORT( Remaining ); // Bytes remaining to satisfy request
  2938. _USHORT( DataLengthHigh );
  2939. _USHORT( DataLength ); // Number of data bytes in buffer (>=0)
  2940. _USHORT( DataOffset ); // Offset to data bytes
  2941. _ULONG( OffsetHigh ); // Used for NT Protocol only
  2942. // Upper 32 bits of offset
  2943. _USHORT( ByteCount ); // Count of data bytes
  2944. UCHAR Buffer[1]; // Buffer containing:
  2945. //UCHAR Pad[]; // Pad to SHORT or LONG
  2946. //UCHAR Data[]; // Data (# = DataLength)
  2947. } REQ_NT_WRITE_ANDX;
  2948. typedef REQ_NT_WRITE_ANDX SMB_UNALIGNED *PREQ_NT_WRITE_ANDX;
  2949. typedef struct _RESP_WRITE_ANDX {
  2950. UCHAR WordCount; // Count of parameter words = 6
  2951. UCHAR AndXCommand; // Secondary (X) command; 0xFF = none
  2952. UCHAR AndXReserved; // Reserved (must be 0)
  2953. _USHORT( AndXOffset ); // Offset to next command WordCount
  2954. _USHORT( Count ); // Number of bytes written
  2955. _USHORT( Remaining ); // Bytes remaining to be read (pipe/dev)
  2956. union {
  2957. _ULONG( Reserved );
  2958. _USHORT( CountHigh ); // if large write&x
  2959. };
  2960. _USHORT( ByteCount ); // Count of data bytes. Inaccurate if
  2961. // large writes
  2962. UCHAR Buffer[1]; // empty
  2963. } RESP_WRITE_ANDX;
  2964. typedef RESP_WRITE_ANDX SMB_UNALIGNED *PRESP_WRITE_ANDX;
  2965. #endif // def INCLUDE_SMB_READ_WRITE
  2966. #ifdef INCLUDE_SMB_MPX
  2967. //
  2968. // Write Block Multiplexed SMB, see #2 page 97
  2969. // Function is SrvSmbWriteMpx()
  2970. // SMB_COM_WRITE_MPX 0x1E
  2971. // SMB_COM_WRITE_MPX_SECONDARY 0x1F
  2972. // SMB_COM_WRITE_MPX_COMPLETE 0x20
  2973. //
  2974. typedef struct _REQ_WRITE_MPX {
  2975. UCHAR WordCount; // Count of parameter words = 12
  2976. _USHORT( Fid ); // File handle
  2977. _USHORT( Count ); // Total bytes, including this buffer
  2978. _USHORT( Reserved );
  2979. _ULONG( Offset ); // Offset in file to begin write
  2980. _ULONG( Timeout );
  2981. _USHORT( WriteMode ); // Write mode:
  2982. // bit 0 - complete write to disk and
  2983. // send final result response
  2984. // bit 1 - return Remaining (pipe/dev)
  2985. // bit 7 - IPX datagram mode
  2986. union {
  2987. struct {
  2988. _USHORT( DataCompactionMode );
  2989. _USHORT( Reserved2 );
  2990. } ;
  2991. _ULONG( Mask ); // IPX datagram mode mask
  2992. } ;
  2993. _USHORT( DataLength ); // Number of data bytes this buffer
  2994. _USHORT( DataOffset ); // Offset (from header start) to data
  2995. _USHORT( ByteCount ); // Count of data bytes
  2996. UCHAR Buffer[1]; // Buffer containing:
  2997. //UCHAR Pad[]; // Pad to SHORT or LONG
  2998. //UCHAR Data[]; // Data (# = DataLength)
  2999. } REQ_WRITE_MPX;
  3000. typedef REQ_WRITE_MPX SMB_UNALIGNED *PREQ_WRITE_MPX;
  3001. typedef struct _RESP_WRITE_MPX_INTERIM { // First response
  3002. UCHAR WordCount; // Count of parameter words = 1
  3003. _USHORT( Remaining ); // Bytes ramaining to be read (pipe/dev)
  3004. _USHORT( ByteCount ); // Count of data bytes = 0
  3005. UCHAR Buffer[1]; // empty
  3006. } RESP_WRITE_MPX_INTERIM;
  3007. typedef RESP_WRITE_MPX_INTERIM SMB_UNALIGNED *PRESP_WRITE_MPX_INTERIM;
  3008. typedef struct _RESP_WRITE_MPX_DATAGRAM { // Response to sequenced request
  3009. UCHAR WordCount; // Count of parameter words = 2
  3010. _ULONG( Mask ); // OR of all masks received
  3011. _USHORT( ByteCount ); // Count of data bytes = 0
  3012. UCHAR Buffer[1]; // empty
  3013. } RESP_WRITE_MPX_DATAGRAM;
  3014. typedef RESP_WRITE_MPX_DATAGRAM SMB_UNALIGNED *PRESP_WRITE_MPX_DATAGRAM;
  3015. // Secondary request format, 0 to N of these.
  3016. typedef struct _REQ_WRITE_MPX_SECONDARY {
  3017. UCHAR WordCount; // Count of parameter words = 8
  3018. _USHORT( Fid ); // File handle
  3019. _USHORT( Count ); // Total bytes to be sent
  3020. _ULONG( Offset ); // Offset in file to begin write
  3021. _ULONG( Reserved );
  3022. _USHORT( DataLength ); // Number of data bytes this buffer
  3023. _USHORT( DataOffset ); // Offset (from header start) to data
  3024. _USHORT( ByteCount ); // Count of data bytes
  3025. UCHAR Buffer[1]; // Buffer containing:
  3026. //UCHAR Pad[]; // Pad to SHORT or LONG
  3027. //UCHAR Data[]; // Data (# = DataLength)
  3028. } REQ_WRITE_MPX_SECONDARY;
  3029. typedef REQ_WRITE_MPX_SECONDARY SMB_UNALIGNED *PREQ_WRITE_MPX_SECONDARY;
  3030. #endif // def INCLUDE_SMB_MPX
  3031. #ifndef INCLUDE_SMB_WRITE_COMPLETE
  3032. #ifdef INCLUDE_SMB_MPX
  3033. #define INCLUDE_SMB_WRITE_COMPLETE
  3034. #else
  3035. #ifdef INCLUDE_SMB_RAW
  3036. #define INCLUDE_SMB_WRITE_COMPLETE
  3037. #endif
  3038. #endif
  3039. #endif
  3040. #ifdef INCLUDE_SMB_WRITE_COMPLETE
  3041. //
  3042. // The following structure is used as the final response to both Write
  3043. // Block Multiplexed and Write Block Raw.
  3044. //
  3045. typedef struct _RESP_WRITE_COMPLETE { // Final response; command is
  3046. // SMB_COM_WRITE_COMPLETE
  3047. UCHAR WordCount; // Count of parameter words = 1
  3048. _USHORT( Count ); // Total number of bytes written
  3049. _USHORT( ByteCount ); // Count of data bytes = 0
  3050. UCHAR Buffer[1]; // empty
  3051. } RESP_WRITE_COMPLETE;
  3052. typedef RESP_WRITE_COMPLETE SMB_UNALIGNED *PRESP_WRITE_COMPLETE;
  3053. #endif // def INCLUDE_SMB_WRITE_COMPLETE
  3054. #ifdef INCLUDE_SMB_READ_WRITE
  3055. //
  3056. // Write Print File SMB, see #1 page 29
  3057. // Function is SrvSmbWritePrintFile()
  3058. // SMB_COM_WRITE_PRINT_FILE 0xC1
  3059. //
  3060. typedef struct _REQ_WRITE_PRINT_FILE {
  3061. UCHAR WordCount; // Count of parameter words = 1
  3062. _USHORT( Fid ); // File handle
  3063. _USHORT( ByteCount ); // Count of data bytes; min = 4
  3064. UCHAR Buffer[1]; // Buffer containing:
  3065. //UCHAR BufferFormat; // 0x01 -- Data block
  3066. //USHORT DataLength; // Length of data
  3067. //UCHAR Data[]; // Data
  3068. } REQ_WRITE_PRINT_FILE;
  3069. typedef REQ_WRITE_PRINT_FILE SMB_UNALIGNED *PREQ_WRITE_PRINT_FILE;
  3070. typedef struct _RESP_WRITE_PRINT_FILE {
  3071. UCHAR WordCount; // Count of parameter words = 0
  3072. _USHORT( ByteCount ); // Count of data bytes = 0
  3073. UCHAR Buffer[1]; // empty
  3074. } RESP_WRITE_PRINT_FILE;
  3075. typedef RESP_WRITE_PRINT_FILE SMB_UNALIGNED *PRESP_WRITE_PRINT_FILE;
  3076. #endif // def INCLUDE_SMB_READ_WRITE
  3077. #ifdef INCLUDE_SMB_RAW
  3078. //
  3079. // Write Block Raw SMB, see #2 page 100
  3080. // Function is SrvSmbWriteRaw()
  3081. // SMB_COM_WRITE_RAW 0x1D
  3082. //
  3083. typedef struct _REQ_WRITE_RAW {
  3084. UCHAR WordCount; // Count of parameter words = 12
  3085. _USHORT( Fid ); // File handle
  3086. _USHORT( Count ); // Total bytes, including this buffer
  3087. _USHORT( Reserved );
  3088. _ULONG( Offset ); // Offset in file to begin write
  3089. _ULONG( Timeout );
  3090. _USHORT( WriteMode ); // Write mode:
  3091. // bit 0 - complete write to disk and
  3092. // send final result response
  3093. // bit 1 - return Remaining (pipe/dev)
  3094. // (see WriteAndX for #defines)
  3095. _ULONG( Reserved2 );
  3096. _USHORT( DataLength ); // Number of data bytes this buffer
  3097. _USHORT( DataOffset ); // Offset (from header start) to data
  3098. _USHORT( ByteCount ); // Count of data bytes
  3099. UCHAR Buffer[1]; // Buffer containing:
  3100. //UCHAR Pad[]; // Pad to SHORT or LONG
  3101. //UCHAR Data[]; // Data (# = DataLength)
  3102. } REQ_WRITE_RAW;
  3103. typedef REQ_WRITE_RAW SMB_UNALIGNED *PREQ_WRITE_RAW;
  3104. typedef struct _REQ_NT_WRITE_RAW {
  3105. UCHAR WordCount; // Count of parameter words = 14
  3106. _USHORT( Fid ); // File handle
  3107. _USHORT( Count ); // Total bytes, including this buffer
  3108. _USHORT( Reserved );
  3109. _ULONG( Offset ); // Offset in file to begin write
  3110. _ULONG( Timeout );
  3111. _USHORT( WriteMode ); // Write mode:
  3112. // bit 0 - complete write to disk and
  3113. // send final result response
  3114. // bit 1 - return Remaining (pipe/dev)
  3115. // (see WriteAndX for #defines)
  3116. _ULONG( Reserved2 );
  3117. _USHORT( DataLength ); // Number of data bytes this buffer
  3118. _USHORT( DataOffset ); // Offset (from header start) to data
  3119. _ULONG( OffsetHigh ); // Used for NT Protocol only
  3120. // Upper 32 bits of offset
  3121. _USHORT( ByteCount ); // Count of data bytes
  3122. UCHAR Buffer[1]; // Buffer containing:
  3123. //UCHAR Pad[]; // Pad to SHORT or LONG
  3124. //UCHAR Data[]; // Data (# = DataLength)
  3125. } REQ_NT_WRITE_RAW;
  3126. typedef REQ_NT_WRITE_RAW SMB_UNALIGNED *PREQ_NT_WRITE_RAW;
  3127. typedef struct _RESP_WRITE_RAW_INTERIM { // First response
  3128. UCHAR WordCount; // Count of parameter words = 1
  3129. _USHORT( Remaining ); // Bytes remaining to be read (pipe/dev)
  3130. _USHORT( ByteCount ); // Count of data bytes = 0
  3131. UCHAR Buffer[1]; // empty
  3132. } RESP_WRITE_RAW_INTERIM;
  3133. typedef RESP_WRITE_RAW_INTERIM SMB_UNALIGNED *PRESP_WRITE_RAW_INTERIM;
  3134. typedef struct _RESP_WRITE_RAW_SECONDARY { // Second (final) response
  3135. UCHAR WordCount; // Count of parameter words = 1
  3136. _USHORT( Count ); // Total number of bytes written
  3137. _USHORT( ByteCount ); // Count of data bytes = 0
  3138. UCHAR Buffer[1]; // empty
  3139. } RESP_WRITE_RAW_SECONDARY;
  3140. typedef RESP_WRITE_RAW_SECONDARY SMB_UNALIGNED *PRESP_WRITE_RAW_SECONDARY;
  3141. typedef struct _REQ_103_WRITE_RAW {
  3142. UCHAR WordCount; // Count of parameter words
  3143. _USHORT( Fid ); // File handle
  3144. _USHORT( Count );
  3145. _USHORT( Reserved );
  3146. _ULONG( Offset );
  3147. _ULONG( Timeout );
  3148. _USHORT( WriteMode );
  3149. _ULONG( Reserved2 );
  3150. _USHORT( ByteCount ); // Count of data bytes; min =
  3151. UCHAR Buffer[1]; //
  3152. } REQ_103_WRITE_RAW;
  3153. typedef REQ_103_WRITE_RAW SMB_UNALIGNED *PREQ_103_WRITE_RAW;
  3154. typedef struct _RESP_103_WRITE_RAW {
  3155. UCHAR WordCount; // Count of parameter words
  3156. _USHORT( ByteCount ); // Count of data bytes; min =
  3157. UCHAR Buffer[1]; //
  3158. } RESP_103_WRITE_RAW;
  3159. typedef RESP_103_WRITE_RAW SMB_UNALIGNED *PRESP_103_WRITE_RAW;
  3160. #endif // def INCLUDE_SMB_RAW
  3161. typedef struct _REQ_NT_CANCEL {
  3162. UCHAR WordCount; // = 0
  3163. _USHORT( ByteCount ); // = 0
  3164. UCHAR Buffer[1];
  3165. } REQ_NT_CANCEL;
  3166. typedef REQ_NT_CANCEL SMB_UNALIGNED *PREQ_NT_CANCEL;
  3167. typedef struct _RESP_NT_CANCEL {
  3168. UCHAR WordCount; // = 0
  3169. _USHORT( ByteCount ); // = 0
  3170. UCHAR Buffer[1];
  3171. } RESP_NT_CANCEL;
  3172. typedef RESP_NT_CANCEL SMB_UNALIGNED *PRESP_NT_CANCEL;
  3173. //
  3174. // File open modes
  3175. //
  3176. #define SMB_ACCESS_READ_ONLY 0
  3177. #define SMB_ACCESS_WRITE_ONLY 1
  3178. #define SMB_ACCESS_READ_WRITE 2
  3179. #define SMB_ACCESS_EXECUTE 3
  3180. //
  3181. // Open flags
  3182. //
  3183. #define SMB_OPEN_QUERY_INFORMATION 0x01
  3184. #define SMB_OPEN_OPLOCK 0x02
  3185. #define SMB_OPEN_OPBATCH 0x04
  3186. #define SMB_OPEN_QUERY_EA_LENGTH 0x08
  3187. #define SMB_OPEN_EXTENDED_RESPONSE 0x10
  3188. //
  3189. // NT open manifests
  3190. //
  3191. #define NT_CREATE_REQUEST_OPLOCK 0x02
  3192. #define NT_CREATE_REQUEST_OPBATCH 0x04
  3193. #define NT_CREATE_OPEN_TARGET_DIR 0x08
  3194. #define Added 0
  3195. #define Removed 1
  3196. #define Modified 2
  3197. #define RenamedOldName 3
  3198. #define RenamedNewName 4
  3199. //
  3200. // Lockrange for use with OS/2 DosFileLocks call
  3201. //
  3202. // *** Where is this used?
  3203. //typedef struct lockrange {
  3204. // ULONG offset;
  3205. // ULONG range;
  3206. // };
  3207. //#define LOCK 0x1
  3208. //#define UNLOCK 0x2
  3209. //
  3210. // Data buffer format codes, from the core protocol.
  3211. //
  3212. #define SMB_FORMAT_DATA 1
  3213. #define SMB_FORMAT_DIALECT 2
  3214. #define SMB_FORMAT_PATHNAME 3
  3215. #define SMB_FORMAT_ASCII 4
  3216. #define SMB_FORMAT_VARIABLE 5
  3217. //
  3218. // WriteMode flags
  3219. //
  3220. #define SMB_WMODE_WRITE_THROUGH 0x0001 // complete write before responding
  3221. #define SMB_WMODE_SET_REMAINING 0x0002 // returning amt remaining in pipe
  3222. #define SMB_WMODE_WRITE_RAW_NAMED_PIPE 0x0004 // write named pipe in raw mode
  3223. #define SMB_WMODE_START_OF_MESSAGE 0x0008 // start of pipe message
  3224. #define SMB_WMODE_DATAGRAM 0x0080 // start of pipe message
  3225. //
  3226. // Various SMB flags:
  3227. //
  3228. //
  3229. // If the server supports LockAndRead and WriteAndUnlock, it sets this
  3230. // bit the Negotiate response.
  3231. //
  3232. #define SMB_FLAGS_LOCK_AND_READ_OK 0x01
  3233. //
  3234. // When on, the consumer guarantees that there is a receive buffer posted
  3235. // such that a "Send.No.Ack" can be used by the server to respond to
  3236. // the consumer's request.
  3237. //
  3238. #define SMB_FLAGS_SEND_NO_ACK 0x2
  3239. //
  3240. // This is part of the Flags field of every SMB header. If this bit
  3241. // is set, then all pathnames in the SMB should be treated as case-
  3242. // insensitive.
  3243. //
  3244. #define SMB_FLAGS_CASE_INSENSITIVE 0x8
  3245. //
  3246. // When on in session setup, this bit indicates that all paths sent to
  3247. // the server are already in OS/2 canonicalized format.
  3248. //
  3249. #define SMB_FLAGS_CANONICALIZED_PATHS 0x10
  3250. //
  3251. // When on in a open file request SMBs (open, create, openX, etc.) this
  3252. // bit indicates a request for an oplock on the file. When on in the
  3253. // response, this bit indicates that the oplock was granted.
  3254. //
  3255. #define SMB_FLAGS_OPLOCK 0x20
  3256. //
  3257. // When on, this bit indicates that the server should notify the client
  3258. // on any request that could cause the file to be changed. If not set,
  3259. // the server only notifies the client on other open requests on the
  3260. // file.
  3261. //
  3262. #define SMB_FLAGS_OPLOCK_NOTIFY_ANY 0x40
  3263. //
  3264. // This bit indicates that the SMB is being sent from server to redir.
  3265. //
  3266. #define SMB_FLAGS_SERVER_TO_REDIR 0x80
  3267. //
  3268. // Valid bits for Flags on an incoming SMB
  3269. //
  3270. #define INCOMING_SMB_FLAGS \
  3271. (SMB_FLAGS_LOCK_AND_READ_OK | \
  3272. SMB_FLAGS_SEND_NO_ACK | \
  3273. SMB_FLAGS_CASE_INSENSITIVE | \
  3274. SMB_FLAGS_CANONICALIZED_PATHS | \
  3275. SMB_FLAGS_OPLOCK_NOTIFY_ANY | \
  3276. SMB_FLAGS_OPLOCK)
  3277. //
  3278. // Names for bits in Flags2 field of SMB header that indicate what the
  3279. // client app is aware of.
  3280. //
  3281. #define SMB_FLAGS2_KNOWS_LONG_NAMES 0x0001
  3282. #define SMB_FLAGS2_KNOWS_EAS 0x0002
  3283. #define SMB_FLAGS2_SMB_SECURITY_SIGNATURE 0x0004
  3284. #define SMB_FLAGS2_IS_LONG_NAME 0x0040
  3285. #define SMB_FLAGS2_DFS 0x1000
  3286. #define SMB_FLAGS2_PAGING_IO 0x2000
  3287. #define SMB_FLAGS2_NT_STATUS 0x4000
  3288. #define SMB_FLAGS2_UNICODE 0x8000
  3289. //
  3290. // Valid bits for Flags2 on an incoming SMB
  3291. //
  3292. #define INCOMING_SMB_FLAGS2 \
  3293. (SMB_FLAGS2_KNOWS_LONG_NAMES | \
  3294. SMB_FLAGS2_KNOWS_EAS | \
  3295. SMB_FLAGS2_DFS | \
  3296. SMB_FLAGS2_PAGING_IO | \
  3297. SMB_FLAGS2_IS_LONG_NAME | \
  3298. SMB_FLAGS2_NT_STATUS | \
  3299. SMB_FLAGS2_UNICODE )
  3300. //
  3301. // The SMB open function determines what action should be taken depending
  3302. // on the existence or lack thereof of files used in the operation. It
  3303. // has the following mapping:
  3304. //
  3305. // 1111 1
  3306. // 5432 1098 7654 3210
  3307. // rrrr rrrr rrrC rrOO
  3308. //
  3309. // where:
  3310. //
  3311. // O - Open (action to be taken if the target file exists)
  3312. // 0 - Fail
  3313. // 1 - Open or Append file
  3314. // 2 - Truncate file
  3315. //
  3316. // C - Create (action to be taken if the target file does not exist)
  3317. // 0 - Fail
  3318. // 1 - Create file
  3319. //
  3320. #define SMB_OFUN_OPEN_MASK 0x3
  3321. #define SMB_OFUN_CREATE_MASK 0x10
  3322. #define SMB_OFUN_OPEN_FAIL 0
  3323. #define SMB_OFUN_OPEN_APPEND 1
  3324. #define SMB_OFUN_OPEN_OPEN 1
  3325. #define SMB_OFUN_OPEN_TRUNCATE 2
  3326. #define SMB_OFUN_CREATE_FAIL 0x00
  3327. #define SMB_OFUN_CREATE_CREATE 0x10
  3328. //++
  3329. //
  3330. // BOOLEAN
  3331. // SmbOfunCreate(
  3332. // IN USHORT SmbOpenFunction
  3333. // )
  3334. //
  3335. //--
  3336. #define SmbOfunCreate(SmbOpenFunction) \
  3337. (BOOLEAN)((SmbOpenFunction & SMB_OFUN_CREATE_MASK) == SMB_OFUN_CREATE_CREATE)
  3338. //++
  3339. //
  3340. // BOOLEAN
  3341. // SmbOfunAppend(
  3342. // IN USHORT SmbOpenFunction
  3343. // )
  3344. //
  3345. //--
  3346. #define SmbOfunAppend(SmbOpenFunction) \
  3347. (BOOLEAN)((SmbOpenFunction & SMB_OFUN_OPEN_MASK) == SMB_OFUN_OPEN_APPEND)
  3348. //++
  3349. //
  3350. // BOOLEAN
  3351. // SmbOfunTruncate(
  3352. // IN USHORT SmbOpenFunction
  3353. // )
  3354. //
  3355. //--
  3356. #define SmbOfunTruncate(SmbOpenFunction) \
  3357. (BOOLEAN)((SmbOpenFunction & SMB_OFUN_OPEN_MASK) == SMB_OFUN_OPEN_TRUNCATE)
  3358. //
  3359. // The desired access mode passed in Open and Open and X has the following
  3360. // mapping:
  3361. //
  3362. // 1111 11
  3363. // 5432 1098 7654 3210
  3364. // rWrC rLLL rSSS rAAA
  3365. //
  3366. // where:
  3367. //
  3368. // W - Write through mode. No read ahead or write behind allowed on
  3369. // this file or device. When protocol is returned, data is expected
  3370. // to be on the disk or device.
  3371. //
  3372. // S - Sharing mode:
  3373. // 0 - Compatibility mode (as in core open)
  3374. // 1 - Deny read/write/execute (exclusive)
  3375. // 2 - Deny write
  3376. // 3 - Deny read/execute
  3377. // 4 - Deny none
  3378. //
  3379. // A - Access mode
  3380. // 0 - Open for reading
  3381. // 1 - Open for writing
  3382. // 2 - Open for reading and writing
  3383. // 3 - Open for execute
  3384. //
  3385. // rSSSrAAA = 11111111 (hex FF) indicates FCB open (as in core protocol)
  3386. //
  3387. // C - Cache mode
  3388. // 0 - Normal file
  3389. // 1 - Do not cache this file
  3390. //
  3391. // L - Locality of reference
  3392. // 0 - Locality of reference is unknown
  3393. // 1 - Mainly sequential access
  3394. // 2 - Mainly random access
  3395. // 3 - Random access with some locality
  3396. // 4 to 7 - Currently undefined
  3397. //
  3398. #define SMB_DA_SHARE_MASK 0x70
  3399. #define SMB_DA_ACCESS_MASK 0x07
  3400. #define SMB_DA_FCB_MASK (UCHAR)0xFF
  3401. #define SMB_DA_ACCESS_READ 0x00
  3402. #define SMB_DA_ACCESS_WRITE 0x01
  3403. #define SMB_DA_ACCESS_READ_WRITE 0x02
  3404. #define SMB_DA_ACCESS_EXECUTE 0x03
  3405. #define SMB_DA_SHARE_COMPATIBILITY 0x00
  3406. #define SMB_DA_SHARE_EXCLUSIVE 0x10
  3407. #define SMB_DA_SHARE_DENY_WRITE 0x20
  3408. #define SMB_DA_SHARE_DENY_READ 0x30
  3409. #define SMB_DA_SHARE_DENY_NONE 0x40
  3410. #define SMB_DA_FCB (UCHAR)0xFF
  3411. #define SMB_CACHE_NORMAL 0x0000
  3412. #define SMB_DO_NOT_CACHE 0x1000
  3413. #define SMB_LR_UNKNOWN 0x0000
  3414. #define SMB_LR_SEQUENTIAL 0x0100
  3415. #define SMB_LR_RANDOM 0x0200
  3416. #define SMB_LR_RANDOM_WITH_LOCALITY 0x0300
  3417. #define SMB_LR_MASK 0x0F00
  3418. #define SMB_DA_WRITE_THROUGH 0x4000
  3419. //
  3420. // The Action field of OpenAndX has the following format:
  3421. //
  3422. // 1111 11
  3423. // 5432 1098 7654 3210
  3424. // Lrrr rrrr rrrr rrOO
  3425. //
  3426. // where:
  3427. //
  3428. // L - Opportunistic lock. 1 if lock granted, else 0.
  3429. //
  3430. // O - Open action:
  3431. // 1 - The file existed and was opened
  3432. // 2 - The file did not exist but was created
  3433. // 3 - The file existed and was truncated
  3434. //
  3435. #define SMB_OACT_OPENED 0x01
  3436. #define SMB_OACT_CREATED 0x02
  3437. #define SMB_OACT_TRUNCATED 0x03
  3438. #define SMB_OACT_OPLOCK 0x8000
  3439. //
  3440. // These flags are passed in the Flags field of the copy and extended rename
  3441. // SMBs.
  3442. //
  3443. //
  3444. // If set, the target must be a file or directory.
  3445. //
  3446. #define SMB_TARGET_IS_FILE 0x1
  3447. #define SMB_TARGET_IS_DIRECTORY 0x2
  3448. //
  3449. // The copy mode--if set, ASCII copying should be done, otherwise binary.
  3450. //
  3451. #define SMB_COPY_TARGET_ASCII 0x4
  3452. #define SMB_COPY_SOURCE_ASCII 0x8
  3453. #define SMB_COPY_TREE 0x20
  3454. //
  3455. // If set, verify all writes.
  3456. //
  3457. #define SMB_VERIFY_WRITES
  3458. //
  3459. // Define file attribute bits as used in the SMB protocol. The specific
  3460. // bit positions are, for the most part, identical to those used in NT.
  3461. // However, NT does not define Volume and Directory bits. It also has
  3462. // an explicit Normal bit; this bit is implied in SMB attributes by
  3463. // Hidden, System, and Directory being off.
  3464. //
  3465. #define SMB_FILE_ATTRIBUTE_READONLY 0x01
  3466. #define SMB_FILE_ATTRIBUTE_HIDDEN 0x02
  3467. #define SMB_FILE_ATTRIBUTE_SYSTEM 0x04
  3468. #define SMB_FILE_ATTRIBUTE_VOLUME 0x08
  3469. #define SMB_FILE_ATTRIBUTE_DIRECTORY 0x10
  3470. #define SMB_FILE_ATTRIBUTE_ARCHIVE 0x20
  3471. //
  3472. // Share type strings are passed in SMBs to indicate what type of shared
  3473. // resource is being or has been connected to.
  3474. //
  3475. #define SHARE_TYPE_NAME_DISK "A:"
  3476. #define SHARE_TYPE_NAME_PIPE "IPC"
  3477. #define SHARE_TYPE_NAME_COMM "COMM"
  3478. #define SHARE_TYPE_NAME_PRINT "LPT1:"
  3479. #define SHARE_TYPE_NAME_WILD "?????"
  3480. //
  3481. // SMB Error codes:
  3482. //
  3483. //
  3484. // Success Class:
  3485. //
  3486. #define SMB_ERR_SUCCESS (UCHAR)0x00
  3487. //
  3488. // DOS Error Class:
  3489. //
  3490. #define SMB_ERR_CLASS_DOS (UCHAR)0x01
  3491. #define SMB_ERR_BAD_FUNCTION 1 // Invalid function
  3492. #define SMB_ERR_BAD_FILE 2 // File not found
  3493. #define SMB_ERR_BAD_PATH 3 // Invalid directory
  3494. #define SMB_ERR_NO_FIDS 4 // Too many open files
  3495. #define SMB_ERR_ACCESS_DENIED 5 // Access not allowed for req. func.
  3496. #define SMB_ERR_BAD_FID 6 // Invalid file handle
  3497. #define SMB_ERR_BAD_MCB 7 // Memory control blocks destroyed
  3498. #define SMB_ERR_INSUFFICIENT_MEMORY 8 // For the desired function
  3499. #define SMB_ERR_BAD_MEMORY 9 // Invalid memory block address
  3500. #define SMB_ERR_BAD_ENVIRONMENT 10 // Invalid environment
  3501. #define SMB_ERR_BAD_FORMAT 11 // Invalid format
  3502. #define SMB_ERR_BAD_ACCESS 12 // Invalid open mode
  3503. #define SMB_ERR_BAD_DATA 13 // Invalid data (only from IOCTL)
  3504. #define SMB_ERR_RESERVED 14
  3505. #define SMB_ERR_BAD_DRIVE 15 // Invalid drive specified
  3506. #define SMB_ERR_CURRENT_DIRECTORY 16 // Attempted to remove currect directory
  3507. #define SMB_ERR_DIFFERENT_DEVICE 17 // Not the same device
  3508. #define SMB_ERR_NO_FILES 18 // File search can't find more files
  3509. #define SMB_ERR_BAD_SHARE 32 // An open conflicts with FIDs on file
  3510. #define SMB_ERR_LOCK 33 // Conflict with existing lock
  3511. #define SMB_ERR_FILE_EXISTS 80 // Tried to overwrite existing file
  3512. #define SMB_ERR_BAD_PIPE 230 // Invalie pipe
  3513. #define SMB_ERR_PIPE_BUSY 231 // All instances of the pipe are busy
  3514. #define SMB_ERR_PIPE_CLOSING 232 // Pipe close in progress
  3515. #define SMB_ERR_PIPE_NOT_CONNECTED 233 // No process on other end of pipe
  3516. #define SMB_ERR_MORE_DATA 234 // There is more data to return
  3517. //
  3518. // SERVER Error Class:
  3519. //
  3520. #define SMB_ERR_CLASS_SERVER (UCHAR)0x02
  3521. #define SMB_ERR_ERROR 1 // Non-specific error code
  3522. #define SMB_ERR_BAD_PASSWORD 2 // Bad name/password pair
  3523. #define SMB_ERR_BAD_TYPE 3 // Reserved
  3524. #define SMB_ERR_ACCESS 4 // Requester lacks necessary access
  3525. #define SMB_ERR_BAD_TID 5 // Invalid TID
  3526. #define SMB_ERR_BAD_NET_NAME 6 // Invalid network name in tree connect
  3527. #define SMB_ERR_BAD_DEVICE 7 // Invalid device request
  3528. #define SMB_ERR_QUEUE_FULL 49 // Print queue full--returned print file
  3529. #define SMB_ERR_QUEUE_TOO_BIG 50 // Print queue full--no space
  3530. #define SMB_ERR_QUEUE_EOF 51 // EOF on print queue dump
  3531. #define SMB_ERR_BAD_PRINT_FID 52 // Invalid print file FID
  3532. #define SMB_ERR_BAD_SMB_COMMAND 64 // SMB command not recognized
  3533. #define SMB_ERR_SERVER_ERROR 65 // Internal server error
  3534. #define SMB_ERR_FILE_SPECS 67 // FID and pathname were incompatible
  3535. #define SMB_ERR_RESERVED2 68
  3536. #define SMB_ERR_BAD_PERMITS 69 // Access permissions invalid
  3537. #define SMB_ERR_RESERVED3 70
  3538. #define SMB_ERR_BAD_ATTRIBUTE_MODE 71 // Invalid attribute mode specified
  3539. #define SMB_ERR_SERVER_PAUSED 81 // Server is paused
  3540. #define SMB_ERR_MESSAGE_OFF 82 // Server not receiving messages
  3541. #define SMB_ERR_NO_ROOM 83 // No room for buffer message
  3542. #define SMB_ERR_TOO_MANY_NAMES 87 // Too many remote user names
  3543. #define SMB_ERR_TIMEOUT 88 // Operation was timed out
  3544. #define SMB_ERR_NO_RESOURCE 89 // No resources available for request
  3545. #define SMB_ERR_TOO_MANY_UIDS 90 // Too many UIDs active in session
  3546. #define SMB_ERR_BAD_UID 91 // UID not known as a valid UID
  3547. #define SMB_ERR_INVALID_NAME 123 // Invalid name returned from FAT.
  3548. #define SMB_ERR_INVALID_NAME_RANGE 206 // Non 8.3 name passed to FAT (or non 255 name to HPFS)
  3549. #define SMB_ERR_USE_MPX 250 // Can't support Raw; use MPX
  3550. #define SMB_ERR_USE_STANDARD 251 // Can't support Raw, use standard r/w
  3551. #define SMB_ERR_CONTINUE_MPX 252 // Reserved
  3552. #define SMB_ERR_RESERVED4 253
  3553. #define SMB_ERR_RESERVED5 254
  3554. #define SMB_ERR_NO_SUPPORT_INTERNAL 255 // Internal code for NO_SUPPORT--
  3555. // allows codes to be stored in a byte
  3556. #define SMB_ERR_NO_SUPPORT (USHORT)0xFFFF // Function not supported
  3557. //
  3558. // HARDWARE Error Class:
  3559. //
  3560. #define SMB_ERR_CLASS_HARDWARE (UCHAR)0x03
  3561. #define SMB_ERR_NO_WRITE 19 // Write attempted to write-prot. disk
  3562. #define SMB_ERR_BAD_UNIT 20 // Unknown unit
  3563. #define SMB_ERR_DRIVE_NOT_READY 21 // Disk drive not ready
  3564. #define SMB_ERR_BAD_COMMAND 22 // Unknown command
  3565. #define SMB_ERR_DATA 23 // Data error (CRC)
  3566. #define SMB_ERR_BAD_REQUEST 24 // Bad request structure length
  3567. #define SMB_ERR_SEEK 25 // Seek error
  3568. #define SMB_ERR_BAD_MEDIA 26 // Unknown media type
  3569. #define SMB_ERR_BAD_SECTOR 27 // Sector not found
  3570. #define SMB_ERR_NO_PAPER 28 // Printer out of paper
  3571. #define SMB_ERR_WRITE_FAULT 29 // Write fault
  3572. #define SMB_ERR_READ_FAULT 30 // Read fault
  3573. #define SMB_ERR_GENERAL 31 // General failure
  3574. #define SMB_ERR_LOCK_CONFLICT 33 // Lock conflicts with existing lock
  3575. #define SMB_ERR_WRONG_DISK 34 // Wrong disk was found in a drive
  3576. #define SMB_ERR_FCB_UNAVAILABLE 35 // No FCBs available to process request
  3577. #define SMB_ERR_SHARE_BUFFER_EXCEEDED 36
  3578. #define SMB_ERR_DISK_FULL 39 // !!! Undocumented, but in LM2.0
  3579. //
  3580. // Other Error Classes:
  3581. //
  3582. #define SMB_ERR_CLASS_XOS (UCHAR)0x04 // Reserved for XENIX
  3583. #define SMB_ERR_CLASS_RMX1 (UCHAR)0xE1 // Reserved for iRMX
  3584. #define SMB_ERR_CLASS_RMX2 (UCHAR)0xE2 // Reserved for iRMX
  3585. #define SMB_ERR_CLASS_RMX3 (UCHAR)0xE3 // Reserved for iRMX
  3586. #define SMB_ERR_CLASS_COMMAND (UCHAR)0xFF // Command was not in the SMB format
  3587. //
  3588. // Turn structure packing back off
  3589. //
  3590. #ifndef NO_PACKING
  3591. #include <packoff.h>
  3592. #endif // ndef NO_PACKING
  3593. // Old (LanMan 1.2) and new (NT) field names:
  3594. // (Undocumented fields have corresponding structure in parenthesis)
  3595. // smb_access Access
  3596. // smb_action Action
  3597. // smb_adate AccessDate
  3598. // smb_allocsize AllocationSize
  3599. // smb_aname AccountName
  3600. // smb_apasslen PasswordSize
  3601. // smb_apasswd AccountPassword
  3602. // smb_atime AccessTime
  3603. // smb_attr Attribute
  3604. // smb_attribute Attribute
  3605. // smb_aunits (RESP_QUERY_INFORMATION_SERVER)
  3606. // smb_bcc BufferSize
  3607. // smb_blkmode BlockMode
  3608. // smb_blksize BlockSize
  3609. // smb_blksperunit BlocksPerUnit
  3610. // smb_bpu BlocksPerUnit
  3611. // smb_bs BlockSize
  3612. // smb_bufsize MaxBufferSize
  3613. // smb_buf[1] Buffer[1]
  3614. // smb_bytes[*] Bytes[*]
  3615. // smb_cat Category
  3616. // smb_cct FilesCopied
  3617. // smb_cdate CreateDate
  3618. // smb_cert CertificateOffset
  3619. // smb_com Command
  3620. // smb_com2 AndXCommand
  3621. // smb_count Count
  3622. // smb_count_left Remaining
  3623. // smb_cryptkey[*] CryptKey
  3624. // smb_ctime CreateTime
  3625. // smb_datablock DataBlock
  3626. // smb_datalen DataSize
  3627. // smb_datasize DataSize
  3628. // smb_data[*] Data[*]
  3629. // smb_dcmode DataCompactMode
  3630. // smb_dev DeviceName
  3631. // smb_doff DataOffset
  3632. // smb_drcnt DataCount
  3633. // smb_drdisp DataDisplacement
  3634. // smb_droff DataOffset
  3635. // smb_dscnt DataCount
  3636. // smb_dsdisp DataDisplacement
  3637. // smb_dsize DataSize
  3638. // smb_dsoff DataOffset
  3639. // smb_encrypt EncryptKey
  3640. // smb_encryptlen EncryptKeySize
  3641. // smb_encryptoff EncryptKeyOffset
  3642. // smb_eos EndOfSearch
  3643. // smb_err Error
  3644. // smb_errmsg[1] ErrorMessage[1]
  3645. // smb_fau (RESP_QUERY_INFORMATION_SERVER)
  3646. // smb_fid Fid
  3647. // smb_fileid ServerFid
  3648. // smb_flag Flag
  3649. // smb_flag2 Flag2
  3650. // smb_flags Flag
  3651. // smb_flg Flag
  3652. // smb_freeunits FreeUnits
  3653. // smb_fsid (RESP_QUERY_INFORMATION_SERVER)
  3654. // smb_fsize FileSize
  3655. // smb_fun Function
  3656. // smb_gid Gid
  3657. // smb_handle Handle
  3658. // smb_ident1 Identifier
  3659. // smb_idf[4] Protocol[4]
  3660. // smb_index Index
  3661. // smb_info Info
  3662. // smb_left Remaining
  3663. // smb_len SetupLength
  3664. // smb_locknum NumberOfLocks
  3665. // smb_lockrng[*] LockRange
  3666. // smb_locktype LockType
  3667. // smb_lpid OwnerPid
  3668. // smb_maxbytes MaxBytes
  3669. // smb_maxcnt MaxCount
  3670. // smb_maxcount MaxCount
  3671. // smb_maxmux (RESP_NEGOTIATE)
  3672. // smb_maxvcs MaxNumberVcs
  3673. // smb_maxxmitsz MaxTransmitSize
  3674. // smb_maxxmt MaxTransmitSize
  3675. // smb_mdate ModificationDate
  3676. // smb_mdrcnt MaxDataCount
  3677. // smb_mid Mid
  3678. // smb_mincnt MinCount
  3679. // smb_mode Mode
  3680. // smb_mprcnt MaxParameterCount
  3681. // smb_mpxmax MaxMpxCount
  3682. // smb_msrcnt MaxSetupCount
  3683. // smb_mtime ModificationTime
  3684. // smb_name[*] Name[*]
  3685. // smb_off2 AndXOffset
  3686. // smb_offset Offset
  3687. // smb_ofun OpenFunction
  3688. // smb_pad Pad
  3689. // smb_pad1[] Pad1
  3690. // smb_pad[] Pad[]
  3691. // smb_param[*] Parameter[*]
  3692. // smb_path ServerName
  3693. // smb_pathname PathName
  3694. // smb_pid Pid
  3695. // smb_prcnt ParameterCount
  3696. // smb_prdisp ParameterDisplacement
  3697. // smb_proff ParameterCount
  3698. // smb_pscnt ParameterCount
  3699. // smb_psdisp ParameterDisplacement
  3700. // smb_psoff ParameterOffset
  3701. // smb_range LockLength or UnlockLength
  3702. // smb_rcls ErrorClass
  3703. // smb_reh ReservedH
  3704. // smb_reh2 ReservedH2
  3705. // smb_remaining Remaining
  3706. // smb_remcnt Remaining
  3707. // smb_res1 Reserved
  3708. // smb_res2 Reserved2
  3709. // smb_res3 Reserved3
  3710. // smb_res4 Reserved4
  3711. // smb_res5 Reserved5
  3712. // smb_reserved Reserved
  3713. // smb_restart Restart
  3714. // smb_resumekey ResumeKey
  3715. // smb_res[5] Reserved[]
  3716. // smb_reverb ReverbCount
  3717. // smb_rsvd Reserved
  3718. // smb_rsvd1 Reserved
  3719. // smb_rsvd2 Reserved2
  3720. // smb_rsvd3 Reserved3
  3721. // smb_rsvd4 Reserved4
  3722. // smb_sattr SearchAttribute
  3723. // smb_secmode SecurityMode
  3724. // smb_seq SequenceNumber
  3725. // smb_services Services
  3726. // smb_sesskey SessionKey
  3727. // smb_setup[*] Setup[*]
  3728. // smb_size Size
  3729. // smb_spasslen ServerPasswordSize
  3730. // smb_spasswd ServerPassword
  3731. // smb_srv_date ServerDate
  3732. // smb_srv_time ServerTime
  3733. // smb_srv_tzone ServerTimeZone
  3734. // smb_start StartIndex
  3735. // smb_state DeviceState
  3736. // smb_suwcnt SetupWordCount
  3737. // smb_su_class SetupClass
  3738. // smb_su_com SetupCommand
  3739. // smb_su_handle SetupFid
  3740. // smb_su_opcode SetupOpcode
  3741. // smb_su_priority SetupPriority
  3742. // smb_tcount Count
  3743. // smb_tdis TreeDisconnect
  3744. // smb_tdrcnt TotalDataCount
  3745. // smb_tdscnt TotalDataCount
  3746. // smb_tid Tid
  3747. // smb_tid2 Tid2
  3748. // smb_time Time
  3749. // smb_timeout Timeout
  3750. // smb_totalunits TotalUnits
  3751. // smb_tprcnt TotalParameterCount
  3752. // smb_tpscnt TotalParameterCount
  3753. // smb_type FileType
  3754. // smb_uid Uid
  3755. // smb_unlkrng[*] UnlockRange
  3756. // smb_unlocknum NumberOfUnlocks
  3757. // smb_vblen DataLength
  3758. // smb_vcnum VcNumber
  3759. // smb_vldate (RESP_QUERY_INFORMATION_SERVER)
  3760. // smb_vllen (RESP_QUERY_INFORMATION_SERVER)
  3761. // smb_vltime (RESP_QUERY_INFORMATION_SERVER)
  3762. // smb_vwv[1] Param
  3763. // smb_wct WordCount
  3764. // smb_wmode WriteMode
  3765. // smb_xchain EncryptChainOffset
  3766. //
  3767. // Force misalignment of the following structures
  3768. //
  3769. #ifndef NO_PACKING
  3770. #include <packon.h>
  3771. #endif // ndef NO_PACKING
  3772. //
  3773. // Named pipe function codes
  3774. //
  3775. #define TRANS_SET_NMPIPE_STATE 0x01
  3776. #define TRANS_RAW_READ_NMPIPE 0x11
  3777. #define TRANS_QUERY_NMPIPE_STATE 0x21
  3778. #define TRANS_QUERY_NMPIPE_INFO 0x22
  3779. #define TRANS_PEEK_NMPIPE 0x23
  3780. #define TRANS_TRANSACT_NMPIPE 0x26
  3781. #define TRANS_RAW_WRITE_NMPIPE 0x31
  3782. #define TRANS_READ_NMPIPE 0x36
  3783. #define TRANS_WRITE_NMPIPE 0x37
  3784. #define TRANS_WAIT_NMPIPE 0x53
  3785. #define TRANS_CALL_NMPIPE 0x54
  3786. //
  3787. // Mailslot function code
  3788. //
  3789. #define TRANS_MAILSLOT_WRITE 0x01
  3790. //
  3791. // Transaction2 function codes
  3792. //
  3793. #define TRANS2_OPEN2 0x00
  3794. #define TRANS2_FIND_FIRST2 0x01
  3795. #define TRANS2_FIND_NEXT2 0x02
  3796. #define TRANS2_QUERY_FS_INFORMATION 0x03
  3797. #define TRANS2_SET_FS_INFORMATION 0x04
  3798. #define TRANS2_QUERY_PATH_INFORMATION 0x05
  3799. #define TRANS2_SET_PATH_INFORMATION 0x06
  3800. #define TRANS2_QUERY_FILE_INFORMATION 0x07
  3801. #define TRANS2_SET_FILE_INFORMATION 0x08
  3802. #define TRANS2_FSCTL 0x09
  3803. #define TRANS2_IOCTL2 0x0A
  3804. #define TRANS2_FIND_NOTIFY_FIRST 0x0B
  3805. #define TRANS2_FIND_NOTIFY_NEXT 0x0C
  3806. #define TRANS2_CREATE_DIRECTORY 0x0D
  3807. #define TRANS2_SESSION_SETUP 0x0E
  3808. #define TRANS2_QUERY_FS_INFORMATION_FID 0x0F
  3809. #define TRANS2_GET_DFS_REFERRAL 0x10
  3810. #define TRANS2_REPORT_DFS_INCONSISTENCY 0x11
  3811. #define TRANS2_MAX_FUNCTION 0x11
  3812. //
  3813. // Nt Transaction function codes
  3814. //
  3815. #define NT_TRANSACT_MIN_FUNCTION 1
  3816. #define NT_TRANSACT_CREATE 1
  3817. #define NT_TRANSACT_IOCTL 2
  3818. #define NT_TRANSACT_SET_SECURITY_DESC 3
  3819. #define NT_TRANSACT_NOTIFY_CHANGE 4
  3820. #define NT_TRANSACT_RENAME 5
  3821. #define NT_TRANSACT_QUERY_SECURITY_DESC 6
  3822. #define NT_TRANSACT_QUERY_QUOTA 7
  3823. #define NT_TRANSACT_SET_QUOTA 8
  3824. #define NT_TRANSACT_MAX_FUNCTION 8
  3825. //
  3826. // File information levels
  3827. //
  3828. #define SMB_INFO_STANDARD 1
  3829. #define SMB_INFO_QUERY_EA_SIZE 2
  3830. #define SMB_INFO_SET_EAS 2
  3831. #define SMB_INFO_QUERY_EAS_FROM_LIST 3
  3832. #define SMB_INFO_QUERY_ALL_EAS 4 // undocumented but supported
  3833. #define SMB_INFO_QUERY_FULL_NAME 5 // never sent by redir
  3834. #define SMB_INFO_IS_NAME_VALID 6
  3835. #define SMB_INFO_PASSTHROUGH 1000 // any info above here is a simple pass-through
  3836. //
  3837. // NT extension to file info levels
  3838. //
  3839. #define SMB_QUERY_FILE_BASIC_INFO 0x101
  3840. #define SMB_QUERY_FILE_STANDARD_INFO 0x102
  3841. #define SMB_QUERY_FILE_EA_INFO 0x103
  3842. #define SMB_QUERY_FILE_NAME_INFO 0x104
  3843. #define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
  3844. #define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
  3845. #define SMB_QUERY_FILE_ALL_INFO 0x107
  3846. #define SMB_QUERY_FILE_ALT_NAME_INFO 0x108
  3847. #define SMB_QUERY_FILE_STREAM_INFO 0x109
  3848. #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
  3849. #define SMB_SET_FILE_BASIC_INFO 0x101
  3850. #define SMB_SET_FILE_DISPOSITION_INFO 0x102
  3851. #define SMB_SET_FILE_ALLOCATION_INFO 0x103
  3852. #define SMB_SET_FILE_END_OF_FILE_INFO 0x104
  3853. #define SMB_QUERY_FS_LABEL_INFO 0x101
  3854. #define SMB_QUERY_FS_VOLUME_INFO 0x102
  3855. #define SMB_QUERY_FS_SIZE_INFO 0x103
  3856. #define SMB_QUERY_FS_DEVICE_INFO 0x104
  3857. #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
  3858. #define SMB_QUERY_FS_QUOTA_INFO 0x106 // unused?
  3859. #define SMB_QUERY_FS_CONTROL_INFO 0x107
  3860. //
  3861. // Volume information levels.
  3862. //
  3863. #define SMB_INFO_ALLOCATION 1
  3864. #define SMB_INFO_VOLUME 2
  3865. //
  3866. // Rename2 information levels.
  3867. //
  3868. #define SMB_NT_RENAME_MOVE_CLUSTER_INFO 0x102
  3869. #define SMB_NT_RENAME_SET_LINK_INFO 0x103
  3870. #define SMB_NT_RENAME_RENAME_FILE 0x104 // Server internal
  3871. #define SMB_NT_RENAME_MOVE_FILE 0x105 // Server internal
  3872. //
  3873. // Protocol for NtQueryQuotaInformationFile
  3874. //
  3875. typedef struct {
  3876. _USHORT( Fid ); // FID of target
  3877. UCHAR ReturnSingleEntry; // Indicates that only a single entry should be returned
  3878. // rather than filling the buffer with as
  3879. // many entries as possible.
  3880. UCHAR RestartScan; // Indicates whether the scan of the quota information
  3881. // is to be restarted from the beginning.
  3882. _ULONG ( SidListLength ); // Supplies the length of the SID list if present
  3883. _ULONG ( StartSidLength ); // Supplies an optional SID that indicates that the returned
  3884. // information is to start with an entry other
  3885. // than the first. This parameter is ignored if a
  3886. // SidList is given
  3887. _ULONG( StartSidOffset); // Supplies the offset of Start Sid in the buffer
  3888. } REQ_NT_QUERY_FS_QUOTA_INFO, *PREQ_NT_QUERY_FS_QUOTA_INFO;
  3889. //
  3890. // Desciptor response
  3891. //
  3892. // Data Bytes: The Quota Information
  3893. //
  3894. typedef struct {
  3895. _ULONG ( Length );
  3896. } RESP_NT_QUERY_FS_QUOTA_INFO, *PRESP_NT_QUERY_FS_QUOTA_INFO;
  3897. //
  3898. // Protocol for NtSetQuotaInformationFile
  3899. //
  3900. typedef struct {
  3901. _USHORT( Fid ); // FID of target
  3902. } REQ_NT_SET_FS_QUOTA_INFO, *PREQ_NT_SET_FS_QUOTA_INFO;
  3903. //
  3904. // Response:
  3905. //
  3906. // Setup words: None.
  3907. // Parameter Bytes: None.
  3908. // Data Bytes: None.
  3909. //
  3910. //
  3911. // Dfs Transactions
  3912. //
  3913. //
  3914. // Request for Referral.
  3915. //
  3916. typedef struct {
  3917. USHORT MaxReferralLevel; // Latest version of referral understood
  3918. UCHAR RequestFileName[1]; // Dfs name for which referral is sought
  3919. } REQ_GET_DFS_REFERRAL;
  3920. typedef REQ_GET_DFS_REFERRAL SMB_UNALIGNED *PREQ_GET_DFS_REFERRAL;
  3921. //
  3922. // The format of an individual referral contains version and length information
  3923. // allowing the client to skip referrals it does not understand.
  3924. //
  3925. // !! All referral elements must have VersionNumber and Size as the first 2 elements !!
  3926. //
  3927. typedef struct {
  3928. USHORT VersionNumber; // == 1
  3929. USHORT Size; // Size of this whole element
  3930. USHORT ServerType; // Type of server: 0 == Don't know, 1 == SMB, 2 == Netware
  3931. struct {
  3932. USHORT StripPath : 1; // Strip off PathConsumed characters from front of
  3933. // DfsPathName prior to submitting name to UncShareName
  3934. };
  3935. WCHAR ShareName[1]; // The server+share name go right here. NULL terminated.
  3936. } DFS_REFERRAL_V1;
  3937. typedef DFS_REFERRAL_V1 SMB_UNALIGNED *PDFS_REFERRAL_V1;
  3938. typedef struct {
  3939. USHORT VersionNumber; // == 2
  3940. USHORT Size; // Size of this whole element
  3941. USHORT ServerType; // Type of server: 0 == Don't know, 1 == SMB, 2 == Netware
  3942. struct {
  3943. USHORT StripPath : 1; // Strip off PathConsumed characters from front of
  3944. // DfsPathName prior to submitting name to UncShareName
  3945. };
  3946. ULONG Proximity; // Hint of transport cost
  3947. ULONG TimeToLive; // In number of seconds
  3948. USHORT DfsPathOffset; // Offset from beginning of this element to Path to access
  3949. USHORT DfsAlternatePathOffset; // Offset from beginning of this element to 8.3 path
  3950. USHORT NetworkAddressOffset; // Offset from beginning of this element to Network path
  3951. } DFS_REFERRAL_V2;
  3952. typedef DFS_REFERRAL_V2 SMB_UNALIGNED *PDFS_REFERRAL_V2;
  3953. typedef struct {
  3954. USHORT VersionNumber; // == 3
  3955. USHORT Size; // Size of this whole element
  3956. USHORT ServerType; // Type of server: 0 == Don't know, 1 == SMB, 2 == Netware
  3957. struct {
  3958. USHORT StripPath : 1; // Strip off PathConsumed characters from front of
  3959. // DfsPathName prior to submitting name to UncShareName
  3960. USHORT NameListReferral : 1; // This referral contains an expanded name list
  3961. };
  3962. ULONG TimeToLive; // In number of seconds
  3963. union {
  3964. struct {
  3965. USHORT DfsPathOffset; // Offset from beginning of this element to Path to access
  3966. USHORT DfsAlternatePathOffset; // Offset from beginning of this element to 8.3 path
  3967. USHORT NetworkAddressOffset; // Offset from beginning of this element to Network path
  3968. GUID ServiceSiteGuid; // The guid for the site
  3969. };
  3970. struct {
  3971. USHORT SpecialNameOffset; // Offset from this element to the special name string
  3972. USHORT NumberOfExpandedNames; // Number of expanded names
  3973. USHORT ExpandedNameOffset; // Offset from this element to the expanded name list
  3974. };
  3975. };
  3976. } DFS_REFERRAL_V3;
  3977. typedef DFS_REFERRAL_V3 SMB_UNALIGNED *PDFS_REFERRAL_V3;
  3978. typedef struct {
  3979. USHORT PathConsumed; // Number of WCHARs consumed in DfsPathName
  3980. USHORT NumberOfReferrals; // Number of referrals contained here
  3981. struct {
  3982. ULONG ReferralServers : 1; // Elements in Referrals[] are referral servers
  3983. ULONG StorageServers : 1; // Elements in Referrals[] are storage servers
  3984. };
  3985. union { // The vector of referrals
  3986. DFS_REFERRAL_V1 v1;
  3987. DFS_REFERRAL_V2 v2;
  3988. DFS_REFERRAL_V3 v3;
  3989. } Referrals[1]; // [ NumberOfReferrals ]
  3990. //
  3991. // WCHAR StringBuffer[]; // Used by DFS_REFERRAL_V2
  3992. //
  3993. } RESP_GET_DFS_REFERRAL;
  3994. typedef RESP_GET_DFS_REFERRAL SMB_UNALIGNED *PRESP_GET_DFS_REFERRAL;
  3995. //
  3996. // During Dfs operations, a client may discover a knowledge inconsistency in the Dfs.
  3997. // The parameter portion of the TRANS2_REPORT_DFS_INCONSISTENCY SMB is
  3998. // encoded in this way
  3999. //
  4000. typedef struct {
  4001. UCHAR RequestFileName[1]; // Dfs name for which inconsistency is being reported
  4002. union {
  4003. DFS_REFERRAL_V1 v1; // The single referral thought to be in error
  4004. } Referral;
  4005. } REQ_REPORT_DFS_INCONSISTENCY;
  4006. typedef REQ_REPORT_DFS_INCONSISTENCY SMB_UNALIGNED *PREQ_REPORT_DFS_INCONSISTENCY;
  4007. typedef struct _REQ_QUERY_FS_INFORMATION_FID {
  4008. _USHORT( InformationLevel );
  4009. _USHORT( Fid );
  4010. } REQ_QUERY_FS_INFORMATION_FID;
  4011. typedef REQ_QUERY_FS_INFORMATION_FID SMB_UNALIGNED *PREQ_QUERY_FS_INFORMATION_FID;
  4012. //
  4013. // The client also needs to send to this server the referral which it believes to be
  4014. // in error. The data part of this transaction contains the errant referral(s), encoded
  4015. // as above in the DFS_REFERRAL_* structures.
  4016. //
  4017. //
  4018. // Find First, information levels
  4019. //
  4020. #define SMB_FIND_FILE_DIRECTORY_INFO 0x101
  4021. #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
  4022. #define SMB_FIND_FILE_NAMES_INFO 0x103
  4023. #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
  4024. #ifdef INCLUDE_SMB_DIRECTORY
  4025. //
  4026. // CreateDirectory2 function code os Transaction2 SMB, see #3 page 51
  4027. // Function is SrvSmbCreateDirectory2()
  4028. // TRANS2_CREATE_DIRECTORY 0x0D
  4029. //
  4030. typedef struct _REQ_CREATE_DIRECTORY2 {
  4031. _ULONG( Reserved ); // Reserved--must be zero
  4032. UCHAR Buffer[1]; // Directory name to create
  4033. } REQ_CREATE_DIRECTORY2;
  4034. typedef REQ_CREATE_DIRECTORY2 SMB_UNALIGNED *PREQ_CREATE_DIRECTORY2;
  4035. // Data bytes for CreateDirectory2 request are the extended attributes for the
  4036. // created file.
  4037. typedef struct _RESP_CREATE_DIRECTORY2 {
  4038. _USHORT( EaErrorOffset ); // Offset into FEAList of first error
  4039. // which occurred while setting EAs
  4040. } RESP_CREATE_DIRECTORY2;
  4041. typedef RESP_CREATE_DIRECTORY2 SMB_UNALIGNED *PRESP_CREATE_DIRECTORY2;
  4042. #endif // def INCLUDE_SMB_DIRECTORY
  4043. #ifdef INCLUDE_SMB_SEARCH
  4044. //
  4045. // FindFirst2 function code of Transaction2 SMB, see #3 page 22
  4046. // Function is SrvSmbFindFirst2()
  4047. // TRANS2_FIND_FIRST2 0x01
  4048. //
  4049. typedef struct _REQ_FIND_FIRST2 {
  4050. _USHORT( SearchAttributes );
  4051. _USHORT( SearchCount ); // Maximum number of entries to return
  4052. _USHORT( Flags ); // Additional information: bit set-
  4053. // 0 - close search after this request
  4054. // 1 - close search if end reached
  4055. // 2 - return resume keys
  4056. _USHORT( InformationLevel );
  4057. _ULONG(SearchStorageType);
  4058. UCHAR Buffer[1]; // File name
  4059. } REQ_FIND_FIRST2;
  4060. typedef REQ_FIND_FIRST2 SMB_UNALIGNED *PREQ_FIND_FIRST2;
  4061. // Data bytes for Find First2 request are a list of extended attributes
  4062. // to retrieve (a GEAList), if InformationLevel is QUERY_EAS_FROM_LIST.
  4063. typedef struct _RESP_FIND_FIRST2 {
  4064. _USHORT( Sid ); // Search handle
  4065. _USHORT( SearchCount ); // Number of entries returned
  4066. _USHORT( EndOfSearch ); // Was last entry returned?
  4067. _USHORT( EaErrorOffset ); // Offset into EA list if EA error
  4068. _USHORT( LastNameOffset ); // Offset into data to file name of
  4069. // last entry, if server needs it
  4070. // to resume search; else 0
  4071. } RESP_FIND_FIRST2;
  4072. typedef RESP_FIND_FIRST2 SMB_UNALIGNED *PRESP_FIND_FIRST2;
  4073. // Data bytes for Find First2 response are level-dependent information
  4074. // about the matching files. If bit 2 in the request parameters was
  4075. // set, each entry is preceded by a four-byte resume key.
  4076. //
  4077. // FindNext2 function code of Transaction2 SMB, see #3 page 26
  4078. // Function is SrvSmbFindNext2()
  4079. // TRANS2_FIND_NEXT2 0x02
  4080. //
  4081. typedef struct _REQ_FIND_NEXT2 {
  4082. _USHORT( Sid ); // Search handle
  4083. _USHORT( SearchCount ); // Maximum number of entries to return
  4084. _USHORT( InformationLevel );
  4085. _ULONG( ResumeKey ); // Value returned by previous find
  4086. _USHORT( Flags ); // Additional information: bit set-
  4087. // 0 - close search after this request
  4088. // 1 - close search if end reached
  4089. // 2 - return resume keys
  4090. // 3 - resume/continue, NOT rewind
  4091. UCHAR Buffer[1]; // Resume file name
  4092. } REQ_FIND_NEXT2;
  4093. typedef REQ_FIND_NEXT2 SMB_UNALIGNED *PREQ_FIND_NEXT2;
  4094. // Data bytes for Find Next2 request are a list of extended attributes
  4095. // to retrieve, if InformationLevel is QUERY_EAS_FROM_LIST.
  4096. typedef struct _RESP_FIND_NEXT2 {
  4097. _USHORT( SearchCount ); // Number of entries returned
  4098. _USHORT( EndOfSearch ); // Was last entry returned?
  4099. _USHORT( EaErrorOffset ); // Offset into EA list if EA error
  4100. _USHORT( LastNameOffset ); // Offset into data to file name of
  4101. // last entry, if server needs it
  4102. // to resume search; else 0
  4103. } RESP_FIND_NEXT2;
  4104. typedef RESP_FIND_NEXT2 SMB_UNALIGNED *PRESP_FIND_NEXT2;
  4105. // Data bytes for Find Next2 response are level-dependent information
  4106. // about the matching files. If bit 2 in the request parameters was
  4107. // set, each entry is preceded by a four-byte resume key.
  4108. //
  4109. // Flags for REQ_FIND_FIRST2.Flags
  4110. //
  4111. #define SMB_FIND_CLOSE_AFTER_REQUEST 0x01
  4112. #define SMB_FIND_CLOSE_AT_EOS 0x02
  4113. #define SMB_FIND_RETURN_RESUME_KEYS 0x04
  4114. #define SMB_FIND_CONTINUE_FROM_LAST 0x08
  4115. #define SMB_FIND_WITH_BACKUP_INTENT 0x10
  4116. #endif // def INCLUDE_SMB_SEARCH
  4117. #ifdef INCLUDE_SMB_OPEN_CLOSE
  4118. //
  4119. // Open2 function code of Transaction2 SMB, see #3 page 19
  4120. // Function is SrvSmbOpen2()
  4121. // TRANS2_OPEN2 0x00
  4122. //
  4123. // *** Note that the REQ_OPEN2 and RESP_OPEN2 structures closely
  4124. // resemble the REQ_OPEN_ANDX and RESP_OPEN_ANDX structures.
  4125. //
  4126. typedef struct _REQ_OPEN2 {
  4127. _USHORT( Flags ); // Additional information: bit set-
  4128. // 0 - return additional info
  4129. // 1 - set single user total file lock
  4130. // 2 - server notifies consumer of
  4131. // actions which may change file
  4132. // 3 - return total length of EAs
  4133. _USHORT( DesiredAccess ); // File open mode
  4134. _USHORT( SearchAttributes ); // *** ignored
  4135. _USHORT( FileAttributes );
  4136. _ULONG( CreationTimeInSeconds );
  4137. _USHORT( OpenFunction );
  4138. _ULONG( AllocationSize ); // Bytes to reserve on create or truncate
  4139. _USHORT( Reserved )[5]; // Pad through OpenAndX's Timeout,
  4140. // Reserved, and ByteCount
  4141. UCHAR Buffer[1]; // File name
  4142. } REQ_OPEN2;
  4143. typedef REQ_OPEN2 SMB_UNALIGNED *PREQ_OPEN2;
  4144. // Data bytes for Open2 request are the extended attributes for the
  4145. // created file.
  4146. typedef struct _RESP_OPEN2 {
  4147. _USHORT( Fid ); // File handle
  4148. _USHORT( FileAttributes );
  4149. _ULONG( CreationTimeInSeconds );
  4150. _ULONG( DataSize ); // Current file size
  4151. _USHORT( GrantedAccess ); // Access permissions actually allowed
  4152. _USHORT( FileType );
  4153. _USHORT( DeviceState ); // state of IPC device (e.g. pipe)
  4154. _USHORT( Action ); // Action taken
  4155. _ULONG( ServerFid ); // Server unique file id
  4156. _USHORT( EaErrorOffset ); // Offset into EA list if EA error
  4157. _ULONG( EaLength ); // Total EA length for opened file
  4158. } RESP_OPEN2;
  4159. typedef RESP_OPEN2 SMB_UNALIGNED *PRESP_OPEN2;
  4160. // The Open2 response has no data bytes.
  4161. #endif // def INCLUDE_SMB_OPEN_CLOSE
  4162. #ifdef INCLUDE_SMB_MISC
  4163. //
  4164. // QueryFsInformation function code of Transaction2 SMB, see #3 page 30
  4165. // Function is SrvSmbQueryFsInformation()
  4166. // TRANS2_QUERY_FS_INFORMATION 0x03
  4167. //
  4168. typedef struct _REQ_QUERY_FS_INFORMATION {
  4169. _USHORT( InformationLevel );
  4170. } REQ_QUERY_FS_INFORMATION;
  4171. typedef REQ_QUERY_FS_INFORMATION SMB_UNALIGNED *PREQ_QUERY_FS_INFORMATION;
  4172. // No data bytes for Query FS Information request.
  4173. //typedef struct _RESP_QUERY_FS_INFORMATION {
  4174. //} RESP_QUERY_FS_INFORMATION;
  4175. //typedef RESP_QUERY_FS_INFORMATION SMB_UNALIGNED *PRESP_QUERY_FS_INFORMATION;
  4176. // Data bytes for Query FS Information response are level-dependent
  4177. // information about the specified volume.
  4178. //
  4179. // SetFSInformation function code of Transaction2 SMB, see #3 page 31
  4180. // Function is SrvSmbSetFSInformation()
  4181. // TRANS2_SET_PATH_INFORMATION 0x04
  4182. //
  4183. typedef struct _REQ_SET_FS_INFORMATION {
  4184. _USHORT( Fid );
  4185. _USHORT( InformationLevel );
  4186. } REQ_SET_FS_INFORMATION;
  4187. typedef REQ_SET_FS_INFORMATION SMB_UNALIGNED *PREQ_SET_FS_INFORMATION;
  4188. // Data bytes for Set FS Information request are level-dependant
  4189. // information about the specified volume.
  4190. //typedef struct _RESP_SET_FS_INFORMATION {
  4191. //} RESP_SET_FS_INFORMATION;
  4192. //typedef RESP_SET_FS_INFORMATION SMB_UNALIGNED *PRESP_SET_FS_INFORMATION;
  4193. // The Set FS Information response has no data bytes.
  4194. #endif // def INCLUDE_SMB_MISC
  4195. #ifdef INCLUDE_SMB_QUERY_SET
  4196. //
  4197. // QueryPathInformation function code of Transaction2 SMB, see #3 page 33
  4198. // Function is SrvSmbQueryPathInformation()
  4199. // TRANS2_QUERY_PATH_INFORMATION 0x05
  4200. //
  4201. typedef struct _REQ_QUERY_PATH_INFORMATION {
  4202. _USHORT( InformationLevel );
  4203. _ULONG( Reserved ); // Must be zero
  4204. UCHAR Buffer[1]; // File name
  4205. } REQ_QUERY_PATH_INFORMATION;
  4206. typedef REQ_QUERY_PATH_INFORMATION SMB_UNALIGNED *PREQ_QUERY_PATH_INFORMATION;
  4207. // Data bytes for Query Path Information request are a list of extended
  4208. // attributes to retrieve, if InformationLevel is QUERY_EAS_FROM_LIST.
  4209. typedef struct _RESP_QUERY_PATH_INFORMATION {
  4210. _USHORT( EaErrorOffset ); // Offset into EA list if EA error
  4211. } RESP_QUERY_PATH_INFORMATION;
  4212. typedef RESP_QUERY_PATH_INFORMATION SMB_UNALIGNED *PRESP_QUERY_PATH_INFORMATION;
  4213. // Data bytes for Query Path Information response are level-dependent
  4214. // information about the specified path/file.
  4215. //
  4216. // SetPathInformation function code of Transaction2 SMB, see #3 page 35
  4217. // Function is SrvSmbSetPathInformation()
  4218. // TRANS2_SET_PATH_INFORMATION 0x06
  4219. //
  4220. typedef struct _REQ_SET_PATH_INFORMATION {
  4221. _USHORT( InformationLevel );
  4222. _ULONG( Reserved ); // Must be zero
  4223. UCHAR Buffer[1]; // File name
  4224. } REQ_SET_PATH_INFORMATION;
  4225. typedef REQ_SET_PATH_INFORMATION SMB_UNALIGNED *PREQ_SET_PATH_INFORMATION;
  4226. // Data bytes for Set Path Information request are either file information
  4227. // and attributes or a list of extended attributes for the file.
  4228. typedef struct _RESP_SET_PATH_INFORMATION {
  4229. _USHORT( EaErrorOffset ); // Offset into EA list if EA error
  4230. } RESP_SET_PATH_INFORMATION;
  4231. typedef RESP_SET_PATH_INFORMATION SMB_UNALIGNED *PRESP_SET_PATH_INFORMATION;
  4232. // The Set Path Information response has no data bytes.
  4233. //
  4234. // QueryFileInformation function code of Transaction2 SMB, see #3 page 37
  4235. // Function is SrvSmbQueryFileInformation()
  4236. // TRANS2_QUERY_FILE_INFORMATION 0x07
  4237. //
  4238. typedef struct _REQ_QUERY_FILE_INFORMATION {
  4239. _USHORT( Fid ); // File handle
  4240. _USHORT( InformationLevel );
  4241. } REQ_QUERY_FILE_INFORMATION;
  4242. typedef REQ_QUERY_FILE_INFORMATION SMB_UNALIGNED *PREQ_QUERY_FILE_INFORMATION;
  4243. // Data bytes for Query File Information request are a list of extended
  4244. // attributes to retrieve, if InformationLevel is QUERY_EAS_FROM_LIST.
  4245. typedef struct _RESP_QUERY_FILE_INFORMATION {
  4246. _USHORT( EaErrorOffset ); // Offset into EA list if EA error
  4247. } RESP_QUERY_FILE_INFORMATION;
  4248. typedef RESP_QUERY_FILE_INFORMATION SMB_UNALIGNED *PRESP_QUERY_FILE_INFORMATION;
  4249. // Data bytes for Query File Information response are level-dependent
  4250. // information about the specified path/file.
  4251. //
  4252. // SetFileInformation function code of Transaction2 SMB, see #3 page 39
  4253. // Function is SrvSmbSetFileInformation()
  4254. // TRANS2_SET_FILE_INFORMATION 0x08
  4255. //
  4256. typedef struct _REQ_SET_FILE_INFORMATION {
  4257. _USHORT( Fid ); // File handle
  4258. _USHORT( InformationLevel );
  4259. _USHORT( Flags ); // File I/O control flags: bit set-
  4260. // 4 - write through
  4261. // 5 - no cache
  4262. } REQ_SET_FILE_INFORMATION;
  4263. typedef REQ_SET_FILE_INFORMATION SMB_UNALIGNED *PREQ_SET_FILE_INFORMATION;
  4264. // Data bytes for Set File Information request are either file information
  4265. // and attributes or a list of extended attributes for the file.
  4266. typedef struct _RESP_SET_FILE_INFORMATION {
  4267. _USHORT( EaErrorOffset ); // Offset into EA list if EA error
  4268. } RESP_SET_FILE_INFORMATION;
  4269. typedef RESP_SET_FILE_INFORMATION SMB_UNALIGNED *PRESP_SET_FILE_INFORMATION;
  4270. // The Set File Information response has no data bytes.
  4271. #endif // def INCLUDE_SMB_QUERY_SET
  4272. //
  4273. // Opcodes for Mailslot transactions. Not all filled in at present.
  4274. // WARNING ... the info here on mailslots (opcode and smb struct)
  4275. // is duplicated in net/h/mslotsmb.h
  4276. //
  4277. #define MS_WRITE_OPCODE 1
  4278. typedef struct _SMB_TRANSACT_MAILSLOT {
  4279. UCHAR WordCount; // Count of data bytes; value = 17
  4280. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  4281. _USHORT( TotalDataCount ); // Total data bytes being sent
  4282. _USHORT( MaxParameterCount ); // Max parameter bytes to return
  4283. _USHORT( MaxDataCount ); // Max data bytes to return
  4284. UCHAR MaxSetupCount; // Max setup words to return
  4285. UCHAR Reserved;
  4286. _USHORT( Flags ); // Additional information:
  4287. // bit 0 - unused
  4288. // bit 1 - one-way transacion (no resp)
  4289. _ULONG( Timeout );
  4290. _USHORT( Reserved1 );
  4291. _USHORT( ParameterCount ); // Parameter bytes sent this buffer
  4292. _USHORT( ParameterOffset ); // Offset (from header start) to params
  4293. _USHORT( DataCount ); // Data bytes sent this buffer
  4294. _USHORT( DataOffset ); // Offset (from header start) to data
  4295. UCHAR SetupWordCount; // = 3
  4296. UCHAR Reserved2; // Reserved (pad above to word)
  4297. _USHORT( Opcode ); // 1 -- Write Mailslot
  4298. _USHORT( Priority ); // Priority of transaction
  4299. _USHORT( Class ); // Class: 1 = reliable, 2 = unreliable
  4300. _USHORT( ByteCount ); // Count of data bytes
  4301. UCHAR Buffer[1]; // Buffer containing:
  4302. //UCHAR MailslotName[]; // "\MAILSLOT\<name>0"
  4303. //UCHAR Pad[] // Pad to SHORT or LONG
  4304. //UCHAR Data[]; // Data to write to mailslot
  4305. } SMB_TRANSACT_MAILSLOT;
  4306. typedef SMB_TRANSACT_MAILSLOT SMB_UNALIGNED *PSMB_TRANSACT_MAILSLOT;
  4307. typedef struct _SMB_TRANSACT_NAMED_PIPE {
  4308. UCHAR WordCount; // Count of data bytes; value = 16
  4309. _USHORT( TotalParameterCount ); // Total parameter bytes being sent
  4310. _USHORT( TotalDataCount ); // Total data bytes being sent
  4311. _USHORT( MaxParameterCount ); // Max parameter bytes to return
  4312. _USHORT( MaxDataCount ); // Max data bytes to return
  4313. UCHAR MaxSetupCount; // Max setup words to return
  4314. UCHAR Reserved;
  4315. _USHORT( Flags ); // Additional information:
  4316. // bit 0 - also disconnect TID in Tid
  4317. // bit 1 - one-way transacion (no resp)
  4318. _ULONG( Timeout );
  4319. _USHORT( Reserved1 );
  4320. _USHORT( ParameterCount );
  4321. // Buffer containing:
  4322. //UCHAR PipeName[]; // "\PIPE\<name>0"
  4323. //UCHAR Pad[] // Pad to SHORT or LONG
  4324. //UCHAR Param[]; // Parameter bytes (# = ParameterCount)
  4325. //UCHAR Pad1[] // Pad to SHORT or LONG
  4326. //UCHAR Data[]; // Data bytes (# = DataCount)
  4327. } SMB_TRANSACT_NAMED_PIPE;
  4328. typedef SMB_TRANSACT_NAMED_PIPE SMB_UNALIGNED *PSMB_TRANSACT_NAMED_PIPE;
  4329. //
  4330. // Transaction - QueryInformationNamedPipe, Level 1, output data format
  4331. //
  4332. typedef struct _NAMED_PIPE_INFORMATION_1 {
  4333. _USHORT( OutputBufferSize );
  4334. _USHORT( InputBufferSize );
  4335. UCHAR MaximumInstances;
  4336. UCHAR CurrentInstances;
  4337. UCHAR PipeNameLength;
  4338. UCHAR PipeName[1];
  4339. } NAMED_PIPE_INFORMATION_1;
  4340. typedef NAMED_PIPE_INFORMATION_1 SMB_UNALIGNED *PNAMED_PIPE_INFORMATION_1;
  4341. //
  4342. // Transaction - PeekNamedPipe, output format
  4343. //
  4344. typedef struct _RESP_PEEK_NMPIPE {
  4345. _USHORT( ReadDataAvailable );
  4346. _USHORT( MessageLength );
  4347. _USHORT( NamedPipeState );
  4348. //UCHAR Pad[];
  4349. //UCHAR Data[];
  4350. } RESP_PEEK_NMPIPE;
  4351. typedef RESP_PEEK_NMPIPE SMB_UNALIGNED *PRESP_PEEK_NMPIPE;
  4352. //
  4353. // Define SMB pipe handle state bits used by Query/SetNamedPipeHandleState
  4354. //
  4355. // These number are the bit location of the fields in the handle state.
  4356. //
  4357. #define PIPE_COMPLETION_MODE_BITS 15
  4358. #define PIPE_PIPE_END_BITS 14
  4359. #define PIPE_PIPE_TYPE_BITS 10
  4360. #define PIPE_READ_MODE_BITS 8
  4361. #define PIPE_MAXIMUM_INSTANCES_BITS 0
  4362. /* DosPeekNmPipe() pipe states */
  4363. #define PIPE_STATE_DISCONNECTED 0x0001
  4364. #define PIPE_STATE_LISTENING 0x0002
  4365. #define PIPE_STATE_CONNECTED 0x0003
  4366. #define PIPE_STATE_CLOSING 0x0004
  4367. /* DosCreateNPipe and DosQueryNPHState state */
  4368. #define SMB_PIPE_READMODE_BYTE 0x0000
  4369. #define SMB_PIPE_READMODE_MESSAGE 0x0100
  4370. #define SMB_PIPE_TYPE_BYTE 0x0000
  4371. #define SMB_PIPE_TYPE_MESSAGE 0x0400
  4372. #define SMB_PIPE_END_CLIENT 0x0000
  4373. #define SMB_PIPE_END_SERVER 0x4000
  4374. #define SMB_PIPE_WAIT 0x0000
  4375. #define SMB_PIPE_NOWAIT 0x8000
  4376. #define SMB_PIPE_UNLIMITED_INSTANCES 0x00FF
  4377. //
  4378. // Pipe name string for conversion between SMB and NT formats.
  4379. //
  4380. #define SMB_PIPE_PREFIX "\\PIPE"
  4381. #define UNICODE_SMB_PIPE_PREFIX L"\\PIPE"
  4382. #define CANONICAL_PIPE_PREFIX "PIPE\\"
  4383. #define NT_PIPE_PREFIX L"\\Device\\NamedPipe"
  4384. #define SMB_PIPE_PREFIX_LENGTH (sizeof(SMB_PIPE_PREFIX) - 1)
  4385. #define UNICODE_SMB_PIPE_PREFIX_LENGTH \
  4386. (sizeof(UNICODE_SMB_PIPE_PREFIX) - sizeof(WCHAR))
  4387. #define CANONICAL_PIPE_PREFIX_LENGTH (sizeof(CANONICAL_PIPE_PREFIX) - 1)
  4388. #define NT_PIPE_PREFIX_LENGTH (sizeof(NT_PIPE_PREFIX) - sizeof(WCHAR))
  4389. //
  4390. // Mailslot name strings.
  4391. //
  4392. #define SMB_MAILSLOT_PREFIX "\\MAILSLOT"
  4393. #define UNICODE_SMB_MAILSLOT_PREFIX L"\\MAILSLOT"
  4394. #define SMB_MAILSLOT_PREFIX_LENGTH (sizeof(SMB_MAILSLOT_PREFIX) - 1)
  4395. #define UNICODE_SMB_MAILSLOT_PREFIX_LENGTH \
  4396. (sizeof(UNICODE_SMB_MAILSLOT_PREFIX) - sizeof(WCHAR))
  4397. //
  4398. // NT Transaction subfunctions
  4399. //
  4400. #ifdef INCLUDE_SMB_OPEN_CLOSE
  4401. typedef struct _REQ_CREATE_WITH_SD_OR_EA {
  4402. _ULONG( Flags ); // Creation flags
  4403. _ULONG( RootDirectoryFid ); // Optional directory for relative open
  4404. ACCESS_MASK DesiredAccess; // Desired access (NT format)
  4405. LARGE_INTEGER AllocationSize; // The initial allocation size in bytes
  4406. _ULONG( FileAttributes ); // The file attributes
  4407. _ULONG( ShareAccess ); // The share access
  4408. _ULONG( CreateDisposition ); // Action to take if file exists or not
  4409. _ULONG( CreateOptions ); // Options for creating a new file
  4410. _ULONG( SecurityDescriptorLength );// Length of SD in bytes
  4411. _ULONG( EaLength ); // Length of EA in bytes
  4412. _ULONG( NameLength ); // Length of name in characters
  4413. _ULONG( ImpersonationLevel ); // Security QOS information
  4414. UCHAR SecurityFlags; // Security QOS information
  4415. UCHAR Buffer[1];
  4416. //UCHAR Name[]; // The name of the file (not NUL terminated)
  4417. } REQ_CREATE_WITH_SD_OR_EA;
  4418. typedef REQ_CREATE_WITH_SD_OR_EA SMB_UNALIGNED *PREQ_CREATE_WITH_SD_OR_EA;
  4419. //
  4420. // Data format:
  4421. // UCHAR SecurityDesciptor[];
  4422. // UCHAR Pad1[]; // Pad to LONG
  4423. // UCHAR EaList[];
  4424. //
  4425. typedef struct _RESP_CREATE_WITH_SD_OR_EA {
  4426. UCHAR OplockLevel; // The oplock level granted
  4427. UCHAR Reserved;
  4428. _USHORT( Fid ); // The file ID
  4429. _ULONG( CreateAction ); // The action taken
  4430. _ULONG( EaErrorOffset ); // Offset of the EA error
  4431. TIME CreationTime; // The time the file was created
  4432. TIME LastAccessTime; // The time the file was accessed
  4433. TIME LastWriteTime; // The time the file was last written
  4434. TIME ChangeTime; // The time the file was last changed
  4435. _ULONG( FileAttributes ); // The file attributes
  4436. LARGE_INTEGER AllocationSize; // The number of byes allocated
  4437. LARGE_INTEGER EndOfFile; // The end of file offset
  4438. _USHORT( FileType );
  4439. _USHORT( DeviceState ); // state of IPC device (e.g. pipe)
  4440. BOOLEAN Directory; // TRUE if this is a directory
  4441. } RESP_CREATE_WITH_SD_OR_EA;
  4442. typedef RESP_CREATE_WITH_SD_OR_EA SMB_UNALIGNED *PRESP_CREATE_WITH_SD_OR_EA;
  4443. // No data bytes for the response
  4444. #endif // INCLUDE_SMB_OPEN_CLOSE
  4445. //
  4446. // Setup words for NT I/O control request
  4447. //
  4448. typedef struct _REQ_NT_IO_CONTROL {
  4449. _ULONG( FunctionCode );
  4450. _USHORT( Fid );
  4451. BOOLEAN IsFsctl;
  4452. UCHAR IsFlags;
  4453. } REQ_NT_IO_CONTROL;
  4454. typedef REQ_NT_IO_CONTROL SMB_UNALIGNED *PREQ_NT_IO_CONTROL;
  4455. //
  4456. // Request parameter bytes - The first buffer
  4457. // Request data bytes - The second buffer
  4458. //
  4459. //
  4460. // NT I/O Control response:
  4461. //
  4462. // Setup Words: None.
  4463. // Parameter Bytes: First buffer.
  4464. // Data Bytes: Second buffer.
  4465. //
  4466. //
  4467. // NT Notify directory change
  4468. //
  4469. // Request Setup Words
  4470. typedef struct _REQ_NOTIFY_CHANGE {
  4471. _ULONG( CompletionFilter ); // Specifies operation to monitor
  4472. _USHORT( Fid ); // Fid of directory to monitor
  4473. BOOLEAN WatchTree; // TRUE = watch all subdirectories too
  4474. UCHAR Reserved; // MBZ
  4475. } REQ_NOTIFY_CHANGE;
  4476. typedef REQ_NOTIFY_CHANGE SMB_UNALIGNED *PREQ_NOTIFY_CHANGE;
  4477. //
  4478. // Request parameter bytes: None
  4479. // Request data bytes: None
  4480. //
  4481. //
  4482. // NT Notify directory change response
  4483. //
  4484. // Setup words: None.
  4485. // Parameter bytes: The change data buffer.
  4486. // Data bytes: None.
  4487. //
  4488. //
  4489. // NT Set Security Descriptor request
  4490. //
  4491. // Setup words: REQ_SET_SECURITY_DESCIPTOR.
  4492. // Parameter Bytes: None.
  4493. // Data Bytes: The Security Descriptor data.
  4494. //
  4495. typedef struct _REQ_SET_SECURITY_DESCRIPTOR {
  4496. _USHORT( Fid ); // FID of target
  4497. _USHORT( Reserved ); // MBZ
  4498. _ULONG( SecurityInformation ); // Fields of SD that to set
  4499. } REQ_SET_SECURITY_DESCRIPTOR;
  4500. typedef REQ_SET_SECURITY_DESCRIPTOR SMB_UNALIGNED *PREQ_SET_SECURITY_DESCRIPTOR;
  4501. //
  4502. // NT Set Security Desciptor response
  4503. //
  4504. // Setup words: None.
  4505. // Parameter Bytes: None.
  4506. // Data Bytes: None.
  4507. //
  4508. //
  4509. // NT Query Security Descriptor request
  4510. //
  4511. // Setup words: None.
  4512. // Parameter Bytes: REQ_QUERY_SECURITY_DESCRIPTOR.
  4513. // Data Bytes: None.
  4514. //
  4515. typedef struct _REQ_QUERY_SECURITY_DESCRIPTOR {
  4516. _USHORT( Fid ); // FID of target
  4517. _USHORT( Reserved ); // MBZ
  4518. _ULONG( SecurityInformation ); // Fields of SD that to query
  4519. } REQ_QUERY_SECURITY_DESCRIPTOR;
  4520. typedef REQ_QUERY_SECURITY_DESCRIPTOR SMB_UNALIGNED *PREQ_QUERY_SECURITY_DESCRIPTOR;
  4521. //
  4522. // NT Query Security Desciptor response
  4523. //
  4524. // Parameter bytes: RESP_QUERY_SECURITY_DESCRIPTOR
  4525. // Data Bytes: The Security Descriptor data.
  4526. //
  4527. typedef struct _RESP_QUERY_SECURITY_DESCRIPTOR {
  4528. _ULONG( LengthNeeded ); // Size of data buffer required for SD
  4529. } RESP_QUERY_SECURITY_DESCRIPTOR;
  4530. typedef RESP_QUERY_SECURITY_DESCRIPTOR SMB_UNALIGNED *PRESP_QUERY_SECURITY_DESCRIPTOR;
  4531. //
  4532. // NT Rename file
  4533. //
  4534. // Setup words: None
  4535. // Parameters bytes: REQ_NT_RENAME
  4536. // Data bytes: None
  4537. //
  4538. typedef struct _REQ_NT_RENAME {
  4539. _USHORT( Fid ); // FID of file to rename
  4540. _USHORT( RenameFlags ); // defined below
  4541. UCHAR NewName[]; // New file name.
  4542. } REQ_NT_RENAME;
  4543. typedef REQ_NT_RENAME SMB_UNALIGNED *PREQ_NT_RENAME;
  4544. //
  4545. // Rename flags defined
  4546. //
  4547. #define SMB_RENAME_REPLACE_IF_EXISTS 1
  4548. //
  4549. // Turn structure packing back off
  4550. //
  4551. #ifndef NO_PACKING
  4552. #include <packoff.h>
  4553. #endif // ndef NO_PACKING
  4554. //
  4555. // The following macros store and retrieve USHORTS and ULONGS from
  4556. // potentially unaligned addresses, avoiding alignment faults. They
  4557. // would best be written as inline assembly code.
  4558. //
  4559. // The macros are designed to be used for accessing SMB fields. Such
  4560. // fields are always stored in little-endian byte order, so these macros
  4561. // do byte swapping when compiled for a big-endian machine.
  4562. //
  4563. // !!! Not yet.
  4564. //
  4565. #if !SMBDBG
  4566. #define BYTE_0_MASK 0xFF
  4567. #define BYTE_0(Value) (UCHAR)( (Value) & BYTE_0_MASK)
  4568. #define BYTE_1(Value) (UCHAR)( ((Value) >> 8) & BYTE_0_MASK)
  4569. #define BYTE_2(Value) (UCHAR)( ((Value) >> 16) & BYTE_0_MASK)
  4570. #define BYTE_3(Value) (UCHAR)( ((Value) >> 24) & BYTE_0_MASK)
  4571. #endif
  4572. //++
  4573. //
  4574. // USHORT
  4575. // SmbGetUshort (
  4576. // IN PSMB_USHORT SrcAddress
  4577. // )
  4578. //
  4579. // Routine Description:
  4580. //
  4581. // This macro retrieves a USHORT value from the possibly misaligned
  4582. // source address, avoiding alignment faults.
  4583. //
  4584. // Arguments:
  4585. //
  4586. // SrcAddress - where to retrieve USHORT value from
  4587. //
  4588. // Return Value:
  4589. //
  4590. // USHORT - the value retrieved. The target must be aligned.
  4591. //
  4592. //--
  4593. #if !SMBDBG
  4594. #if !SMBDBG1
  4595. #if SMB_USE_UNALIGNED
  4596. #define SmbGetUshort(SrcAddress) *(PSMB_USHORT)(SrcAddress)
  4597. #else
  4598. #define SmbGetUshort(SrcAddress) (USHORT)( \
  4599. ( ( (PUCHAR)(SrcAddress) )[0] ) | \
  4600. ( ( (PUCHAR)(SrcAddress) )[1] << 8 ) \
  4601. )
  4602. #endif
  4603. #else
  4604. #define SmbGetUshort(SrcAddress) (USHORT)( \
  4605. ( ( (PUCHAR)(SrcAddress ## S) )[0] ) | \
  4606. ( ( (PUCHAR)(SrcAddress ## S) )[1] << 8 ) \
  4607. )
  4608. #endif
  4609. #else
  4610. USHORT
  4611. SmbGetUshort (
  4612. IN PSMB_USHORT SrcAddress
  4613. );
  4614. #endif
  4615. //++
  4616. //
  4617. // USHORT
  4618. // SmbGetAlignedUshort (
  4619. // IN PUSHORT SrcAddress
  4620. // )
  4621. //
  4622. // Routine Description:
  4623. //
  4624. // This macro retrieves a USHORT value from the source address,
  4625. // correcting for the endian characteristics of the server if
  4626. // necessary.
  4627. //
  4628. // Arguments:
  4629. //
  4630. // SrcAddress - where to retrieve USHORT value from; must be aligned.
  4631. //
  4632. // Return Value:
  4633. //
  4634. // USHORT - the value retrieved. The target must be aligned.
  4635. //
  4636. //--
  4637. #if !SMBDBG
  4638. #if !SMBDBG1
  4639. #define SmbGetAlignedUshort(SrcAddress) *(SrcAddress)
  4640. #else
  4641. #define SmbGetAlignedUshort(SrcAddress) *(SrcAddress ## S)
  4642. #endif
  4643. #else
  4644. USHORT
  4645. SmbGetAlignedUshort (
  4646. IN PUSHORT SrcAddress
  4647. );
  4648. #endif
  4649. //++
  4650. //
  4651. // VOID
  4652. // SmbPutUshort (
  4653. // OUT PSMB_USHORT DestAddress,
  4654. // IN USHORT Value
  4655. // )
  4656. //
  4657. // Routine Description:
  4658. //
  4659. // This macro stores a USHORT value at the possibly misaligned
  4660. // destination address, avoiding alignment faults.
  4661. //
  4662. // Arguments:
  4663. //
  4664. // DestAddress - where to store USHORT value. Address may be
  4665. // misaligned.
  4666. //
  4667. // Value - USHORT to store. Value must be a constant or an aligned
  4668. // field.
  4669. //
  4670. // Return Value:
  4671. //
  4672. // None.
  4673. //
  4674. //--
  4675. #if !SMBDBG
  4676. #if !SMBDBG1
  4677. #if SMB_USE_UNALIGNED
  4678. #define SmbPutUshort(SrcAddress, Value) \
  4679. *(PSMB_USHORT)(SrcAddress) = (Value)
  4680. #else
  4681. #define SmbPutUshort(DestAddress,Value) { \
  4682. ( (PUCHAR)(DestAddress) )[0] = BYTE_0(Value); \
  4683. ( (PUCHAR)(DestAddress) )[1] = BYTE_1(Value); \
  4684. }
  4685. #endif
  4686. #else
  4687. #define SmbPutUshort(DestAddress,Value) { \
  4688. ( (PUCHAR)(DestAddress ## S) )[0] = BYTE_0(Value); \
  4689. ( (PUCHAR)(DestAddress ## S) )[1] = BYTE_1(Value); \
  4690. }
  4691. #endif
  4692. #else
  4693. VOID
  4694. SmbPutUshort (
  4695. OUT PSMB_USHORT DestAddress,
  4696. IN USHORT Value
  4697. );
  4698. #endif
  4699. //++
  4700. //
  4701. // VOID
  4702. // SmbPutAlignedUshort (
  4703. // OUT PUSHORT DestAddres,
  4704. // IN USHORT Value
  4705. // )
  4706. //
  4707. // Routine Description:
  4708. //
  4709. // This macro stores a USHORT value from the source address,
  4710. // correcting for the endian characteristics of the server if
  4711. // necessary.
  4712. //
  4713. // Arguments:
  4714. //
  4715. // DestAddress - where to store USHORT value. Address may not be
  4716. // misaligned.
  4717. //
  4718. // Value - USHORT to store. Value must be a constant or an aligned
  4719. // field.
  4720. //
  4721. // Return Value:
  4722. //
  4723. // None.
  4724. //
  4725. //--
  4726. #if !SMBDBG
  4727. #if !SMBDBG1
  4728. #define SmbPutAlignedUshort(DestAddress,Value) *(DestAddress) = (Value)
  4729. #else
  4730. #define SmbPutAlignedUshort(DestAddress,Value) *(DestAddress ## S) = (Value)
  4731. #endif
  4732. #else
  4733. VOID
  4734. SmbPutAlignedUshort (
  4735. OUT PUSHORT DestAddress,
  4736. IN USHORT Value
  4737. );
  4738. #endif
  4739. //++
  4740. //
  4741. // VOID
  4742. // SmbMoveUshort (
  4743. // OUT PSMB_USHORT DestAddress
  4744. // IN PSMB_USHORT SrcAddress
  4745. // )
  4746. //
  4747. // Routine Description:
  4748. //
  4749. // This macro moves a USHORT value from the possibly misaligned
  4750. // source address to the possibly misaligned destination address,
  4751. // avoiding alignment faults.
  4752. //
  4753. // Arguments:
  4754. //
  4755. // DestAddress - where to store USHORT value
  4756. //
  4757. // SrcAddress - where to retrieve USHORT value from
  4758. //
  4759. // Return Value:
  4760. //
  4761. // None.
  4762. //
  4763. //--
  4764. #if !SMBDBG
  4765. #if !SMBDBG1
  4766. #if SMB_USE_UNALIGNED
  4767. #define SmbMoveUshort(DestAddress, SrcAddress) \
  4768. *(PSMB_USHORT)(DestAddress) = *(PSMB_USHORT)(SrcAddress)
  4769. #else
  4770. #define SmbMoveUshort(DestAddress,SrcAddress) { \
  4771. ( (PUCHAR)(DestAddress) )[0] = ( (PUCHAR)(SrcAddress) )[0]; \
  4772. ( (PUCHAR)(DestAddress) )[1] = ( (PUCHAR)(SrcAddress) )[1]; \
  4773. }
  4774. #endif
  4775. #else
  4776. #define SmbMoveUshort(DestAddress,SrcAddress) { \
  4777. ( (PUCHAR)(DestAddress ## S) )[0] = ( (PUCHAR)(SrcAddress ## S) )[0]; \
  4778. ( (PUCHAR)(DestAddress ## S) )[1] = ( (PUCHAR)(SrcAddress ## S) )[1]; \
  4779. }
  4780. #endif
  4781. #else
  4782. VOID
  4783. SmbMoveUshort (
  4784. OUT PSMB_USHORT DestAddress,
  4785. IN PSMB_USHORT SrcAddress
  4786. );
  4787. #endif
  4788. //++
  4789. //
  4790. // ULONG
  4791. // SmbGetUlong (
  4792. // IN PSMB_ULONG SrcAddress
  4793. // )
  4794. //
  4795. // Routine Description:
  4796. //
  4797. // This macro retrieves a ULONG value from the possibly misaligned
  4798. // source address, avoiding alignment faults.
  4799. //
  4800. // Arguments:
  4801. //
  4802. // SrcAddress - where to retrieve ULONG value from
  4803. //
  4804. // Return Value:
  4805. //
  4806. // ULONG - the value retrieved. The target must be aligned.
  4807. //
  4808. //--
  4809. #if !SMBDBG
  4810. #if !SMBDBG1
  4811. #if SMB_USE_UNALIGNED
  4812. #define SmbGetUlong(SrcAddress) *(PSMB_ULONG)(SrcAddress)
  4813. #else
  4814. #define SmbGetUlong(SrcAddress) (ULONG)( \
  4815. ( ( (PUCHAR)(SrcAddress) )[0] ) | \
  4816. ( ( (PUCHAR)(SrcAddress) )[1] << 8 ) | \
  4817. ( ( (PUCHAR)(SrcAddress) )[2] << 16 ) | \
  4818. ( ( (PUCHAR)(SrcAddress) )[3] << 24 ) \
  4819. )
  4820. #endif
  4821. #else
  4822. #define SmbGetUlong(SrcAddress) (ULONG)( \
  4823. ( ( (PUCHAR)(SrcAddress ## L) )[0] ) | \
  4824. ( ( (PUCHAR)(SrcAddress ## L) )[1] << 8 ) | \
  4825. ( ( (PUCHAR)(SrcAddress ## L) )[2] << 16 ) | \
  4826. ( ( (PUCHAR)(SrcAddress ## L) )[3] << 24 ) \
  4827. )
  4828. #endif
  4829. #else
  4830. ULONG
  4831. SmbGetUlong (
  4832. IN PSMB_ULONG SrcAddress
  4833. );
  4834. #endif
  4835. //++
  4836. //
  4837. // USHORT
  4838. // SmbGetAlignedUlong (
  4839. // IN PULONG SrcAddress
  4840. // )
  4841. //
  4842. // Routine Description:
  4843. //
  4844. // This macro retrieves a ULONG value from the source address,
  4845. // correcting for the endian characteristics of the server if
  4846. // necessary.
  4847. //
  4848. // Arguments:
  4849. //
  4850. // SrcAddress - where to retrieve ULONG value from; must be aligned.
  4851. //
  4852. // Return Value:
  4853. //
  4854. // ULONG - the value retrieved. The target must be aligned.
  4855. //
  4856. //--
  4857. #if !SMBDBG
  4858. #if !SMBDBG1
  4859. #define SmbGetAlignedUlong(SrcAddress) *(SrcAddress)
  4860. #else
  4861. #define SmbGetAlignedUlong(SrcAddress) *(SrcAddress ## L)
  4862. #endif
  4863. #else
  4864. ULONG
  4865. SmbGetAlignedUlong (
  4866. IN PULONG SrcAddress
  4867. );
  4868. #endif
  4869. //++
  4870. //
  4871. // VOID
  4872. // SmbPutUlong (
  4873. // OUT PSMB_ULONG DestAddress,
  4874. // IN ULONG Value
  4875. // )
  4876. //
  4877. // Routine Description:
  4878. //
  4879. // This macro stores a ULONG value at the possibly misaligned
  4880. // destination address, avoiding alignment faults.
  4881. //
  4882. // Arguments:
  4883. //
  4884. // DestAddress - where to store ULONG value
  4885. //
  4886. // Value - ULONG to store. Value must be a constant or an aligned
  4887. // field.
  4888. //
  4889. // Return Value:
  4890. //
  4891. // None.
  4892. //
  4893. //--
  4894. #if !SMBDBG
  4895. #if !SMBDBG1
  4896. #if SMB_USE_UNALIGNED
  4897. #define SmbPutUlong(SrcAddress, Value) *(PSMB_ULONG)(SrcAddress) = Value
  4898. #else
  4899. #define SmbPutUlong(DestAddress,Value) { \
  4900. ( (PUCHAR)(DestAddress) )[0] = BYTE_0(Value); \
  4901. ( (PUCHAR)(DestAddress) )[1] = BYTE_1(Value); \
  4902. ( (PUCHAR)(DestAddress) )[2] = BYTE_2(Value); \
  4903. ( (PUCHAR)(DestAddress) )[3] = BYTE_3(Value); \
  4904. }
  4905. #endif
  4906. #else
  4907. #define SmbPutUlong(DestAddress,Value) { \
  4908. ( (PUCHAR)(DestAddress ## L) )[0] = BYTE_0(Value); \
  4909. ( (PUCHAR)(DestAddress ## L) )[1] = BYTE_1(Value); \
  4910. ( (PUCHAR)(DestAddress ## L) )[2] = BYTE_2(Value); \
  4911. ( (PUCHAR)(DestAddress ## L) )[3] = BYTE_3(Value); \
  4912. }
  4913. #endif
  4914. #else
  4915. VOID
  4916. SmbPutUlong (
  4917. OUT PSMB_ULONG DestAddress,
  4918. IN ULONG Value
  4919. );
  4920. #endif
  4921. //++
  4922. //
  4923. // VOID
  4924. // SmbPutAlignedUlong (
  4925. // OUT PULONG DestAddres,
  4926. // IN ULONG Value
  4927. // )
  4928. //
  4929. // Routine Description:
  4930. //
  4931. // This macro stores a ULONG value from the source address,
  4932. // correcting for the endian characteristics of the server if
  4933. // necessary.
  4934. //
  4935. // Arguments:
  4936. //
  4937. // DestAddress - where to store ULONG value. Address may not be
  4938. // misaligned.
  4939. //
  4940. // Value - ULONG to store. Value must be a constant or an aligned
  4941. // field.
  4942. //
  4943. // Return Value:
  4944. //
  4945. // None.
  4946. //
  4947. //--
  4948. #if !SMBDBG
  4949. #if !SMBDBG1
  4950. #define SmbPutAlignedUlong(DestAddress,Value) *(DestAddress) = (Value)
  4951. #else
  4952. #define SmbPutAlignedUlong(DestAddress,Value) *(DestAddress ## L) = (Value)
  4953. #endif
  4954. #else
  4955. VOID
  4956. SmbPutAlignedUlong (
  4957. OUT PULONG DestAddress,
  4958. IN ULONG Value
  4959. );
  4960. #endif
  4961. //++
  4962. //
  4963. // VOID
  4964. // SmbMoveUlong (
  4965. // OUT PSMB_ULONG DestAddress,
  4966. // IN PSMB_ULONG SrcAddress
  4967. // )
  4968. //
  4969. // Routine Description:
  4970. //
  4971. // This macro moves a ULONG value from the possibly misaligned
  4972. // source address to the possible misaligned destination address,
  4973. // avoiding alignment faults.
  4974. //
  4975. // Arguments:
  4976. //
  4977. // DestAddress - where to store ULONG value
  4978. //
  4979. // SrcAddress - where to retrieve ULONG value from
  4980. //
  4981. // Return Value:
  4982. //
  4983. // None.
  4984. //
  4985. //--
  4986. #if !SMBDBG
  4987. #if !SMBDBG1
  4988. #if SMB_USE_UNALIGNED
  4989. #define SmbMoveUlong(DestAddress,SrcAddress) \
  4990. *(PSMB_ULONG)(DestAddress) = *(PSMB_ULONG)(SrcAddress)
  4991. #else
  4992. #define SmbMoveUlong(DestAddress,SrcAddress) { \
  4993. ( (PUCHAR)(DestAddress) )[0] = ( (PUCHAR)(SrcAddress) )[0]; \
  4994. ( (PUCHAR)(DestAddress) )[1] = ( (PUCHAR)(SrcAddress) )[1]; \
  4995. ( (PUCHAR)(DestAddress) )[2] = ( (PUCHAR)(SrcAddress) )[2]; \
  4996. ( (PUCHAR)(DestAddress) )[3] = ( (PUCHAR)(SrcAddress) )[3]; \
  4997. }
  4998. #endif
  4999. #else
  5000. #define SmbMoveUlong(DestAddress,SrcAddress) { \
  5001. ( (PUCHAR)(DestAddress ## L) )[0] = ( (PUCHAR)(SrcAddress ## L) )[0]; \
  5002. ( (PUCHAR)(DestAddress ## L) )[1] = ( (PUCHAR)(SrcAddress ## L) )[1]; \
  5003. ( (PUCHAR)(DestAddress ## L) )[2] = ( (PUCHAR)(SrcAddress ## L) )[2]; \
  5004. ( (PUCHAR)(DestAddress ## L) )[3] = ( (PUCHAR)(SrcAddress ## L) )[3]; \
  5005. }
  5006. #endif
  5007. #else
  5008. VOID
  5009. SmbMoveUlong (
  5010. OUT PSMB_ULONG DestAddress,
  5011. IN PSMB_ULONG SrcAddress
  5012. );
  5013. #endif
  5014. //++
  5015. //
  5016. // VOID
  5017. // SmbPutDate (
  5018. // OUT PSMB_DATE DestAddress,
  5019. // IN SMB_DATE Value
  5020. // )
  5021. //
  5022. // Routine Description:
  5023. //
  5024. // This macro stores an SMB_DATE value at the possibly misaligned
  5025. // destination address, avoiding alignment faults. This macro
  5026. // is different from SmbPutUshort in order to be able to handle
  5027. // funny bitfield / big-endian interactions.
  5028. //
  5029. // Arguments:
  5030. //
  5031. // DestAddress - where to store SMB_DATE value
  5032. //
  5033. // Value - SMB_DATE to store. Value must be a constant or an
  5034. // aligned field.
  5035. //
  5036. // Return Value:
  5037. //
  5038. // None.
  5039. //
  5040. //--
  5041. #if !SMBDBG
  5042. #if SMB_USE_UNALIGNED
  5043. #define SmbPutDate(DestAddress,Value) (DestAddress)->Ushort = (Value).Ushort
  5044. #else
  5045. #define SmbPutDate(DestAddress,Value) { \
  5046. ( (PUCHAR)&(DestAddress)->Ushort )[0] = BYTE_0((Value).Ushort); \
  5047. ( (PUCHAR)&(DestAddress)->Ushort )[1] = BYTE_1((Value).Ushort); \
  5048. }
  5049. #endif
  5050. #else
  5051. VOID
  5052. SmbPutDate (
  5053. OUT PSMB_DATE DestAddress,
  5054. IN SMB_DATE Value
  5055. );
  5056. #endif
  5057. //++
  5058. //
  5059. // VOID
  5060. // SmbMoveDate (
  5061. // OUT PSMB_DATE DestAddress,
  5062. // IN PSMB_DATE SrcAddress
  5063. // )
  5064. //
  5065. // Routine Description:
  5066. //
  5067. // This macro copies an SMB_DATE value from the possibly misaligned
  5068. // source address, avoiding alignment faults. This macro is
  5069. // different from SmbGetUshort in order to be able to handle funny
  5070. // bitfield / big-endian interactions.
  5071. //
  5072. // Note that there is no SmbGetDate because of the way SMB_DATE is
  5073. // defined. It is a union containing a USHORT and a bitfield
  5074. // struct. The caller of an SmbGetDate macro would have to
  5075. // explicitly use one part of the union.
  5076. //
  5077. // Arguments:
  5078. //
  5079. // DestAddress - where to store SMB_DATE value. MUST BE ALIGNED!
  5080. //
  5081. // SrcAddress - where to retrieve SMB_DATE value from
  5082. //
  5083. // Return Value:
  5084. //
  5085. // None.
  5086. //
  5087. //--
  5088. #if !SMBDBG
  5089. #if SMB_USE_UNALIGNED
  5090. #define SmbMoveDate(DestAddress,SrcAddress) \
  5091. (DestAddress)->Ushort = (SrcAddress)->Ushort
  5092. #else
  5093. #define SmbMoveDate(DestAddress,SrcAddress) \
  5094. (DestAddress)->Ushort = \
  5095. ( ( (PUCHAR)&(SrcAddress)->Ushort )[0] ) | \
  5096. ( ( (PUCHAR)&(SrcAddress)->Ushort )[1] << 8 )
  5097. #endif
  5098. #else
  5099. VOID
  5100. SmbMoveDate (
  5101. OUT PSMB_DATE DestAddress,
  5102. IN PSMB_DATE SrcAddress
  5103. );
  5104. #endif
  5105. //++
  5106. //
  5107. // VOID
  5108. // SmbZeroDate (
  5109. // IN PSMB_DATE Date
  5110. // )
  5111. //
  5112. // Routine Description:
  5113. //
  5114. // This macro zeroes a possibly misaligned SMB_DATE field.
  5115. //
  5116. // Arguments:
  5117. //
  5118. // Date - Pointer to SMB_DATE field to zero.
  5119. //
  5120. // Return Value:
  5121. //
  5122. // None.
  5123. //
  5124. //--
  5125. #if !SMBDBG
  5126. #if SMB_USE_UNALIGNED
  5127. #define SmbZeroDate(Date) (Date)->Ushort = 0
  5128. #else
  5129. #define SmbZeroDate(Date) { \
  5130. ( (PUCHAR)&(Date)->Ushort )[0] = 0; \
  5131. ( (PUCHAR)&(Date)->Ushort )[1] = 0; \
  5132. }
  5133. #endif
  5134. #else
  5135. VOID
  5136. SmbZeroDate (
  5137. IN PSMB_DATE Date
  5138. );
  5139. #endif
  5140. //++
  5141. //
  5142. // BOOLEAN
  5143. // SmbIsDateZero (
  5144. // IN PSMB_DATE Date
  5145. // )
  5146. //
  5147. // Routine Description:
  5148. //
  5149. // This macro returns TRUE if the supplied SMB_DATE value is zero.
  5150. //
  5151. // Arguments:
  5152. //
  5153. // Date - Pointer to SMB_DATE value to check. MUST BE ALIGNED!
  5154. //
  5155. // Return Value:
  5156. //
  5157. // BOOLEAN - TRUE if Date is zero, else FALSE.
  5158. //
  5159. //--
  5160. #if !SMBDBG
  5161. #define SmbIsDateZero(Date) ( (Date)->Ushort == 0 )
  5162. #else
  5163. BOOLEAN
  5164. SmbIsDateZero (
  5165. IN PSMB_DATE Date
  5166. );
  5167. #endif
  5168. //++
  5169. //
  5170. // VOID
  5171. // SmbPutTime (
  5172. // OUT PSMB_TIME DestAddress,
  5173. // IN SMB_TIME Value
  5174. // )
  5175. //
  5176. // Routine Description:
  5177. //
  5178. // This macro stores an SMB_TIME value at the possibly misaligned
  5179. // destination address, avoiding alignment faults. This macro
  5180. // is different from SmbPutUshort in order to be able to handle
  5181. // funny bitfield / big-endian interactions.
  5182. //
  5183. // Arguments:
  5184. //
  5185. // DestAddress - where to store SMB_TIME value
  5186. //
  5187. // Value - SMB_TIME to store. Value must be a constant or an
  5188. // aligned field.
  5189. //
  5190. // Return Value:
  5191. //
  5192. // None.
  5193. //
  5194. //--
  5195. #if !SMBDBG
  5196. #if SMB_USE_UNALIGNED
  5197. #define SmbPutTime(DestAddress,Value) (DestAddress)->Ushort = (Value).Ushort
  5198. #else
  5199. #define SmbPutTime(DestAddress,Value) { \
  5200. ( (PUCHAR)&(DestAddress)->Ushort )[0] = BYTE_0((Value).Ushort); \
  5201. ( (PUCHAR)&(DestAddress)->Ushort )[1] = BYTE_1((Value).Ushort); \
  5202. }
  5203. #endif
  5204. #else
  5205. VOID
  5206. SmbPutTime (
  5207. OUT PSMB_TIME DestAddress,
  5208. IN SMB_TIME Value
  5209. );
  5210. #endif
  5211. //++
  5212. //
  5213. // VOID
  5214. // SmbMoveTime (
  5215. // OUT PSMB_TIME DestAddress,
  5216. // IN PSMB_TIME SrcAddress
  5217. // )
  5218. //
  5219. // Routine Description:
  5220. //
  5221. // This macro copies an SMB_TIME value from the possibly
  5222. // misaligned source address, avoiding alignment faults. This macro
  5223. // is different from SmbGetUshort in order to be able to handle
  5224. // funny bitfield / big-endian interactions.
  5225. //
  5226. // Note that there is no SmbGetTime because of the way SMB_TIME is
  5227. // defined. It is a union containing a USHORT and a bitfield
  5228. // struct. The caller of an SmbGetTime macro would have to
  5229. // explicitly use one part of the union.
  5230. //
  5231. // Arguments:
  5232. //
  5233. // DestAddress - where to store SMB_TIME value. MUST BE ALIGNED!
  5234. //
  5235. // SrcAddress - where to retrieve SMB_TIME value from
  5236. //
  5237. // Return Value:
  5238. //
  5239. // None.
  5240. //
  5241. //--
  5242. #if !SMBDBG
  5243. #if SMB_USE_UNALIGNED
  5244. #define SmbMoveTime(DestAddress,SrcAddress) \
  5245. (DestAddress)->Ushort = (SrcAddress)->Ushort
  5246. #else
  5247. #define SmbMoveTime(DestAddress,SrcAddress) \
  5248. (DestAddress)->Ushort = \
  5249. ( ( (PUCHAR)&(SrcAddress)->Ushort )[0] ) | \
  5250. ( ( (PUCHAR)&(SrcAddress)->Ushort )[1] << 8 )
  5251. #endif
  5252. #else
  5253. VOID
  5254. SmbMoveTime (
  5255. OUT PSMB_TIME DestAddress,
  5256. IN PSMB_TIME SrcAddress
  5257. );
  5258. #endif
  5259. //++
  5260. //
  5261. // VOID
  5262. // SmbZeroTime (
  5263. // IN PSMB_TIME Time
  5264. // )
  5265. //
  5266. // Routine Description:
  5267. //
  5268. // This macro zeroes a possibly misaligned SMB_TIME field.
  5269. //
  5270. // Arguments:
  5271. //
  5272. // Time - Pointer to SMB_TIME field to zero.
  5273. //
  5274. // Return Value:
  5275. //
  5276. // None.
  5277. //
  5278. //--
  5279. #if !SMBDBG
  5280. #if SMB_USE_UNALIGNED
  5281. #define SmbZeroTime(Time) (Time)->Ushort = 0
  5282. #else
  5283. #define SmbZeroTime(Time) { \
  5284. ( (PUCHAR)&(Time)->Ushort )[0] = 0; \
  5285. ( (PUCHAR)&(Time)->Ushort )[1] = 0; \
  5286. }
  5287. #endif
  5288. #else
  5289. VOID
  5290. SmbZeroTime (
  5291. IN PSMB_TIME Time
  5292. );
  5293. #endif
  5294. //++
  5295. //
  5296. // BOOLEAN
  5297. // SmbIsTimeZero (
  5298. // IN PSMB_TIME Time
  5299. // )
  5300. //
  5301. // Routine Description:
  5302. //
  5303. // This macro returns TRUE if the supplied SMB_TIME value is zero.
  5304. //
  5305. // Arguments:
  5306. //
  5307. // Time - Pointer to SMB_TIME value to check. Must be aligned and
  5308. // in native format!
  5309. //
  5310. // Return Value:
  5311. //
  5312. // BOOLEAN - TRUE if Time is zero, else FALSE.
  5313. //
  5314. //--
  5315. #if !SMBDBG
  5316. #define SmbIsTimeZero(Time) ( (Time)->Ushort == 0 )
  5317. #else
  5318. BOOLEAN
  5319. SmbIsTimeZero (
  5320. IN PSMB_TIME Time
  5321. );
  5322. #endif
  5323. //
  5324. //
  5325. // Define protocol names
  5326. //
  5327. //
  5328. //
  5329. // PCNET1 is the original SMB protocol (CORE).
  5330. //
  5331. #define PCNET1 "PC NETWORK PROGRAM 1.0"
  5332. //
  5333. // Some versions of the original MSNET defined this as an alternate
  5334. // to the core protocol name
  5335. //
  5336. #define PCLAN1 "PCLAN1.0"
  5337. //
  5338. // This is used for the MS-NET 1.03 product. It defines Lock&Read,
  5339. // Write&Unlock, and a special version of raw read and raw write.
  5340. //
  5341. #define MSNET103 "MICROSOFT NETWORKS 1.03"
  5342. //
  5343. // This is the DOS Lanman 1.0 specific protocol. It is equivilant
  5344. // to the LANMAN 1.0 protocol, except the server is required to
  5345. // map errors from the OS/2 error to an appropriate DOS error.
  5346. //
  5347. #define MSNET30 "MICROSOFT NETWORKS 3.0"
  5348. //
  5349. // This is the first version of the full LANMAN 1.0 protocol, defined in
  5350. // the SMB FILE SHARING PROTOCOL EXTENSIONS VERSION 2.0 document.
  5351. //
  5352. #define LANMAN10 "LANMAN1.0"
  5353. //
  5354. // This is the first version of the full LANMAN 2.0 protocol, defined in
  5355. // the SMB FILE SHARING PROTOCOL EXTENSIONS VERSION 3.0 document. Note
  5356. // that the name is an interim protocol definition. This is for
  5357. // interoperability with IBM LAN SERVER 1.2
  5358. //
  5359. #define LANMAN12 "LM1.2X002"
  5360. //
  5361. // This is the dos equivilant of the LANMAN12 protocol. It is identical
  5362. // to the LANMAN12 protocol, but the server will perform error mapping
  5363. // to appropriate DOS errors.
  5364. //
  5365. #define DOSLANMAN12 "DOS LM1.2X002" /* DOS equivalant of above. Final
  5366. * string will be "DOS LANMAN2.0" */
  5367. //
  5368. // Strings for LANMAN 2.1.
  5369. //
  5370. #define LANMAN21 "LANMAN2.1"
  5371. #define DOSLANMAN21 "DOS LANMAN2.1"
  5372. //
  5373. // !!! Do not set to final protcol string until the spec
  5374. // is cast in stone.
  5375. //
  5376. // The SMB protocol designed for NT. This has special SMBs
  5377. // which duplicate the NT semantics.
  5378. //
  5379. #define NTLANMAN "NT LM 0.12"
  5380. //
  5381. // The XENIXCORE dialect is a bit special. It is identical to core,
  5382. // except user passwords are not to be uppercased before being shipped
  5383. // to the server
  5384. //
  5385. #define XENIXCORE "XENIX CORE"
  5386. //
  5387. // Windows for Workgroups V1.0
  5388. //
  5389. #define WFW10 "Windows for Workgroups 3.1a"
  5390. #define PCNET1_SZ 22
  5391. #define PCLAN1_SZ 8
  5392. #define MSNET103_SZ 23
  5393. #define MSNET30_SZ 22
  5394. #define LANMAN10_SZ 9
  5395. #define LANMAN12_SZ 9
  5396. #define DOSLANMAN12_SZ 13
  5397. /*
  5398. * Defines and data for Negotiate Protocol
  5399. */
  5400. #define PC1 0
  5401. #define PC2 1
  5402. #define LM1 2
  5403. #define MS30 3
  5404. #define MS103 4
  5405. #define LM12 5
  5406. #define DOSLM12 6
  5407. /* Protocol indexes definition. */
  5408. #define PCLAN 1 /* PC Lan 1.0 & MS Lan 1.03 */
  5409. #define MSNT30 2 /* MS Net 3.0 redirector */
  5410. #define DOSLM20 3 /* Dos LAN Manager 2.0 */
  5411. #define LANMAN 4 /* Lanman redirector */
  5412. #define LANMAN20 5 /* Lan Manager 2.0 */
  5413. //
  5414. // Protocol specific path constraints.
  5415. //
  5416. #define MAXIMUM_PATHLEN_LANMAN12 260
  5417. #define MAXIMUM_PATHLEN_CORE 128
  5418. #define MAXIMUM_COMPONENT_LANMAN12 254
  5419. #define MAXIMUM_COMPONENT_CORE 8+1+3 // 8.3 filenames.
  5420. #endif // _CIFS_