13 #define SMB_TIME uint16
14 #define SMB_DATE uint16
46 case 0 Q_NEGPROT_0 q0;
51 USHORT DialectIndex; /* Index of selected dialect */
52 USHORT SecurityMode; /* Security mode: */
53 /* bit 0: 0 = share, 1 = user */
54 /* bit 1: 1 = use challenge/response */
56 USHORT MaxBufferSize; /* Max transmit buffer size (>= 1024) */
57 USHORT MaxMpxCount; /* Max pending multiplexed requests */
58 USHORT MaxNumberVcs; /* Max VCs between client and server */
59 USHORT RawMode; /* Raw modes supported: */
60 /* bit 0: 1 = Read Raw supported */
61 /* bit 1: 1 = Write Raw supported */
62 ULONG SessionKey; /* Unique token identifying this session */
63 SMB_TIME ServerTime; /* Current time at server */
64 SMB_DATE ServerDate; /* Current date at server */
65 USHORT ServerTimeZone; /* Current time zone at server */
66 USHORT ChallengeLength; /* Length of Challenge; MBZ if not LM2.1
67 /* dialect or later */
68 USHORT Reserved; /* MBZ */
69 USHORT ByteCount; /* Count of data bytes */
70 UCHAR Challenge[ChallengeLength]; /* The challenge */
71 STRING PrimaryDomain; /* The server's primary domain */
76 USHORT DialectIndex; /*Index of selected dialect */
77 UCHAR SecurityMode; /*Security mode: */
78 /* bit 0: 0 = share, 1 = user */
79 /* bit 1: 1 = use challenge/response */
81 /* bit 2: 1 = Security Signatures (SMB integrity */
83 /* bit 3: 1 = Security Signatures (SMB integrity */
85 USHORT MaxMpxCount; /*Max pending outstanding requests */
86 USHORT MaxNumberVcs; /*Max VCs between client and server */
87 ULONG MaxBufferSize; /*Max transmit buffer size */
88 ULONG MaxRawSize; /*Maximum raw buffer size */
89 ULONG SessionKey; /*Unique token identifying this session */
90 ULONG Capabilities; /*Server capabilities */
91 ULONG SystemTimeLow; /*System (UTC) time of the server (low). */
92 ULONG SystemTimeHigh; /*System (UTC) time of the server (high). */
93 USHORT ServerTimeZone;/*Time zone of server (minutes from UTC) */
94 UCHAR SecurityBlobLength;/*Length of SecurityBlob */
96 USHORT bcount; /*Count of data bytes */
97 /*UCHAR GUID[16]; A globally unique identifier assigned to the */
98 /* server; present only when */
99 /* CAP_EXTENDED_SECURITY is on in the */
100 /* Capabilities field. */
101 UCHAR SecurityBlob[SecurityBlobLength]; /*Opaque Security Blob associated with the */
102 /* security package if CAP_EXTENDED_SECURITY is */
103 /* on in the Capabilities field; else challenge */
104 /* for CIFS challenge/response authentication. */
105 STRING OemDomainName[+]; /*The name of the domain (in OEM chars); not */
106 /* present if CAP_EXTENDED_SECURITY is on in the */
107 /* Capabilities field */
114 case 17 R_NEGPROT_17 r17;
141 case 2 R_ULOGOFF_ANDX_2 q2;
154 case 2 Q_ULOGOFF_ANDX_2 q2;
168 uint8 password[pwlen];
173 } Q_SESSION_SETUP_ANDX_10;
187 uint8 password[pwlen];
188 uint8 upassword[upwlen];
194 } Q_SESSION_SETUP_ANDX_13;
196 typedef struct _Q_SESSION_SETUP_ANDX {
199 case 10 Q_SESSION_SETUP_ANDX_10 q10;
200 case 13 Q_SESSION_SETUP_ANDX_13 q13;
202 } Q_SESSION_SETUP_ANDX;
209 uint8 password[passlen];
214 typedef struct _Q_TCON_ANDX {
217 case 4 Q_TCON_ANDX_4 q4;
228 typedef struct _R_TCON_ANDX {
231 case 3 R_TCON_ANDX_3 q3;
243 } R_SESSION_SETUP_ANDX_10;
245 typedef struct _R_SESSION_SETUP_ANDX {
248 case 3 R_SESSION_SETUP_ANDX_10 r3;
250 } R_SESSION_SETUP_ANDX;
253 typedef struct _R_CLOSE {
260 typedef struct _Q_CLOSE {
285 case 5 R_DSKATTR_5 r5;
295 typedef struct _Q_DSKATTR {
298 case 0 Q_DSKATTR_0 q1;
314 case 2 R_LOCKING_2 r2;
318 /* XXXX must do a switch on bit 0x10 to do large locks XXXX */
319 /* LockType Flag Name Value Description */
321 #define LOCKING_ANDX_SHARED_LOCK 0x01 /* Read-only lock */
322 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02 /* Oplock break notification */
323 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04 /* Change lock type */
324 #define LOCKING_ANDX_CANCEL_LOCK 0x08 /* Cancel outstanding request */
325 #define LOCKING_ANDX_LARGE_FILES 0x10 /* Large file locking format */
328 USHORT Pid; /* PID of process "owning" lock */
329 ULONG Offset; /* Offset to bytes to [un]lock */
330 ULONG Length; /* Number of bytes to [un]lock */
331 } LOCKING_ANDX_RANGE_SHORT;
334 USHORT Pid; /* PID of process "owning" lock */
336 ULONG OffsetHigh; /* Offset to bytes to [un]lock (high) */
337 ULONG OffsetLow; /* Offset to bytes to [un]lock (low) */
338 ULONG LengthHigh; /* Number of bytes to [un]lock (high) */
339 ULONG LengthLow; /* Number of bytes to [un]lock (low) */
341 } LOCKING_ANDX_RANGE_LARGE;
343 /* typedef struct { */
344 /* union ctr[LockType&0x10] { */
345 /* case 0 LOCKING_ANDX_RANGE_SHORT ls; */
346 /* case 0x10 LOCKING_ANDX_RANGE_LARGE ll; */
348 /* } LOCKING_ANDX_RANGE; */
353 USHORT Fid; /* File handle */
354 UCHAR LockType; /* See LockType table below */
355 UCHAR OplockLevel; /* The new oplock level */
356 ULONG Timeout; /* Milliseconds to wait for unlock */
357 USHORT NumberOfUnlocks; /* Num. unlock range structs following */
358 USHORT NumberOfLocks; /* Num. lock range structs following */
360 USHORT ByteCount; /* Count of data bytes */
361 LOCKING_ANDX_RANGE_SHORT Unlocks[NumberOfUnlocks]; /* Unlock ranges */
362 LOCKING_ANDX_RANGE_SHORT Locks[NumberOfLocks]; /* Lock ranges */
366 typedef struct _Q_LOCKING {
369 case 8 Q_LOCKING_8 q8;
377 uint8 protocols[bcount];
384 case 0 R_UNLINK_0 r0;
396 typedef struct _Q_UNLINK {
399 case 1 Q_UNLINK_1 q1;
404 typedef struct _R_OPEN_ANDX{
424 typedef struct _Q_OPEN_ANDX{
444 typedef struct _R_READ_ANDX {
463 typedef struct _Q_READ_ANDX_10 {
478 typedef struct _Q_READ_ANDX_12 {
494 typedef struct _Q_READ_ANDX {
497 case 10 Q_READ_ANDX_10 q10;
498 case 12 Q_READ_ANDX_12 q12;
502 typedef struct _R_WRITE_ANDX {
515 typedef struct _Q_WRITE_ANDX_12 {
521 uint16 write_through;
532 typedef struct _Q_WRITE_ANDX_14 {
538 uint16 write_through;
550 typedef struct _Q_WRITE_ANDX {
553 case 12 Q_WRITE_ANDX_12 q12;
554 case 14 Q_WRITE_ANDX_14 q14;
560 typedef struct _Q_NTTRANS_19 {
561 UCHAR MaxSetupCount; /* Max setup words to return */
563 ULONG TotalParameterCount; /* Total parameter bytes being sent */
564 ULONG TotalDataCount; /* Total data bytes being sent */
565 ULONG MaxParameterCount; /* Max parameter bytes to return */
566 ULONG MaxDataCount; /* Max data bytes to return */
567 ULONG ParameterCount; /* Parameter bytes sent this buffer */
568 ULONG ParameterOffset; /* Offset (from header start) to */
570 ULONG DataCount; /* Data bytes sent this buffer */
571 ULONG DataOffset; /* Offset (from header start) to data */
572 UCHAR SetupCount; /* Count of setup words */
573 USHORT Function; /* The transaction function code */
575 USHORT Setup[SetupCount]; /* Setup words */
576 USHORT ByteCount; /* Count of data bytes */
578 UCHAR Parameters[ParameterCount];/* Parameter bytes */
580 UCHAR Data[DataCount]; /* Data bytes */
584 typedef struct _Q_NTTRANS {
587 case 19 Q_NTTRANS_19 q19;
591 typedef struct _R_NTTRANS_18 {
593 ULONG TotalParameterCount; /* Total parameter bytes being sent */
594 ULONG TotalDataCount; /* Total data bytes being sent */
595 ULONG ParameterCount; /* Parameter bytes sent this buffer */
596 ULONG ParameterOffset; /* Offset (from header start) to */
598 ULONG ParameterDisplacement; /* Specifies the offset from the start */
599 /* of the overall parameter block to */
600 /* the parameter bytes that are */
601 /* contained in this message */
602 ULONG DataCount; /* Data bytes sent this buffer */
603 ULONG DataOffset; /* Offset (from header start) to data */
604 ULONG DataDisplacement; /* Specifies the offset from the start */
605 /* of the overall data block to the */
606 /* data bytes that are contained in */
608 UCHAR SetupCount; /* Count of setup words */
609 USHORT Setup[SetupCount]; /* Setup words */
610 USHORT ByteCount; /* Count of data bytes */
612 UCHAR Parameters[ParameterCount]; /* Parameter bytes */
614 UCHAR Data[DataCount]; /* Data bytes */
617 typedef struct _R_NTTRANS {
620 case 18 R_NTTRANS_18 q18;
625 /*Setup[0] Transaction2 Value Description */
627 /*=============================== ===== ============================= */
629 #define TRANS2_OPEN2 0x00 /* Create file with extended attributes */
630 #define TRANS2_FIND_FIRST2 0x01 /* Begin search for files */
631 #define TRANS2_FIND_NEXT2 0x02 /* Resume search for files */
632 #define TRANS2_QUERY_FS_INFO 0x03 /* Get file system information
633 #define TRANS2_RESERVED4 0x04 /* Reserved */
634 #define TRANS2_QUERY_PATH_INFO 0x05 /* Get information about a named file or directory */
635 #define TRANS2_SET_PATH_INFO 0x06 /* Set information about a named file or directory */
636 #define TRANS2_QUERY_FILE_INFO 0x07 /* Get information about a handle */
637 #define TRANS2_SET_FILE_INFO 0x08 /* Set information by handle */
638 #define TRANS2_FSCTL 0x09 /* Not implemented by NT server */
639 #define TRANS2_IOCTL2 0x0A /* Not implemented by NT server */
640 #define TRANS2_FIND_NOTIFY_FIRST 0x0B /* Not implemented by NT server */
641 #define TRANS2_FIND_NOTIFY_NEXT 0x0C /* Not implemented by NT server */
642 #define TRANS2_CREATE_DIRECTORY 0x0D /* Create directory with extended attributes */
643 #define TRANS2_SESSION_SETUP 0x0E /* Session setup with extended security information */
644 #define TRANS2_GET_DFS_REFERRAL 0x10 /* Get a DFS referral */
645 #define TRANS2_REPORT_DFS_INCONSISTENCY 0x11 /* Report a DFS knowledge inconsistency */
648 USHORT InformationLevel; /* Level of information requested */
649 } TRANS2_QUERY_FS_INFO_STRUCT;
651 #define SMB_INFO_STANDARD 1
652 #define SMB_INFO_QUERY_EA_SIZE 2
653 #define SMB_SET_FILE_BASIC_INFO 0x101
654 #define SMB_SET_FILE_DISPOSITION_INFO 0x102
655 #define SMB_SET_FILE_ALLOCATION_INFO 0x103
656 #define SMB_SET_FILE_END_OF_FILE_INFO 0x104
661 hyper LastAccessTime;
666 } SMB_QUERY_FILE_BASIC_INFO_STRUCT;
671 LONG max_len_filename;
675 } SMB_QUERY_FS_ATTRIBUTE_INFO_STRUCT;
677 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
678 #define FILE_CASE_PRESERVED_NAMES 0x00000002
679 #define FILE_PRSISTENT_ACLS 0x00000004
680 #define FILE_FILE_COMPRESSION 0x00000008
681 #define FILE_VOLUME_QUOTAS 0x00000010
682 #define FILE_DEVICE_IS_MOUNTED 0x00000020
683 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
687 USHORT InformationLevel;
691 union ctr[InformationLevel] {
692 case 0x101 SMB_QUERY_FILE_BASIC_INFO_STRUCT t101;
695 } TRANS2_SET_FILE_INFO_STRUCT;
698 USHORT InformationLevel; /* Level of information requested */
699 ULONG Reserved; /* Must be zero */
700 STRING FileName; /* File or directory name */
701 } TRANS2_QUERY_PATH_INFO_STRUCT;
704 USHORT SearchAttributes;
707 USHORT InformationLevel;
708 ULONG SearchStorageType;
710 } TRANS2_FIND_FIRST2_STRUCT;
712 typedef struct _Q_TRANS2_15 {
713 USHORT TotalParameterCount; /* Total parameter bytes being sent */
714 USHORT TotalDataCount; /* Total data bytes being sent */
715 USHORT MaxParameterCount; /* Max parameter bytes to return */
716 USHORT MaxDataCount; /* Max data bytes to return */
717 UCHAR MaxSetupCount; /* Max setup words to return */
719 USHORT Flags; /* Additional information: */
720 /* bit 0 - also disconnect TID in TID */
723 USHORT ParameterCount; /* Parameter bytes sent this buffer */
724 USHORT ParameterOffset; /* Offset (from header start) to */
726 USHORT DataCount; /* Data bytes sent this buffer */
727 USHORT DataOffset; /* Offset (from header start) to data */
728 UCHAR SetupCount; /* Count of setup words */
729 UCHAR Reserved3; /* Reserved (pad above to word) */
730 USHORT Setup[SetupCount]; /* Setup words (# = SetupWordCount) */
731 USHORT ByteCount; /* Count of data bytes */
733 union ctr[Setup[0]] {
734 case 1 TRANS2_FIND_FIRST2_STRUCT t1;
735 case 3 TRANS2_QUERY_FS_INFO_STRUCT t3;
736 case 5 TRANS2_QUERY_PATH_INFO_STRUCT t5;
737 case 8 TRANS2_SET_FILE_INFO_STRUCT t8;
742 typedef struct _Q_TRANS2 {
745 case 15 Q_TRANS2_15 q15;
750 ULONG NextEntryOffset;
753 hyper LastAccessTime;
757 hyper AllocationSize;
758 ULONG ExtFileAttributes;
759 ULONG FileNameLength;
761 UCHAR ShortNameLength;
764 UCHAR FileName[FileNameLength];
766 } SMB_FIND_FILE_BOTH_DIRECTORY_INFO;
781 USHORT Sid; /* Search handle */
782 USHORT SearchCount; /* Number of entries returned */
783 USHORT EndOfSearch; /* Was last entry returned? */
784 USHORT EaErrorOffset; /* Offset into EA list if EA error */
785 USHORT LastNameOffset; /* Offset into data to file name of last */
786 /* entry, if server needs it to resume */
789 SMB_FIND_FILE_BOTH_DIRECTORY_INFO i104[SearchCount];
790 } R_TRANS2_FIND_FIRST2_STRUCT;
793 SMB_QUERY_FILE_BASIC_INFO_STRUCT i101;
795 } R_TRANS2_FILE_BASIC_STRUCT;
797 typedef struct _R_TRANS2_10 {
798 USHORT TotalParameterCount;/* Total parameter bytes being sent */
799 USHORT TotalDataCount; /* Total data bytes being sent */
801 USHORT ParameterCount; /* Parameter bytes sent this buffer */
802 USHORT ParameterOffset; /* Offset (from header start) to */
804 USHORT ParameterDisplacement; /* Specifies the offset from the start */
805 /* of the overall parameter block to */
806 /* the parameter bytes that are */
807 /* contained in this message */
808 USHORT DataCount; /* Data bytes sent this buffer */
809 USHORT DataOffset; /* Offset (from header start) to data */
810 USHORT DataDisplacement; /* Specifies the offset from the start */
811 /* of the overall data block to the */
812 /* data bytes that are contained in */
814 UCHAR SetupCount; /* Count of setup words */
815 UCHAR Reserved3; /* Reserved (pad above to word) */
816 USHORT Setup[SetupCount]; /* Setup words */
817 USHORT ByteCount; /* Count of data bytes */
819 union pctr[ParameterCount] {
820 case 0 R_TRANS2_P0 p0;
821 case 2 R_TRANS2_P2 p2;
822 case 10 R_TRANS2_FIND_FIRST2_STRUCT r10;
824 union dctr[DataCount] {
825 case 0 R_TRANS2_D0 d0;
826 case 0x24 R_TRANS2_FILE_BASIC_STRUCT r24;
827 case 0x14 SMB_QUERY_FS_ATTRIBUTE_INFO_STRUCT r14;
832 USHORT ByteCount; /* Count of data bytes */
835 typedef struct _R_TRANS2 {
838 case 0 R_TRANS2_0 q0;
839 case 10 R_TRANS2_10 q10;
843 typedef struct _Q_TRANS_16 {
844 USHORT TotalParameterCount; /* Total parameter bytes being sent */
845 USHORT TotalDataCount; /* Total data bytes being sent */
846 USHORT MaxParameterCount; /* Max parameter bytes to return */
847 USHORT MaxDataCount; /* Max data bytes to return */
848 UCHAR MaxSetupCount; /* Max setup words to return */
850 USHORT Flags; /* Additional information: */
851 /* bit 0 - also disconnect TID in TID */
854 USHORT ParameterCount; /* Parameter bytes sent this buffer */
855 USHORT ParameterOffset; /* Offset (from header start) to */
857 USHORT DataCount; /* Data bytes sent this buffer */
858 USHORT DataOffset; /* Offset (from header start) to data */
859 UCHAR SetupCount; /* Count of setup words */
860 UCHAR Reserved3; /* Reserved (pad above to word) */
861 USHORT Setup[SetupCount]; /* Setup words (# = SetupWordCount) */
862 USHORT ByteCount; /* Count of data bytes */
863 STRING Name; /* Must be NULL */
865 UCHAR Parameters[ParameterCount];/* Parameter bytes (# = ParameterCount) */
867 UCHAR Data[DataCount]; /* Data bytes (# = DataCount) */
871 typedef struct _Q_TRANS {
874 case 16 Q_TRANS_16 q16;
878 typedef struct _R_TRANS_10 {
879 USHORT TotalParameterCount;/* Total parameter bytes being sent */
880 USHORT TotalDataCount; /* Total data bytes being sent */
882 USHORT ParameterCount; /* Parameter bytes sent this buffer */
883 USHORT ParameterOffset; /* Offset (from header start) to */
885 USHORT ParameterDisplacement; /* Specifies the offset from the start */
886 /* of the overall parameter block to */
887 /* the parameter bytes that are */
888 /* contained in this message */
889 USHORT DataCount; /* Data bytes sent this buffer */
890 USHORT DataOffset; /* Offset (from header start) to data */
891 USHORT DataDisplacement; /* Specifies the offset from the start */
892 /* of the overall data block to the */
893 /* data bytes that are contained in */
895 UCHAR SetupCount; /* Count of setup words */
896 UCHAR Reserved3; /* Reserved (pad above to word) */
897 USHORT Setup[SetupCount]; /* Setup words */
898 USHORT ByteCount; /* Count of data bytes */
900 UCHAR Parameters[ParameterCount];/* Parameter bytes */
902 UCHAR Data[DataCount]; /* Data bytes */
905 typedef struct _R_TRANS {
908 case 10 R_TRANS_10 q10;
912 typedef struct _Q_NT_CREATE_ANDX_24 {
928 uint8 name[name_len];
930 } Q_NTCREATE_ANDX_24;
932 typedef struct _Q_NTCREATE_ANDX{
935 case 24 Q_NTCREATE_ANDX_24 q24;
958 } R_NTCREATE_ANDX_34;
960 typedef struct _R_NTCREATE_ANDX{
963 case 34 R_NTCREATE_ANDX_34 q34;
976 uint8 SecuritySignature[8];
984 typedef struct _R_SMB {
990 case 36 R_LOCKING_ANDX r36;
992 case 45 R_OPEN_ANDX r45;
993 case 46 R_READ_ANDX r46;
994 case 47 R_WRITE_ANDX r47;
995 case 50 R_TRANS2 q50;
996 case 113 R_TDIS r113;
997 case 114 R_NEGPROT r114;
998 case 115 R_SESSION_SETUP_ANDX r115;
999 case 116 R_ULOGOFF_ANDX r116;
1000 case 117 R_TCON_ANDX r117;
1001 case 128 R_DSKATTR r128;
1002 case 160 R_NTTRANS r160;
1003 case 162 R_NTCREATE_ANDX r162;
1007 typedef struct _Q_SMB {
1010 union ctr[hdr.com] {
1013 case 36 Q_LOCKING_ANDX q36;
1014 case 37 Q_TRANS q37;
1015 case 45 Q_OPEN_ANDX q45;
1016 case 46 Q_READ_ANDX q46;
1017 case 47 Q_WRITE_ANDX q47;
1018 case 50 Q_TRANS2 q50;
1019 case 113 Q_TDIS q113;
1020 case 114 Q_NEGPROT q114;
1021 case 115 Q_SESSION_SETUP_ANDX q115;
1022 case 116 Q_ULOGOFF_ANDX q116;
1023 case 117 Q_TCON_ANDX q117;
1024 case 128 Q_DSKATTR q128;
1025 case 160 Q_NTTRANS q160;
1026 case 162 Q_NTCREATE_ANDX q162;