diff options
Diffstat (limited to 'src/Boot/Windows/BootEncryptedIo.cpp')
-rw-r--r-- | src/Boot/Windows/BootEncryptedIo.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/Boot/Windows/BootEncryptedIo.cpp b/src/Boot/Windows/BootEncryptedIo.cpp index 63fd0f47..24fbbbd0 100644 --- a/src/Boot/Windows/BootEncryptedIo.cpp +++ b/src/Boot/Windows/BootEncryptedIo.cpp @@ -3,9 +3,9 @@ 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 + 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. */ @@ -18,9 +18,9 @@ #include "BootDiskIo.h" #include "BootEncryptedIo.h" -BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte drive, uint64 sector, uint16 sectorCount) +BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, uint8 drive, uint64 sector, uint16 sectorCount) { BiosResult result; bool decrypt = true; @@ -75,9 +75,9 @@ BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte dri return result; } -BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, byte drive, uint64 sector, uint16 sectorCount) +BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, uint8 drive, uint64 sector, uint16 sectorCount) { BiosResult result = BiosResultSuccess; AcquireSectorBuffer(); uint64 dataUnitNo; @@ -107,12 +107,24 @@ BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, byt { EncryptDataUnits (SectorBuffer, &dataUnitNo, 1, BootCryptoInfo); } - result = WriteSectors (SectorBuffer, drive, sector + writeOffset, 1); + result = ReadWriteSectors (true, SectorBuffer, drive, sector + writeOffset, 1, true); + if (BiosResultTimeout == result) + { + if (BiosResultSuccess == ReadWriteSectors (false, TC_BOOT_LOADER_BUFFER_SEGMENT, 0, drive, sector + writeOffset, 8, false)) + { + CopyMemory (SectorBuffer, TC_BOOT_LOADER_BUFFER_SEGMENT,0, TC_LB_SIZE); + result = ReadWriteSectors (true, TC_BOOT_LOADER_BUFFER_SEGMENT, 0, drive, sector + writeOffset, 8, true); + } + } if (result != BiosResultSuccess) + { + sector += writeOffset; + PrintDiskError (result, true, drive, §or); break; + } ++sector; ++dataUnitNo; sourceOffset += TC_LB_SIZE; |