Annotation of truecrypt/common/tcdefs.h, revision 1.1.1.15

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
                      8:  by the TrueCrypt License 2.4 the full text of which is contained in the
                      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.15! root       18: #define VERSION_STRING                                 "5.0a"
1.1       root       19: 
                     20: // Version number to compare against driver
1.1.1.15! root       21: #define VERSION_NUM                                            0x050a
1.1       root       22: 
                     23: // Version number written to volume header during format,
                     24: // specifies the minimum program version required to mount the volume
1.1.1.14  root       25: #define VOL_REQ_PROG_VERSION                   0x0500
1.1.1.6   root       26: 
                     27: // Volume header version
1.1.1.14  root       28: #define VOLUME_HEADER_VERSION                  0x0003 
1.1       root       29: 
1.1.1.13  root       30: // Sector size of encrypted filesystem, which may differ from sector size 
                     31: // of host filesystem/device (this is fully supported since v4.3). 
1.1.1.12  root       32: #define SECTOR_SIZE                     512
1.1       root       33: 
1.1.1.10  root       34: #define BYTES_PER_KB                    1024LL
                     35: #define BYTES_PER_MB                    1048576LL
                     36: #define BYTES_PER_GB                    1073741824LL
                     37: #define BYTES_PER_TB                    1099511627776LL
                     38: #define BYTES_PER_PB                    1125899906842624LL
1.1       root       39: 
                     40: /* GUI/driver errors */
                     41: 
1.1.1.14  root       42: #define MAX_128BIT_BLOCK_VOLUME_SIZE   BYTES_PER_PB                    // Security bound (128-bit block XTS mode)
                     43: #define MAX_VOLUME_SIZE_GENERAL                        0x7fffFFFFffffFFFFLL    // Signed 64-bit integer file offset values
                     44: #define MAX_VOLUME_SIZE                 MAX_128BIT_BLOCK_VOLUME_SIZE
                     45: #define MIN_FAT_VOLUME_SIZE                            19456
1.1.1.12  root       46: #define MAX_FAT_VOLUME_SIZE                            0x20000000000LL
1.1.1.14  root       47: #define MIN_NTFS_VOLUME_SIZE                   2634752
                     48: #define MAX_NTFS_VOLUME_SIZE                   128LL * BYTES_PER_TB    // NTFS volume can theoretically be up to 16 exabytes, but Windows XP and 2003 limit the size to that addressable with 32-bit clusters, i.e. max size is 128 TB (if 64-KB clusters are used).
                     49: #define MAX_HIDDEN_VOLUME_HOST_SIZE     MAX_NTFS_VOLUME_SIZE
1.1.1.6   root       50: #define MAX_HIDDEN_VOLUME_SIZE          ( MAX_HIDDEN_VOLUME_HOST_SIZE - HIDDEN_VOL_HEADER_OFFSET - HEADER_SIZE )
1.1.1.14  root       51: #define MIN_VOLUME_SIZE                 MIN_FAT_VOLUME_SIZE
                     52: #define MIN_HIDDEN_VOLUME_HOST_SIZE     ( MIN_VOLUME_SIZE * 2 + HIDDEN_VOL_HEADER_OFFSET + HEADER_SIZE )
                     53: 
                     54: #ifndef TC_NO_COMPILER_INT64
                     55: #if MAX_VOLUME_SIZE > MAX_VOLUME_SIZE_GENERAL
                     56: #error MAX_VOLUME_SIZE must be less than or equal to MAX_VOLUME_SIZE_GENERAL
                     57: #endif
                     58: #endif
1.1       root       59: 
                     60: #define WIDE(x) (LPWSTR)L##x
                     61: 
1.1.1.14  root       62: typedef __int8 int8;
                     63: typedef __int16 int16;
                     64: typedef __int32 int32;
                     65: typedef unsigned __int8 byte;
                     66: typedef unsigned __int16 uint16;
                     67: typedef unsigned __int32 uint32;
                     68: 
                     69: #ifdef TC_NO_COMPILER_INT64
                     70: typedef unsigned __int32       TC_LARGEST_COMPILER_UINT;
                     71: #else
                     72: typedef unsigned __int64       TC_LARGEST_COMPILER_UINT;
                     73: typedef __int64 int64;
                     74: typedef unsigned __int64 uint64;
                     75: #endif
                     76: 
                     77: // Needed by Cryptolib
                     78: typedef unsigned __int8 uint_8t;
                     79: typedef unsigned __int16 uint_16t;
                     80: typedef unsigned __int32 uint_32t;
                     81: #ifndef TC_NO_COMPILER_INT64
                     82: typedef unsigned __int64 uint_64t;
                     83: #endif
                     84: 
                     85: typedef union 
                     86: {
                     87:        struct 
                     88:        {
                     89:                unsigned __int32 LowPart;
                     90:                unsigned __int32 HighPart;
                     91:        };
                     92: #ifndef TC_NO_COMPILER_INT64
                     93:        unsigned __int64 Value;
                     94: #endif
                     95: 
                     96: } UINT64_STRUCT;
                     97: 
                     98: #ifdef TC_WINDOWS_BOOT
                     99: #      define TC_THROW_FATAL_EXCEPTION do { __asm hlt } while (1)
                    100: #elif defined (NT4_DRIVER)
                    101: #      define TC_THROW_FATAL_EXCEPTION KeBugCheckEx (SECURITY_SYSTEM, __LINE__, 0, 0, 'TC')
                    102: #else
                    103: #      define TC_THROW_FATAL_EXCEPTION *(char *) 0 = 0
                    104: #endif
                    105: 
1.1       root      106: #ifdef NT4_DRIVER
                    107: 
                    108: #pragma warning( disable : 4201 )
                    109: #pragma warning( disable : 4214 )
                    110: #pragma warning( disable : 4115 )
                    111: #pragma warning( disable : 4100 )
                    112: #pragma warning( disable : 4101 )
                    113: #pragma warning( disable : 4057 )
                    114: #pragma warning( disable : 4244 )
                    115: #pragma warning( disable : 4514 )
                    116: #pragma warning( disable : 4127 )
                    117: 
                    118: 
1.1.1.14  root      119: #include <ntifs.h>
1.1       root      120: #include <ntddk.h>             /* Standard header file for nt drivers */
1.1.1.14  root      121: 
1.1       root      122: #undef _WIN32_WINNT
                    123: #define        _WIN32_WINNT 0x0501
                    124: #include <ntdddisk.h>          /* Standard I/O control codes  */
                    125: #include <ntiologc.h>
                    126: 
                    127: #pragma warning( default : 4201 )
                    128: #pragma warning( default : 4214 )
                    129: #pragma warning( default : 4115 )
                    130: #pragma warning( default : 4100 )
                    131: #pragma warning( default : 4101 )
                    132: #pragma warning( default : 4057 )
                    133: #pragma warning( default : 4244 )
                    134: #pragma warning( default : 4127 )
                    135: 
                    136: /* #pragma warning( default : 4514 ) this warning remains disabled */
                    137: 
                    138: #define TCalloc(size) ((void *) ExAllocatePoolWithTag( NonPagedPool, size, 'MMCT' ))
                    139: #define TCfree(memblock) ExFreePoolWithTag( memblock, 'MMCT' )
                    140: 
                    141: #define DEVICE_DRIVER
                    142: 
                    143: #ifndef BOOL
                    144: typedef int BOOL;
                    145: #endif
                    146: 
                    147: #ifndef TRUE
                    148: #define TRUE 1
                    149: #endif
                    150: 
                    151: #ifndef FALSE
                    152: #define FALSE !TRUE
                    153: #endif
                    154: 
                    155: /* Define dummies for the drivers */
                    156: typedef int HFILE;
                    157: typedef unsigned int WPARAM;
1.1.1.8   root      158: typedef unsigned __int32 LPARAM;
1.1       root      159: #define CALLBACK
                    160: 
                    161: #ifndef UINT
                    162: typedef unsigned int UINT;
                    163: #endif
                    164: 
                    165: #ifndef LRESULT
1.1.1.8   root      166: typedef unsigned __int32 LRESULT;
1.1       root      167: #endif
1.1.1.9   root      168: /* NT4_DRIVER */
                    169: 
                    170: #elif defined(LINUX_DRIVER)    
                    171: 
                    172: #define TCalloc(size) (kmalloc( size, GFP_KERNEL ))
                    173: #define TCfree(memblock) kfree( memblock )
1.1       root      174: 
1.1.1.9   root      175: #else
1.1       root      176: 
                    177: #define TCalloc malloc
                    178: #define TCfree free
                    179: 
1.1.1.8   root      180: #ifdef _WIN32
                    181: 
1.1       root      182: #pragma warning( disable : 4201 )
                    183: #pragma warning( disable : 4214 )
                    184: #pragma warning( disable : 4115 )
                    185: #pragma warning( disable : 4514 )
                    186: 
                    187: #undef _WIN32_WINNT
                    188: #define        _WIN32_WINNT 0x0501
                    189: #include <windows.h>           /* Windows header */
                    190: #include <commctrl.h>          /* The common controls */
                    191: #include <process.h>           /* Process control */
                    192: #include <winioctl.h>
                    193: #include <stdio.h>             /* For sprintf */
                    194: 
                    195: #pragma warning( default : 4201 )
                    196: #pragma warning( default : 4214 )
                    197: #pragma warning( default : 4115 )
                    198: 
                    199: /* #pragma warning( default : 4514 ) this warning remains disabled */
                    200: 
                    201: /* This is needed to fix a bug with VC 5, the TCHAR macro _ttoi64 maps
1.1.1.10  root      202:    incorrectly to atoLL when it should be _atoi64 */
1.1       root      203: #define atoi64 _atoi64
                    204: 
1.1.1.8   root      205: #endif                         /* _WIN32 */
1.1       root      206: 
1.1.1.8   root      207: #endif                         /* NT4_DRIVER */
                    208: 
                    209: #ifdef _WIN32
1.1.1.12  root      210: #define burn(mem,size) do { volatile char *burnm = (volatile char *)(mem); int burnc = size; RtlSecureZeroMemory (mem, size); while (burnc--) *burnm++ = 0; } while (0)
                    211: #else
                    212: #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      213: #endif
1.1.1.11  root      214: 
1.1.1.14  root      215: // The size of the memory area to wipe is in bytes amd it must be a multiple of 8.
                    216: #ifndef TC_NO_COMPILER_INT64
                    217: #      define FAST_ERASE64(mem,size) do { volatile unsigned __int64 *burnm = (volatile unsigned __int64 *)(mem); int burnc = size >> 3; while (burnc--) *burnm++ = 0; } while (0)
                    218: #else
                    219: #      define FAST_ERASE64(mem,size) do { volatile unsigned __int32 *burnm = (volatile unsigned __int32 *)(mem); int burnc = size >> 2; while (burnc--) *burnm++ = 0; } while (0)
                    220: #endif
                    221: 
1.1.1.11  root      222: #ifdef MAX_PATH
1.1.1.12  root      223: #define TC_MAX_PATH            MAX_PATH
1.1.1.11  root      224: #else
1.1.1.12  root      225: #define TC_MAX_PATH            260     /* Includes the null terminator */
1.1.1.11  root      226: #endif
1.1.1.12  root      227: 
                    228: #define MAX_URL_LENGTH 2084 /* Internet Explorer limit. Includes the terminating null character. */
                    229: 
                    230: #define TC_APPLINK "http://www.truecrypt.org/applink.php?version=" VERSION_STRING
                    231: #define TC_APPLINK_SECURE "https://www.truecrypt.org/applink.php?version=" VERSION_STRING
1.1.1.14  root      232: 
                    233: enum
                    234: {
                    235:        ERR_SUCCESS = 0,
                    236:        ERR_OS_ERROR = 1,
                    237:        ERR_OUTOFMEMORY,
                    238:        ERR_PASSWORD_WRONG,
                    239:        ERR_VOL_FORMAT_BAD,
                    240:        ERR_DRIVE_NOT_FOUND,
                    241:        ERR_FILES_OPEN,
                    242:        ERR_VOL_SIZE_WRONG,
                    243:        ERR_COMPRESSION_NOT_SUPPORTED,
                    244:        ERR_PASSWORD_CHANGE_VOL_TYPE,
                    245:        ERR_PASSWORD_CHANGE_VOL_VERSION,
                    246:        ERR_VOL_SEEKING,
                    247:        ERR_VOL_WRITING,
                    248:        ERR_FILES_OPEN_LOCK,
                    249:        ERR_VOL_READING,
                    250:        ERR_DRIVER_VERSION,
                    251:        ERR_NEW_VERSION_REQUIRED,
                    252:        ERR_CIPHER_INIT_FAILURE,
                    253:        ERR_CIPHER_INIT_WEAK_KEY,
                    254:        ERR_SELF_TESTS_FAILED,
                    255:        ERR_SECTOR_SIZE_INCOMPATIBLE,
                    256:        ERR_VOL_ALREADY_MOUNTED,
                    257:        ERR_NO_FREE_DRIVES,
                    258:        ERR_FILE_OPEN_FAILED,
                    259:        ERR_VOL_MOUNT_FAILED,
                    260:        ERR_INVALID_DEVICE,
                    261:        ERR_ACCESS_DENIED,
                    262:        ERR_MODE_INIT_FAILED,
                    263:        ERR_DONT_REPORT
                    264: };
                    265: 
                    266: #endif         // #ifndef TCDEFS_H

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.