📄 cifs.h
字号:
//
// !!! These structures are not portable--they depend on a little-endian
// machine (TwoSeconds in lowest bits, etc.)
//
typedef union _SMB_DATE {
USHORT Ushort;
struct {
USHORT Day : 5;
USHORT Month : 4;
USHORT Year : 7;
} Struct;
} SMB_DATE;
typedef SMB_DATE SMB_UNALIGNED *PSMB_DATE;
typedef union _SMB_TIME {
USHORT Ushort;
struct {
USHORT TwoSeconds : 5;
USHORT Minutes : 6;
USHORT Hours : 5;
} Struct;
} SMB_TIME;
typedef SMB_TIME SMB_UNALIGNED *PSMB_TIME;
//
// The SMB_FIND_BUFFER and SMB_FIND_BUFFER2 structures are used in the
// Transaction2 Find protocols to return files matching the requested
// specifications. They are identical except for the EaSize field
// in SMB_FIND_BUFFER2.
//
typedef struct _SMB_FIND_BUFFER {
SMB_DATE CreationDate;
SMB_TIME CreationTime;
SMB_DATE LastAccessDate;
SMB_TIME LastAccessTime;
SMB_DATE LastWriteDate;
SMB_TIME LastWriteTime;
_ULONG( DataSize );
_ULONG( AllocationSize );
_USHORT( Attributes );
UCHAR FileNameLength;
CHAR FileName[1];
} SMB_FIND_BUFFER;
typedef SMB_FIND_BUFFER SMB_UNALIGNED *PSMB_FIND_BUFFER;
typedef struct _SMB_FIND_BUFFER2 {
SMB_DATE CreationDate;
SMB_TIME CreationTime;
SMB_DATE LastAccessDate;
SMB_TIME LastAccessTime;
SMB_DATE LastWriteDate;
SMB_TIME LastWriteTime;
_ULONG( DataSize );
_ULONG( AllocationSize );
_USHORT( Attributes );
_ULONG( EaSize ); // this field intentionally misaligned!
UCHAR FileNameLength;
CHAR FileName[1];
} SMB_FIND_BUFFER2;
typedef SMB_FIND_BUFFER2 SMB_UNALIGNED *PSMB_FIND_BUFFER2;
//
// The following structures are used in OS/2 1.2 for extended attributes
// (EAs). OS/2 2.0 uses the same structures as NT. See the OS/2
// Programmer's Reference, Volume 4, Chapter 4 for more information.
//
// The FEA structure holds a single EA's name and value and is the
// equivalent ofthe NT structure FILE_FULL_EA_INFORMATION.
//
typedef struct _FEA {
UCHAR fEA;
UCHAR cbName;
_USHORT( cbValue );
} FEA;
typedef FEA SMB_UNALIGNED *PFEA;
//
// The only legal bit in fEA is FEA_NEEDEA.
//
#define FEA_NEEDEA 0x80
//
// The FEALIST structure holds the names and values of multiple EAs
// NT has no direct equivalent but rather strings together
// FILE_FULL_EA_INFORMATION structures.
//
typedef struct _FEALIST {
_ULONG( cbList );
FEA list[1];
} FEALIST;
typedef FEALIST SMB_UNALIGNED *PFEALIST;
//
// The GEA structure holds the name of a single EA. It is used to
// request the value of that EA in OS/2 API functions. The NT
// equivalent is FILE_GET_EA_INFORMATION.
//
typedef struct _GEA {
UCHAR cbName;
CHAR szName[1];
} GEA;
typedef GEA SMB_UNALIGNED *PGEA;
//
// The GEALIST structure holds the names of multiple EAs. NT has no
// direct equivalent but rather strings together FILE_GET_EA_INFORMATION
// structures.
//
typedef struct _GEALIST {
_ULONG( cbList );
GEA list[1];
} GEALIST;
typedef GEALIST SMB_UNALIGNED *PGEALIST;
//
// The EAOP structure holds EA information needed by API calls. It has
// no NT equivalent.
//
typedef struct _EAOP {
PGEALIST fpGEAList;
PFEALIST fpFEAList;
ULONG oError;
} EAOP;
typedef EAOP SMB_UNALIGNED *PEAOP;
//
// FSALLOCATE contains information about a disk returned by
// SrvSmbQueryFsInfo.
//
typedef struct _FSALLOCATE {
_ULONG( idFileSystem );
_ULONG( cSectorUnit );
_ULONG( cUnit );
_ULONG( cUnitAvail );
_USHORT( cbSector );
} FSALLOCATE, *PFSALLOCATE; // *** NOT SMB_UNALIGNED!
//
// VOLUMELABEL contains information about a volume label returned by
// SrvSmbQueryFsInformation.
//
typedef struct _VOLUMELABEL {
UCHAR cch;
CHAR szVolLabel[12];
} VOLUMELABEL, *PVOLUMELABEL; // *** NOT SMB_UNALIGNED!
//
// FSINFO holds information about a volume returned by
// SrvSmbQueryFsInformation.
//
typedef struct _FSINFO {
_ULONG( ulVsn );
VOLUMELABEL vol;
} FSINFO, *PFSINFO; // *** NOT SMB_UNALIGNED!
//
// File types (returned by OpenAndX and Transact2_Open)
// FileTypeIPC is a private definition for the NT redirector and
// is not in the smb protocol.
//
typedef enum _FILE_TYPE {
FileTypeDisk = 0,
FileTypeByteModePipe = 1,
FileTypeMessageModePipe = 2,
FileTypePrinter = 3,
FileTypeCommDevice = 4,
FileTypeIPC = 0xFFFE,
FileTypeUnknown = 0xFFFF
} FILE_TYPE;
//
// Turn structure packing back off
//
#ifndef NO_PACKING
#include <packoff.h>
#endif // ndef NO_PACKING
//
// PVOID
// ALIGN_SMB_WSTR(
// IN PVOID Pointer
// )
//
// Routine description:
//
// This macro aligns the input pointer to the next 2-byte boundary.
// Used to align Unicode strings in SMBs.
//
// Arguments:
//
// Pointer - A pointer
//
// Return Value:
//
// PVOID - Pointer aligned to next 2-byte boundary.
//
#define ALIGN_SMB_WSTR( Pointer ) \
(PVOID)( ((ULONG_PTR)Pointer + 1) & ~1 )
//
// Macro to find the size of an SMB parameter block. This macro takes
// as input the type of a parameter block and a byte count. It finds
// the offset of the Buffer field, which appears at the end of all
// parameter blocks, and adds the byte count to find the total size.
// The type of the returned offset is USHORT.
//
// Note that this macro does NOT pad to a word or longword boundary.
//
#define SIZEOF_SMB_PARAMS(type,byteCount) \
(USHORT)( (ULONG_PTR)&((type *)0)->Buffer[0] + (byteCount) )
//
// Macro to find the next location after an SMB parameter block. This
// macro takes as input the address of the current parameter block, its
// type, and a byte count. It finds the address of the Buffer field,
// which appears at the end of all parameter blocks, and adds the byte
// count to find the next available location. The type of the returned
// pointer is PVOID.
//
// The byte count is passed in even though it is available through
// base->ByteCount. The reason for this is that this number will be a
// compile-time constant in most cases, so the resulting code will be
// simpler and faster.
//
// !!! This macro does not round to a longword boundary when packing
// is turned off. Pre-LM 2.0 DOS redirectors cannot handle having
// too much data sent to them; the exact amount must be sent.
// We may want to make this macro such that the first location
// AFTER the returned value (WordCount field of the SMB) is aligned,
// since most of the fields are misaligned USHORTs. This would
// result in a minor performance win on the 386 and other CISC
// machines.
//
#ifndef NO_PACKING
#define NEXT_LOCATION(base,type,byteCount) \
(PVOID)( (ULONG_PTR)( (PUCHAR)( &((type *)(base))->Buffer[0] ) ) + \
(byteCount) )
#else
#define NEXT_LOCATION(base,type,byteCount) \
(PVOID)(( (ULONG_PTR)( (PUCHAR)( &((type *)(base))->Buffer[0] ) ) + \
(byteCount) + 3) & ~3)
#endif
//
// Macro to find the offset of a followon command to an and X command.
// This offset is the number of bytes from the start of the SMB header
// to where the followon command's parameters should start.
//
#define GET_ANDX_OFFSET(header,params,type,byteCount) \
(USHORT)( (PCHAR)(params) - (PCHAR)(header) + \
SIZEOF_SMB_PARAMS( type,(byteCount) ) )
//
// The following are macros to assist in converting OS/2 1.2 EAs to
// NT style and vice-versa.
//
//++
//
// ULONG
// SmbGetNtSizeOfFea (
// IN PFEA Fea
// )
//
// Routine Description:
//
// This macro gets the size that would be required to hold the FEA
// in NT format. The length is padded to account for the fact that
// each FILE_FULL_EA_INFORMATION structure must start on a
// longword boundary.
//
// Arguments:
//
// Fea - a pointer to the OS/2 1.2 FEA structure to evaluate.
//
// Return Value:
//
// ULONG - number of bytes the FEA would require in NT format.
//
//--
//
// The +1 is for the zero terminator on the name, the +3 is for padding.
//
#define SmbGetNtSizeOfFea( Fea ) \
(ULONG)(( FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]) + \
(Fea)->cbName + 1 + SmbGetUshort( &(Fea)->cbValue ) + \
3 ) & ~3 )
//++
//
// ULONG
// SmbGetNtSizeOfGea (
// IN PFEA Gea
// )
//
// Routine Description:
//
// This macro gets the size that would be required to hold the GEA
// in NT format. The length is padded to account for the fact that
// each FILE_FULL_EA_INFORMATION structure must start on a
// longword boundary.
//
// Arguments:
//
// Gea - a pointer to the OS/2 1.2 GEA structure to evaluate.
//
// Return Value:
//
// ULONG - number of bytes the GEA would require in NT format.
//
//--
//
// The +1 is for the zero terminator on the name, the +3 is for padding.
//
#define SmbGetNtSizeOfGea( Gea ) \
(ULONG)(( FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName[0]) + \
(Gea)->cbName + 1 + 3 ) & ~3 )
//++
//
// ULONG
// SmbGetOs2SizeOfNtFullEa (
// IN PFILE_FULL_EA_INFORMATION NtFullEa;
// )
//
// Routine Description:
//
// This macro gets the size a FILE_FULL_EA_INFORMATION structure would
// require to be represented in a OS/2 1.2 style FEA.
//
// Arguments:
//
// NtFullEa - a pointer to the NT FILE_FULL_EA_INFORMATION structure
// to evaluate.
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -