"Fossies" - the Fresh Open Source Software Archive

Member "src/Boot/Windows/BootConfig.cpp" (10 Oct 2018, 2804 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 "BootConfig.cpp" 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 #include "BootConfig.h"
   14 
   15 byte BootSectorFlags;
   16 
   17 byte BootLoaderDrive;
   18 byte BootDrive;
   19 bool BootDriveGeometryValid = false;
   20 bool PreventNormalSystemBoot = false;
   21 bool PreventBootMenu = false;
   22 char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
   23 uint32 OuterVolumeBackupHeaderCrc;
   24 
   25 bool BootStarted = false;
   26 
   27 DriveGeometry BootDriveGeometry;
   28 
   29 CRYPTO_INFO *BootCryptoInfo;
   30 Partition EncryptedVirtualPartition;
   31 
   32 Partition ActivePartition;
   33 Partition PartitionFollowingActive;
   34 bool ExtraBootPartitionPresent = false;
   35 uint64 PimValueOrHiddenVolumeStartUnitNo; // reuse this variable for stored PIM value to reduce memory usage
   36 uint64 HiddenVolumeStartSector;
   37 
   38 #ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
   39 
   40 void ReadBootSectorUserConfiguration ()
   41 {
   42     byte userConfig;
   43 
   44     AcquireSectorBuffer();
   45 
   46     if (ReadWriteMBR (false, BootLoaderDrive, true) != BiosResultSuccess)
   47         goto ret;
   48 
   49     userConfig = SectorBuffer[TC_BOOT_SECTOR_USER_CONFIG_OFFSET];
   50 
   51 #ifdef TC_WINDOWS_BOOT_AES
   52     EnableHwEncryption (!(userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION));
   53 #endif
   54 
   55     PreventBootMenu = (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_ESC);
   56 
   57     memcpy (CustomUserMessage, SectorBuffer + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET, TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH);
   58     CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH] = 0;
   59 
   60     if (userConfig & TC_BOOT_USER_CFG_FLAG_SILENT_MODE)
   61     {
   62         if (CustomUserMessage[0])
   63         {
   64             InitVideoMode();
   65             Print (CustomUserMessage);
   66         }
   67 
   68         DisableScreenOutput();
   69     }
   70 
   71     if (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_PIM)
   72     {
   73         PimValueOrHiddenVolumeStartUnitNo.LowPart = 0;
   74         memcpy (&PimValueOrHiddenVolumeStartUnitNo.LowPart, SectorBuffer + TC_BOOT_SECTOR_PIM_VALUE_OFFSET, TC_BOOT_SECTOR_PIM_VALUE_SIZE);
   75     }
   76     else
   77         PimValueOrHiddenVolumeStartUnitNo.LowPart = -1;
   78 
   79     OuterVolumeBackupHeaderCrc = *(uint32 *) (SectorBuffer + TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET);
   80 
   81 ret:
   82     ReleaseSectorBuffer();
   83 }
   84 
   85 
   86 BiosResult UpdateBootSectorConfiguration (byte drive)
   87 {
   88     AcquireSectorBuffer();
   89 
   90     BiosResult result = ReadWriteMBR (false, drive);
   91     if (result != BiosResultSuccess)
   92         goto ret;
   93 
   94     SectorBuffer[TC_BOOT_SECTOR_CONFIG_OFFSET] = BootSectorFlags;
   95     result = ReadWriteMBR (true, drive);
   96 
   97 ret:
   98     ReleaseSectorBuffer();
   99     return result;
  100 }
  101 
  102 #endif // !TC_WINDOWS_BOOT_RESCUE_DISK_MODE