From 9e1e128b14dd51de4e036a8002d2cad40efaaf54 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 16 Sep 2015 01:17:03 +0200 Subject: Windows: Add functionality to verify Rescue Disk ISO image file. --- src/Common/BootEncryption.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/Common/BootEncryption.cpp') diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp index d84dd05d..8b8c122c 100644 --- a/src/Common/BootEncryption.cpp +++ b/src/Common/BootEncryption.cpp @@ -1795,6 +1795,31 @@ namespace VeraCrypt return false; } + bool BootEncryption::VerifyRescueDiskIsoImage (const char* imageFile) + { + if (!RescueIsoImage) + throw ParameterIncorrect (SRC_POS); + + try + { + File isoFile (imageFile, true); + isoFile.CheckOpened (SRC_POS); + size_t verifiedSectorCount = (TC_CD_BOOTSECTOR_OFFSET + TC_ORIG_BOOT_LOADER_BACKUP_SECTOR_OFFSET + TC_BOOT_LOADER_AREA_SIZE) / 2048; + Buffer buffer ((verifiedSectorCount + 1) * 2048); + + DWORD bytesRead = isoFile.Read (buffer.Ptr(), (DWORD) buffer.Size()); + if ( (bytesRead == buffer.Size()) + && (memcmp (buffer.Ptr(), RescueIsoImage, buffer.Size()) == 0) + ) + { + return true; + } + } + catch (...) { } + + return false; + } + #ifndef SETUP -- cgit v1.2.3