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

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.20! root        8:  by the TrueCrypt License 2.6 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.20! root       18: #define VERSION_STRING                                 "6.1"
1.1       root       19: 
                     20: // Version number to compare against driver
1.1.1.20! root       21: #define VERSION_NUM                                            0x0610
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.1.20! root      102: #ifndef TC_LOCAL_WIN32_WINNT_OVERRIDE
        !           103: #      undef _WIN32_WINNT
        !           104: #      define  _WIN32_WINNT 0x0501     /* Does not apply to user-space apps */
        !           105: #endif
        !           106: 
1.1       root      107: #include <ntdddisk.h>          /* Standard I/O control codes  */
                    108: #include <ntiologc.h>
                    109: 
                    110: #pragma warning( default : 4201 )
                    111: #pragma warning( default : 4214 )
                    112: #pragma warning( default : 4115 )
                    113: #pragma warning( default : 4100 )
                    114: #pragma warning( default : 4101 )
                    115: #pragma warning( default : 4057 )
                    116: #pragma warning( default : 4244 )
                    117: #pragma warning( default : 4127 )
                    118: 
                    119: /* #pragma warning( default : 4514 ) this warning remains disabled */
                    120: 
                    121: #define TCalloc(size) ((void *) ExAllocatePoolWithTag( NonPagedPool, size, 'MMCT' ))
                    122: #define TCfree(memblock) ExFreePoolWithTag( memblock, 'MMCT' )
                    123: 
                    124: #define DEVICE_DRIVER
                    125: 
                    126: #ifndef BOOL
                    127: typedef int BOOL;
                    128: #endif
                    129: 
                    130: #ifndef TRUE
                    131: #define TRUE 1
                    132: #endif
                    133: 
                    134: #ifndef FALSE
                    135: #define FALSE !TRUE
                    136: #endif
                    137: 
                    138: /* Define dummies for the drivers */
                    139: typedef int HFILE;
                    140: typedef unsigned int WPARAM;
1.1.1.8   root      141: typedef unsigned __int32 LPARAM;
1.1       root      142: #define CALLBACK
                    143: 
                    144: #ifndef UINT
                    145: typedef unsigned int UINT;
                    146: #endif
                    147: 
                    148: #ifndef LRESULT
1.1.1.8   root      149: typedef unsigned __int32 LRESULT;
1.1       root      150: #endif
1.1.1.9   root      151: /* NT4_DRIVER */
                    152: 
                    153: #else
1.1       root      154: 
                    155: #define TCalloc malloc
                    156: #define TCfree free
                    157: 
1.1.1.8   root      158: #ifdef _WIN32
                    159: 
1.1       root      160: #pragma warning( disable : 4201 )
                    161: #pragma warning( disable : 4214 )
                    162: #pragma warning( disable : 4115 )
                    163: #pragma warning( disable : 4514 )
                    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: 
                    176: #pragma warning( default : 4201 )
                    177: #pragma warning( default : 4214 )
                    178: #pragma warning( default : 4115 )
                    179: 
                    180: /* #pragma warning( default : 4514 ) this warning remains disabled */
                    181: 
                    182: /* This is needed to fix a bug with VC 5, the TCHAR macro _ttoi64 maps
1.1.1.10  root      183:    incorrectly to atoLL when it should be _atoi64 */
1.1       root      184: #define atoi64 _atoi64
                    185: 
1.1.1.8   root      186: #endif                         /* _WIN32 */
1.1       root      187: 
1.1.1.8   root      188: #endif                         /* NT4_DRIVER */
                    189: 
1.1.1.18  root      190: #ifndef TC_TO_STRING
                    191: #      define TC_TO_STRING2(n) #n
                    192: #      define TC_TO_STRING(n) TC_TO_STRING2(n)
                    193: #endif
                    194: 
                    195: #ifdef DEVICE_DRIVER
                    196: #      if defined (DEBUG) || 0
                    197: #              if 1 // DbgPrintEx is not available on Windows 2000
                    198: #                      define Dump DbgPrint
                    199: #              else
                    200: #                      define Dump(...) DbgPrintEx (DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, __VA_ARGS__)
                    201: #              endif
                    202: #                      define DumpMem(...) DumpMemory (__VA_ARGS__)
                    203: #      else
                    204: #              define Dump(...) ((void) 0)
                    205: #              define DumpMem(...) ((void) 0)
                    206: #      endif
                    207: #endif
                    208: 
                    209: #if !defined (trace_msg) && !defined (TC_WINDOWS_BOOT)
                    210: #      ifdef DEBUG
                    211: #              ifdef DEVICE_DRIVER
                    212: #                      define trace_msg Dump
                    213: #              elif defined (_WIN32)
                    214: #                      define trace_msg(...) do { char msg[2048]; _snprintf (msg, sizeof (msg), __VA_ARGS__); OutputDebugString (msg); } while (0)
                    215: #              endif
                    216: #              define trace_point trace_msg (__FUNCTION__ ":" TC_TO_STRING(__LINE__) "\n")
                    217: #      else
                    218: #              define trace_msg(...)
                    219: #              define trace_point
                    220: #      endif
                    221: #endif
                    222: 
                    223: #ifdef DEVICE_DRIVER
                    224: #      define TC_EVENT KEVENT
                    225: #      define TC_WAIT_EVENT(EVENT) KeWaitForSingleObject (&EVENT, Executive, KernelMode, FALSE, NULL)
                    226: #elif defined (_WIN32)
                    227: #      define TC_EVENT HANDLE
                    228: #      define TC_WAIT_EVENT(EVENT) WaitForSingleObject (EVENT, INFINITE)
                    229: #endif
                    230: 
1.1.1.8   root      231: #ifdef _WIN32
1.1.1.12  root      232: #define burn(mem,size) do { volatile char *burnm = (volatile char *)(mem); int burnc = size; RtlSecureZeroMemory (mem, size); while (burnc--) *burnm++ = 0; } while (0)
                    233: #else
                    234: #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      235: #endif
1.1.1.11  root      236: 
1.1.1.14  root      237: // The size of the memory area to wipe is in bytes amd it must be a multiple of 8.
                    238: #ifndef TC_NO_COMPILER_INT64
                    239: #      define FAST_ERASE64(mem,size) do { volatile unsigned __int64 *burnm = (volatile unsigned __int64 *)(mem); int burnc = size >> 3; while (burnc--) *burnm++ = 0; } while (0)
                    240: #else
                    241: #      define FAST_ERASE64(mem,size) do { volatile unsigned __int32 *burnm = (volatile unsigned __int32 *)(mem); int burnc = size >> 2; while (burnc--) *burnm++ = 0; } while (0)
                    242: #endif
                    243: 
1.1.1.16  root      244: #ifdef TC_WINDOWS_BOOT
1.1.1.18  root      245: #      ifndef max
                    246: #              define max(a,b) (((a) > (b)) ? (a) : (b))
                    247: #      endif
                    248: #      undef burn
                    249: #      define burn EraseMemory
1.1.1.16  root      250: #endif
                    251: 
1.1.1.11  root      252: #ifdef MAX_PATH
1.1.1.12  root      253: #define TC_MAX_PATH            MAX_PATH
1.1.1.11  root      254: #else
1.1.1.12  root      255: #define TC_MAX_PATH            260     /* Includes the null terminator */
1.1.1.11  root      256: #endif
1.1.1.12  root      257: 
                    258: #define MAX_URL_LENGTH 2084 /* Internet Explorer limit. Includes the terminating null character. */
                    259: 
                    260: #define TC_APPLINK "http://www.truecrypt.org/applink.php?version=" VERSION_STRING
                    261: #define TC_APPLINK_SECURE "https://www.truecrypt.org/applink.php?version=" VERSION_STRING
1.1.1.14  root      262: 
                    263: enum
                    264: {
1.1.1.18  root      265:        /* WARNING: ADD ANY NEW CODES AT THE END (DO NOT INSERT THEM BETWEEN EXISTING). DO *NOT* DELETE ANY 
                    266:        EXISTING CODES! Changing these values or their meanings may cause incompatibility with other versions
                    267:        (for example, if a new version of the TrueCrypt installer receives an error code from an installed 
                    268:        driver whose version is lower, it will report and interpret the error incorrectly). */
                    269: 
                    270:        ERR_SUCCESS                                                             = 0,
                    271:        ERR_OS_ERROR                                                    = 1,
                    272:        ERR_OUTOFMEMORY                                                 = 2,
                    273:        ERR_PASSWORD_WRONG                                              = 3,
                    274:        ERR_VOL_FORMAT_BAD                                              = 4,
                    275:        ERR_DRIVE_NOT_FOUND                                             = 5,
                    276:        ERR_FILES_OPEN                                                  = 6,
                    277:        ERR_VOL_SIZE_WRONG                                              = 7,
                    278:        ERR_COMPRESSION_NOT_SUPPORTED                   = 8,
                    279:        ERR_PASSWORD_CHANGE_VOL_TYPE                    = 9,
                    280:        ERR_PASSWORD_CHANGE_VOL_VERSION                 = 10,
                    281:        ERR_VOL_SEEKING                                                 = 11,
                    282:        ERR_VOL_WRITING                                                 = 12,
                    283:        ERR_FILES_OPEN_LOCK                                             = 13,
                    284:        ERR_VOL_READING                                                 = 14,
                    285:        ERR_DRIVER_VERSION                                              = 15,
                    286:        ERR_NEW_VERSION_REQUIRED                                = 16,
                    287:        ERR_CIPHER_INIT_FAILURE                                 = 17,
                    288:        ERR_CIPHER_INIT_WEAK_KEY                                = 18,
                    289:        ERR_SELF_TESTS_FAILED                                   = 19,
                    290:        ERR_SECTOR_SIZE_INCOMPATIBLE                    = 20,
                    291:        ERR_VOL_ALREADY_MOUNTED                                 = 21,
                    292:        ERR_NO_FREE_DRIVES                                              = 22,
                    293:        ERR_FILE_OPEN_FAILED                                    = 23,
                    294:        ERR_VOL_MOUNT_FAILED                                    = 24,
1.1.1.20! root      295:        DEPRECATED_ERR_INVALID_DEVICE                   = 25,
1.1.1.18  root      296:        ERR_ACCESS_DENIED                                               = 26,
                    297:        ERR_MODE_INIT_FAILED                                    = 27,
                    298:        ERR_DONT_REPORT                                                 = 28,
                    299:        ERR_ENCRYPTION_NOT_COMPLETED                    = 29,
                    300:        ERR_PARAMETER_INCORRECT                                 = 30,
1.1.1.20! root      301:        ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG    = 31,
        !           302:        ERR_NONSYS_INPLACE_ENC_INCOMPLETE               = 32,
        !           303:        ERR_USER_ABORT                                                  = 33
1.1.1.14  root      304: };
                    305: 
                    306: #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.