"Fossies" - the Fresh Open Source Software Archive

Member "src/Boot/Windows/BootDefs.h" (10 Oct 2018, 11115 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "BootDefs.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  Derived from source code of TrueCrypt 7.1a, which is
    3  Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
    4  by the TrueCrypt License 3.0.
    5 
    6  Modifications and additions to the original source code (contained in this file)
    7  and all other portions of this file are Copyright (c) 2013-2017 IDRIX
    8  and are governed by the Apache License 2.0 the full text of which is
    9  contained in the file License.txt included in VeraCrypt binary and source
   10  code distribution packages.
   11 */
   12 
   13 #ifndef TC_HEADER_Boot_BootDefs
   14 #define TC_HEADER_Boot_BootDefs
   15 
   16 // Total memory required (CODE + DATA + BSS + STACK + 0x100) in KBytes - determined from linker map.
   17 #define TC__BOOT_MEMORY_REQUIRED    43
   18 
   19 #ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
   20 #   undef TC__BOOT_MEMORY_REQUIRED
   21 
   22 #   ifdef TC_WINDOWS_BOOT_AES
   23 #       ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
   24 #           define TC__BOOT_MEMORY_REQUIRED 31
   25 #       else
   26 #           define TC__BOOT_MEMORY_REQUIRED 29
   27 #       endif
   28 #   elif defined (TC_WINDOWS_BOOT_SERPENT)
   29 #       define TC__BOOT_MEMORY_REQUIRED     33
   30 #   elif defined (TC_WINDOWS_BOOT_TWOFISH)
   31 #       define TC__BOOT_MEMORY_REQUIRED     41
   32 #   elif defined (TC_WINDOWS_BOOT_CAMELLIA)
   33 #       define TC__BOOT_MEMORY_REQUIRED     31
   34 #   endif
   35 
   36 #if 0
   37 #   undef TC__BOOT_MEMORY_REQUIRED
   38 #   define TC__BOOT_MEMORY_REQUIRED 60
   39 #endif
   40 
   41 #endif
   42 
   43 // Modifying this value can introduce incompatibility with previous versions
   44 #define TC__BOOT_LOADER_SEGMENT         TC_HEX (9000)   // Some buggy BIOS routines fail if CS bits 0-10 are not zero
   45 
   46 #if TC__BOOT_MEMORY_REQUIRED <= 32
   47 #   define TC__BOOT_LOADER_SEGMENT_LOW  (TC__BOOT_LOADER_SEGMENT - 32 * 1024 / 16)
   48 #else
   49 #   define TC__BOOT_LOADER_SEGMENT_LOW  (TC__BOOT_LOADER_SEGMENT - 64 * 1024 / 16)
   50 #endif
   51 
   52 #define TC__COM_EXECUTABLE_OFFSET       TC_HEX (100)
   53 
   54 #define TC__BOOT_LOADER_LOWMEM_SEGMENT  TC_HEX (2000)
   55 #define TC__BOOT_LOADER_BUFFER_SEGMENT  TC_HEX (4000)
   56 #define TC__BOOT_LOADER_ALT_SEGMENT     TC_HEX (6000)
   57 
   58 #define TC__BOOT_LOADER_STACK_TOP (TC_BOOT_MEMORY_REQUIRED * TC_UNSIGNED (1024) - 4)
   59 
   60 #define TC__LB_SIZE 512
   61 #define TC__BOOT_LOADER_AREA_SECTOR_COUNT 63
   62 
   63 #define TC__BOOT_SECTOR_VERSION_OFFSET 430
   64 #define TC__BOOT_SECTOR_LOADER_LENGTH_OFFSET 432
   65 #define TC__BOOT_SECTOR_LOADER_CHECKSUM_OFFSET 434
   66 #define TC__BOOT_SECTOR_USER_CONFIG_OFFSET 438
   67 #define TC__BOOT_SECTOR_CONFIG_OFFSET 439   // The last byte that is reserved for the boot loader
   68 
   69 #define TC__BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH 24
   70 #define TC__BOOT_SECTOR_USER_MESSAGE_OFFSET (TC__BOOT_SECTOR_VERSION_OFFSET - TC__BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH)
   71 
   72 #define TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE 4
   73 #define TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET (TC__BOOT_SECTOR_USER_MESSAGE_OFFSET - TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE)
   74 
   75 #define TC__BOOT_SECTOR_PIM_VALUE_SIZE  2
   76 #define TC__BOOT_SECTOR_PIM_VALUE_OFFSET    (TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET - TC__BOOT_SECTOR_PIM_VALUE_SIZE)
   77 
   78 #define TC__BOOT_LOADER_DECOMPRESSOR_START_SECTOR 2
   79 #define TC__BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT 4
   80 #define TC__BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE 32768
   81 #define TC__BOOT_LOADER_COMPRESSED_BUFFER_OFFSET (TC_COM_EXECUTABLE_OFFSET + 3072)
   82 
   83 #define TC__BOOT_LOADER_START_SECTOR (TC_BOOT_LOADER_DECOMPRESSOR_START_SECTOR + TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT)
   84 #define TC__MAX_BOOT_LOADER_SECTOR_COUNT (TC_BOOT_LOADER_AREA_SECTOR_COUNT - TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT - 2)
   85 #define TC__MAX_BOOT_LOADER_DECOMPRESSED_SIZE ((TC_BOOT_LOADER_AREA_SECTOR_COUNT - 2) * TC_LB_SIZE)
   86 
   87 #define TC__BOOT_LOADER_BACKUP_SECTOR_COUNT 30
   88 
   89 #define TC__GZIP_HEADER_SIZE 10
   90 
   91 #define TC__BOOT_CFG_FLAG_AREA_SIZE 1   // In bytes
   92 
   93 // If you add more flags, revise TC__BOOT_CFG_FLAG_AREA_SIZE
   94 #define TC__BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE       TC_HEX (02)
   95 #define TC__BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER        TC_HEX (04)
   96 #define TC__BOOT_CFG_FLAG_RESCUE_DISABLE_HW_ENCRYPTION  TC_HEX (10)
   97 #define TC__BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER   TC_HEX (20)
   98 #define TC__BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE      (TC_HEX (40) + TC_HEX (80))
   99 
  100 // Modifying the following values can introduce incompatibility with previous versions
  101 #define TC__BOOT_USER_CFG_FLAG_SILENT_MODE              TC_HEX (01)
  102 #define TC__BOOT_USER_CFG_FLAG_DISABLE_ESC              TC_HEX (02)
  103 #define TC__BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION    TC_HEX (04)
  104 #define TC__BOOT_USER_CFG_FLAG_DISABLE_PIM              TC_HEX (08)
  105 #define TC__BOOT_USER_CFG_FLAG_STORE_HASH               TC_HEX (10)
  106 
  107 // The following items are treated as a 2-bit value (apply TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE to obtain the value)
  108 #define TC__HIDDEN_OS_CREATION_PHASE_NONE       0
  109 #define TC__HIDDEN_OS_CREATION_PHASE_CLONING    TC_HEX (40)     // The boot loader is to copy the content of the system partition to the hidden volume
  110 #define TC__HIDDEN_OS_CREATION_PHASE_WIPING     TC_HEX (80)     // The boot loader has successfully copied the content of the system partition to the hidden volume. The original OS is to be wiped now.
  111 #define TC__HIDDEN_OS_CREATION_PHASE_WIPED      (TC_HEX (40) + TC_HEX (80)) // The original OS has been wiped. The user is required to install a new OS (decoy OS) on the system partition now.
  112 
  113 
  114 #ifdef TC_ASM_PREPROCESS
  115 
  116 #define TC_HEX(N) 0##N##h
  117 #define TC_UNSIGNED(N) N
  118 
  119 TC_BOOT_MEMORY_REQUIRED = TC__BOOT_MEMORY_REQUIRED
  120 TC_BOOT_LOADER_SEGMENT = TC__BOOT_LOADER_SEGMENT
  121 TC_BOOT_LOADER_SEGMENT_LOW = TC__BOOT_LOADER_SEGMENT_LOW
  122 TC_COM_EXECUTABLE_OFFSET = TC__COM_EXECUTABLE_OFFSET
  123 TC_BOOT_LOADER_LOWMEM_SEGMENT = TC__BOOT_LOADER_LOWMEM_SEGMENT
  124 TC_BOOT_LOADER_BUFFER_SEGMENT = TC__BOOT_LOADER_BUFFER_SEGMENT
  125 TC_BOOT_LOADER_ALT_SEGMENT = TC__BOOT_LOADER_ALT_SEGMENT
  126 TC_BOOT_LOADER_STACK_TOP = TC__BOOT_LOADER_STACK_TOP
  127 TC_LB_SIZE = TC__LB_SIZE
  128 TC_BOOT_LOADER_AREA_SECTOR_COUNT = TC__BOOT_LOADER_AREA_SECTOR_COUNT
  129 TC_BOOT_SECTOR_LOADER_LENGTH_OFFSET = TC__BOOT_SECTOR_LOADER_LENGTH_OFFSET
  130 TC_BOOT_SECTOR_LOADER_CHECKSUM_OFFSET = TC__BOOT_SECTOR_LOADER_CHECKSUM_OFFSET
  131 TC_BOOT_SECTOR_CONFIG_OFFSET = TC__BOOT_SECTOR_CONFIG_OFFSET
  132 TC_BOOT_SECTOR_USER_CONFIG_OFFSET = TC__BOOT_SECTOR_USER_CONFIG_OFFSET
  133 TC_BOOT_LOADER_DECOMPRESSOR_START_SECTOR = TC__BOOT_LOADER_DECOMPRESSOR_START_SECTOR
  134 TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT = TC__BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT
  135 TC_BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE = TC__BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE
  136 TC_BOOT_LOADER_COMPRESSED_BUFFER_OFFSET = TC__BOOT_LOADER_COMPRESSED_BUFFER_OFFSET
  137 TC_BOOT_LOADER_START_SECTOR = TC__BOOT_LOADER_START_SECTOR
  138 TC_MAX_BOOT_LOADER_SECTOR_COUNT = TC__MAX_BOOT_LOADER_SECTOR_COUNT
  139 TC_MAX_BOOT_LOADER_DECOMPRESSED_SIZE = TC__MAX_BOOT_LOADER_DECOMPRESSED_SIZE
  140 TC_BOOT_LOADER_BACKUP_SECTOR_COUNT = TC__BOOT_LOADER_BACKUP_SECTOR_COUNT
  141 TC_GZIP_HEADER_SIZE = TC__GZIP_HEADER_SIZE
  142 TC_BOOT_CFG_FLAG_AREA_SIZE = TC__BOOT_CFG_FLAG_AREA_SIZE
  143 TC_BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE = TC__BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE
  144 TC_BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER = TC__BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER
  145 TC_BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER = TC__BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER
  146 TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE = TC__BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE
  147 TC_BOOT_USER_CFG_FLAG_SILENT_MODE = TC__BOOT_USER_CFG_FLAG_SILENT_MODE
  148 TC_HIDDEN_OS_CREATION_PHASE_NONE = TC__HIDDEN_OS_CREATION_PHASE_NONE
  149 TC_HIDDEN_OS_CREATION_PHASE_CLONING = TC__HIDDEN_OS_CREATION_PHASE_CLONING
  150 TC_HIDDEN_OS_CREATION_PHASE_WIPING = TC__HIDDEN_OS_CREATION_PHASE_WIPING
  151 TC_HIDDEN_OS_CREATION_PHASE_WIPED = TC__HIDDEN_OS_CREATION_PHASE_WIPED
  152 
  153 #else // TC_ASM_PREPROCESS
  154 
  155 #define TC_HEX(N) 0x##N
  156 #define TC_UNSIGNED(N) N##U
  157 
  158 #define TC_BOOT_MEMORY_REQUIRED TC__BOOT_MEMORY_REQUIRED
  159 #define TC_BOOT_LOADER_SEGMENT TC__BOOT_LOADER_SEGMENT
  160 #define TC_COM_EXECUTABLE_OFFSET TC__COM_EXECUTABLE_OFFSET
  161 #define TC_BOOT_LOADER_LOWMEM_SEGMENT TC__BOOT_LOADER_LOWMEM_SEGMENT
  162 #define TC_BOOT_LOADER_BUFFER_SEGMENT TC__BOOT_LOADER_BUFFER_SEGMENT
  163 #define TC_BOOT_LOADER_ALT_SEGMENT TC__BOOT_LOADER_ALT_SEGMENT
  164 #define TC_BOOT_LOADER_STACK_TOP (TC__BOOT_LOADER_STACK_TOP)
  165 #define TC_BOOT_LOADER_AREA_SECTOR_COUNT TC__BOOT_LOADER_AREA_SECTOR_COUNT
  166 #define TC_BOOT_SECTOR_USER_MESSAGE_OFFSET TC__BOOT_SECTOR_USER_MESSAGE_OFFSET
  167 #define TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE
  168 #define TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET
  169 #define TC_BOOT_SECTOR_PIM_VALUE_SIZE TC__BOOT_SECTOR_PIM_VALUE_SIZE
  170 #define TC_BOOT_SECTOR_PIM_VALUE_OFFSET TC__BOOT_SECTOR_PIM_VALUE_OFFSET
  171 #define TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH TC__BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH
  172 #define TC_BOOT_SECTOR_VERSION_OFFSET TC__BOOT_SECTOR_VERSION_OFFSET
  173 #define TC_BOOT_SECTOR_LOADER_LENGTH_OFFSET TC__BOOT_SECTOR_LOADER_LENGTH_OFFSET
  174 #define TC_BOOT_SECTOR_LOADER_CHECKSUM_OFFSET TC__BOOT_SECTOR_LOADER_CHECKSUM_OFFSET
  175 #define TC_BOOT_LOADER_DECOMPRESSOR_START_SECTOR TC__BOOT_LOADER_DECOMPRESSOR_START_SECTOR
  176 #define TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT TC__BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT
  177 #define TC_BOOT_SECTOR_CONFIG_OFFSET TC__BOOT_SECTOR_CONFIG_OFFSET
  178 #define TC_BOOT_SECTOR_USER_CONFIG_OFFSET TC__BOOT_SECTOR_USER_CONFIG_OFFSET
  179 #define TC_BOOT_LOADER_START_SECTOR TC__BOOT_LOADER_START_SECTOR
  180 #define TC_LB_SIZE TC__LB_SIZE
  181 #define TC_MAX_BOOT_LOADER_SECTOR_COUNT TC__MAX_BOOT_LOADER_SECTOR_COUNT
  182 #define TC_MAX_BOOT_LOADER_DECOMPRESSED_SIZE TC__MAX_BOOT_LOADER_DECOMPRESSED_SIZE
  183 #define TC_BOOT_LOADER_BACKUP_SECTOR_COUNT TC__BOOT_LOADER_BACKUP_SECTOR_COUNT
  184 #define TC_GZIP_HEADER_SIZE TC__GZIP_HEADER_SIZE
  185 #define TC_BOOT_CFG_FLAG_AREA_SIZE TC__BOOT_CFG_FLAG_AREA_SIZE
  186 #define TC_BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE TC__BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE
  187 #define TC_BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER TC__BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER
  188 #define TC_BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER TC__BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER
  189 #define TC_BOOT_CFG_FLAG_RESCUE_DISABLE_HW_ENCRYPTION TC__BOOT_CFG_FLAG_RESCUE_DISABLE_HW_ENCRYPTION
  190 #define TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE TC__BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE
  191 #define TC_BOOT_USER_CFG_FLAG_SILENT_MODE TC__BOOT_USER_CFG_FLAG_SILENT_MODE
  192 #define TC_BOOT_USER_CFG_FLAG_DISABLE_ESC TC__BOOT_USER_CFG_FLAG_DISABLE_ESC
  193 #define TC_BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION TC__BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION
  194 #define TC_BOOT_USER_CFG_FLAG_DISABLE_PIM TC__BOOT_USER_CFG_FLAG_DISABLE_PIM
  195 #define TC_BOOT_USER_CFG_FLAG_STORE_HASH TC__BOOT_USER_CFG_FLAG_STORE_HASH
  196 #define TC_HIDDEN_OS_CREATION_PHASE_NONE TC__HIDDEN_OS_CREATION_PHASE_NONE
  197 #define TC_HIDDEN_OS_CREATION_PHASE_CLONING TC__HIDDEN_OS_CREATION_PHASE_CLONING
  198 #define TC_HIDDEN_OS_CREATION_PHASE_WIPING TC__HIDDEN_OS_CREATION_PHASE_WIPING
  199 #define TC_HIDDEN_OS_CREATION_PHASE_WIPED TC__HIDDEN_OS_CREATION_PHASE_WIPED
  200 
  201 #endif // TC_ASM_PREPROCESS
  202 
  203 #define EFI_BOOTARGS_REGIONS_LOW 0x90000, 0x88000, 0x80000
  204 #define EFI_BOOTARGS_REGIONS_HIGH \
  205 0x100000, 0x200000, 0x300000, 0x400000, 0x500000, 0x600000, 0x700000, 0x800000, \
  206 0x900000, 0xA00000, 0xB00000, 0xC00000, 0xD00000, 0xE00000, 0xF00000, 0x1000000
  207 
  208 #define EFI_BOOTARGS_REGIONS EFI_BOOTARGS_REGIONS_LOW, EFI_BOOTARGS_REGIONS_HIGH
  209 
  210 #endif // TC_HEADER_Boot_BootDefs