|
|
1.1.1.12 root 1: /*
1.1.1.14 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
1.1.1.22 root 7: this file are Copyright (c) 2003-2009 TrueCrypt Foundation and are governed
1.1.1.23! root 8: by the TrueCrypt License 2.7 the full text of which is contained in the
1.1.1.14 root 9: file License.txt included in TrueCrypt binary and source code distribution
1.1.1.12 root 10: packages. */
1.1 root 11:
1.1.1.14 root 12: #ifndef TCDEFS_H
13: #define TCDEFS_H
14:
15: #define TC_APP_NAME "TrueCrypt"
16:
1.1 root 17: // Version displayed to user
1.1.1.23! root 18: #define VERSION_STRING "6.2a"
1.1 root 19:
20: // Version number to compare against driver
1.1.1.23! root 21: #define VERSION_NUM 0x062a
1.1 root 22:
1.1.1.22 root 23: // Sector size of encrypted filesystem, which may differ from sector size of host filesystem/device
1.1.1.12 root 24: #define SECTOR_SIZE 512
1.1 root 25:
1.1.1.18 root 26: // "Second generation standard" sector size
27: #define SECTOR_SIZE_GEN2_STANDARD 4096
28:
1.1.1.10 root 29: #define BYTES_PER_KB 1024LL
30: #define BYTES_PER_MB 1048576LL
31: #define BYTES_PER_GB 1073741824LL
32: #define BYTES_PER_TB 1099511627776LL
33: #define BYTES_PER_PB 1125899906842624LL
1.1 root 34:
35: /* GUI/driver errors */
36:
37: #define WIDE(x) (LPWSTR)L##x
38:
1.1.1.22 root 39: #ifdef _MSC_VER
40:
1.1.1.14 root 41: typedef __int8 int8;
42: typedef __int16 int16;
43: typedef __int32 int32;
44: typedef unsigned __int8 byte;
45: typedef unsigned __int16 uint16;
46: typedef unsigned __int32 uint32;
47:
48: #ifdef TC_NO_COMPILER_INT64
49: typedef unsigned __int32 TC_LARGEST_COMPILER_UINT;
50: #else
51: typedef unsigned __int64 TC_LARGEST_COMPILER_UINT;
52: typedef __int64 int64;
53: typedef unsigned __int64 uint64;
54: #endif
55:
1.1.1.22 root 56: #else // !_MSC_VER
57:
58: #include <inttypes.h>
59: #include <limits.h>
60:
61: typedef int8_t int8;
62: typedef int16_t int16;
63: typedef int32_t int32;
64: typedef int64_t int64;
65: typedef uint8_t byte;
66: typedef uint16_t uint16;
67: typedef uint32_t uint32;
68: typedef uint64_t uint64;
69:
70: #if UCHAR_MAX != 0xffU
71: #error UCHAR_MAX != 0xff
72: #endif
73: #define __int8 char
74:
75: #if USHRT_MAX != 0xffffU
76: #error USHRT_MAX != 0xffff
77: #endif
78: #define __int16 short
79:
80: #if UINT_MAX != 0xffffffffU
81: #error UINT_MAX != 0xffffffff
82: #endif
83: #define __int32 int
84:
85: typedef uint64 TC_LARGEST_COMPILER_UINT;
86:
87: #define BOOL int
88: #ifndef FALSE
89: #define FALSE 0
90: #define TRUE 1
91: #endif
92:
93: #endif // !_MSC_VER
94:
1.1.1.18 root 95: #define TC_INT_TYPES_DEFINED
96:
97: // Integer types required by Cryptolib
1.1.1.14 root 98: typedef unsigned __int8 uint_8t;
99: typedef unsigned __int16 uint_16t;
100: typedef unsigned __int32 uint_32t;
101: #ifndef TC_NO_COMPILER_INT64
1.1.1.22 root 102: typedef uint64 uint_64t;
1.1.1.14 root 103: #endif
104:
105: typedef union
106: {
107: struct
108: {
109: unsigned __int32 LowPart;
110: unsigned __int32 HighPart;
111: };
112: #ifndef TC_NO_COMPILER_INT64
1.1.1.22 root 113: uint64 Value;
1.1.1.14 root 114: #endif
115:
116: } UINT64_STRUCT;
117:
118: #ifdef TC_WINDOWS_BOOT
1.1.1.18 root 119: # define TC_THROW_FATAL_EXCEPTION ThrowFatalException (__LINE__)
1.1.1.14 root 120: #elif defined (NT4_DRIVER)
121: # define TC_THROW_FATAL_EXCEPTION KeBugCheckEx (SECURITY_SYSTEM, __LINE__, 0, 0, 'TC')
122: #else
123: # define TC_THROW_FATAL_EXCEPTION *(char *) 0 = 0
124: #endif
125:
1.1 root 126: #ifdef NT4_DRIVER
127:
128: #pragma warning( disable : 4201 )
129: #pragma warning( disable : 4214 )
130: #pragma warning( disable : 4115 )
131: #pragma warning( disable : 4100 )
132: #pragma warning( disable : 4101 )
133: #pragma warning( disable : 4057 )
134: #pragma warning( disable : 4244 )
135: #pragma warning( disable : 4514 )
136: #pragma warning( disable : 4127 )
137:
138:
1.1.1.14 root 139: #include <ntifs.h>
1.1 root 140: #include <ntddk.h> /* Standard header file for nt drivers */
1.1.1.14 root 141:
1.1.1.20 root 142: #ifndef TC_LOCAL_WIN32_WINNT_OVERRIDE
143: # undef _WIN32_WINNT
144: # define _WIN32_WINNT 0x0501 /* Does not apply to user-space apps */
145: #endif
146:
1.1 root 147: #include <ntdddisk.h> /* Standard I/O control codes */
148: #include <ntiologc.h>
149:
150: #pragma warning( default : 4201 )
151: #pragma warning( default : 4214 )
152: #pragma warning( default : 4115 )
153: #pragma warning( default : 4100 )
154: #pragma warning( default : 4101 )
155: #pragma warning( default : 4057 )
156: #pragma warning( default : 4244 )
157: #pragma warning( default : 4127 )
158:
159: /* #pragma warning( default : 4514 ) this warning remains disabled */
160:
161: #define TCalloc(size) ((void *) ExAllocatePoolWithTag( NonPagedPool, size, 'MMCT' ))
162: #define TCfree(memblock) ExFreePoolWithTag( memblock, 'MMCT' )
163:
164: #define DEVICE_DRIVER
165:
166: #ifndef BOOL
167: typedef int BOOL;
168: #endif
169:
170: #ifndef TRUE
171: #define TRUE 1
172: #endif
173:
174: #ifndef FALSE
175: #define FALSE !TRUE
176: #endif
177:
178: /* Define dummies for the drivers */
179: typedef int HFILE;
180: typedef unsigned int WPARAM;
1.1.1.8 root 181: typedef unsigned __int32 LPARAM;
1.1 root 182: #define CALLBACK
183:
184: #ifndef UINT
185: typedef unsigned int UINT;
186: #endif
187:
188: #ifndef LRESULT
1.1.1.8 root 189: typedef unsigned __int32 LRESULT;
1.1 root 190: #endif
1.1.1.9 root 191: /* NT4_DRIVER */
192:
193: #else
1.1 root 194:
195: #define TCalloc malloc
196: #define TCfree free
197:
1.1.1.8 root 198: #ifdef _WIN32
199:
1.1 root 200: #pragma warning( disable : 4201 )
201: #pragma warning( disable : 4214 )
202: #pragma warning( disable : 4115 )
203: #pragma warning( disable : 4514 )
204:
1.1.1.20 root 205: #ifndef TC_LOCAL_WIN32_WINNT_OVERRIDE
206: # undef _WIN32_WINNT
207: # define _WIN32_WINNT 0x0501 /* Does not apply to the driver */
208: #endif
209:
1.1 root 210: #include <windows.h> /* Windows header */
211: #include <commctrl.h> /* The common controls */
212: #include <process.h> /* Process control */
213: #include <winioctl.h>
214: #include <stdio.h> /* For sprintf */
215:
216: #pragma warning( default : 4201 )
217: #pragma warning( default : 4214 )
218: #pragma warning( default : 4115 )
219:
220: /* #pragma warning( default : 4514 ) this warning remains disabled */
221:
222: /* This is needed to fix a bug with VC 5, the TCHAR macro _ttoi64 maps
1.1.1.10 root 223: incorrectly to atoLL when it should be _atoi64 */
1.1 root 224: #define atoi64 _atoi64
225:
1.1.1.8 root 226: #endif /* _WIN32 */
1.1 root 227:
1.1.1.8 root 228: #endif /* NT4_DRIVER */
229:
1.1.1.18 root 230: #ifndef TC_TO_STRING
231: # define TC_TO_STRING2(n) #n
232: # define TC_TO_STRING(n) TC_TO_STRING2(n)
233: #endif
234:
235: #ifdef DEVICE_DRIVER
236: # if defined (DEBUG) || 0
237: # if 1 // DbgPrintEx is not available on Windows 2000
238: # define Dump DbgPrint
239: # else
240: # define Dump(...) DbgPrintEx (DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, __VA_ARGS__)
241: # endif
1.1.1.22 root 242: # define DumpMem(...) DumpMemory (__VA_ARGS__)
1.1.1.18 root 243: # else
244: # define Dump(...) ((void) 0)
245: # define DumpMem(...) ((void) 0)
246: # endif
247: #endif
248:
249: #if !defined (trace_msg) && !defined (TC_WINDOWS_BOOT)
250: # ifdef DEBUG
251: # ifdef DEVICE_DRIVER
252: # define trace_msg Dump
253: # elif defined (_WIN32)
254: # define trace_msg(...) do { char msg[2048]; _snprintf (msg, sizeof (msg), __VA_ARGS__); OutputDebugString (msg); } while (0)
255: # endif
256: # define trace_point trace_msg (__FUNCTION__ ":" TC_TO_STRING(__LINE__) "\n")
257: # else
258: # define trace_msg(...)
259: # define trace_point
260: # endif
261: #endif
262:
263: #ifdef DEVICE_DRIVER
264: # define TC_EVENT KEVENT
265: # define TC_WAIT_EVENT(EVENT) KeWaitForSingleObject (&EVENT, Executive, KernelMode, FALSE, NULL)
266: #elif defined (_WIN32)
267: # define TC_EVENT HANDLE
268: # define TC_WAIT_EVENT(EVENT) WaitForSingleObject (EVENT, INFINITE)
269: #endif
270:
1.1.1.8 root 271: #ifdef _WIN32
1.1.1.12 root 272: #define burn(mem,size) do { volatile char *burnm = (volatile char *)(mem); int burnc = size; RtlSecureZeroMemory (mem, size); while (burnc--) *burnm++ = 0; } while (0)
273: #else
274: #define burn(mem,size) do { volatile char *burnm = (volatile char *)(mem); int burnc = size; while (burnc--) *burnm++ = 0; } while (0)
1.1.1.8 root 275: #endif
1.1.1.11 root 276:
1.1.1.14 root 277: // The size of the memory area to wipe is in bytes amd it must be a multiple of 8.
278: #ifndef TC_NO_COMPILER_INT64
1.1.1.22 root 279: # define FAST_ERASE64(mem,size) do { volatile uint64 *burnm = (volatile uint64 *)(mem); int burnc = size >> 3; while (burnc--) *burnm++ = 0; } while (0)
1.1.1.14 root 280: #else
281: # define FAST_ERASE64(mem,size) do { volatile unsigned __int32 *burnm = (volatile unsigned __int32 *)(mem); int burnc = size >> 2; while (burnc--) *burnm++ = 0; } while (0)
282: #endif
283:
1.1.1.16 root 284: #ifdef TC_WINDOWS_BOOT
1.1.1.18 root 285: # ifndef max
286: # define max(a,b) (((a) > (b)) ? (a) : (b))
287: # endif
288: # undef burn
289: # define burn EraseMemory
1.1.1.16 root 290: #endif
291:
1.1.1.11 root 292: #ifdef MAX_PATH
1.1.1.12 root 293: #define TC_MAX_PATH MAX_PATH
1.1.1.11 root 294: #else
1.1.1.12 root 295: #define TC_MAX_PATH 260 /* Includes the null terminator */
1.1.1.11 root 296: #endif
1.1.1.12 root 297:
298: #define MAX_URL_LENGTH 2084 /* Internet Explorer limit. Includes the terminating null character. */
299:
1.1.1.23! root 300: #define TC_HOMEPAGE "http://www.truecrypt.org/"
1.1.1.22 root 301: #define TC_APPLINK "http://www.truecrypt.org/applink?version=" VERSION_STRING
302: #define TC_APPLINK_SECURE "https://www.truecrypt.org/applink?version=" VERSION_STRING
1.1.1.14 root 303:
304: enum
305: {
1.1.1.18 root 306: /* WARNING: ADD ANY NEW CODES AT THE END (DO NOT INSERT THEM BETWEEN EXISTING). DO *NOT* DELETE ANY
307: EXISTING CODES! Changing these values or their meanings may cause incompatibility with other versions
308: (for example, if a new version of the TrueCrypt installer receives an error code from an installed
309: driver whose version is lower, it will report and interpret the error incorrectly). */
310:
311: ERR_SUCCESS = 0,
312: ERR_OS_ERROR = 1,
313: ERR_OUTOFMEMORY = 2,
314: ERR_PASSWORD_WRONG = 3,
315: ERR_VOL_FORMAT_BAD = 4,
316: ERR_DRIVE_NOT_FOUND = 5,
317: ERR_FILES_OPEN = 6,
318: ERR_VOL_SIZE_WRONG = 7,
319: ERR_COMPRESSION_NOT_SUPPORTED = 8,
320: ERR_PASSWORD_CHANGE_VOL_TYPE = 9,
321: ERR_PASSWORD_CHANGE_VOL_VERSION = 10,
322: ERR_VOL_SEEKING = 11,
323: ERR_VOL_WRITING = 12,
324: ERR_FILES_OPEN_LOCK = 13,
325: ERR_VOL_READING = 14,
326: ERR_DRIVER_VERSION = 15,
327: ERR_NEW_VERSION_REQUIRED = 16,
328: ERR_CIPHER_INIT_FAILURE = 17,
329: ERR_CIPHER_INIT_WEAK_KEY = 18,
330: ERR_SELF_TESTS_FAILED = 19,
331: ERR_SECTOR_SIZE_INCOMPATIBLE = 20,
332: ERR_VOL_ALREADY_MOUNTED = 21,
333: ERR_NO_FREE_DRIVES = 22,
334: ERR_FILE_OPEN_FAILED = 23,
335: ERR_VOL_MOUNT_FAILED = 24,
1.1.1.20 root 336: DEPRECATED_ERR_INVALID_DEVICE = 25,
1.1.1.18 root 337: ERR_ACCESS_DENIED = 26,
338: ERR_MODE_INIT_FAILED = 27,
339: ERR_DONT_REPORT = 28,
340: ERR_ENCRYPTION_NOT_COMPLETED = 29,
341: ERR_PARAMETER_INCORRECT = 30,
1.1.1.20 root 342: ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG = 31,
343: ERR_NONSYS_INPLACE_ENC_INCOMPLETE = 32,
344: ERR_USER_ABORT = 33
1.1.1.14 root 345: };
346:
347: #endif // #ifndef TCDEFS_H
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.