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