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