|
|
1.1.1.10 root 1: /*
2: Legal Notice: The source code contained in this file has been derived from
3: the source code of Encryption for the Masses 2.02a, which is Copyright (c)
4: Paul Le Roux and which is covered by the 'License Agreement for Encryption
5: for the Masses'. Modifications and additions to that source code contained
6: in this file are Copyright (c) TrueCrypt Foundation and are covered by the
1.1.1.11! root 7: TrueCrypt License 2.3 the full text of which is contained in the file
1.1.1.10 root 8: License.txt included in TrueCrypt binary and source code distribution
9: packages. */
1.1 root 10:
11: /* This structure is used to start new threads */
12: typedef struct _THREAD_BLOCK_
13: {
14: PDEVICE_OBJECT DeviceObject;
15: NTSTATUS ntCreateStatus;
1.1.1.7 root 16: WCHAR wszMountVolume[TC_MAX_PATH + 8];
1.1 root 17: MOUNT_STRUCT *mount;
18: } THREAD_BLOCK, *PTHREAD_BLOCK;
19:
20: /* This structure is allocated for non-root devices! WARNING: bRootDevice
21: must be the first member of the structure! */
22: typedef struct EXTENSION
23: {
24: BOOL bRootDevice; /* Is this the root device ? which the
25: user-mode apps talk to */
26:
27: ULONG lMagicNumber; /* To ensure the completion routine is not
28: sending us bad IRP's */
29:
1.1.1.6 root 30: int UniqueVolumeId;
1.1 root 31: int nDosDriveNo; /* Drive number this extension is mounted
32: against */
33: BOOL bShuttingDown; /* Is the driver shutting down ? */
34: BOOL bThreadShouldQuit; /* Instruct per device worker thread to quit */
35: PETHREAD peThread; /* Thread handle */
36: KEVENT keCreateEvent; /* Device creation event */
37: KSPIN_LOCK ListSpinLock; /* IRP spinlock */
38: LIST_ENTRY ListEntry; /* IRP listentry */
39: KSEMAPHORE RequestSemaphore; /* IRP list request Semaphore */
40:
41: HANDLE hDeviceFile; /* Device handle for this device */
42: PFILE_OBJECT pfoDeviceFile; /* Device fileobject for this device */
43: PDEVICE_OBJECT pFsdDevice; /* lower level device handle */
44:
1.1.1.6 root 45: CRYPTO_INFO *cryptoInfo; /* Cryptographic and other information for this device */
1.1 root 46:
47: __int64 DiskLength; /* The length of the disk referred to by this device */
48: __int64 NumberOfCylinders; /* Partition info */
49: ULONG TracksPerCylinder; /* Partition info */
50: ULONG SectorsPerTrack; /* Partition info */
51: ULONG BytesPerSector; /* Partition info */
52: UCHAR PartitionType; /* Partition info */
1.1.1.10 root 53:
54: int HostBytesPerSector;
1.1 root 55:
56: KEVENT keVolumeEvent; /* Event structure used when setting up a device */
57:
1.1.1.8 root 58: BOOL bSystemVolume; /* System volume is hidden from user and supports system files (paging, hibernation). */
59: BOOL bPersistentVolume; /* Persistent volume is hidden from user. */
60:
1.1.1.4 root 61: BOOL bReadOnly; /* Is this device read-only ? */
62: BOOL bRemovable; /* Is this device removable media ? */
63: BOOL bRawDevice; /* Is this a raw-partition or raw-floppy device ? */
64: BOOL bMountManager; /* Mount manager knows about volume */
1.1 root 65:
1.1.1.7 root 66: WCHAR wszVolume[TC_MAX_PATH]; /* DONT change this size without also changing MOUNT_LIST_STRUCT! */
1.1 root 67:
1.1.1.6 root 68: // Container file date/time (used to reset date and time of file-hosted volumes after dismount or unsuccessful mount attempt, to preserve plausible deniability of hidden volumes).
1.1.1.4 root 69: LARGE_INTEGER fileCreationTime;
70: LARGE_INTEGER fileLastAccessTime;
71: LARGE_INTEGER fileLastWriteTime;
72: LARGE_INTEGER fileLastChangeTime;
1.1.1.6 root 73: BOOL bTimeStampValid;
74:
75: unsigned __int64 TotalBytesRead; // Bytes read from volume
76: unsigned __int64 TotalBytesWritten; // Bytes written to volume
1.1.1.4 root 77:
1.1 root 78: } EXTENSION, *PEXTENSION;
79:
1.1.1.10 root 80: extern ULONG OsMajorVersion;
81:
1.1 root 82: /* Helper macro returning x seconds in units of 100 nanoseconds */
1.1.1.4 root 83: #define WAIT_SECONDS(x) ((x)*10000000)
1.1 root 84:
85: /* In order to see any debug output you will need to run a checked build of
86: NT */
87: #ifdef DEBUG
88: #define Dump DbgPrint
89: #else
90: #define Dump
91: #endif
92:
1.1.1.4 root 93: #define FSCTL_LOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
94: #define FSCTL_UNLOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
95: #define FSCTL_DISMOUNT_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
1.1.1.6 root 96: NTKERNELAPI NTSTATUS ObOpenObjectByPointer (IN PVOID Object, IN ULONG HandleAttributes, IN PACCESS_STATE PassedAccessState OPTIONAL, IN ACCESS_MASK DesiredAccess OPTIONAL, IN POBJECT_TYPE ObjectType OPTIONAL, IN KPROCESSOR_MODE AccessMode, OUT PHANDLE Handle);
1.1 root 97:
98: NTSTATUS DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath);
99: NTSTATUS TCDispatchQueueIRP (PDEVICE_OBJECT DeviceObject, PIRP Irp);
100: NTSTATUS TCCreateRootDeviceObject (PDRIVER_OBJECT DriverObject);
1.1.1.4 root 101: NTSTATUS TCCreateDeviceObject (PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT * ppDeviceObject, MOUNT_STRUCT * mount);
1.1 root 102: NTSTATUS TCDeviceControl (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension, PIRP Irp);
103: NTSTATUS TCStartThread (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension, MOUNT_STRUCT * mount);
104: void TCStopThread (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension);
105: VOID TCThreadIRP (PVOID Context);
1.1.1.5 root 106: void TCSleep (int milliSeconds);
1.1 root 107: void TCGetNTNameFromNumber (LPWSTR ntname, int nDriveNo);
108: void TCGetDosNameFromNumber (LPWSTR dosname, int nDriveNo);
109: LPWSTR TCTranslateCode (ULONG ulCode);
110: PDEVICE_OBJECT TCDeleteDeviceObject (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension);
111: VOID TCUnloadDriver (PDRIVER_OBJECT DriverObject);
1.1.1.4 root 112: NTSTATUS TCDeviceIoControl (PWSTR deviceName, ULONG IoControlCode, void *InputBuffer, int InputBufferSize, void *OutputBuffer, int OutputBufferSize);
113: NTSTATUS TCOpenFsVolume (PEXTENSION Extension, PHANDLE volumeHandle, PFILE_OBJECT * fileObject);
114: void TCCloseFsVolume (HANDLE volumeHandle, PFILE_OBJECT fileObject);
115: NTSTATUS TCFsctlCall (PFILE_OBJECT fileObject, LONG IoControlCode, void *InputBuffer, int InputBufferSize, void *OutputBuffer, int OutputBufferSize);
1.1.1.6 root 116: NTSTATUS CreateDriveLink (int nDosDriveNo);
117: NTSTATUS RemoveDriveLink (int nDosDriveNo);
1.1.1.4 root 118: NTSTATUS MountManagerMount (MOUNT_STRUCT *mount);
119: NTSTATUS MountManagerUnmount (int nDosDriveNo);
120: NTSTATUS MountDevice (PDEVICE_OBJECT deviceObject, MOUNT_STRUCT *mount);
121: NTSTATUS UnmountDevice (PDEVICE_OBJECT deviceObject, BOOL ignoreOpenFiles);
1.1.1.8 root 122: NTSTATUS UnmountAllDevices (PDEVICE_OBJECT DeviceObject, BOOL ignoreOpenFiles, BOOL unmountSystem, BOOL unmountPersistent);
1.1.1.4 root 123: NTSTATUS SymbolicLinkToTarget (PWSTR symlinkName, PWSTR targetName, USHORT maxTargetNameLength);
1.1.1.5 root 124: void DriverMutexWait ();
125: void DriverMutexRelease ();
1.1.1.6 root 126: BOOL RegionsOverlap (unsigned __int64 start1, unsigned __int64 end1, unsigned __int64 start2, unsigned __int64 end2);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.