|
|
1.1 root 1: /* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
2: This product uses components written by Paul Le Roux <[email protected]> */
3:
4: /* This structure is used to start new threads */
5: typedef struct _THREAD_BLOCK_
6: {
7: PDEVICE_OBJECT DeviceObject;
8: NTSTATUS ntCreateStatus;
9: WCHAR wszMountVolume[TC_MAX_PATH];
10: MOUNT_STRUCT *mount;
11: } THREAD_BLOCK, *PTHREAD_BLOCK;
12:
13: /* This structure is allocated for non-root devices! WARNING: bRootDevice
14: must be the first member of the structure! */
15: typedef struct EXTENSION
16: {
17: BOOL bRootDevice; /* Is this the root device ? which the
18: user-mode apps talk to */
19:
20: ULONG lMagicNumber; /* To ensure the completion routine is not
21: sending us bad IRP's */
22:
23: int nDosDriveNo; /* Drive number this extension is mounted
24: against */
25: BOOL bShuttingDown; /* Is the driver shutting down ? */
26: BOOL bThreadShouldQuit; /* Instruct per device worker thread to quit */
27: PETHREAD peThread; /* Thread handle */
28: KEVENT keCreateEvent; /* Device creation event */
29: KSPIN_LOCK ListSpinLock; /* IRP spinlock */
30: LIST_ENTRY ListEntry; /* IRP listentry */
31: KSEMAPHORE RequestSemaphore; /* IRP list request Semaphore */
32:
33: #ifdef USE_KERNEL_MUTEX
34: KMUTEX KernelMutex; /* Sync. mutex for entire thread */
35: #endif
36:
37: HANDLE hDeviceFile; /* Device handle for this device */
38: PFILE_OBJECT pfoDeviceFile; /* Device fileobject for this device */
39: PDEVICE_OBJECT pFsdDevice; /* lower level device handle */
40:
41: CRYPTO_INFO *cryptoInfo; /* Cryptographic information for this device */
42:
43: __int64 DiskLength; /* The length of the disk referred to by this device */
44: __int64 NumberOfCylinders; /* Partition info */
45: ULONG TracksPerCylinder; /* Partition info */
46: ULONG SectorsPerTrack; /* Partition info */
47: ULONG BytesPerSector; /* Partition info */
48: UCHAR PartitionType; /* Partition info */
49:
50: KEVENT keVolumeEvent; /* Event structure used when setting up a device */
51:
52: BOOL bReadOnly; /* Is this device readonly ? */
53: BOOL bRawDevice; /* Is this a raw-partition or raw-floppy device ? */
54:
55: WCHAR wszVolume[64]; /* For the tree view in the user-mode
56: application, here we only store 64
57: characters rather than TC_MAX_PATH to try
58: to keep this structures size down - DONT
59: change this size without also changing
60: MOUNT_LIST_STRUCT! */
61:
62: long mountTime; /* The time this volume was last mounted, for
63: the user-mode application */
64:
65: } EXTENSION, *PEXTENSION;
66:
67: /* Helper macro returning x seconds in units of 100 nanoseconds */
68: #define WAIT_SECONDS(x) (x*10000000)
69:
70: /* In order to see any debug output you will need to run a checked build of
71: NT */
72: #ifdef DEBUG
73: #define Dump DbgPrint
74: #else
75: #define Dump
76: #endif
77:
78: /* Sync. mutex for entire driver */
79: extern KMUTEX driverMutex;
80:
81: #ifdef USE_KERNEL_MUTEX
82: #pragma message ("Compiling " __FILE__ " with USE_KERNEL_MUTEX on")
83: #endif
84:
85: /* Everything below this line is automatically updated by the -mkproto-tool- */
86:
87: NTSTATUS DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath);
88: NTSTATUS TCDispatchQueueIRP (PDEVICE_OBJECT DeviceObject, PIRP Irp);
89: NTSTATUS TCCreateRootDeviceObject (PDRIVER_OBJECT DriverObject);
90: NTSTATUS TCCreateDeviceObject (PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT * ppDeviceObject, int nDosDriveNo);
91: NTSTATUS TCDeviceControl (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension, PIRP Irp);
92: NTSTATUS TCStartThread (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension, MOUNT_STRUCT * mount);
93: void TCStopThread (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension);
94: VOID TCThreadIRP (PVOID Context);
95: void TCGetNTNameFromNumber (LPWSTR ntname, int nDriveNo);
96: void TCGetDosNameFromNumber (LPWSTR dosname, int nDriveNo);
97: LPWSTR TCTranslateCode (ULONG ulCode);
98: PDEVICE_OBJECT TCDeleteDeviceObject (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension);
99: VOID TCUnloadDriver (PDRIVER_OBJECT DriverObject);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.