📄 cdstruc.h
字号:
// volume mounted by the file system. They are ordered in a queue off
// of CdData.VcbQueue.
//
// The Vcb will be in several conditions during its lifespan.
//
// NotMounted - Disk is not currently mounted (i.e. removed
// from system) but cleanup and close operations are
// supported.
//
// MountInProgress - State of the Vcb from the time it is
// created until it is successfully mounted or the mount
// fails.
//
// Mounted - Volume is currently in the mounted state.
//
// Invalid - User has invalidated the volume. Only legal operations
// are cleanup and close.
//
// DismountInProgress - We have begun the process of tearing down the
// Vcb. It can be deleted when all the references to it
// have gone away.
//
typedef enum _VCB_CONDITION {
VcbNotMounted = 0,
VcbMountInProgress,
VcbMounted,
VcbInvalid,
VcbDismountInProgress
} VCB_CONDITION;
typedef struct _VCB {
//
// The type and size of this record (must be CDFS_NTC_VCB)
//
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
//
// Vpb for this volume.
//
PVPB Vpb;
//
// Device object for the driver below us.
//
PDEVICE_OBJECT TargetDeviceObject;
//
// File object used to lock the volume.
//
PFILE_OBJECT VolumeLockFileObject;
//
// Link into queue of Vcb's in the CdData structure. We will create a union with
// a LONGLONG to force the Vcb to be quad-aligned.
//
union {
LIST_ENTRY VcbLinks;
LONGLONG Alignment;
};
//
// State flags and condition for the Vcb.
//
ULONG VcbState;
VCB_CONDITION VcbCondition;
//
// Various counts for this Vcb.
//
// VcbCleanup - Open handles left on this system.
// VcbReference - Number of reasons this Vcb is still present.
// VcbUserReference - Number of user file objects still present.
//
ULONG VcbCleanup;
ULONG VcbReference;
ULONG VcbUserReference;
//
// Fcb for the Volume Dasd file, root directory and the Path Table.
//
struct _FCB *VolumeDasdFcb;
struct _FCB *RootIndexFcb;
struct _FCB *PathTableFcb;
//
// Location of current session and offset of volume descriptors.
//
ULONG BaseSector;
ULONG VdSectorOffset;
ULONG PrimaryVdSectorOffset;
//
// Following is a sector from the last non-cached read of an XA file.
// Also the cooked offset on the disk.
//
PVOID XASector;
LONGLONG XADiskOffset;
//
// Vcb resource. This is used to synchronize open/cleanup/close operations.
//
ERESOURCE VcbResource;
//
// File resource. This is used to synchronize all file operations except
// open/cleanup/close.
//
ERESOURCE FileResource;
//
// Vcb fast mutex. This is used to synchronize the fields in the Vcb
// when modified when the Vcb is not held exclusively. Included here
// are the count fields and Fcb table.
//
// We also use this to synchronize changes to the Fcb reference field.
//
FAST_MUTEX VcbMutex;
PVOID VcbLockThread;
//
// The following is used to synchronize the dir notify package.
//
PNOTIFY_SYNC NotifySync;
//
// The following is the head of a list of notify Irps.
//
LIST_ENTRY DirNotifyList;
//
// Logical block size for this volume as well constant values
// associated with the block size.
//
ULONG BlockSize;
ULONG BlockToSectorShift;
ULONG BlockToByteShift;
ULONG BlocksPerSector;
ULONG BlockMask;
ULONG BlockInverseMask;
//
// Fcb table. Synchronized with the Vcb fast mutex.
//
RTL_GENERIC_TABLE FcbTable;
//
// Volume TOC. Cache this information for quick lookup.
//
PCDROM_TOC_LARGE CdromToc;
ULONG TocLength;
ULONG TrackCount;
ULONG DiskFlags;
//
// Block factor to determine last session information.
//
ULONG BlockFactor;
//
// Media change count from device driver for bulletproof detection
// of media movement
//
ULONG MediaChangeCount;
//
// For raw reads, CDFS must obey the port maximum transfer restrictions.
//
ULONG MaximumTransferRawSectors;
ULONG MaximumPhysicalPages;
//
// Preallocated VPB for swapout, so we are not forced to consider
// must succeed pool.
//
PVPB SwapVpb;
//
// Directory block cache. Read large numbers of blocks on directory
// reads, hoping to benefit from the fact that most mastered/pressed
// discs clump metadata in one place thus allowing us to crudely
// pre-cache and reduce seeks back to directory data during app install,
// file copy etc.
//
// Note that the purpose of this is to PRE cache unread data,
// not cache already read data (since Cc already provides that), thus
// speeding initial access to the volume.
//
PUCHAR SectorCacheBuffer;
CD_SECTOR_CACHE_CHUNK SecCacheChunks[ CD_SEC_CACHE_CHUNKS];
ULONG SecCacheLRUChunkIndex;
PIRP SectorCacheIrp;
KEVENT SectorCacheEvent;
ERESOURCE SectorCacheResource;
#if DBG
ULONG SecCacheHits;
ULONG SecCacheMisses;
#endif
} VCB, *PVCB;
#define VCB_STATE_HSG (0x00000001)
#define VCB_STATE_ISO (0x00000002)
#define VCB_STATE_JOLIET (0x00000004)
#define VCB_STATE_LOCKED (0x00000010)
#define VCB_STATE_REMOVABLE_MEDIA (0x00000020)
#define VCB_STATE_CDXA (0x00000040)
#define VCB_STATE_AUDIO_DISK (0x00000080)
#define VCB_STATE_NOTIFY_REMOUNT (0x00000100)
#define VCB_STATE_VPB_NOT_ON_DEVICE (0x00000200)
//
// The Volume Device Object is an I/O system device object with a
// workqueue and an VCB record appended to the end. There are multiple
// of these records, one for every mounted volume, and are created during
// a volume mount operation. The work queue is for handling an overload
// of work requests to the volume.
//
typedef struct _VOLUME_DEVICE_OBJECT {
DEVICE_OBJECT DeviceObject;
//
// The following field tells how many requests for this volume have
// either been enqueued to ExWorker threads or are currently being
// serviced by ExWorker threads. If the number goes above
// a certain threshold, put the request on the overflow queue to be
// executed later.
//
ULONG PostedRequestCount;
//
// The following field indicates the number of IRP's waiting
// to be serviced in the overflow queue.
//
ULONG OverflowQueueCount;
//
// The following field contains the queue header of the overflow queue.
// The Overflow queue is a list of IRP's linked via the IRP's ListEntry
// field.
//
LIST_ENTRY OverflowQueue;
//
// The following spinlock protects access to all the above fields.
//
KSPIN_LOCK OverflowQueueSpinLock;
//
// This is the file system specific volume control block.
//
VCB Vcb;
} VOLUME_DEVICE_OBJECT;
typedef VOLUME_DEVICE_OBJECT *PVOLUME_DEVICE_OBJECT;
//
// The following two structures are the separate union structures for
// data and index Fcb's. The path table is actually the same structure
// as the index Fcb since it uses the first few fields.
//
typedef enum _FCB_CONDITION {
FcbGood = 1,
FcbBad,
FcbNeedsToBeVerified
} FCB_CONDITION;
typedef struct _FCB_DATA {
//
// The following field is used by the oplock module
// to maintain current oplock information.
//
OPLOCK Oplock;
//
// The following field is used by the filelock module
// to maintain current byte range locking information.
// A file lock is allocated as needed.
//
PFILE_LOCK FileLock;
} FCB_DATA;
typedef FCB_DATA *PFCB_DATA;
typedef struct _FCB_INDEX {
//
// Internal stream file.
//
PFILE_OBJECT FileObject;
//
// Offset of first entry in stream. This is for case where directory
// or path table does not begin on a sector boundary. This value is
// added to all offset values to determine the real offset.
//
ULONG StreamOffset;
//
// List of child fcbs.
//
LIST_ENTRY FcbQueue;
//
// Ordinal number for this directory. Combine this with the path table offset
// in the FileId and you have a starting point in the path table.
//
ULONG Ordinal;
//
// Children path table start. This is the offset in the path table
// for the first child of the directory. A value of zero indicates
// that we haven't found the first child yet. If there are no child
// directories we will position at a point in the path table so that
// subsequent searches will fail quickly.
//
ULONG ChildPathTableOffset;
ULONG ChildOrdinal;
//
// Root of splay trees for exact and ignore case prefix trees.
//
PRTL_SPLAY_LINKS ExactCaseRoot;
PRTL_SPLAY_LINKS IgnoreCaseRoot;
} FCB_INDEX;
typedef FCB_INDEX *PFCB_INDEX;
typedef struct _FCB_NONPAGED {
//
// Type and size of this record must be CDFS_NTC_FCB_NONPAGED
//
NODE_TYPE_CODE NodeTypeCode;
NODE_BYTE_SIZE NodeByteSize;
//
// The following field contains a record of special pointers used by
// MM and Cache to manipluate section objects. Note that the values
// are set outside of the file system. However the file system on an
// open/create will set the file object's SectionObject field to
// point to this field
//
SECTION_OBJECT_POINTERS SegmentObject;
//
// This is the resource structure for this Fcb.
//
ERESOURCE FcbResource;
//
// This is the FastMutex for this Fcb.
//
FAST_MUTEX FcbMutex;
//
// This is the mutex that is inserted into the FCB_ADVANCED_HEADER
// FastMutex field
//
FAST_MUTEX AdvancedFcbHeaderMutex;
} FCB_NONPAGED;
typedef FCB_NONPAGED *PFCB_NONPAGED;
//
// The Fcb/Dcb record corresponds to every open file and directory, and to
// every directory on an opened path.
//
typedef struct _FCB {
//
// The following field is used for fast I/O. It contains the node
// type code and size, indicates if fast I/O is possible, contains
// allocation, file, and valid data size, a resource, and call back
// pointers for FastIoRead and FastMdlRead.
//
//
// Node type codes for the Fcb must be one of the following.
//
// CDFS_NTC_FCB_PATH_TABLE
// CDFS_NTC_FCB_INDEX
// CDFS_NTC_FCB_DATA
//
//
// Common Fsrtl Header. The named header is for the fieldoff.c output. We
// use the unnamed header internally.
//
union{
FSRTL_ADVANCED_FCB_HEADER Header;
FSRTL_ADVANCED_FCB_HEADER;
};
//
// Vcb for this Fcb.
//
PVCB Vcb;
//
// Parent Fcb for this Fcb. This may be NULL if this file was opened
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -