|
|
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
8: by the TrueCrypt License 2.4 the full text of which is contained in the
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"
15: #include "Common.h"
16: #include "Crypto.h"
1.1.1.12 root 17: #include "Wipe.h"
1.1.1.6 root 18:
19: #ifdef _WIN32
20:
1.1.1.13! root 21: /* WARNING: Modifying the following values or their meanings can introduce incompatibility with previous versions. */
1.1 root 22:
1.1.1.12 root 23: #define TC_IOCTL(CODE) (CTL_CODE (FILE_DEVICE_UNKNOWN, 0x800 + (CODE), METHOD_BUFFERED, FILE_ANY_ACCESS))
1.1 root 24:
1.1.1.12 root 25: #define TC_IOCTL_GET_DRIVER_VERSION TC_IOCTL (1)
26: #define TC_IOCTL_GET_BOOT_LOADER_VERSION TC_IOCTL (2)
27: #define TC_IOCTL_MOUNT_VOLUME TC_IOCTL (3)
28: #define TC_IOCTL_DISMOUNT_VOLUME TC_IOCTL (4)
29: #define TC_IOCTL_DISMOUNT_ALL_VOLUMES TC_IOCTL (5)
30: #define TC_IOCTL_GET_MOUNTED_VOLUMES TC_IOCTL (6)
31: #define TC_IOCTL_GET_VOLUME_PROPERTIES TC_IOCTL (7)
32: #define TC_IOCTL_GET_DEVICE_REFCOUNT TC_IOCTL (8)
33: #define TC_IOCTL_WAS_REFERENCED_DEVICE_DELETED TC_IOCTL (9)
34: #define TC_IOCTL_IS_ANY_VOLUME_MOUNTED TC_IOCTL (10)
35: #define TC_IOCTL_GET_PASSWORD_CACHE_STATUS TC_IOCTL (11)
36: #define TC_IOCTL_WIPE_PASSWORD_CACHE TC_IOCTL (12)
37: #define TC_IOCTL_OPEN_TEST TC_IOCTL (13)
38: #define TC_IOCTL_GET_DRIVE_PARTITION_INFO TC_IOCTL (14)
39: #define TC_IOCTL_GET_DRIVE_GEOMETRY TC_IOCTL (15)
40: #define TC_IOCTL_PROBE_REAL_DRIVE_SIZE TC_IOCTL (16)
41: #define TC_IOCTL_GET_RESOLVED_SYMLINK TC_IOCTL (17)
42: #define TC_IOCTL_GET_BOOT_ENCRYPTION_STATUS TC_IOCTL (18)
43: #define TC_IOCTL_BOOT_ENCRYPTION_SETUP TC_IOCTL (19)
44: #define TC_IOCTL_ABORT_BOOT_ENCRYPTION_SETUP TC_IOCTL (20)
45: #define TC_IOCTL_GET_BOOT_ENCRYPTION_SETUP_RESULT TC_IOCTL (21)
46: #define TC_IOCTL_GET_BOOT_DRIVE_VOLUME_PROPERTIES TC_IOCTL (22)
47: #define TC_IOCTL_REOPEN_BOOT_VOLUME_HEADER TC_IOCTL (23)
1.1.1.13! root 48: #define TC_IOCTL_GET_BOOT_ENCRYPTION_ALGORITHM_NAME TC_IOCTL (24)
! 49: #define TC_IOCTL_GET_TRAVELER_MODE_STATUS TC_IOCTL (25)
! 50: #define TC_IOCTL_SET_TRAVELER_MODE_STATUS TC_IOCTL (26)
1.1.1.12 root 51:
52: // Legacy IOCTLs used before version 5.0
53: #define TC_IOCTL_LEGACY_GET_DRIVER_VERSION 466968
54: #define TC_IOCTL_LEGACY_GET_MOUNTED_VOLUMES 466948
1.1 root 55:
56:
57: /* Start of driver interface structures, the size of these structures may
58: change between versions; so make sure you first send DRIVER_VERSION to
59: check that it's the correct device driver */
60:
61: #pragma pack (push)
62: #pragma pack(1)
63:
64: typedef struct
65: {
1.1.1.6 root 66: int nReturnCode; /* Return code back from driver */
67: short wszVolume[TC_MAX_PATH]; /* Volume to be mounted */
68: Password VolumePassword; /* User password */
69: BOOL bCache; /* Cache passwords in driver */
70: int nDosDriveNo; /* Drive number to mount */
1.1.1.10 root 71: int BytesPerSector;
1.1.1.6 root 72: BOOL bMountReadOnly; /* Mount volume in read-only mode */
73: BOOL bMountRemovable; /* Mount volume as removable media */
74: BOOL bExclusiveAccess; /* Open host file/device in exclusive access mode */
75: BOOL bMountManager; /* Announce volume to mount manager */
76: BOOL bUserContext; /* Mount volume in user process context */
77: BOOL bPreserveTimestamp; /* Preserve file container timestamp */
1.1.1.13! root 78: BOOL bPartitionInInactiveSysEncScope; /* If TRUE, we are to attempt to mount a partition located on an encrypted system drive without pre-boot authentication. */
! 79: 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 80: // Hidden volume protection
81: BOOL bProtectHiddenVolume; /* TRUE if the user wants the hidden volume within this volume to be protected against being overwritten (damaged) */
82: Password ProtectedHidVolPassword; /* Password to the hidden volume to be protected against overwriting */
1.1 root 83: } MOUNT_STRUCT;
84:
85: typedef struct
86: {
87: int nDosDriveNo; /* Drive letter to unmount */
1.1.1.4 root 88: BOOL ignoreOpenFiles;
89: int nReturnCode; /* Return code back from driver */
1.1 root 90: } UNMOUNT_STRUCT;
91:
92: typedef struct
93: {
1.1.1.6 root 94: unsigned __int32 ulMountedDrives; /* Bitfield of all mounted drive letters */
1.1.1.7 root 95: short wszVolume[26][TC_MAX_PATH]; /* Volume names of mounted volumes */
1.1 root 96: unsigned __int64 diskLength[26];
1.1.1.4 root 97: int ea[26];
1.1.1.6 root 98: int volumeType[26]; /* Volume type (e.g. PROP_VOL_TYPE_OUTER, PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED, etc.) */
1.1 root 99: } MOUNT_LIST_STRUCT;
100:
101: typedef struct
102: {
103: int driveNo;
1.1.1.6 root 104: int uniqueId;
1.1.1.7 root 105: short wszVolume[TC_MAX_PATH];
1.1 root 106: unsigned __int64 diskLength;
1.1.1.4 root 107: int ea;
1.1.1.7 root 108: int mode;
1.1 root 109: int pkcs5;
110: int pkcs5Iterations;
1.1.1.4 root 111: BOOL hiddenVolume;
1.1.1.6 root 112: BOOL readOnly;
1.1 root 113: unsigned __int64 volumeCreationTime;
114: unsigned __int64 headerCreationTime;
1.1.1.6 root 115: unsigned __int64 totalBytesRead;
116: unsigned __int64 totalBytesWritten;
117: int hiddenVolProtection; /* Hidden volume protection status (e.g. HIDVOL_PROT_STATUS_NONE, HIDVOL_PROT_STATUS_ACTIVE, etc.) */
1.1 root 118: } VOLUME_PROPERTIES_STRUCT;
119:
120: typedef struct
121: {
1.1.1.4 root 122: WCHAR symLinkName[TC_MAX_PATH];
123: WCHAR targetName[TC_MAX_PATH];
124: } RESOLVE_SYMLINK_STRUCT;
125:
126: typedef struct
127: {
1.1.1.10 root 128: WCHAR deviceName[TC_MAX_PATH];
129: PARTITION_INFORMATION partInfo;
1.1.1.12 root 130: BOOL IsGPT;
1.1.1.10 root 131: }
132: DISK_PARTITION_INFO_STRUCT;
133:
134: typedef struct
135: {
136: WCHAR deviceName[TC_MAX_PATH];
137: DISK_GEOMETRY diskGeometry;
138: }
139: DISK_GEOMETRY_STRUCT;
140:
141: typedef struct
142: {
1.1.1.12 root 143: WCHAR DeviceName[TC_MAX_PATH];
144: LARGE_INTEGER RealDriveSize;
1.1.1.13! root 145: BOOL TimeOut;
1.1.1.12 root 146: } ProbeRealDriveSizeRequest;
147:
148: typedef struct
149: {
1.1.1.13! root 150: short wszFileName[TC_MAX_PATH]; // Volume to be "open tested"
! 151: BOOL bDetectTCBootLoader; // Whether the driver is to determine if the first sector contains a portion of the TrueCrypt Boot Loader
1.1 root 152: } OPEN_TEST_STRUCT;
153:
154:
1.1.1.12 root 155: typedef enum
156: {
157: SetupNone = 0,
158: SetupEncryption,
159: SetupDecryption
160: } BootEncryptionSetupMode;
161:
162:
163: typedef struct
164: {
165: BOOL DeviceFilterActive;
166:
167: uint16 BootLoaderVersion;
168:
169: BOOL DriveMounted;
170: BOOL VolumeHeaderPresent;
171: BOOL DriveEncrypted;
172:
173: LARGE_INTEGER BootDriveLength;
174:
175: int64 ConfiguredEncryptedAreaStart;
176: int64 ConfiguredEncryptedAreaEnd;
177: int64 EncryptedAreaStart;
178: int64 EncryptedAreaEnd;
179:
180: uint32 VolumeHeaderSaltCrc32;
181:
182: BOOL SetupInProgress;
183: BootEncryptionSetupMode SetupMode;
184: BOOL TransformWaitingForIdle;
185:
186: uint32 HibernationPreventionCount;
187:
188: } BootEncryptionStatus;
189:
190:
191: typedef struct
192: {
193: BootEncryptionSetupMode SetupMode;
194: WipeAlgorithmId WipeAlgorithm;
195: } BootEncryptionSetupRequest;
196:
197:
198: typedef struct
199: {
200: Password VolumePassword;
201: } ReopenBootVolumeHeaderRequest;
202:
203:
1.1.1.13! root 204: typedef struct
! 205: {
! 206: char BootEncryptionAlgorithmName[256];
! 207: } GetBootEncryptionAlgorithmNameRequest;
! 208:
! 209:
1.1 root 210: #pragma pack (pop)
211:
212: #ifdef NT4_DRIVER
213: #define DRIVER_STR WIDE
214: #else
215: #define DRIVER_STR
216: #endif
217:
218: /* NT only */
219:
1.1.1.13! root 220: #define TC_UNIQUE_ID_PREFIX "TrueCryptVolume"
1.1 root 221: #define TC_MOUNT_PREFIX L"\\Device\\TrueCryptVolume"
222:
223: #define NT_MOUNT_PREFIX DRIVER_STR("\\Device\\TrueCryptVolume")
224: #define NT_ROOT_PREFIX DRIVER_STR("\\Device\\TrueCrypt")
225: #define DOS_MOUNT_PREFIX DRIVER_STR("\\DosDevices\\")
226: #define DOS_ROOT_PREFIX DRIVER_STR("\\DosDevices\\TrueCrypt")
227: #define WIN32_ROOT_PREFIX DRIVER_STR("\\\\.\\TrueCrypt")
1.1.1.6 root 228:
229: #endif /* _WIN32 */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.