📄 cdstruc.h
字号:
// by ID, also for the root Fcb.
//
struct _FCB *ParentFcb;
//
// Links to the queue of Fcb's in the parent.
//
LIST_ENTRY FcbLinks;
//
// FileId for this file.
//
FILE_ID FileId;
//
// Counts on this Fcb. Cleanup count represents the number of open handles
// on this Fcb. Reference count represents the number of reasons this Fcb
// is still present. It includes file objects, children Fcb and anyone
// who wants to prevent this Fcb from going away. Cleanup count is synchronized
// with the FcbResource. The reference count is synchronized with the
// VcbMutex.
//
ULONG FcbCleanup;
ULONG FcbReference;
ULONG FcbUserReference;
//
// State flags for this Fcb.
//
ULONG FcbState;
//
// NT style attributes for the Fcb.
//
ULONG FileAttributes;
//
// CDXA attributes for this file.
//
USHORT XAAttributes;
//
// File number from the system use area.
//
UCHAR XAFileNumber;
//
// This is the thread and count for the thread which has locked this
// Fcb.
//
PVOID FcbLockThread;
ULONG FcbLockCount;
//
// Pointer to the Fcb non-paged structures.
//
PFCB_NONPAGED FcbNonpaged;
//
// Share access structure.
//
SHARE_ACCESS ShareAccess;
//
// Mcb for the on disk mapping and a single map entry.
//
CD_MCB_ENTRY McbEntry;
CD_MCB Mcb;
//
// Embed the prefix entry for the longname. Store an optional pointer
// to a prefix structure for the short name.
//
PPREFIX_ENTRY ShortNamePrefix;
PREFIX_ENTRY FileNamePrefix;
//
// Time stamp for this file.
//
LONGLONG CreationTime;
union{
ULONG FcbType;
FCB_DATA;
FCB_INDEX;
};
} FCB;
typedef FCB *PFCB;
#define FCB_STATE_INITIALIZED (0x00000001)
#define FCB_STATE_IN_FCB_TABLE (0x00000002)
#define FCB_STATE_MODE2FORM2_FILE (0x00000004)
#define FCB_STATE_MODE2_FILE (0x00000008)
#define FCB_STATE_DA_FILE (0x00000010)
//
// These file types are read as raw 2352 byte sectors
//
#define FCB_STATE_RAWSECTOR_MASK ( FCB_STATE_MODE2FORM2_FILE | \
FCB_STATE_MODE2_FILE | \
FCB_STATE_DA_FILE )
#define SIZEOF_FCB_DATA \
(FIELD_OFFSET( FCB, FcbType ) + sizeof( FCB_DATA ))
#define SIZEOF_FCB_INDEX \
(FIELD_OFFSET( FCB, FcbType ) + sizeof( FCB_INDEX ))
//
// The Ccb record is allocated for every file object
//
typedef struct _CCB {
//
// Type and size of this record (must be CDFS_NTC_CCB)
//
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
//
// Flags. Indicates flags to apply for the current open.
//
ULONG Flags;
//
// Fcb for the file being opened.
//
PFCB Fcb;
//
// We store state information in the Ccb for a directory
// enumeration on this handle.
//
//
// Offset in the directory stream to base the next enumeration.
//
ULONG CurrentDirentOffset;
CD_NAME SearchExpression;
} CCB;
typedef CCB *PCCB;
#define CCB_FLAG_OPEN_BY_ID (0x00000001)
#define CCB_FLAG_OPEN_RELATIVE_BY_ID (0x00000002)
#define CCB_FLAG_IGNORE_CASE (0x00000004)
#define CCB_FLAG_OPEN_WITH_VERSION (0x00000008)
#define CCB_FLAG_DISMOUNT_ON_CLOSE (0x00000010)
//
// Following flags refer to index enumeration.
//
#define CCB_FLAG_ENUM_NAME_EXP_HAS_WILD (0x00010000)
#define CCB_FLAG_ENUM_VERSION_EXP_HAS_WILD (0x00020000)
#define CCB_FLAG_ENUM_MATCH_ALL (0x00040000)
#define CCB_FLAG_ENUM_VERSION_MATCH_ALL (0x00080000)
#define CCB_FLAG_ENUM_RETURN_NEXT (0x00100000)
#define CCB_FLAG_ENUM_INITIALIZED (0x00200000)
#define CCB_FLAG_ENUM_NOMATCH_CONSTANT_ENTRY (0x00400000)
//
// The Irp Context record is allocated for every orginating Irp. It is
// created by the Fsd dispatch routines, and deallocated by the CdComplete
// request routine
//
typedef struct _IRP_CONTEXT {
//
// Type and size of this record (must be CDFS_NTC_IRP_CONTEXT)
//
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
//
// Originating Irp for the request.
//
PIRP Irp;
//
// Vcb for this operation. When this is NULL it means we were called
// with our filesystem device object instead of a volume device object.
// (Mount will fill this in once the Vcb is created)
//
PVCB Vcb;
//
// Exception encountered during the request. Any error raised explicitly by
// the file system will be stored here. Any other error raised by the system
// is stored here after normalizing it.
//
NTSTATUS ExceptionStatus;
ULONG RaisedAtLineFile;
//
// Flags for this request.
//
ULONG Flags;
//
// Real device object. This represents the physical device closest to the media.
//
PDEVICE_OBJECT RealDevice;
//
// Io context for a read request.
// Address of Fcb for teardown oplock in create case.
//
union {
struct _CD_IO_CONTEXT *IoContext;
PFCB *TeardownFcb;
};
//
// Top level irp context for this thread.
//
struct _IRP_CONTEXT *TopLevel;
//
// Major and minor function codes.
//
UCHAR MajorFunction;
UCHAR MinorFunction;
//
// Pointer to the top-level context if this IrpContext is responsible
// for cleaning it up.
//
struct _THREAD_CONTEXT *ThreadContext;
//
// This structure is used for posting to the Ex worker threads.
//
WORK_QUEUE_ITEM WorkQueueItem;
} IRP_CONTEXT;
typedef IRP_CONTEXT *PIRP_CONTEXT;
#define IRP_CONTEXT_FLAG_ON_STACK (0x00000001)
#define IRP_CONTEXT_FLAG_MORE_PROCESSING (0x00000002)
#define IRP_CONTEXT_FLAG_WAIT (0x00000004)
#define IRP_CONTEXT_FLAG_FORCE_POST (0x00000008)
#define IRP_CONTEXT_FLAG_TOP_LEVEL (0x00000010)
#define IRP_CONTEXT_FLAG_TOP_LEVEL_CDFS (0x00000020)
#define IRP_CONTEXT_FLAG_IN_FSP (0x00000040)
#define IRP_CONTEXT_FLAG_IN_TEARDOWN (0x00000080)
#define IRP_CONTEXT_FLAG_ALLOC_IO (0x00000100)
#define IRP_CONTEXT_FLAG_DISABLE_POPUPS (0x00000200)
#define IRP_CONTEXT_FLAG_FORCE_VERIFY (0x00000400)
//
// Flags used for create.
//
#define IRP_CONTEXT_FLAG_FULL_NAME (0x10000000)
#define IRP_CONTEXT_FLAG_TRAIL_BACKSLASH (0x20000000)
//
// The following flags need to be cleared when a request is posted.
//
#define IRP_CONTEXT_FLAGS_CLEAR_ON_POST ( \
IRP_CONTEXT_FLAG_MORE_PROCESSING | \
IRP_CONTEXT_FLAG_WAIT | \
IRP_CONTEXT_FLAG_FORCE_POST | \
IRP_CONTEXT_FLAG_TOP_LEVEL | \
IRP_CONTEXT_FLAG_TOP_LEVEL_CDFS | \
IRP_CONTEXT_FLAG_IN_FSP | \
IRP_CONTEXT_FLAG_IN_TEARDOWN | \
IRP_CONTEXT_FLAG_DISABLE_POPUPS \
)
//
// The following flags need to be cleared when a request is retried.
//
#define IRP_CONTEXT_FLAGS_CLEAR_ON_RETRY ( \
IRP_CONTEXT_FLAG_MORE_PROCESSING | \
IRP_CONTEXT_FLAG_IN_TEARDOWN | \
IRP_CONTEXT_FLAG_DISABLE_POPUPS \
)
//
// The following flags are set each time through the Fsp loop.
//
#define IRP_CONTEXT_FSP_FLAGS ( \
IRP_CONTEXT_FLAG_WAIT | \
IRP_CONTEXT_FLAG_TOP_LEVEL | \
IRP_CONTEXT_FLAG_TOP_LEVEL_CDFS | \
IRP_CONTEXT_FLAG_IN_FSP \
)
//
// Following structure is used to queue a request to the delayed close queue.
// This structure should be the minimum block allocation size.
//
typedef struct _IRP_CONTEXT_LITE {
//
// Type and size of this record (must be CDFS_NTC_IRP_CONTEXT_LITE)
//
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
//
// Fcb for the file object being closed.
//
PFCB Fcb;
//
// List entry to attach to delayed close queue.
//
LIST_ENTRY DelayedCloseLinks;
//
// User reference count for the file object being closed.
//
ULONG UserReference;
//
// Real device object. This represents the physical device closest to the media.
//
PDEVICE_OBJECT RealDevice;
} IRP_CONTEXT_LITE;
typedef IRP_CONTEXT_LITE *PIRP_CONTEXT_LITE;
//
// Context structure for asynchronous I/O calls. Most of these fields
// are actually only required for the ReadMultiple routines, but
// the caller must allocate one as a local variable anyway before knowing
// whether there are multiple requests are not. Therefore, a single
// structure is used for simplicity.
//
typedef struct _CD_IO_CONTEXT {
//
// These two fields are used for multiple run Io
//
LONG IrpCount;
PIRP MasterIrp;
NTSTATUS Status;
BOOLEAN AllocatedContext;
union {
//
// This element handles the asynchronous non-cached Io
//
struct {
PERESOURCE Resource;
ERESOURCE_THREAD ResourceThreadId;
ULONG RequestedByteCount;
};
//
// and this element handles the synchronous non-cached Io.
//
KEVENT SyncEvent;
};
} CD_IO_CONTEXT;
typedef CD_IO_CONTEXT *PCD_IO_CONTEXT;
//
// Following structure is used to track the top level request. Each Cdfs
// Fsd and Fsp entry point will examine the top level irp location in the
// thread local storage to determine if this request is top level and/or
// top level Cdfs. The top level Cdfs request will remember the previous
// value and update that location with a stack location. This location
// can be accessed by recursive Cdfs entry points.
//
typedef struct _THREAD_CONTEXT {
//
// CDFS signature. Used to confirm structure on stack is valid.
//
ULONG Cdfs;
//
// Previous value in top-level thread location. We restore this
// when done.
//
PIRP SavedTopLevelIrp;
//
// Top level Cdfs IrpContext. Initial Cdfs entry point on stack
// will store the IrpContext for the request in this stack location.
//
PIRP_CONTEXT TopLevelIrpContext;
} THREAD_CONTEXT;
typedef THREAD_CONTEXT *PTHREAD_CONTEXT;
//
// The following structure is used for enumerating the entries in the
// path table. We will always map this two sectors at a time so we don't
// have to worry about entries which span sectors. We move through
// one sector at a time though. We will unpin and remap after
// crossing a sector boundary.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -