VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-09-15 23:12:56 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-09-16 01:33:16 +0200
commit52c7445a795a623bc326699a5c465e8fa5294425 (patch)
treef8f8e18295107d4e90c49243f51f3800154d596d /src
parentdb80c0234236dc9beff60b4c47b5627dbfb99bd2 (diff)
downloadVeraCrypt-52c7445a795a623bc326699a5c465e8fa5294425.tar.gz
VeraCrypt-52c7445a795a623bc326699a5c465e8fa5294425.zip
Windows: Correctly detect presence of CD/DVD recorder during the creation of Rescue Disk. Check only CD/DVD drives and removable media when looking for rescue disk during its verification.
Diffstat (limited to 'src')
-rw-r--r--src/Common/BootEncryption.cpp48
-rw-r--r--src/Common/BootEncryption.h2
-rw-r--r--src/Format/Tcformat.c2
3 files changed, 30 insertions, 22 deletions
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp
index 02affc89..d84dd05d 100644
--- a/src/Common/BootEncryption.cpp
+++ b/src/Common/BootEncryption.cpp
@@ -1742,18 +1742,20 @@ namespace VeraCrypt
#endif
- bool BootEncryption::IsCDDrivePresent ()
+ bool BootEncryption::IsCDRecorderPresent ()
{
- for (char drive = 'Z'; drive >= 'C'; --drive)
- {
- string path = "X:\\";
- path[0] = drive;
+ ICDBurn* pICDBurn;
+ BOOL bHasRecorder = FALSE;
- if (GetDriveType (path.c_str()) == DRIVE_CDROM)
- return true;
+ if (SUCCEEDED( CoCreateInstance (CLSID_CDBurn, NULL,CLSCTX_INPROC_SERVER,IID_ICDBurn,(LPVOID*)&pICDBurn)))
+ {
+ if (pICDBurn->HasRecordableDrive (&bHasRecorder) != S_OK)
+ {
+ bHasRecorder = FALSE;
+ }
+ pICDBurn->Release();
}
-
- return false;
+ return bHasRecorder? true : false;
}
@@ -1766,20 +1768,26 @@ namespace VeraCrypt
{
try
{
- string path = "X:";
- path[0] = drive;
+ char rootPath[4] = { drive, ':', '\\', 0};
+ UINT driveType = GetDriveTypeA (rootPath);
+ // check that it is a CD/DVD drive or a removable media in case a bootable
+ // USB key was created from the rescue disk ISO file
+ if ((DRIVE_CDROM == driveType) || (DRIVE_REMOVABLE == driveType))
+ {
+ rootPath[2] = 0; // remove trailing backslash
- Device driveDevice (path, true);
- driveDevice.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);
+ Device driveDevice (rootPath, true);
+ driveDevice.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 = driveDevice.Read (buffer.Ptr(), (DWORD) buffer.Size());
- if (bytesRead != buffer.Size())
- continue;
+ DWORD bytesRead = driveDevice.Read (buffer.Ptr(), (DWORD) buffer.Size());
+ if (bytesRead != buffer.Size())
+ continue;
- if (memcmp (buffer.Ptr(), RescueIsoImage, buffer.Size()) == 0)
- return true;
+ if (memcmp (buffer.Ptr(), RescueIsoImage, buffer.Size()) == 0)
+ return true;
+ }
}
catch (...) { }
}
diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h
index 561e1723..eb546de2 100644
--- a/src/Common/BootEncryption.h
+++ b/src/Common/BootEncryption.h
@@ -174,7 +174,7 @@ namespace VeraCrypt
void InstallBootLoader (bool preserveUserConfig = false, bool hiddenOSCreation = false);
bool CheckBootloaderFingerprint (bool bSilent = false);
void InvalidateCachedSysDriveProperties ();
- bool IsCDDrivePresent ();
+ bool IsCDRecorderPresent ();
bool IsHiddenSystemRunning ();
bool IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
void PrepareHiddenOSCreation (int ea, int mode, int pkcs5);
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index 7dd34196..54196dee 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -7779,7 +7779,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
retryCDDriveCheck:
- if (!bDontVerifyRescueDisk && !BootEncObj->IsCDDrivePresent())
+ if (!bDontVerifyRescueDisk && !BootEncObj->IsCDRecorderPresent())
{
char *multiChoiceStr[] = { 0, "CD_BURNER_NOT_PRESENT",
"CD_BURNER_NOT_PRESENT_WILL_STORE_ISO",