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

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;
1.1.1.16! root       77:        BOOL VolumeMountedReadOnlyAfterAccessDenied;
1.1.1.15  root       78: 
1.1.1.6   root       79:        short wszVolume[TC_MAX_PATH];           /* Volume to be mounted */
                     80:        Password VolumePassword;                        /* User password */
                     81:        BOOL bCache;                                            /* Cache passwords in driver */
                     82:        int nDosDriveNo;                                        /* Drive number to mount */
1.1.1.10  root       83:        int BytesPerSector;
1.1.1.6   root       84:        BOOL bMountReadOnly;                            /* Mount volume in read-only mode */
                     85:        BOOL bMountRemovable;                           /* Mount volume as removable media */
                     86:        BOOL bExclusiveAccess;                          /* Open host file/device in exclusive access mode */
                     87:        BOOL bMountManager;                                     /* Announce volume to mount manager */
                     88:        BOOL bPreserveTimestamp;                        /* Preserve file container timestamp */
1.1.1.13  root       89:        BOOL bPartitionInInactiveSysEncScope;           /* If TRUE, we are to attempt to mount a partition located on an encrypted system drive without pre-boot authentication. */
                     90:        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       91:        // Hidden volume protection
                     92:        BOOL bProtectHiddenVolume;                      /* TRUE if the user wants the hidden volume within this volume to be protected against being overwritten (damaged) */
                     93:        Password ProtectedHidVolPassword;       /* Password to the hidden volume to be protected against overwriting */
1.1.1.14  root       94:        BOOL UseBackupHeader;
1.1.1.15  root       95:        BOOL RecoveryMode;
1.1       root       96: } MOUNT_STRUCT;
                     97: 
                     98: typedef struct
                     99: {
                    100:        int nDosDriveNo;        /* Drive letter to unmount */
1.1.1.4   root      101:        BOOL ignoreOpenFiles;
1.1.1.14  root      102:        BOOL HiddenVolumeProtectionTriggered;
1.1.1.4   root      103:        int nReturnCode;        /* Return code back from driver */
1.1       root      104: } UNMOUNT_STRUCT;
                    105: 
                    106: typedef struct
                    107: {
1.1.1.6   root      108:        unsigned __int32 ulMountedDrives;       /* Bitfield of all mounted drive letters */
1.1.1.7   root      109:        short wszVolume[26][TC_MAX_PATH];       /* Volume names of mounted volumes */
1.1       root      110:        unsigned __int64 diskLength[26];
1.1.1.4   root      111:        int ea[26];
1.1.1.6   root      112:        int volumeType[26];     /* Volume type (e.g. PROP_VOL_TYPE_OUTER, PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED, etc.) */
1.1       root      113: } MOUNT_LIST_STRUCT;
                    114: 
                    115: typedef struct
                    116: {
                    117:        int driveNo;
1.1.1.6   root      118:        int uniqueId;
1.1.1.7   root      119:        short wszVolume[TC_MAX_PATH];
1.1       root      120:        unsigned __int64 diskLength;
1.1.1.4   root      121:        int ea;
1.1.1.7   root      122:        int mode;
1.1       root      123:        int pkcs5;
                    124:        int pkcs5Iterations;
1.1.1.4   root      125:        BOOL hiddenVolume;
1.1.1.6   root      126:        BOOL readOnly;
1.1.1.15  root      127: #if 0
                    128:        unsigned __int64 volumeCreationTime;    // Deprecated in v6.0
                    129:        unsigned __int64 headerCreationTime;    // Deprecated in v6.0
                    130: #endif
                    131:        uint32 volumeHeaderFlags;
1.1.1.6   root      132:        unsigned __int64 totalBytesRead;
                    133:        unsigned __int64 totalBytesWritten;
                    134:        int hiddenVolProtection;        /* Hidden volume protection status (e.g. HIDVOL_PROT_STATUS_NONE, HIDVOL_PROT_STATUS_ACTIVE, etc.) */
1.1.1.14  root      135:        int volFormatVersion;
1.1       root      136: } VOLUME_PROPERTIES_STRUCT;
                    137: 
                    138: typedef struct
                    139: {
1.1.1.4   root      140:        WCHAR symLinkName[TC_MAX_PATH];
                    141:        WCHAR targetName[TC_MAX_PATH];
                    142: } RESOLVE_SYMLINK_STRUCT;
                    143: 
                    144: typedef struct
                    145: {
1.1.1.10  root      146:        WCHAR deviceName[TC_MAX_PATH];
                    147:        PARTITION_INFORMATION partInfo;
1.1.1.12  root      148:        BOOL IsGPT;
1.1.1.15  root      149:        BOOL IsDynamic;
1.1.1.10  root      150: }
                    151: DISK_PARTITION_INFO_STRUCT;
                    152: 
                    153: typedef struct
                    154: {
                    155:        WCHAR deviceName[TC_MAX_PATH];
                    156:        DISK_GEOMETRY diskGeometry;
                    157: }
                    158: DISK_GEOMETRY_STRUCT;
                    159: 
                    160: typedef struct
                    161: {
1.1.1.12  root      162:        WCHAR DeviceName[TC_MAX_PATH];
                    163:        LARGE_INTEGER RealDriveSize;
1.1.1.13  root      164:        BOOL TimeOut;
1.1.1.12  root      165: } ProbeRealDriveSizeRequest;
                    166: 
                    167: typedef struct
                    168: {
1.1.1.13  root      169:        short wszFileName[TC_MAX_PATH];         // Volume to be "open tested"
                    170:        BOOL bDetectTCBootLoader;                       // Whether the driver is to determine if the first sector contains a portion of the TrueCrypt Boot Loader
1.1       root      171: } OPEN_TEST_STRUCT;
                    172: 
                    173: 
1.1.1.12  root      174: typedef enum
                    175: {
                    176:        SetupNone = 0,
                    177:        SetupEncryption,
                    178:        SetupDecryption
                    179: } BootEncryptionSetupMode;
                    180: 
                    181: 
                    182: typedef struct
                    183: {
1.1.1.14  root      184:        // New fields must be added at the end of the structure to maintain compatibility with previous versions
1.1.1.12  root      185:        BOOL DeviceFilterActive;
                    186: 
                    187:        uint16 BootLoaderVersion;
                    188: 
                    189:        BOOL DriveMounted;
                    190:        BOOL VolumeHeaderPresent;
                    191:        BOOL DriveEncrypted;
                    192: 
                    193:        LARGE_INTEGER BootDriveLength;
                    194: 
                    195:        int64 ConfiguredEncryptedAreaStart;
                    196:        int64 ConfiguredEncryptedAreaEnd;
                    197:        int64 EncryptedAreaStart;
                    198:        int64 EncryptedAreaEnd;
                    199: 
                    200:        uint32 VolumeHeaderSaltCrc32;
                    201: 
                    202:        BOOL SetupInProgress;
                    203:        BootEncryptionSetupMode SetupMode;
                    204:        BOOL TransformWaitingForIdle;
                    205: 
                    206:        uint32 HibernationPreventionCount;
                    207: 
1.1.1.14  root      208:        BOOL HiddenSystem;
                    209:        int64 HiddenSystemPartitionStart;
                    210: 
                    211:        // Number of times the filter driver answered that an unencrypted volume
                    212:        // is read-only (or mounted an outer/normal TrueCrypt volume as read only)
                    213:        uint32 HiddenSysLeakProtectionCount;
                    214: 
1.1.1.12  root      215: } BootEncryptionStatus;
                    216: 
                    217: 
                    218: typedef struct
                    219: {
                    220:        BootEncryptionSetupMode SetupMode;
                    221:        WipeAlgorithmId WipeAlgorithm;
1.1.1.15  root      222:        BOOL ZeroUnreadableSectors;
1.1.1.12  root      223: } BootEncryptionSetupRequest;
                    224: 
                    225: 
                    226: typedef struct
                    227: {
                    228:        Password VolumePassword;
                    229: } ReopenBootVolumeHeaderRequest;
                    230: 
                    231: 
1.1.1.13  root      232: typedef struct
                    233: {
                    234:        char BootEncryptionAlgorithmName[256];
                    235: } GetBootEncryptionAlgorithmNameRequest;
                    236: 
1.1.1.14  root      237: typedef struct
                    238: {
                    239:        wchar_t DevicePath[TC_MAX_PATH];
                    240:        byte Configuration;
                    241:        BOOL DriveIsDynamic;
1.1.1.15  root      242:        uint16 BootLoaderVersion;
                    243:        byte UserConfiguration;
                    244:        char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
1.1.1.14  root      245: } GetSystemDriveConfigurationRequest;
1.1.1.13  root      246: 
1.1.1.15  root      247: typedef struct
                    248: {
                    249:        WipeAlgorithmId WipeAlgorithm;
                    250:        byte WipeKey[MASTER_KEYDATA_SIZE];
                    251: } WipeDecoySystemRequest;
                    252: 
                    253: typedef struct
                    254: {
                    255:        BOOL WipeInProgress;
                    256:        WipeAlgorithmId WipeAlgorithm;
                    257:        int64 WipedAreaEnd;
                    258: } DecoySystemWipeStatus;
                    259: 
                    260: typedef struct
                    261: {
                    262:        LARGE_INTEGER Offset;
                    263:        byte Data[SECTOR_SIZE];
                    264: } WriteBootDriveSectorRequest;
                    265: 
1.1       root      266: #pragma pack (pop)
                    267: 
                    268: #ifdef NT4_DRIVER
                    269: #define DRIVER_STR WIDE
                    270: #else
                    271: #define DRIVER_STR
                    272: #endif
                    273: 
                    274: /* NT only */
                    275: 
1.1.1.13  root      276: #define TC_UNIQUE_ID_PREFIX "TrueCryptVolume"
1.1       root      277: #define TC_MOUNT_PREFIX L"\\Device\\TrueCryptVolume"
                    278: 
                    279: #define NT_MOUNT_PREFIX DRIVER_STR("\\Device\\TrueCryptVolume")
                    280: #define NT_ROOT_PREFIX DRIVER_STR("\\Device\\TrueCrypt")
                    281: #define DOS_MOUNT_PREFIX DRIVER_STR("\\DosDevices\\")
                    282: #define DOS_ROOT_PREFIX DRIVER_STR("\\DosDevices\\TrueCrypt")
                    283: #define WIN32_ROOT_PREFIX DRIVER_STR("\\\\.\\TrueCrypt")
1.1.1.6   root      284: 
1.1.1.14  root      285: #define TC_DRIVER_CONFIG_REG_VALUE_NAME DRIVER_STR("TrueCryptConfig")
                    286: 
1.1.1.15  root      287: #define TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD   0x1
                    288: 
1.1.1.6   root      289: #endif         /* _WIN32 */

unix.superglobalmegacorp.com

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