--- truecrypt/common/tcdefs.h 2018/04/24 16:38:02 1.1.1.2 +++ truecrypt/common/tcdefs.h 2018/04/24 16:46:24 1.1.1.12 @@ -1,29 +1,43 @@ -/* Copyright (C) 2004 TrueCrypt Team, truecrypt.org - This product uses components written by Paul Le Roux */ +/* + Legal Notice: The source code contained in this file has been derived from + the source code of Encryption for the Masses 2.02a, which is Copyright (c) + Paul Le Roux and which is covered by the 'License Agreement for Encryption + for the Masses'. Modifications and additions to that source code contained + in this file are Copyright (c) TrueCrypt Foundation and are covered by the + TrueCrypt License 2.2 the full text of which is contained in the file + License.txt included in TrueCrypt binary and source code distribution + packages. */ // Version displayed to user -#define VERSION_STRING "1.0a" +#define VERSION_STRING "4.3" // Version number to compare against driver -#define VERSION_NUM 0x010a +#define VERSION_NUM 0x0430 // Version number written to volume header during format, // specifies the minimum program version required to mount the volume -#define VOLUME_VERSION_NUM 0x0100 +#define VOL_REQ_PROG_VERSION 0x0410 -#define TC_MAX_PATH 260 /* Includes the null terminator */ -#define SECTOR_SIZE 512 /* sector size */ +// Volume header version +#define VOLUME_HEADER_VERSION 0x0002 -#define BYTES_PER_KB 1024 -#define BYTES_PER_MB 1048576 +// Sector size of encrypted filesystem, which may differ from sector size of host filesystem/device (this +// is fully supported since v4.3). To retain maximum portability and compatibility, it should always be 512. +#define SECTOR_SIZE 512 + +#define BYTES_PER_KB 1024LL +#define BYTES_PER_MB 1048576LL +#define BYTES_PER_GB 1073741824LL +#define BYTES_PER_TB 1099511627776LL +#define BYTES_PER_PB 1125899906842624LL /* GUI/driver errors */ +#define ERR_SUCCESS 0 #define ERR_OS_ERROR 1 #define ERR_OUTOFMEMORY 2 #define ERR_PASSWORD_WRONG 3 #define ERR_VOL_FORMAT_BAD 4 -#define ERR_BAD_DRIVE_LETTER 5 #define ERR_DRIVE_NOT_FOUND 6 #define ERR_FILES_OPEN 7 #define ERR_VOL_SIZE_WRONG 8 @@ -36,28 +50,30 @@ #define ERR_VOL_READING 15 #define ERR_DRIVER_VERSION 16 #define ERR_NEW_VERSION_REQUIRED 17 +#define ERR_CIPHER_INIT_FAILURE 18 +#define ERR_CIPHER_INIT_WEAK_KEY 19 +#define ERR_SELF_TESTS_FAILED 20 +#define ERR_SECTOR_SIZE_INCOMPATIBLE 21 #define ERR_VOL_ALREADY_MOUNTED 32 -#define ERR_NO_FREE_SLOTS 33 #define ERR_NO_FREE_DRIVES 34 #define ERR_FILE_OPEN_FAILED 35 #define ERR_VOL_MOUNT_FAILED 36 #define ERR_INVALID_DEVICE 37 #define ERR_ACCESS_DENIED 38 +#define ERR_MODE_INIT_FAILED 39 -#define MIN_VOLUME_SIZE 19456 -#define MAX_VOLUME_SIZE 0x7fffFFFFffffFFFFI64 +#define ERR_DONT_REPORT 100 -#define burn(mem,size) \ - memset(mem,0xff,size); \ - memset(mem,0,size); +#define MIN_VOLUME_SIZE 19456 +#define MIN_HIDDEN_VOLUME_HOST_SIZE ( MIN_VOLUME_SIZE * 2 + HIDDEN_VOL_HEADER_OFFSET + HEADER_SIZE ) +#define MAX_VOLUME_SIZE 0x7fffFFFFffffFFFFLL +#define MAX_FAT_VOLUME_SIZE 0x20000000000LL +#define MAX_HIDDEN_VOLUME_HOST_SIZE MAX_FAT_VOLUME_SIZE +#define MAX_HIDDEN_VOLUME_SIZE ( MAX_HIDDEN_VOLUME_HOST_SIZE - HIDDEN_VOL_HEADER_OFFSET - HEADER_SIZE ) #define WIDE(x) (LPWSTR)L##x -#include - -#pragma intrinsic(memcmp, memcpy, memset, strcat, strcmp, strcpy, strlen) - #ifdef NT4_DRIVER #pragma warning( disable : 4201 ) @@ -93,45 +109,6 @@ #define DEVICE_DRIVER -#endif /* NT4_DRIVER */ - - -#ifdef WIN9X_DRIVER - -#pragma warning( disable : 4047 ) - -#include "iosdcls.inc" /* VMM and IOS headers */ - -#pragma warning( default : 4047 ) - -#include -#include -#undef WANTVDXWRAPS -#pragma warning( disable : 4229 ) -#include -#pragma warning( default : 4229 ) -#pragma hdrstop -#include -#include -#include "ifs.h" -#include -#define MBYTE16 3967 -#define UWORD unsigned short -#define UBYTE unsigned char - -#define MBYTE16 3967 - -#define TCalloc(size) _PageAllocate(size % 4096 ? (size/4096)+1 : size/4096,\ - PG_SYS,0,0,0,MBYTE16,NULL,PAGEZEROINIT|PAGEFIXED|PAGECONTIG|PAGEUSEALIGN); - -#define TCfree(memblock) _PageFree(memblock,0) - -#define DEVICE_DRIVER - -#endif /* WIN9X_DRIVER */ - -#ifdef DEVICE_DRIVER - #ifndef BOOL typedef int BOOL; #endif @@ -147,7 +124,7 @@ typedef int BOOL; /* Define dummies for the drivers */ typedef int HFILE; typedef unsigned int WPARAM; -typedef unsigned long LPARAM; +typedef unsigned __int32 LPARAM; #define CALLBACK #ifndef UINT @@ -155,14 +132,22 @@ typedef unsigned int UINT; #endif #ifndef LRESULT -typedef unsigned long LRESULT; +typedef unsigned __int32 LRESULT; #endif +/* NT4_DRIVER */ + +#elif defined(LINUX_DRIVER) + +#define TCalloc(size) (kmalloc( size, GFP_KERNEL )) +#define TCfree(memblock) kfree( memblock ) #else #define TCalloc malloc #define TCfree free +#ifdef _WIN32 + #pragma warning( disable : 4201 ) #pragma warning( disable : 4214 ) #pragma warning( disable : 4115 ) @@ -183,11 +168,26 @@ typedef unsigned long LRESULT; /* #pragma warning( default : 4514 ) this warning remains disabled */ /* This is needed to fix a bug with VC 5, the TCHAR macro _ttoi64 maps - incorrectly to atoi64 when it should be _atoi64 */ + incorrectly to atoLL when it should be _atoi64 */ #define atoi64 _atoi64 -#endif /* DEVICE_DRIVER */ +#endif /* _WIN32 */ + +#endif /* NT4_DRIVER */ + +#ifdef _WIN32 +#define burn(mem,size) do { volatile char *burnm = (volatile char *)(mem); int burnc = size; RtlSecureZeroMemory (mem, size); while (burnc--) *burnm++ = 0; } while (0) +#else +#define burn(mem,size) do { volatile char *burnm = (volatile char *)(mem); int burnc = size; while (burnc--) *burnm++ = 0; } while (0) +#endif + +#ifdef MAX_PATH +#define TC_MAX_PATH MAX_PATH +#else +#define TC_MAX_PATH 260 /* Includes the null terminator */ +#endif -typedef UINT (_stdcall * diskio_f) (int, void *, UINT); +#define MAX_URL_LENGTH 2084 /* Internet Explorer limit. Includes the terminating null character. */ -#pragma hdrstop +#define TC_APPLINK "http://www.truecrypt.org/applink.php?version=" VERSION_STRING +#define TC_APPLINK_SECURE "https://www.truecrypt.org/applink.php?version=" VERSION_STRING