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

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.16! root       18: #define VERSION_STRING                                 "5.1"
1.1       root       19: 
                     20: // Version number to compare against driver
1.1.1.16! root       21: #define VERSION_NUM                                            0x0510
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
1.1.1.16! root       48: #define OPTIMAL_MIN_NTFS_VOLUME_SIZE   (4 * BYTES_PER_GB)
        !            49: #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).
1.1.1.14  root       50: #define MAX_HIDDEN_VOLUME_HOST_SIZE     MAX_NTFS_VOLUME_SIZE
1.1.1.6   root       51: #define MAX_HIDDEN_VOLUME_SIZE          ( MAX_HIDDEN_VOLUME_HOST_SIZE - HIDDEN_VOL_HEADER_OFFSET - HEADER_SIZE )
1.1.1.14  root       52: #define MIN_VOLUME_SIZE                 MIN_FAT_VOLUME_SIZE
                     53: #define MIN_HIDDEN_VOLUME_HOST_SIZE     ( MIN_VOLUME_SIZE * 2 + HIDDEN_VOL_HEADER_OFFSET + HEADER_SIZE )
                     54: 
                     55: #ifndef TC_NO_COMPILER_INT64
                     56: #if MAX_VOLUME_SIZE > MAX_VOLUME_SIZE_GENERAL
                     57: #error MAX_VOLUME_SIZE must be less than or equal to MAX_VOLUME_SIZE_GENERAL
                     58: #endif
                     59: #endif
1.1       root       60: 
                     61: #define WIDE(x) (LPWSTR)L##x
                     62: 
1.1.1.14  root       63: typedef __int8 int8;
                     64: typedef __int16 int16;
                     65: typedef __int32 int32;
                     66: typedef unsigned __int8 byte;
                     67: typedef unsigned __int16 uint16;
                     68: typedef unsigned __int32 uint32;
                     69: 
                     70: #ifdef TC_NO_COMPILER_INT64
                     71: typedef unsigned __int32       TC_LARGEST_COMPILER_UINT;
                     72: #else
                     73: typedef unsigned __int64       TC_LARGEST_COMPILER_UINT;
                     74: typedef __int64 int64;
                     75: typedef unsigned __int64 uint64;
                     76: #endif
                     77: 
                     78: // Needed by Cryptolib
                     79: typedef unsigned __int8 uint_8t;
                     80: typedef unsigned __int16 uint_16t;
                     81: typedef unsigned __int32 uint_32t;
                     82: #ifndef TC_NO_COMPILER_INT64
                     83: typedef unsigned __int64 uint_64t;
                     84: #endif
                     85: 
                     86: typedef union 
                     87: {
                     88:        struct 
                     89:        {
                     90:                unsigned __int32 LowPart;
                     91:                unsigned __int32 HighPart;
                     92:        };
                     93: #ifndef TC_NO_COMPILER_INT64
                     94:        unsigned __int64 Value;
                     95: #endif
                     96: 
                     97: } UINT64_STRUCT;
                     98: 
                     99: #ifdef TC_WINDOWS_BOOT
                    100: #      define TC_THROW_FATAL_EXCEPTION do { __asm hlt } while (1)
                    101: #elif defined (NT4_DRIVER)
                    102: #      define TC_THROW_FATAL_EXCEPTION KeBugCheckEx (SECURITY_SYSTEM, __LINE__, 0, 0, 'TC')
                    103: #else
                    104: #      define TC_THROW_FATAL_EXCEPTION *(char *) 0 = 0
                    105: #endif
                    106: 
1.1       root      107: #ifdef NT4_DRIVER
                    108: 
                    109: #pragma warning( disable : 4201 )
                    110: #pragma warning( disable : 4214 )
                    111: #pragma warning( disable : 4115 )
                    112: #pragma warning( disable : 4100 )
                    113: #pragma warning( disable : 4101 )
                    114: #pragma warning( disable : 4057 )
                    115: #pragma warning( disable : 4244 )
                    116: #pragma warning( disable : 4514 )
                    117: #pragma warning( disable : 4127 )
                    118: 
                    119: 
1.1.1.14  root      120: #include <ntifs.h>
1.1       root      121: #include <ntddk.h>             /* Standard header file for nt drivers */
1.1.1.14  root      122: 
1.1       root      123: #undef _WIN32_WINNT
                    124: #define        _WIN32_WINNT 0x0501
                    125: #include <ntdddisk.h>          /* Standard I/O control codes  */
                    126: #include <ntiologc.h>
                    127: 
                    128: #pragma warning( default : 4201 )
                    129: #pragma warning( default : 4214 )
                    130: #pragma warning( default : 4115 )
                    131: #pragma warning( default : 4100 )
                    132: #pragma warning( default : 4101 )
                    133: #pragma warning( default : 4057 )
                    134: #pragma warning( default : 4244 )
                    135: #pragma warning( default : 4127 )
                    136: 
                    137: /* #pragma warning( default : 4514 ) this warning remains disabled */
                    138: 
                    139: #define TCalloc(size) ((void *) ExAllocatePoolWithTag( NonPagedPool, size, 'MMCT' ))
                    140: #define TCfree(memblock) ExFreePoolWithTag( memblock, 'MMCT' )
                    141: 
                    142: #define DEVICE_DRIVER
                    143: 
                    144: #ifndef BOOL
                    145: typedef int BOOL;
                    146: #endif
                    147: 
                    148: #ifndef TRUE
                    149: #define TRUE 1
                    150: #endif
                    151: 
                    152: #ifndef FALSE
                    153: #define FALSE !TRUE
                    154: #endif
                    155: 
                    156: /* Define dummies for the drivers */
                    157: typedef int HFILE;
                    158: typedef unsigned int WPARAM;
1.1.1.8   root      159: typedef unsigned __int32 LPARAM;
1.1       root      160: #define CALLBACK
                    161: 
                    162: #ifndef UINT
                    163: typedef unsigned int UINT;
                    164: #endif
                    165: 
                    166: #ifndef LRESULT
1.1.1.8   root      167: typedef unsigned __int32 LRESULT;
1.1       root      168: #endif
1.1.1.9   root      169: /* NT4_DRIVER */
                    170: 
                    171: #else
1.1       root      172: 
                    173: #define TCalloc malloc
                    174: #define TCfree free
                    175: 
1.1.1.8   root      176: #ifdef _WIN32
                    177: 
1.1       root      178: #pragma warning( disable : 4201 )
                    179: #pragma warning( disable : 4214 )
                    180: #pragma warning( disable : 4115 )
                    181: #pragma warning( disable : 4514 )
                    182: 
                    183: #undef _WIN32_WINNT
                    184: #define        _WIN32_WINNT 0x0501
                    185: #include <windows.h>           /* Windows header */
                    186: #include <commctrl.h>          /* The common controls */
                    187: #include <process.h>           /* Process control */
                    188: #include <winioctl.h>
                    189: #include <stdio.h>             /* For sprintf */
                    190: 
                    191: #pragma warning( default : 4201 )
                    192: #pragma warning( default : 4214 )
                    193: #pragma warning( default : 4115 )
                    194: 
                    195: /* #pragma warning( default : 4514 ) this warning remains disabled */
                    196: 
                    197: /* This is needed to fix a bug with VC 5, the TCHAR macro _ttoi64 maps
1.1.1.10  root      198:    incorrectly to atoLL when it should be _atoi64 */
1.1       root      199: #define atoi64 _atoi64
                    200: 
1.1.1.8   root      201: #endif                         /* _WIN32 */
1.1       root      202: 
1.1.1.8   root      203: #endif                         /* NT4_DRIVER */
                    204: 
                    205: #ifdef _WIN32
1.1.1.12  root      206: #define burn(mem,size) do { volatile char *burnm = (volatile char *)(mem); int burnc = size; RtlSecureZeroMemory (mem, size); while (burnc--) *burnm++ = 0; } while (0)
                    207: #else
                    208: #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      209: #endif
1.1.1.11  root      210: 
1.1.1.14  root      211: // The size of the memory area to wipe is in bytes amd it must be a multiple of 8.
                    212: #ifndef TC_NO_COMPILER_INT64
                    213: #      define FAST_ERASE64(mem,size) do { volatile unsigned __int64 *burnm = (volatile unsigned __int64 *)(mem); int burnc = size >> 3; while (burnc--) *burnm++ = 0; } while (0)
                    214: #else
                    215: #      define FAST_ERASE64(mem,size) do { volatile unsigned __int32 *burnm = (volatile unsigned __int32 *)(mem); int burnc = size >> 2; while (burnc--) *burnm++ = 0; } while (0)
                    216: #endif
                    217: 
1.1.1.16! root      218: #ifdef TC_WINDOWS_BOOT
        !           219: #undef burn
        !           220: #define burn EraseMemory
        !           221: #endif
        !           222: 
1.1.1.11  root      223: #ifdef MAX_PATH
1.1.1.12  root      224: #define TC_MAX_PATH            MAX_PATH
1.1.1.11  root      225: #else
1.1.1.12  root      226: #define TC_MAX_PATH            260     /* Includes the null terminator */
1.1.1.11  root      227: #endif
1.1.1.12  root      228: 
                    229: #define MAX_URL_LENGTH 2084 /* Internet Explorer limit. Includes the terminating null character. */
                    230: 
                    231: #define TC_APPLINK "http://www.truecrypt.org/applink.php?version=" VERSION_STRING
                    232: #define TC_APPLINK_SECURE "https://www.truecrypt.org/applink.php?version=" VERSION_STRING
1.1.1.14  root      233: 
                    234: enum
                    235: {
1.1.1.16! root      236:        /* WARNING: Add any new codes at the end (do NOT insert them between existing). Do NOT delete any 
        !           237:        existing codes. Changing these values or their meanings may cause incompatibility with other 
        !           238:        versions (for example, if a new version of the TrueCrypt installer receives an error code from
        !           239:        an installed driver whose version is lower, it will interpret the error incorrectly). */
        !           240: 
1.1.1.14  root      241:        ERR_SUCCESS = 0,
                    242:        ERR_OS_ERROR = 1,
                    243:        ERR_OUTOFMEMORY,
                    244:        ERR_PASSWORD_WRONG,
                    245:        ERR_VOL_FORMAT_BAD,
                    246:        ERR_DRIVE_NOT_FOUND,
                    247:        ERR_FILES_OPEN,
                    248:        ERR_VOL_SIZE_WRONG,
                    249:        ERR_COMPRESSION_NOT_SUPPORTED,
                    250:        ERR_PASSWORD_CHANGE_VOL_TYPE,
                    251:        ERR_PASSWORD_CHANGE_VOL_VERSION,
                    252:        ERR_VOL_SEEKING,
                    253:        ERR_VOL_WRITING,
                    254:        ERR_FILES_OPEN_LOCK,
                    255:        ERR_VOL_READING,
                    256:        ERR_DRIVER_VERSION,
                    257:        ERR_NEW_VERSION_REQUIRED,
                    258:        ERR_CIPHER_INIT_FAILURE,
                    259:        ERR_CIPHER_INIT_WEAK_KEY,
                    260:        ERR_SELF_TESTS_FAILED,
                    261:        ERR_SECTOR_SIZE_INCOMPATIBLE,
                    262:        ERR_VOL_ALREADY_MOUNTED,
                    263:        ERR_NO_FREE_DRIVES,
                    264:        ERR_FILE_OPEN_FAILED,
                    265:        ERR_VOL_MOUNT_FAILED,
                    266:        ERR_INVALID_DEVICE,
                    267:        ERR_ACCESS_DENIED,
                    268:        ERR_MODE_INIT_FAILED,
1.1.1.16! root      269:        ERR_DONT_REPORT,
        !           270:        ERR_ENCRYPTION_NOT_COMPLETED,
        !           271:        ERR_PARAMETER_INCORRECT
1.1.1.14  root      272: };
                    273: 
                    274: #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.