diff options
Diffstat (limited to 'src/Boot/Windows/BootCommon.h')
-rw-r--r-- | src/Boot/Windows/BootCommon.h | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/src/Boot/Windows/BootCommon.h b/src/Boot/Windows/BootCommon.h index 5d099a21..45a1a650 100644 --- a/src/Boot/Windows/BootCommon.h +++ b/src/Boot/Windows/BootCommon.h @@ -2,10 +2,10 @@ Derived from source code of TrueCrypt 7.1a, which is Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) - and all other portions of this file are Copyright (c) 2013-2016 IDRIX + Modifications and additions to the original source code (contained in this file) + and all other portions of this file are Copyright (c) 2013-2017 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source code distribution packages. */ @@ -16,9 +16,9 @@ #include "Common/Password.h" #include "BootDefs.h" // The user will be advised to upgrade the rescue disk if upgrading from the following or any previous version -#define TC_RESCUE_DISK_UPGRADE_NOTICE_MAX_VERSION 0x0118 +#define TC_RESCUE_DISK_UPGRADE_NOTICE_MAX_VERSION 0x0125 #define TC_BOOT_LOADER_AREA_SIZE (TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS) #define TC_BOOT_VOLUME_HEADER_SECTOR (TC_BOOT_LOADER_AREA_SECTOR_COUNT - 1) @@ -42,9 +42,9 @@ #pragma pack (1) typedef struct { - byte Flags; + uint8 Flags; } BootSectorConfiguration; // Modifying this value can introduce incompatibility with previous versions @@ -57,9 +57,9 @@ typedef struct uint16 BootLoaderVersion; uint16 CryptoInfoOffset; uint16 CryptoInfoLength; uint32 HeaderSaltCrc32; - Password BootPassword; + PasswordLegacy BootPassword; uint64 HiddenSystemPartitionStart; uint64 DecoySystemPartitionStart; uint32 Flags; uint32 BootDriveSignature; @@ -81,8 +81,12 @@ typedef struct #if defined(_MSC_VER) && !defined(TC_WINDOWS_BOOT) #define DCS_DISK_ENTRY_LIST_HEADER_SIGN SIGNATURE_64 ('D','C','S','D','E','L','S','T') +#ifndef CSTATIC_ASSERT +#define CSTATIC_ASSERT(b, name) typedef int StaticAssertFailed##name[b ? 1 : -1]; +#endif + #define DE_IDX_CRYPTOHEADER 0 #define DE_IDX_LIST 1 #define DE_IDX_DISKID 2 #define DE_IDX_MAINGPTHDR 3 @@ -92,9 +96,9 @@ typedef struct #define DE_IDX_EXEC 7 #define DE_IDX_PWDCACHE 8 #define DE_IDX_RND 9 #define DE_IDX_TOTAL 10 -static_assert(DE_IDX_TOTAL <= 15, "DE_IDX_TOTAL too big"); +CSTATIC_ASSERT(DE_IDX_TOTAL <= 15, DE_IDX_TOTAL_too_big); enum DcsDiskEntryTypes { DE_Unused = 0, DE_Sectors, @@ -115,9 +119,9 @@ typedef struct _SECREGION_BOOT_PARAMS { typedef struct { uint32 Data1; uint16 Data2; uint16 Data3; - byte Data4[8]; + uint8 Data4[8]; } DCS_GUID; // DE types typedef struct _DCS_DISK_ENTRY_SECTORS { @@ -126,56 +130,56 @@ typedef struct _DCS_DISK_ENTRY_SECTORS { uint64 Reserved; uint64 Start; // Start on disk (byte) uint64 Length; // length on disk (byte) } DCS_DISK_ENTRY_SECTORS; -static_assert(sizeof(DCS_DISK_ENTRY_SECTORS) == 32, "Wrong size DCS_DISK_ENTRY_SECTORS"); +CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_SECTORS) == 32, Wrong_size_DCS_DISK_ENTRY_SECTORS); typedef struct _DCS_DISK_ENTRY_PARAMS { uint32 Type; uint32 Offset; uint64 Reserved[2]; uint64 Length; // size of data } DCS_DISK_ENTRY_PARAMS; -static_assert(sizeof(DCS_DISK_ENTRY_PARAMS) == 32, "Wrong size DCS_DISK_ENTRY_PARAMS"); +CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_PARAMS) == 32, Wrong_size_DCS_DISK_ENTRY_PARAMS); typedef struct _DCS_DISK_ENTRY_DISKID { uint32 Type; uint32 MbrID; uint64 ReservedDiskId; DCS_GUID GptID; } DCS_DISK_ENTRY_DISKID; -static_assert(sizeof(DCS_DISK_ENTRY_DISKID) == 32, "Wrong size DCS_DISK_ENTRY_DISKID"); +CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_DISKID) == 32, Wrong_size_DCS_DISK_ENTRY_DISKID); #pragma warning(disable:4201) typedef struct _DCS_DISK_ENTRY { union { struct { uint32 Type; uint32 Offset; - byte reserved[16]; + uint8 reserved[16]; uint64 Length; // size of structure at Offset }; DCS_DISK_ENTRY_SECTORS Sectors; DCS_DISK_ENTRY_DISKID DiskId; DCS_DISK_ENTRY_PARAMS Prm; }; } DCS_DISK_ENTRY; #pragma warning(default:4201) -static_assert(sizeof(DCS_DISK_ENTRY) == 32, "Wrong size DCS_DISK_ENTRY"); +CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY) == 32, Wrong_size_DCS_DISK_ENTRY); // Static compile time checks field offsets #ifndef FIELD_OFFSET #define FIELD_OFFSET(t, f) ((UINTN)(&((t*)0)->f)) #endif -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Type), "Wrong Type offset"); -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_DISKID, Type), "Wrong Type offset"); -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Type), "Wrong Type offset"); -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Length), "Wrong Length offset"); -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Length), "Wrong Length offset"); -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Offset), "Wrong Offset offset"); -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Offset), "Wrong Offset offset"); - -// DE type specific data +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Type), Wrong_Type_offset); +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_DISKID, Type), Wrong_Type_offset); +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Type), Wrong_Type_offset); +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Length), Wrong_Length_offset); +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Length), Wrong_Length_offset); +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Offset), Wrong_Offset_offset); +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Offset), Wrong_Offset_offset); + +// DE type specific data // DE List typedef struct _DCS_DISK_ENTRY_LIST { // EFI_TABLE_HEADER uint64 Signature; @@ -188,26 +192,26 @@ typedef struct _DCS_DISK_ENTRY_LIST { uint32 DataSize; // DCS_DISK_ENTRY DE[15]; } DCS_DISK_ENTRY_LIST; -static_assert(sizeof(DCS_DISK_ENTRY_LIST) == 512, "Wrong size DCS_DISK_ENTRY_LIST"); +CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_LIST) == 512, Wrong_size_DCS_DISK_ENTRY_LIST); typedef struct _DCS_DEP_EXEC { DCS_GUID ExecPartGuid; uint16 ExecCmd[248]; } DCS_DEP_EXEC; -static_assert(sizeof(DCS_DEP_EXEC) == 512, "Wrong size DCS_DEP_EXEC"); +CSTATIC_ASSERT(sizeof(DCS_DEP_EXEC) == 512, Wrong_size_DCS_DEP_EXEC); #define DCS_DEP_PWD_CACHE_SIGN SIGNATURE_64 ('P','W','D','C','A','C','H','E') typedef struct _DCS_DEP_PWD_CACHE { uint64 Sign; uint32 CRC; uint32 Count; - Password Pwd[4]; + PasswordLegacy Pwd[4]; int32 Pim[4]; - byte pad[512 - 8 - 4 - 4 - (sizeof(Password) + 4) * 4]; + uint8 pad[512 - 8 - 4 - 4 - (sizeof(PasswordLegacy) + 4) * 4]; } DCS_DEP_PWD_CACHE; -static_assert(sizeof(DCS_DEP_PWD_CACHE) == 512, "Wrong size DCS_DEP_PWD_CACHE"); +CSTATIC_ASSERT(sizeof(DCS_DEP_PWD_CACHE) == 512, Wrong_size_DCS_DEP_PWD_CACHE); #pragma pack() #endif // #if !defined(TC_WINDOWS_BOOT) |