Annotation of truecrypt/common/apidrvr.h, revision 1.1.1.15

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
                      6:  the original source code (contained in this file) and all other portions of
                      7:  this file are Copyright (c) 2003-2008 TrueCrypt Foundation and are governed
1.1.1.15! root        8:  by the TrueCrypt License 2.6 the full text of which is contained in the
1.1.1.12  root        9:  file License.txt included in TrueCrypt binary and source code distribution
1.1.1.10  root       10:  packages. */
1.1       root       11: 
1.1.1.6   root       12: #pragma once
                     13: 
                     14: #include "Tcdefs.h"
1.1.1.15! root       15: #include "Boot/Windows/BootDefs.h"
1.1.1.6   root       16: #include "Common.h"
                     17: #include "Crypto.h"
1.1.1.12  root       18: #include "Wipe.h"
1.1.1.6   root       19: 
                     20: #ifdef _WIN32
                     21: 
1.1.1.13  root       22: /* WARNING: Modifying the following values or their meanings can introduce incompatibility with previous versions. */
1.1       root       23: 
1.1.1.12  root       24: #define TC_IOCTL(CODE) (CTL_CODE (FILE_DEVICE_UNKNOWN, 0x800 + (CODE), METHOD_BUFFERED, FILE_ANY_ACCESS))
1.1       root       25: 
1.1.1.12  root       26: #define TC_IOCTL_GET_DRIVER_VERSION                                            TC_IOCTL (1)
                     27: #define TC_IOCTL_GET_BOOT_LOADER_VERSION                               TC_IOCTL (2)
                     28: #define TC_IOCTL_MOUNT_VOLUME                                                  TC_IOCTL (3)
                     29: #define TC_IOCTL_DISMOUNT_VOLUME                                               TC_IOCTL (4)
                     30: #define TC_IOCTL_DISMOUNT_ALL_VOLUMES                                  TC_IOCTL (5)
                     31: #define TC_IOCTL_GET_MOUNTED_VOLUMES                                   TC_IOCTL (6)
                     32: #define TC_IOCTL_GET_VOLUME_PROPERTIES                                 TC_IOCTL (7)
                     33: #define TC_IOCTL_GET_DEVICE_REFCOUNT                                   TC_IOCTL (8)
                     34: #define TC_IOCTL_WAS_REFERENCED_DEVICE_DELETED                 TC_IOCTL (9)
                     35: #define TC_IOCTL_IS_ANY_VOLUME_MOUNTED                                 TC_IOCTL (10)
                     36: #define TC_IOCTL_GET_PASSWORD_CACHE_STATUS                             TC_IOCTL (11)
                     37: #define TC_IOCTL_WIPE_PASSWORD_CACHE                                   TC_IOCTL (12)
                     38: #define TC_IOCTL_OPEN_TEST                                                             TC_IOCTL (13)
                     39: #define TC_IOCTL_GET_DRIVE_PARTITION_INFO                              TC_IOCTL (14)
                     40: #define TC_IOCTL_GET_DRIVE_GEOMETRY                                            TC_IOCTL (15)
                     41: #define TC_IOCTL_PROBE_REAL_DRIVE_SIZE                                 TC_IOCTL (16)
                     42: #define TC_IOCTL_GET_RESOLVED_SYMLINK                                  TC_IOCTL (17)
                     43: #define TC_IOCTL_GET_BOOT_ENCRYPTION_STATUS                            TC_IOCTL (18)
                     44: #define TC_IOCTL_BOOT_ENCRYPTION_SETUP                                 TC_IOCTL (19)
                     45: #define TC_IOCTL_ABORT_BOOT_ENCRYPTION_SETUP                   TC_IOCTL (20)
                     46: #define TC_IOCTL_GET_BOOT_ENCRYPTION_SETUP_RESULT              TC_IOCTL (21)
                     47: #define TC_IOCTL_GET_BOOT_DRIVE_VOLUME_PROPERTIES              TC_IOCTL (22)
                     48: #define TC_IOCTL_REOPEN_BOOT_VOLUME_HEADER                             TC_IOCTL (23)
1.1.1.13  root       49: #define TC_IOCTL_GET_BOOT_ENCRYPTION_ALGORITHM_NAME            TC_IOCTL (24)
                     50: #define TC_IOCTL_GET_TRAVELER_MODE_STATUS                              TC_IOCTL (25)
                     51: #define TC_IOCTL_SET_TRAVELER_MODE_STATUS                              TC_IOCTL (26)
1.1.1.14  root       52: #define TC_IOCTL_IS_HIDDEN_SYSTEM_RUNNING                              TC_IOCTL (27)
                     53: #define TC_IOCTL_GET_SYSTEM_DRIVE_CONFIG                               TC_IOCTL (28)
                     54: #define TC_IOCTL_DISK_IS_WRITABLE                                              TC_IOCTL (29)
1.1.1.15! root       55: #define TC_IOCTL_START_DECOY_SYSTEM_WIPE                               TC_IOCTL (30)
        !            56: #define TC_IOCTL_ABORT_DECOY_SYSTEM_WIPE                               TC_IOCTL (31)
        !            57: #define TC_IOCTL_GET_DECOY_SYSTEM_WIPE_STATUS                  TC_IOCTL (32)
        !            58: #define TC_IOCTL_GET_DECOY_SYSTEM_WIPE_RESULT                  TC_IOCTL (33)
        !            59: #define TC_IOCTL_WRITE_BOOT_DRIVE_SECTOR                               TC_IOCTL (34)
1.1.1.12  root       60: 
                     61: // Legacy IOCTLs used before version 5.0
                     62: #define TC_IOCTL_LEGACY_GET_DRIVER_VERSION             466968
                     63: #define TC_IOCTL_LEGACY_GET_MOUNTED_VOLUMES            466948
1.1       root       64: 
                     65: 
                     66: /* Start of driver interface structures, the size of these structures may
                     67:    change between versions; so make sure you first send DRIVER_VERSION to
                     68:    check that it's the correct device driver */
                     69: 
                     70: #pragma pack (push)
                     71: #pragma pack(1)
                     72: 
                     73: typedef struct
                     74: {
1.1.1.6   root       75:        int nReturnCode;                                        /* Return code back from driver */
1.1.1.15! root       76:        BOOL FilesystemDirty;
        !            77: 
1.1.1.6   root       78:        short wszVolume[TC_MAX_PATH];           /* Volume to be mounted */
                     79:        Password VolumePassword;                        /* User password */
                     80:        BOOL bCache;                                            /* Cache passwords in driver */
                     81:        int nDosDriveNo;                                        /* Drive number to mount */
1.1.1.10  root       82:        int BytesPerSector;
1.1.1.6   root       83:        BOOL bMountReadOnly;                            /* Mount volume in read-only mode */
                     84:        BOOL bMountRemovable;                           /* Mount volume as removable media */
                     85:        BOOL bExclusiveAccess;                          /* Open host file/device in exclusive access mode */
                     86:        BOOL bMountManager;                                     /* Announce volume to mount manager */
                     87:        BOOL bPreserveTimestamp;                        /* Preserve file container timestamp */
1.1.1.13  root       88:        BOOL bPartitionInInactiveSysEncScope;           /* If TRUE, we are to attempt to mount a partition located on an encrypted system drive without pre-boot authentication. */
                     89:        int nPartitionInInactiveSysEncScopeDriveNo;     /* If bPartitionInInactiveSysEncScope is TRUE, this contains the drive number of the system drive on which the partition is located. */
1.1.1.6   root       90:        // Hidden volume protection
                     91:        BOOL bProtectHiddenVolume;                      /* TRUE if the user wants the hidden volume within this volume to be protected against being overwritten (damaged) */
                     92:        Password ProtectedHidVolPassword;       /* Password to the hidden volume to be protected against overwriting */
1.1.1.14  root       93:        BOOL UseBackupHeader;
1.1.1.15! root       94:        BOOL RecoveryMode;
1.1       root       95: } MOUNT_STRUCT;
                     96: 
                     97: typedef struct
                     98: {
                     99:        int nDosDriveNo;        /* Drive letter to unmount */
1.1.1.4   root      100:        BOOL ignoreOpenFiles;
1.1.1.14  root      101:        BOOL HiddenVolumeProtectionTriggered;
1.1.1.4   root      102:        int nReturnCode;        /* Return code back from driver */
1.1       root      103: } UNMOUNT_STRUCT;
                    104: 
                    105: typedef struct
                    106: {
1.1.1.6   root      107:        unsigned __int32 ulMountedDrives;       /* Bitfield of all mounted drive letters */
1.1.1.7   root      108:        short wszVolume[26][TC_MAX_PATH];       /* Volume names of mounted volumes */
1.1       root      109:        unsigned __int64 diskLength[26];
1.1.1.4   root      110:        int ea[26];
1.1.1.6   root      111:        int volumeType[26];     /* Volume type (e.g. PROP_VOL_TYPE_OUTER, PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED, etc.) */
1.1       root      112: } MOUNT_LIST_STRUCT;
                    113: 
                    114: typedef struct
                    115: {
                    116:        int driveNo;
1.1.1.6   root      117:        int uniqueId;
1.1.1.7   root      118:        short wszVolume[TC_MAX_PATH];
1.1       root      119:        unsigned __int64 diskLength;
1.1.1.4   root      120:        int ea;
1.1.1.7   root      121:        int mode;
1.1       root      122:        int pkcs5;
                    123:        int pkcs5Iterations;
1.1.1.4   root      124:        BOOL hiddenVolume;
1.1.1.6   root      125:        BOOL readOnly;
1.1.1.15! root      126: #if 0
        !           127:        unsigned __int64 volumeCreationTime;    // Deprecated in v6.0
        !           128:        unsigned __int64 headerCreationTime;    // Deprecated in v6.0
        !           129: #endif
        !           130:        uint32 volumeHeaderFlags;
1.1.1.6   root      131:        unsigned __int64 totalBytesRead;
                    132:        unsigned __int64 totalBytesWritten;
                    133:        int hiddenVolProtection;        /* Hidden volume protection status (e.g. HIDVOL_PROT_STATUS_NONE, HIDVOL_PROT_STATUS_ACTIVE, etc.) */
1.1.1.14  root      134:        int volFormatVersion;
1.1       root      135: } VOLUME_PROPERTIES_STRUCT;
                    136: 
                    137: typedef struct
                    138: {
1.1.1.4   root      139:        WCHAR symLinkName[TC_MAX_PATH];
                    140:        WCHAR targetName[TC_MAX_PATH];
                    141: } RESOLVE_SYMLINK_STRUCT;
                    142: 
                    143: typedef struct
                    144: {
1.1.1.10  root      145:        WCHAR deviceName[TC_MAX_PATH];
                    146:        PARTITION_INFORMATION partInfo;
1.1.1.12  root      147:        BOOL IsGPT;
1.1.1.15! root      148:        BOOL IsDynamic;
1.1.1.10  root      149: }
                    150: DISK_PARTITION_INFO_STRUCT;
                    151: 
                    152: typedef struct
                    153: {
                    154:        WCHAR deviceName[TC_MAX_PATH];
                    155:        DISK_GEOMETRY diskGeometry;
                    156: }
                    157: DISK_GEOMETRY_STRUCT;
                    158: 
                    159: typedef struct
                    160: {
1.1.1.12  root      161:        WCHAR DeviceName[TC_MAX_PATH];
                    162:        LARGE_INTEGER RealDriveSize;
1.1.1.13  root      163:        BOOL TimeOut;
1.1.1.12  root      164: } ProbeRealDriveSizeRequest;
                    165: 
                    166: typedef struct
                    167: {
1.1.1.13  root      168:        short wszFileName[TC_MAX_PATH];         // Volume to be "open tested"
                    169:        BOOL bDetectTCBootLoader;                       // Whether the driver is to determine if the first sector contains a portion of the TrueCrypt Boot Loader
1.1       root      170: } OPEN_TEST_STRUCT;
                    171: 
                    172: 
1.1.1.12  root      173: typedef enum
                    174: {
                    175:        SetupNone = 0,
                    176:        SetupEncryption,
                    177:        SetupDecryption
                    178: } BootEncryptionSetupMode;
                    179: 
                    180: 
                    181: typedef struct
                    182: {
1.1.1.14  root      183:        // New fields must be added at the end of the structure to maintain compatibility with previous versions
1.1.1.12  root      184:        BOOL DeviceFilterActive;
                    185: 
                    186:        uint16 BootLoaderVersion;
                    187: 
                    188:        BOOL DriveMounted;
                    189:        BOOL VolumeHeaderPresent;
                    190:        BOOL DriveEncrypted;
                    191: 
                    192:        LARGE_INTEGER BootDriveLength;
                    193: 
                    194:        int64 ConfiguredEncryptedAreaStart;
                    195:        int64 ConfiguredEncryptedAreaEnd;
                    196:        int64 EncryptedAreaStart;
                    197:        int64 EncryptedAreaEnd;
                    198: 
                    199:        uint32 VolumeHeaderSaltCrc32;
                    200: 
                    201:        BOOL SetupInProgress;
                    202:        BootEncryptionSetupMode SetupMode;
                    203:        BOOL TransformWaitingForIdle;
                    204: 
                    205:        uint32 HibernationPreventionCount;
                    206: 
1.1.1.14  root      207:        BOOL HiddenSystem;
                    208:        int64 HiddenSystemPartitionStart;
                    209: 
                    210:        // Number of times the filter driver answered that an unencrypted volume
                    211:        // is read-only (or mounted an outer/normal TrueCrypt volume as read only)
                    212:        uint32 HiddenSysLeakProtectionCount;
                    213: 
1.1.1.12  root      214: } BootEncryptionStatus;
                    215: 
                    216: 
                    217: typedef struct
                    218: {
                    219:        BootEncryptionSetupMode SetupMode;
                    220:        WipeAlgorithmId WipeAlgorithm;
1.1.1.15! root      221:        BOOL ZeroUnreadableSectors;
1.1.1.12  root      222: } BootEncryptionSetupRequest;
                    223: 
                    224: 
                    225: typedef struct
                    226: {
                    227:        Password VolumePassword;
                    228: } ReopenBootVolumeHeaderRequest;
                    229: 
                    230: 
1.1.1.13  root      231: typedef struct
                    232: {
                    233:        char BootEncryptionAlgorithmName[256];
                    234: } GetBootEncryptionAlgorithmNameRequest;
                    235: 
1.1.1.14  root      236: typedef struct
                    237: {
                    238:        wchar_t DevicePath[TC_MAX_PATH];
                    239:        byte Configuration;
                    240:        BOOL DriveIsDynamic;
1.1.1.15! root      241:        uint16 BootLoaderVersion;
        !           242:        byte UserConfiguration;
        !           243:        char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
1.1.1.14  root      244: } GetSystemDriveConfigurationRequest;
1.1.1.13  root      245: 
1.1.1.15! root      246: typedef struct
        !           247: {
        !           248:        WipeAlgorithmId WipeAlgorithm;
        !           249:        byte WipeKey[MASTER_KEYDATA_SIZE];
        !           250: } WipeDecoySystemRequest;
        !           251: 
        !           252: typedef struct
        !           253: {
        !           254:        BOOL WipeInProgress;
        !           255:        WipeAlgorithmId WipeAlgorithm;
        !           256:        int64 WipedAreaEnd;
        !           257: } DecoySystemWipeStatus;
        !           258: 
        !           259: typedef struct
        !           260: {
        !           261:        LARGE_INTEGER Offset;
        !           262:        byte Data[SECTOR_SIZE];
        !           263: } WriteBootDriveSectorRequest;
        !           264: 
1.1       root      265: #pragma pack (pop)
                    266: 
                    267: #ifdef NT4_DRIVER
                    268: #define DRIVER_STR WIDE
                    269: #else
                    270: #define DRIVER_STR
                    271: #endif
                    272: 
                    273: /* NT only */
                    274: 
1.1.1.13  root      275: #define TC_UNIQUE_ID_PREFIX "TrueCryptVolume"
1.1       root      276: #define TC_MOUNT_PREFIX L"\\Device\\TrueCryptVolume"
                    277: 
                    278: #define NT_MOUNT_PREFIX DRIVER_STR("\\Device\\TrueCryptVolume")
                    279: #define NT_ROOT_PREFIX DRIVER_STR("\\Device\\TrueCrypt")
                    280: #define DOS_MOUNT_PREFIX DRIVER_STR("\\DosDevices\\")
                    281: #define DOS_ROOT_PREFIX DRIVER_STR("\\DosDevices\\TrueCrypt")
                    282: #define WIN32_ROOT_PREFIX DRIVER_STR("\\\\.\\TrueCrypt")
1.1.1.6   root      283: 
1.1.1.14  root      284: #define TC_DRIVER_CONFIG_REG_VALUE_NAME DRIVER_STR("TrueCryptConfig")
                    285: 
1.1.1.15! root      286: #define TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD   0x1
        !           287: 
1.1.1.6   root      288: #endif         /* _WIN32 */

unix.superglobalmegacorp.com

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