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