private struct SMB { public UInt32 E_00_PacketID; public UInt16 E_01_Header; public UInt16 E_02_Epoch; public UInt32 E_03_NTStatus; public UInt16 E_04_Command; public UInt16 E_05_CreditsRequested; public UInt32 E_06_Flags; public UInt32 E_07_ChainOffset; public UInt64 E_08_CommandSequence; public UInt32 E_09_ProcessID; public UInt32 E_10_TreeID; public UInt64 E_11_SessionID; public UInt64 E_12_Signature1; public UInt64 E_13_Signature2; public UInt16 E_14_RequestLength; // remember to add 1 for Dynamic flag public UInt16 E_15_Oplock; public UInt32 E_16_Impersonate; public UInt64 E_17_CreateFlags; public UInt32 E_18_AccessMask; public UInt32 E_19_FileAttributes; public UInt32 E_20_ShareAccess; public UInt32 E_21_AccessMode; public UInt32 E_22_CreateOptions; public UInt16 E_23_FilenameOffset; public UInt16 E_24_FilenameLength; public string E_25_Name; public SMB(byte[] packet) { E_00_PacketID = BitConverter.ToUInt32(packet, 0); E_01_Header = BitConverter.ToUInt16(packet, 4); E_02_Epoch = BitConverter.ToUInt16(packet, 6); E_03_NTStatus = BitConverter.ToUInt32(packet, 8); E_04_Command = BitConverter.ToUInt16(packet, 12); E_05_CreditsRequested = BitConverter.ToUInt16(packet, 14); E_06_Flags = BitConverter.ToUInt32(packet, 16); E_07_ChainOffset = BitConverter.ToUInt32(packet, 20); E_08_CommandSequence = BitConverter.ToUInt64(packet, 24); E_09_ProcessID = BitConverter.ToUInt32(packet, 32); E_10_TreeID = BitConverter.ToUInt32(packet, 36); E_11_SessionID = BitConverter.ToUInt64(packet, 40); E_12_Signature1 = BitConverter.ToUInt64(packet, 48); E_13_Signature2 = BitConverter.ToUInt64(packet, 56); E_14_RequestLength = BitConverter.ToUInt16(packet, 64); E_15_Oplock = BitConverter.ToUInt16(packet, 66); E_16_Impersonate = BitConverter.ToUInt32(packet, 68); E_17_CreateFlags = BitConverter.ToUInt64(packet, 72); // there are 8 bytes of padding here E_18_AccessMask = BitConverter.ToUInt32(packet, 88); E_19_FileAttributes = BitConverter.ToUInt32(packet, 92); E_20_ShareAccess = BitConverter.ToUInt32(packet, 96); E_21_AccessMode = BitConverter.ToUInt32(packet, 100); E_22_CreateOptions = BitConverter.ToUInt32(packet, 104); E_23_FilenameOffset = BitConverter.ToUInt16(packet, 108); E_24_FilenameLength = BitConverter.ToUInt16(packet, 110); E_25_Name = UnicodeEncoding.Unicode.GetString(packet, E_23_FilenameOffset, E_24_FilenameLength); } }