Annotation of truecrypt/driver/ntdriver.h, revision 1.1.1.23

1.1.1.10  root        1: /*
1.1.1.12  root        2:  Legal Notice: Some portions of the source code contained in this file were
                      3:  derived from the source code of Encryption for the Masses 2.02a, which is
                      4:  Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License
                      5:  Agreement for Encryption for the Masses'. Modifications and additions to
1.1.1.20  root        6:  the original source code (contained in this file) and all other portions
1.1.1.22  root        7:  of this file are Copyright (c) 2003-2011 TrueCrypt Developers Association
1.1.1.21  root        8:  and are governed by the TrueCrypt License 3.0 the full text of which is
1.1.1.20  root        9:  contained in the file License.txt included in TrueCrypt binary and source
                     10:  code distribution packages. */
1.1       root       11: 
1.1.1.12  root       12: #ifndef TC_HEADER_NTDRIVER
                     13: #define TC_HEADER_NTDRIVER
                     14: 
1.1.1.19  root       15: #include "Common.h"
1.1.1.12  root       16: #include "EncryptedIoQueue.h"
                     17: 
1.1       root       18: /* This structure is used to start new threads */
                     19: typedef struct _THREAD_BLOCK_
                     20: {
                     21:        PDEVICE_OBJECT DeviceObject;
                     22:        NTSTATUS ntCreateStatus;
1.1.1.7   root       23:        WCHAR wszMountVolume[TC_MAX_PATH + 8];
1.1       root       24:        MOUNT_STRUCT *mount;
                     25: } THREAD_BLOCK, *PTHREAD_BLOCK;
                     26: 
1.1.1.12  root       27: 
1.1       root       28: /* This structure is allocated for non-root devices! WARNING: bRootDevice
                     29:    must be the first member of the structure! */
                     30: typedef struct EXTENSION
                     31: {
1.1.1.14  root       32:        BOOL bRootDevice;       /* Is this the root device ? which the user-mode apps talk to */
1.1.1.15  root       33:        BOOL IsVolumeDevice;
1.1.1.12  root       34:        BOOL IsDriveFilterDevice;
1.1.1.15  root       35:        BOOL IsVolumeFilterDevice;
1.1       root       36: 
1.1.1.6   root       37:        int UniqueVolumeId;
1.1.1.14  root       38:        int nDosDriveNo;        /* Drive number this extension is mounted against */
                     39: 
1.1       root       40:        BOOL bShuttingDown;                     /* Is the driver shutting down ? */
                     41:        BOOL bThreadShouldQuit;         /* Instruct per device worker thread to quit */
                     42:        PETHREAD peThread;                      /* Thread handle */
                     43:        KEVENT keCreateEvent;           /* Device creation event */
                     44:        KSPIN_LOCK ListSpinLock;        /* IRP spinlock */
                     45:        LIST_ENTRY ListEntry;           /* IRP listentry */
                     46:        KSEMAPHORE RequestSemaphore;    /* IRP list request  Semaphore */
                     47: 
                     48:        HANDLE hDeviceFile;                     /* Device handle for this device */
                     49:        PFILE_OBJECT pfoDeviceFile;     /* Device fileobject for this device */
                     50:        PDEVICE_OBJECT pFsdDevice;      /* lower level device handle */
                     51: 
1.1.1.6   root       52:        CRYPTO_INFO *cryptoInfo;        /* Cryptographic and other information for this device */
1.1       root       53: 
1.1.1.17  root       54:        __int64 HostLength;
1.1       root       55:        __int64 DiskLength;                     /* The length of the disk referred to by this device */  
                     56:        __int64 NumberOfCylinders;              /* Partition info */
                     57:        ULONG TracksPerCylinder;        /* Partition info */
                     58:        ULONG SectorsPerTrack;          /* Partition info */
                     59:        ULONG BytesPerSector;           /* Partition info */
                     60:        UCHAR PartitionType;            /* Partition info */
1.1.1.10  root       61:        
1.1.1.21  root       62:        uint32 HostBytesPerSector;
1.1       root       63: 
                     64:        KEVENT keVolumeEvent;           /* Event structure used when setting up a device */
                     65: 
1.1.1.12  root       66:        EncryptedIoQueue Queue;
1.1.1.8   root       67: 
1.1.1.4   root       68:        BOOL bReadOnly;                         /* Is this device read-only ? */
                     69:        BOOL bRemovable;                        /* Is this device removable media ? */
1.1.1.19  root       70:        BOOL PartitionInInactiveSysEncScope;
1.1.1.4   root       71:        BOOL bRawDevice;                        /* Is this a raw-partition or raw-floppy device ? */
                     72:        BOOL bMountManager;                     /* Mount manager knows about volume */
1.1.1.19  root       73:        BOOL SystemFavorite;
1.1       root       74: 
1.1.1.7   root       75:        WCHAR wszVolume[TC_MAX_PATH];   /*  DONT change this size without also changing MOUNT_LIST_STRUCT! */
1.1       root       76: 
1.1.1.4   root       77:        LARGE_INTEGER fileCreationTime;
                     78:        LARGE_INTEGER fileLastAccessTime;
                     79:        LARGE_INTEGER fileLastWriteTime;
                     80:        LARGE_INTEGER fileLastChangeTime;
1.1.1.6   root       81:        BOOL bTimeStampValid;
                     82: 
1.1.1.16  root       83:        PSID UserSid;
                     84:        BOOL SecurityClientContextValid;
                     85:        SECURITY_CLIENT_CONTEXT SecurityClientContext;
                     86: 
1.1       root       87: } EXTENSION, *PEXTENSION;
                     88: 
1.1.1.16  root       89: 
                     90: typedef enum
                     91: {
                     92:        ValidateInput,
                     93:        ValidateOutput,
                     94:        ValidateInputOutput
                     95: } ValidateIOBufferSizeType;
                     96: 
                     97: 
1.1.1.14  root       98: extern PDRIVER_OBJECT TCDriverObject;
1.1.1.23! root       99: extern PDEVICE_OBJECT RootDeviceObject;
1.1.1.12  root      100: extern BOOL DriverShuttingDown;
1.1.1.10  root      101: extern ULONG OsMajorVersion;
1.1.1.14  root      102: extern ULONG OsMinorVersion;
1.1.1.17  root      103: extern BOOL VolumeClassFilterRegistered;
1.1.1.16  root      104: extern BOOL CacheBootPassword;
1.1.1.10  root      105: 
1.1       root      106: /* Helper macro returning x seconds in units of 100 nanoseconds */
1.1.1.4   root      107: #define WAIT_SECONDS(x) ((x)*10000000)
1.1       root      108: 
                    109: NTSTATUS DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath);
1.1.1.15  root      110: NTSTATUS DriverAddDevice (PDRIVER_OBJECT driverObject, PDEVICE_OBJECT pdo);
1.1.1.12  root      111: void DumpMemory (void *memory, int size);
                    112: BOOL IsAccessibleByUser (PUNICODE_STRING objectFileName, BOOL readOnly);
                    113: NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension, PIRP Irp);
                    114: NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension, PIRP Irp);
                    115: NTSTATUS SendDeviceIoControlRequest (PDEVICE_OBJECT deviceObject, ULONG ioControlCode, void *inputBuffer, int inputBufferSize, void *outputBuffer, int outputBufferSize);
1.1       root      116: NTSTATUS TCDispatchQueueIRP (PDEVICE_OBJECT DeviceObject, PIRP Irp);
                    117: NTSTATUS TCCreateRootDeviceObject (PDRIVER_OBJECT DriverObject);
1.1.1.4   root      118: NTSTATUS TCCreateDeviceObject (PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT * ppDeviceObject, MOUNT_STRUCT * mount);
1.1.1.12  root      119: NTSTATUS TCReadDevice (PDEVICE_OBJECT deviceObject, PVOID buffer, LARGE_INTEGER offset, ULONG length);
                    120: NTSTATUS TCWriteDevice (PDEVICE_OBJECT deviceObject, PVOID buffer, LARGE_INTEGER offset, ULONG length);
                    121: NTSTATUS TCStartThread (PKSTART_ROUTINE threadProc, PVOID threadArg, PKTHREAD *kThread);
1.1.1.13  root      122: NTSTATUS TCStartThreadInProcess (PKSTART_ROUTINE threadProc, PVOID threadArg, PKTHREAD *kThread, PEPROCESS process);
1.1.1.12  root      123: NTSTATUS TCStartVolumeThread (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension, MOUNT_STRUCT * mount);
                    124: void TCStopThread (PKTHREAD kThread, PKEVENT wakeUpEvent);
                    125: void TCStopVolumeThread (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension);
                    126: VOID VolumeThreadProc (PVOID Context);
1.1.1.5   root      127: void TCSleep (int milliSeconds);
1.1       root      128: void TCGetNTNameFromNumber (LPWSTR ntname, int nDriveNo);
                    129: void TCGetDosNameFromNumber (LPWSTR dosname, int nDriveNo);
                    130: LPWSTR TCTranslateCode (ULONG ulCode);
1.1.1.22  root      131: void TCDeleteDeviceObject (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension);
1.1       root      132: VOID TCUnloadDriver (PDRIVER_OBJECT DriverObject);
1.1.1.22  root      133: void OnShutdownPending ();
1.1.1.19  root      134: NTSTATUS TCDeviceIoControl (PWSTR deviceName, ULONG IoControlCode, void *InputBuffer, ULONG InputBufferSize, void *OutputBuffer, ULONG OutputBufferSize);
1.1.1.4   root      135: NTSTATUS TCOpenFsVolume (PEXTENSION Extension, PHANDLE volumeHandle, PFILE_OBJECT * fileObject);
                    136: void TCCloseFsVolume (HANDLE volumeHandle, PFILE_OBJECT fileObject);
                    137: NTSTATUS TCFsctlCall (PFILE_OBJECT fileObject, LONG IoControlCode, void *InputBuffer, int InputBufferSize, void *OutputBuffer, int OutputBufferSize);
1.1.1.6   root      138: NTSTATUS CreateDriveLink (int nDosDriveNo);
                    139: NTSTATUS RemoveDriveLink (int nDosDriveNo);
1.1.1.4   root      140: NTSTATUS MountManagerMount (MOUNT_STRUCT *mount);
                    141: NTSTATUS MountManagerUnmount (int nDosDriveNo);
                    142: NTSTATUS MountDevice (PDEVICE_OBJECT deviceObject, MOUNT_STRUCT *mount);
1.1.1.15  root      143: NTSTATUS UnmountDevice (UNMOUNT_STRUCT *unmountRequest, PDEVICE_OBJECT deviceObject, BOOL ignoreOpenFiles);
1.1.1.22  root      144: NTSTATUS UnmountAllDevices (UNMOUNT_STRUCT *unmountRequest, BOOL ignoreOpenFiles);
1.1.1.4   root      145: NTSTATUS SymbolicLinkToTarget (PWSTR symlinkName, PWSTR targetName, USHORT maxTargetNameLength);
1.1.1.22  root      146: BOOL RootDeviceControlMutexAcquireNoWait ();
                    147: void RootDeviceControlMutexRelease ();
1.1.1.6   root      148: BOOL RegionsOverlap (unsigned __int64 start1, unsigned __int64 end1, unsigned __int64 start2, unsigned __int64 end2);
1.1.1.12  root      149: void GetIntersection (uint64 start1, uint32 length1, uint64 start2, uint64 end2, uint64 *intersectStart, uint32 *intersectLength);
                    150: NTSTATUS TCCompleteIrp (PIRP irp, NTSTATUS status, ULONG_PTR information);
                    151: NTSTATUS TCCompleteDiskIrp (PIRP irp, NTSTATUS status, ULONG_PTR information);
                    152: NTSTATUS ProbeRealDriveSize (PDEVICE_OBJECT driveDeviceObject, LARGE_INTEGER *driveSize);
1.1.1.14  root      153: BOOL UserCanAccessDriveDevice ();
1.1.1.15  root      154: size_t GetCpuCount ();
                    155: void EnsureNullTerminatedString (wchar_t *str, size_t maxSizeInBytes);
                    156: void *AllocateMemoryWithTimeout (size_t size, int retryDelay, int timeout);
                    157: BOOL IsDriveLetterAvailable (int nDosDriveNo);
                    158: NTSTATUS TCReadRegistryKey (PUNICODE_STRING keyPath, wchar_t *keyValueName, PKEY_VALUE_PARTIAL_INFORMATION *keyData);
                    159: NTSTATUS TCWriteRegistryKey (PUNICODE_STRING keyPath, wchar_t *keyValueName, ULONG keyValueType, void *valueData, ULONG valueSize);
                    160: BOOL IsVolumeClassFilterRegistered ();
1.1.1.21  root      161: NTSTATUS ReadRegistryConfigFlags (BOOL driverEntry);
1.1.1.15  root      162: NTSTATUS WriteRegistryConfigFlags (uint32 flags);
1.1.1.16  root      163: BOOL ValidateIOBufferSize (PIRP irp, size_t requiredBufferSize, ValidateIOBufferSizeType type);
                    164: NTSTATUS GetDeviceSectorSize (PDEVICE_OBJECT deviceObject, ULONG *bytesPerSector);
                    165: NTSTATUS ZeroUnreadableSectors (PDEVICE_OBJECT deviceObject, LARGE_INTEGER startOffset, ULONG size, uint64 *zeroedSectorCount);
1.1.1.17  root      166: NTSTATUS ReadDeviceSkipUnreadableSectors (PDEVICE_OBJECT deviceObject, byte *buffer, LARGE_INTEGER startOffset, ULONG size, uint64 *badSectorCount);
1.1.1.16  root      167: BOOL IsVolumeAccessibleByCurrentUser (PEXTENSION volumeDeviceExtension);
1.1.1.17  root      168: void GetElapsedTimeInit (LARGE_INTEGER *lastPerfCounter);
                    169: int64 GetElapsedTime (LARGE_INTEGER *lastPerfCounter);
1.1.1.19  root      170: BOOL IsOSAtLeast (OSVersionEnum reqMinOS);
1.1.1.12  root      171: 
1.1.1.19  root      172: #define TC_BUG_CHECK(status) KeBugCheckEx (SECURITY_SYSTEM, __LINE__, (ULONG_PTR) status, 0, 'TC')
1.1.1.12  root      173: 
                    174: #endif // TC_HEADER_NTDRIVER

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.