www.pudn.com > truecrypt.zip > NTDRIVER.H
/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org This product uses components written by Paul Le Roux*/ /* This structure is used to start new threads */ typedef struct _THREAD_BLOCK_ { PDEVICE_OBJECT DeviceObject; NTSTATUS ntCreateStatus; WCHAR wszMountVolume[TC_MAX_PATH]; MOUNT_STRUCT *mount; } THREAD_BLOCK, *PTHREAD_BLOCK; /* This structure is allocated for non-root devices! WARNING: bRootDevice must be the first member of the structure! */ typedef struct EXTENSION { BOOL bRootDevice; /* Is this the root device ? which the user-mode apps talk to */ ULONG lMagicNumber; /* To ensure the completion routine is not sending us bad IRP's */ int nDosDriveNo; /* Drive number this extension is mounted against */ BOOL bShuttingDown; /* Is the driver shutting down ? */ BOOL bThreadShouldQuit; /* Instruct per device worker thread to quit */ PETHREAD peThread; /* Thread handle */ KEVENT keCreateEvent; /* Device creation event */ KSPIN_LOCK ListSpinLock; /* IRP spinlock */ LIST_ENTRY ListEntry; /* IRP listentry */ KSEMAPHORE RequestSemaphore; /* IRP list request Semaphore */ #ifdef USE_KERNEL_MUTEX KMUTEX KernelMutex; /* Sync. mutex for entire thread */ #endif HANDLE hDeviceFile; /* Device handle for this device */ PFILE_OBJECT pfoDeviceFile; /* Device fileobject for this device */ PDEVICE_OBJECT pFsdDevice; /* lower level device handle */ CRYPTO_INFO *cryptoInfo; /* Cryptographic information for this device */ __int64 DiskLength; /* The length of the disk referred to by this device */ __int64 NumberOfCylinders; /* Partition info */ ULONG TracksPerCylinder; /* Partition info */ ULONG SectorsPerTrack; /* Partition info */ ULONG BytesPerSector; /* Partition info */ UCHAR PartitionType; /* Partition info */ KEVENT keVolumeEvent; /* Event structure used when setting up a device */ BOOL bReadOnly; /* Is this device readonly ? */ BOOL bRawDevice; /* Is this a raw-partition or raw-floppy device ? */ WCHAR wszVolume[64]; /* For the tree view in the user-mode application, here we only store 64 characters rather than TC_MAX_PATH to try to keep this structures size down - DONT change this size without also changing MOUNT_LIST_STRUCT! */ long mountTime; /* The time this volume was last mounted, for the user-mode application */ } EXTENSION, *PEXTENSION; /* Helper macro returning x seconds in units of 100 nanoseconds */ #define WAIT_SECONDS(x) (x*10000000) /* In order to see any debug output you will need to run a checked build of NT */ #ifdef DEBUG #define Dump DbgPrint #else #define Dump #endif /* Sync. mutex for entire driver */ extern KMUTEX driverMutex; #ifdef USE_KERNEL_MUTEX #pragma message ("Compiling " __FILE__ " with USE_KERNEL_MUTEX on") #endif /* Everything below this line is automatically updated by the -mkproto-tool- */ NTSTATUS DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath); NTSTATUS TCDispatchQueueIRP (PDEVICE_OBJECT DeviceObject, PIRP Irp); NTSTATUS TCCreateRootDeviceObject (PDRIVER_OBJECT DriverObject); NTSTATUS TCCreateDeviceObject (PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT * ppDeviceObject, int nDosDriveNo); NTSTATUS TCDeviceControl (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension, PIRP Irp); NTSTATUS TCStartThread (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension, MOUNT_STRUCT * mount); void TCStopThread (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension); VOID TCThreadIRP (PVOID Context); void TCGetNTNameFromNumber (LPWSTR ntname, int nDriveNo); void TCGetDosNameFromNumber (LPWSTR dosname, int nDriveNo); LPWSTR TCTranslateCode (ULONG ulCode); PDEVICE_OBJECT TCDeleteDeviceObject (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension); VOID TCUnloadDriver (PDRIVER_OBJECT DriverObject);