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

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
1.1.1.25  root        6:  the original source code (contained in this file) and all other portions
1.1.1.26  root        7:  of this file are Copyright (c) 2003-2010 TrueCrypt Developers Association
                      8:  and are governed by the TrueCrypt License 3.0 the full text of which is
1.1.1.25  root        9:  contained in the file License.txt included in TrueCrypt binary and source
                     10:  code distribution 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.29! root       18: #define VERSION_STRING                                 "7.1a"
1.1       root       19: 
                     20: // Version number to compare against driver
1.1.1.29! root       21: #define VERSION_NUM                                            0x071a
1.1.1.24  root       22: 
                     23: // Release date
1.1.1.29! root       24: #define TC_STR_RELEASE_DATE                            "February 7, 2012"
        !            25: #define TC_RELEASE_DATE_YEAR                   2012
        !            26: #define TC_RELEASE_DATE_MONTH                  2
1.1.1.18  root       27: 
1.1.1.10  root       28: #define BYTES_PER_KB                    1024LL
                     29: #define BYTES_PER_MB                    1048576LL
                     30: #define BYTES_PER_GB                    1073741824LL
                     31: #define BYTES_PER_TB                    1099511627776LL
                     32: #define BYTES_PER_PB                    1125899906842624LL
1.1       root       33: 
                     34: /* GUI/driver errors */
                     35: 
                     36: #define WIDE(x) (LPWSTR)L##x
                     37: 
1.1.1.22  root       38: #ifdef _MSC_VER
                     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.22  root       55: #else // !_MSC_VER
                     56: 
                     57: #include <inttypes.h>
                     58: #include <limits.h>
                     59: 
                     60: typedef int8_t int8;
                     61: typedef int16_t int16;
                     62: typedef int32_t int32;
                     63: typedef int64_t int64;
                     64: typedef uint8_t byte;
                     65: typedef uint16_t uint16;
                     66: typedef uint32_t uint32;
                     67: typedef uint64_t uint64;
                     68: 
                     69: #if UCHAR_MAX != 0xffU
                     70: #error UCHAR_MAX != 0xff
                     71: #endif
                     72: #define __int8 char
                     73: 
                     74: #if USHRT_MAX != 0xffffU
                     75: #error USHRT_MAX != 0xffff
                     76: #endif
                     77: #define __int16 short
                     78: 
                     79: #if UINT_MAX != 0xffffffffU
                     80: #error UINT_MAX != 0xffffffff
                     81: #endif
                     82: #define __int32 int
                     83: 
                     84: typedef uint64 TC_LARGEST_COMPILER_UINT;
                     85: 
                     86: #define BOOL int
                     87: #ifndef FALSE
                     88: #define FALSE 0
                     89: #define TRUE 1
                     90: #endif
                     91: 
                     92: #endif // !_MSC_VER
                     93: 
1.1.1.18  root       94: #define TC_INT_TYPES_DEFINED
                     95: 
                     96: // Integer types required by Cryptolib
1.1.1.14  root       97: typedef unsigned __int8 uint_8t;
                     98: typedef unsigned __int16 uint_16t;
                     99: typedef unsigned __int32 uint_32t;
                    100: #ifndef TC_NO_COMPILER_INT64
1.1.1.22  root      101: typedef uint64 uint_64t;
1.1.1.14  root      102: #endif
                    103: 
                    104: typedef union 
                    105: {
                    106:        struct 
                    107:        {
                    108:                unsigned __int32 LowPart;
                    109:                unsigned __int32 HighPart;
                    110:        };
                    111: #ifndef TC_NO_COMPILER_INT64
1.1.1.22  root      112:        uint64 Value;
1.1.1.14  root      113: #endif
                    114: 
                    115: } UINT64_STRUCT;
                    116: 
                    117: #ifdef TC_WINDOWS_BOOT
1.1.1.24  root      118: 
                    119: #      ifdef  __cplusplus
                    120: extern "C"
                    121: #      endif
                    122: void ThrowFatalException (int line);
                    123: 
1.1.1.18  root      124: #      define TC_THROW_FATAL_EXCEPTION ThrowFatalException (__LINE__)
1.1.1.26  root      125: #elif defined (TC_WINDOWS_DRIVER)
1.1.1.14  root      126: #      define TC_THROW_FATAL_EXCEPTION KeBugCheckEx (SECURITY_SYSTEM, __LINE__, 0, 0, 'TC')
                    127: #else
                    128: #      define TC_THROW_FATAL_EXCEPTION *(char *) 0 = 0
                    129: #endif
                    130: 
1.1.1.26  root      131: #ifdef TC_WINDOWS_DRIVER
1.1       root      132: 
1.1.1.14  root      133: #include <ntifs.h>
1.1       root      134: #include <ntddk.h>             /* Standard header file for nt drivers */
                    135: #include <ntdddisk.h>          /* Standard I/O control codes  */
                    136: 
                    137: #define TCalloc(size) ((void *) ExAllocatePoolWithTag( NonPagedPool, size, 'MMCT' ))
                    138: #define TCfree(memblock) ExFreePoolWithTag( memblock, 'MMCT' )
                    139: 
                    140: #define DEVICE_DRIVER
                    141: 
                    142: #ifndef BOOL
                    143: typedef int BOOL;
                    144: #endif
                    145: 
                    146: #ifndef TRUE
                    147: #define TRUE 1
                    148: #endif
                    149: 
                    150: #ifndef FALSE
                    151: #define FALSE !TRUE
                    152: #endif
                    153: 
1.1.1.26  root      154: #else                          /* !TC_WINDOWS_DRIVER */
1.1       root      155: 
                    156: #define TCalloc malloc
                    157: #define TCfree free
                    158: 
1.1.1.8   root      159: #ifdef _WIN32
                    160: 
1.1.1.20  root      161: #ifndef TC_LOCAL_WIN32_WINNT_OVERRIDE
                    162: #      undef _WIN32_WINNT
                    163: #      define  _WIN32_WINNT 0x0501     /* Does not apply to the driver */
                    164: #endif
                    165: 
1.1       root      166: #include <windows.h>           /* Windows header */
                    167: #include <commctrl.h>          /* The common controls */
                    168: #include <process.h>           /* Process control */
                    169: #include <winioctl.h>
                    170: #include <stdio.h>             /* For sprintf */
                    171: 
1.1.1.8   root      172: #endif                         /* _WIN32 */
1.1       root      173: 
1.1.1.26  root      174: #endif                         /* !TC_WINDOWS_DRIVER */
1.1.1.8   root      175: 
1.1.1.18  root      176: #ifndef TC_TO_STRING
                    177: #      define TC_TO_STRING2(n) #n
                    178: #      define TC_TO_STRING(n) TC_TO_STRING2(n)
                    179: #endif
                    180: 
                    181: #ifdef DEVICE_DRIVER
                    182: #      if defined (DEBUG) || 0
                    183: #              if 1 // DbgPrintEx is not available on Windows 2000
                    184: #                      define Dump DbgPrint
                    185: #              else
                    186: #                      define Dump(...) DbgPrintEx (DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, __VA_ARGS__)
                    187: #              endif
1.1.1.22  root      188: #              define DumpMem(...) DumpMemory (__VA_ARGS__)
1.1.1.18  root      189: #      else
1.1.1.26  root      190: #              define Dump(...)
                    191: #              define DumpMem(...)
1.1.1.18  root      192: #      endif
                    193: #endif
                    194: 
                    195: #if !defined (trace_msg) && !defined (TC_WINDOWS_BOOT)
                    196: #      ifdef DEBUG
                    197: #              ifdef DEVICE_DRIVER
                    198: #                      define trace_msg Dump
                    199: #              elif defined (_WIN32)
                    200: #                      define trace_msg(...) do { char msg[2048]; _snprintf (msg, sizeof (msg), __VA_ARGS__); OutputDebugString (msg); } while (0)
                    201: #              endif
                    202: #              define trace_point trace_msg (__FUNCTION__ ":" TC_TO_STRING(__LINE__) "\n")
                    203: #      else
                    204: #              define trace_msg(...)
                    205: #              define trace_point
                    206: #      endif
                    207: #endif
                    208: 
                    209: #ifdef DEVICE_DRIVER
                    210: #      define TC_EVENT KEVENT
                    211: #      define TC_WAIT_EVENT(EVENT) KeWaitForSingleObject (&EVENT, Executive, KernelMode, FALSE, NULL)
                    212: #elif defined (_WIN32)
                    213: #      define TC_EVENT HANDLE
                    214: #      define TC_WAIT_EVENT(EVENT) WaitForSingleObject (EVENT, INFINITE)
                    215: #endif
                    216: 
1.1.1.8   root      217: #ifdef _WIN32
1.1.1.12  root      218: #define burn(mem,size) do { volatile char *burnm = (volatile char *)(mem); int burnc = size; RtlSecureZeroMemory (mem, size); while (burnc--) *burnm++ = 0; } while (0)
                    219: #else
                    220: #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      221: #endif
1.1.1.11  root      222: 
1.1.1.14  root      223: // The size of the memory area to wipe is in bytes amd it must be a multiple of 8.
                    224: #ifndef TC_NO_COMPILER_INT64
1.1.1.22  root      225: #      define FAST_ERASE64(mem,size) do { volatile uint64 *burnm = (volatile uint64 *)(mem); int burnc = size >> 3; while (burnc--) *burnm++ = 0; } while (0)
1.1.1.14  root      226: #else
                    227: #      define FAST_ERASE64(mem,size) do { volatile unsigned __int32 *burnm = (volatile unsigned __int32 *)(mem); int burnc = size >> 2; while (burnc--) *burnm++ = 0; } while (0)
                    228: #endif
                    229: 
1.1.1.16  root      230: #ifdef TC_WINDOWS_BOOT
1.1.1.18  root      231: #      ifndef max
                    232: #              define max(a,b) (((a) > (b)) ? (a) : (b))
                    233: #      endif
1.1.1.24  root      234: 
                    235: #      ifdef  __cplusplus
                    236: extern "C"
                    237: #      endif
                    238: void EraseMemory (void *memory, int size);
                    239: 
1.1.1.18  root      240: #      undef burn
                    241: #      define burn EraseMemory
1.1.1.16  root      242: #endif
                    243: 
1.1.1.11  root      244: #ifdef MAX_PATH
1.1.1.12  root      245: #define TC_MAX_PATH            MAX_PATH
1.1.1.11  root      246: #else
1.1.1.12  root      247: #define TC_MAX_PATH            260     /* Includes the null terminator */
1.1.1.11  root      248: #endif
1.1.1.12  root      249: 
1.1.1.24  root      250: #define TC_STR_RELEASED_BY "Released by TrueCrypt Foundation on " TC_STR_RELEASE_DATE
                    251: 
1.1.1.12  root      252: #define MAX_URL_LENGTH 2084 /* Internet Explorer limit. Includes the terminating null character. */
                    253: 
1.1.1.23  root      254: #define TC_HOMEPAGE "http://www.truecrypt.org/"
1.1.1.22  root      255: #define TC_APPLINK "http://www.truecrypt.org/applink?version=" VERSION_STRING
                    256: #define TC_APPLINK_SECURE "https://www.truecrypt.org/applink?version=" VERSION_STRING
1.1.1.14  root      257: 
                    258: enum
                    259: {
1.1.1.18  root      260:        /* WARNING: ADD ANY NEW CODES AT THE END (DO NOT INSERT THEM BETWEEN EXISTING). DO *NOT* DELETE ANY 
                    261:        EXISTING CODES! Changing these values or their meanings may cause incompatibility with other versions
                    262:        (for example, if a new version of the TrueCrypt installer receives an error code from an installed 
                    263:        driver whose version is lower, it will report and interpret the error incorrectly). */
                    264: 
                    265:        ERR_SUCCESS                                                             = 0,
                    266:        ERR_OS_ERROR                                                    = 1,
                    267:        ERR_OUTOFMEMORY                                                 = 2,
                    268:        ERR_PASSWORD_WRONG                                              = 3,
                    269:        ERR_VOL_FORMAT_BAD                                              = 4,
                    270:        ERR_DRIVE_NOT_FOUND                                             = 5,
                    271:        ERR_FILES_OPEN                                                  = 6,
                    272:        ERR_VOL_SIZE_WRONG                                              = 7,
                    273:        ERR_COMPRESSION_NOT_SUPPORTED                   = 8,
                    274:        ERR_PASSWORD_CHANGE_VOL_TYPE                    = 9,
                    275:        ERR_PASSWORD_CHANGE_VOL_VERSION                 = 10,
                    276:        ERR_VOL_SEEKING                                                 = 11,
                    277:        ERR_VOL_WRITING                                                 = 12,
                    278:        ERR_FILES_OPEN_LOCK                                             = 13,
                    279:        ERR_VOL_READING                                                 = 14,
                    280:        ERR_DRIVER_VERSION                                              = 15,
                    281:        ERR_NEW_VERSION_REQUIRED                                = 16,
                    282:        ERR_CIPHER_INIT_FAILURE                                 = 17,
                    283:        ERR_CIPHER_INIT_WEAK_KEY                                = 18,
                    284:        ERR_SELF_TESTS_FAILED                                   = 19,
                    285:        ERR_SECTOR_SIZE_INCOMPATIBLE                    = 20,
                    286:        ERR_VOL_ALREADY_MOUNTED                                 = 21,
                    287:        ERR_NO_FREE_DRIVES                                              = 22,
                    288:        ERR_FILE_OPEN_FAILED                                    = 23,
                    289:        ERR_VOL_MOUNT_FAILED                                    = 24,
1.1.1.20  root      290:        DEPRECATED_ERR_INVALID_DEVICE                   = 25,
1.1.1.18  root      291:        ERR_ACCESS_DENIED                                               = 26,
                    292:        ERR_MODE_INIT_FAILED                                    = 27,
                    293:        ERR_DONT_REPORT                                                 = 28,
                    294:        ERR_ENCRYPTION_NOT_COMPLETED                    = 29,
                    295:        ERR_PARAMETER_INCORRECT                                 = 30,
1.1.1.20  root      296:        ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG    = 31,
                    297:        ERR_NONSYS_INPLACE_ENC_INCOMPLETE               = 32,
                    298:        ERR_USER_ABORT                                                  = 33
1.1.1.14  root      299: };
                    300: 
                    301: #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.