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

1.1.1.3   root        1: /* The source code contained in this file has been derived from the source code
                      2:    of Encryption for the Masses 2.02a by Paul Le Roux. Modifications and
                      3:    additions to that source code contained in this file are Copyright (c) 2004
1.1.1.4 ! root        4:    TrueCrypt Foundation and Copyright (c) 2004 TrueCrypt Team. Unmodified
1.1.1.3   root        5:    parts are Copyright (c) 1998-99 Paul Le Roux. This is a TrueCrypt Foundation
                      6:    release. Please see the file license.txt for full license details. */
1.1       root        7: 
                      8: /* This structure is used to start new threads */
                      9: typedef struct _THREAD_BLOCK_
                     10: {
                     11:        PDEVICE_OBJECT DeviceObject;
                     12:        NTSTATUS ntCreateStatus;
                     13:        WCHAR wszMountVolume[TC_MAX_PATH];
                     14:        MOUNT_STRUCT *mount;
                     15: } THREAD_BLOCK, *PTHREAD_BLOCK;
                     16: 
                     17: /* This structure is allocated for non-root devices! WARNING: bRootDevice
                     18:    must be the first member of the structure! */
                     19: typedef struct EXTENSION
                     20: {
                     21:        BOOL bRootDevice;       /* Is this the root device ? which the
                     22:                                   user-mode apps talk to */
                     23: 
                     24:        ULONG lMagicNumber;     /* To ensure the completion routine is not
                     25:                                   sending us bad IRP's */
                     26: 
                     27:        int nDosDriveNo;        /* Drive number this extension is mounted
                     28:                                   against */
                     29:        BOOL bShuttingDown;                     /* Is the driver shutting down ? */
                     30:        BOOL bThreadShouldQuit;         /* Instruct per device worker thread to quit */
                     31:        PETHREAD peThread;                      /* Thread handle */
                     32:        KEVENT keCreateEvent;           /* Device creation event */
                     33:        KSPIN_LOCK ListSpinLock;        /* IRP spinlock */
                     34:        LIST_ENTRY ListEntry;           /* IRP listentry */
                     35:        KSEMAPHORE RequestSemaphore;    /* IRP list request  Semaphore */
                     36: 
                     37: #ifdef USE_KERNEL_MUTEX
                     38:        KMUTEX KernelMutex;                     /* Sync. mutex for entire thread */
                     39: #endif
                     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: 
                     45:        CRYPTO_INFO *cryptoInfo;        /* Cryptographic information for this device */
                     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 */
                     53: 
                     54:        KEVENT keVolumeEvent;           /* Event structure used when setting up a device */
                     55: 
1.1.1.4 ! root       56:        BOOL bReadOnly;                         /* Is this device read-only ? */
        !            57:        BOOL bRemovable;                        /* Is this device removable media ? */
        !            58:        BOOL bRawDevice;                        /* Is this a raw-partition or raw-floppy device ? */
        !            59:        BOOL bMountManager;                     /* Mount manager knows about volume */
1.1       root       60: 
                     61:        WCHAR wszVolume[64];    /* For the tree view in the user-mode
                     62:                                   application, here we only store 64
                     63:                                   characters rather than TC_MAX_PATH to try
                     64:                                   to keep this structures size down - DONT
                     65:                                   change this size without also changing
                     66:                                   MOUNT_LIST_STRUCT! */
                     67: 
                     68:        long mountTime;         /* The time this volume was last mounted, for
                     69:                                   the user-mode application */
                     70: 
1.1.1.4 ! root       71:        // Container file date/time (used to reset date and time of file-hosted containers after dismount or unsuccessful mount attempt, to preserve plausible deniability of hidden volumes).
        !            72:        LARGE_INTEGER fileCreationTime;
        !            73:        LARGE_INTEGER fileLastAccessTime;
        !            74:        LARGE_INTEGER fileLastWriteTime;
        !            75:        LARGE_INTEGER fileLastChangeTime;
        !            76: 
1.1       root       77: } EXTENSION, *PEXTENSION;
                     78: 
                     79: /* Helper macro returning x seconds in units of 100 nanoseconds */
1.1.1.4 ! root       80: #define WAIT_SECONDS(x) ((x)*10000000)
1.1       root       81: 
                     82: /* In order to see any debug output you will need to run a checked build of
                     83:    NT */
                     84: #ifdef DEBUG
                     85: #define Dump DbgPrint
                     86: #else
                     87: #define Dump
                     88: #endif
                     89: 
                     90: /* Sync. mutex for entire driver */
                     91: extern KMUTEX driverMutex;
                     92: 
                     93: #ifdef USE_KERNEL_MUTEX
                     94: #pragma message ("Compiling " __FILE__ " with USE_KERNEL_MUTEX on")
                     95: #endif
                     96: 
1.1.1.4 ! root       97: #define FSCTL_LOCK_VOLUME               CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  6, METHOD_BUFFERED, FILE_ANY_ACCESS)
        !            98: #define FSCTL_UNLOCK_VOLUME             CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  7, METHOD_BUFFERED, FILE_ANY_ACCESS)
        !            99: #define FSCTL_DISMOUNT_VOLUME           CTL_CODE(FILE_DEVICE_FILE_SYSTEM,  8, METHOD_BUFFERED, FILE_ANY_ACCESS)
        !           100: 
1.1       root      101: /* Everything below this line is automatically updated by the -mkproto-tool- */
                    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);
                    111: void TCGetNTNameFromNumber (LPWSTR ntname, int nDriveNo);
                    112: void TCGetDosNameFromNumber (LPWSTR dosname, int nDriveNo);
                    113: LPWSTR TCTranslateCode (ULONG ulCode);
                    114: PDEVICE_OBJECT TCDeleteDeviceObject (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension);
                    115: VOID TCUnloadDriver (PDRIVER_OBJECT DriverObject);
1.1.1.4 ! root      116: NTSTATUS TCDeviceIoControl (PWSTR deviceName, ULONG IoControlCode, void *InputBuffer, int InputBufferSize, void *OutputBuffer, int OutputBufferSize);
        !           117: NTSTATUS TCOpenFsVolume (PEXTENSION Extension, PHANDLE volumeHandle, PFILE_OBJECT * fileObject);
        !           118: void TCCloseFsVolume (HANDLE volumeHandle, PFILE_OBJECT fileObject);
        !           119: NTSTATUS TCFsctlCall (PFILE_OBJECT fileObject, LONG IoControlCode, void *InputBuffer, int InputBufferSize, void *OutputBuffer, int OutputBufferSize);
        !           120: NTSTATUS MountManagerMount (MOUNT_STRUCT *mount);
        !           121: NTSTATUS MountManagerUnmount (int nDosDriveNo);
        !           122: NTSTATUS MountDevice (PDEVICE_OBJECT deviceObject, MOUNT_STRUCT *mount);
        !           123: NTSTATUS UnmountDevice (PDEVICE_OBJECT deviceObject, BOOL ignoreOpenFiles);
        !           124: NTSTATUS UnmountAllDevices (PDEVICE_OBJECT DeviceObject, BOOL ignoreOpenFiles);
        !           125: NTSTATUS SymbolicLinkToTarget (PWSTR symlinkName, PWSTR targetName, USHORT maxTargetNameLength);

unix.superglobalmegacorp.com

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