|
|
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: /* DeviceIoControl values.
9:
10: */
11:
12: #ifndef CTL_CODE
13:
14: /* A macro from the NT DDK */
15:
16: #define CTL_CODE( DeviceType, Function, Method, Access ) ( \
17: ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
18: )
19:
20: #endif
21:
22: /* More macros from the NT DDK */
23:
24: #ifndef METHOD_BUFFERED
25: #define METHOD_BUFFERED 0
26: #endif
27:
28: #ifndef FILE_ANY_ACCESS
29: #define FILE_ANY_ACCESS 0
30: #endif
31:
32: #ifndef FILE_DEVICE_DISK
33: #define FILE_DEVICE_DISK 0x00000007
34: #endif
35:
36: #ifndef IOCTL_DISK_BASE
37: #define IOCTL_DISK_BASE FILE_DEVICE_DISK
38: #endif
39:
40: /* These values originate from the following NT DDK macro :
41:
42: #define ANYNAME CTL_CODE(IOCTL_DISK_BASE, 0x800, METHOD_BUFFERED, \
43: FILE_ANY_ACCESS)
44:
45: #define ANYNAME2 CTL_CODE(IOCTL_DISK_BASE, 0x801, METHOD_BUFFERED, \
46: FILE_ANY_ACCESS)
47:
48: etc... */
49:
50: /* Public driver interface codes */
51:
52: #define MOUNT 466944 /* Mount a volume or partition */
53: #define MOUNT_LIST 466948 /* Return list of mounted volumes */
54: #define OPEN_TEST 466952 /* Open a file at ring0 */
55: #define UNMOUNT 466956 /* Unmount a volume */
56: #define WIPE_CACHE 466960 /* Wipe the driver password cache */
57: #define HALT_SYSTEM 466964 /* Halt system; (only NT when compiled with debug) */
58: #define DRIVER_VERSION 466968 /* Current driver version */
59: #define RELEASE_TIME_SLICE 466972 /* Release time slice on apps behalf (only Win9x) */
60: #define MOUNT_LIST_N 466976 /* Get volume info from the device (only Win9x) */
61: #define DISKIO 466980 /* Read/Write at ring0 for win32 gui (only Win9x) */
62: #define ALLOW_FAST_SHUTDOWN 466984 /* Fast shutdown under win98 (only Win9x) */
63: #define CACHE_STATUS 466988 /* Get password cache status */
64: #define VOLUME_PROPERTIES 466992 /* Get mounted volume properties */
1.1.1.4 ! root 65: #define RESOLVE_SYMLINK 466996 /* Resolve symbolic link to target */
! 66: #define UNMOUNT_ALL 475112 /* Unmount all volumes */
1.1 root 67:
68: #define TC_FIRST_PRIVATE MOUNT /* First private control code */
1.1.1.4 ! root 69: #define TC_LAST_PRIVATE UNMOUNT_ALL /* Last private control code */
1.1 root 70:
71: /* Start of driver interface structures, the size of these structures may
72: change between versions; so make sure you first send DRIVER_VERSION to
73: check that it's the correct device driver */
74:
75: #pragma pack (push)
76: #pragma pack(1)
77:
78: typedef struct
79: {
80: int nReturnCode; /* Return code back from driver */
81: short wszVolume[TC_MAX_PATH]; /* Volume to be mounted */
1.1.1.4 ! root 82: char szPassword[MAX_PASSWORD + 1]; /* User password */
1.1 root 83: int nPasswordLen; /* User password length */
84: BOOL bCache; /* Cache passwords in driver */
85: int nDosDriveNo; /* Drive number to mount */
1.1.1.4 ! root 86: BOOL bMountReadOnly; /* Mount volume in read-only mode */
! 87: BOOL bMountRemovable; /* Mount volume as removable media */
! 88: BOOL bExclusiveAccess; /* Open host file/device in exclusive access mode */
! 89: BOOL bMountManager; /* Announce volume to mount manager */
1.1 root 90: long time; /* Time when this volume was mounted */
91: } MOUNT_STRUCT;
92:
93: typedef struct
94: {
95: int nDosDriveNo; /* Drive letter to unmount */
1.1.1.4 ! root 96: BOOL ignoreOpenFiles;
! 97: int nReturnCode; /* Return code back from driver */
1.1 root 98: } UNMOUNT_STRUCT;
99:
100: typedef struct
101: {
102: unsigned long ulMountedDrives; /* Bitfield of all mounted drive letters */
103: short wszVolume[26][64]; /* Volume names of mounted volumes */
104: unsigned __int64 diskLength[26];
1.1.1.4 ! root 105: int ea[26];
! 106: BOOL hiddenVol[26];
1.1 root 107: } MOUNT_LIST_STRUCT;
108:
109: typedef struct
110: {
111: int driveNo;
112: short wszVolume[64];
113: unsigned __int64 diskLength;
1.1.1.4 ! root 114: int ea;
1.1 root 115: int pkcs5;
116: int pkcs5Iterations;
1.1.1.4 ! root 117: BOOL hiddenVolume;
1.1 root 118: unsigned __int64 volumeCreationTime;
119: unsigned __int64 headerCreationTime;
120: //int readOnly;
121: } VOLUME_PROPERTIES_STRUCT;
122:
123: typedef struct
124: {
1.1.1.4 ! root 125: WCHAR symLinkName[TC_MAX_PATH];
! 126: WCHAR targetName[TC_MAX_PATH];
! 127: } RESOLVE_SYMLINK_STRUCT;
! 128:
! 129: typedef struct
! 130: {
1.1 root 131: short wszFileName[TC_MAX_PATH]; /* Volume to be "open tested" */
132: int nReturnCode; /* Win9x only */
133: unsigned long secstart; /* Win9x only */
134: unsigned long seclast; /* Win9x only */
135: unsigned long device; /* Win9x only */
136: } OPEN_TEST_STRUCT;
137:
138: /* Win9x only */
139: typedef struct
140: {
141: int nReturnCode; /* Return code back from driver */
142: int nDosDriveNo; /* Drive letter to get info on */
143: short wszVolume[TC_MAX_PATH]; /* Volume names of mounted volumes */
144: unsigned long mountfilehandle; /* Device file handle or 0 */
145: } MOUNT_LIST_N_STRUCT;
146:
147: /* Win9x only */
148: typedef struct
149: {
150: unsigned int devicenum; /* Ptr to dcb for device */
151: unsigned int sectorstart; /* Start sector */
152: unsigned int sectorlen; /* Number of sectors */
153: char *bufferad; /* Address of buffer */
154: int mode; /* Read=0 or Write=1 */
155: int nReturnCode; /* Return code back from driver */
156: } DISKIO_STRUCT;
157:
158:
159: #pragma pack (pop)
160:
161: #ifdef NT4_DRIVER
162: #define DRIVER_STR WIDE
163: #else
164: #define DRIVER_STR
165: #endif
166:
167: /* NT only */
168:
169: #define TC_UNIQUE_ID_PREFIX "TrueCrypt"
170: #define TC_MOUNT_PREFIX L"\\Device\\TrueCryptVolume"
171:
172: #define NT_MOUNT_PREFIX DRIVER_STR("\\Device\\TrueCryptVolume")
173: #define NT_ROOT_PREFIX DRIVER_STR("\\Device\\TrueCrypt")
174: #define DOS_MOUNT_PREFIX DRIVER_STR("\\DosDevices\\")
175: #define DOS_ROOT_PREFIX DRIVER_STR("\\DosDevices\\TrueCrypt")
176: #define WIN32_ROOT_PREFIX DRIVER_STR("\\\\.\\TrueCrypt")
177:
178: /* Win9x only */
179:
180: #define WIN9X_DRIVER_NAME "\\\\.\\TRUCRYPT"
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.