diff options
Diffstat (limited to 'src/Common')
-rw-r--r-- | src/Common/BaseCom.cpp | 2 | ||||
-rw-r--r-- | src/Common/BootEncryption.cpp | 18 | ||||
-rw-r--r-- | src/Common/Dlgcode.c | 298 | ||||
-rw-r--r-- | src/Common/Dlgcode.h | 76 | ||||
-rw-r--r-- | src/Common/Exception.h | 6 | ||||
-rw-r--r-- | src/Common/Fat.c | 9 | ||||
-rw-r--r-- | src/Common/Fat.h | 2 | ||||
-rw-r--r-- | src/Common/Format.c | 29 | ||||
-rw-r--r-- | src/Common/Format.h | 2 | ||||
-rw-r--r-- | src/Common/Keyfiles.c | 28 | ||||
-rw-r--r-- | src/Common/Keyfiles.h | 2 | ||||
-rw-r--r-- | src/Common/Password.c | 4 | ||||
-rw-r--r-- | src/Common/Random.c | 12 | ||||
-rw-r--r-- | src/Common/Random.h | 6 | ||||
-rw-r--r-- | src/Common/SecurityToken.cpp | 4 | ||||
-rw-r--r-- | src/Common/SecurityToken.h | 8 | ||||
-rw-r--r-- | src/Common/Volumes.c | 12 | ||||
-rw-r--r-- | src/Common/Volumes.h | 4 |
18 files changed, 264 insertions, 258 deletions
diff --git a/src/Common/BaseCom.cpp b/src/Common/BaseCom.cpp index 69c614af..349edabc 100644 --- a/src/Common/BaseCom.cpp +++ b/src/Common/BaseCom.cpp @@ -48,7 +48,7 @@ BOOL ComGetInstanceBase (HWND hWnd, REFCLSID clsid, REFIID iid, void **tcServer) r = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, iid, tcServer) == S_OK;
if (!r)
- Error ("UAC_INIT_ERROR");
+ Error ("UAC_INIT_ERROR", hWnd);
return r;
}
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp index 47f6418f..a974c47d 100644 --- a/src/Common/BootEncryption.cpp +++ b/src/Common/BootEncryption.cpp @@ -1295,7 +1295,7 @@ namespace VeraCrypt UserEnrichRandomPool (ParentWindow);
- if (!RandgetBytes (request.WipeKey, sizeof (request.WipeKey), TRUE))
+ if (!RandgetBytes (ParentWindow, request.WipeKey, sizeof (request.WipeKey), TRUE))
throw ParameterIncorrect (SRC_POS);
CallDriver (TC_IOCTL_START_DECOY_SYSTEM_WIPE, &request, sizeof (request), NULL, 0);
@@ -1348,7 +1348,7 @@ namespace VeraCrypt #endif
byte randData[PRAND_DISK_WIPE_PASSES];
- if (!RandgetBytes (randData, sizeof (randData), FALSE))
+ if (!RandgetBytes (ParentWindow, randData, sizeof (randData), FALSE))
throw ParameterIncorrect (SRC_POS);
for (int wipePass = 0; wipePass < PRAND_DISK_WIPE_PASSES; wipePass++)
@@ -1557,7 +1557,7 @@ namespace VeraCrypt catch (Exception &e)
{
e.Show (ParentWindow);
- Warning ("SYS_LOADER_UNAVAILABLE_FOR_RESCUE_DISK");
+ Warning ("SYS_LOADER_UNAVAILABLE_FOR_RESCUE_DISK", ParentWindow);
}
// Boot loader backup
@@ -1631,7 +1631,7 @@ namespace VeraCrypt if (!IsRandomNumberGeneratorStarted())
throw ParameterIncorrect (SRC_POS);
- throw_sys_if (CreateVolumeHeaderInMemory (TRUE, (char *) VolumeHeader, ea, mode, password, pkcs5, NULL, &cryptoInfo,
+ throw_sys_if (CreateVolumeHeaderInMemory (ParentWindow, TRUE, (char *) VolumeHeader, ea, mode, password, pkcs5, NULL, &cryptoInfo,
volumeSize, 0, encryptedAreaStart, 0, TC_SYSENC_KEYSCOPE_MIN_REQ_PROG_VERSION, TC_HEADER_FLAG_ENCRYPTED_SYSTEM, TC_SECTOR_SIZE_BIOS, FALSE) != 0);
finally_do_arg (PCRYPTO_INFO*, &cryptoInfo, { crypto_close (*finally_arg); });
@@ -1708,7 +1708,7 @@ namespace VeraCrypt {
if (memcmp (bootLoaderBuf + i, TC_APP_NAME, strlen (TC_APP_NAME)) == 0)
{
- if (AskWarnNoYes ("TC_BOOT_LOADER_ALREADY_INSTALLED") == IDNO)
+ if (AskWarnNoYes ("TC_BOOT_LOADER_ALREADY_INSTALLED", ParentWindow) == IDNO)
throw UserAbort (SRC_POS);
return;
}
@@ -1974,7 +1974,7 @@ namespace VeraCrypt {
static bool confirmed = false;
- if (!confirmed && AskWarnNoYes ("WINDOWS_NOT_ON_BOOT_DRIVE_ERROR") == IDNO)
+ if (!confirmed && AskWarnNoYes ("WINDOWS_NOT_ON_BOOT_DRIVE_ERROR", ParentWindow) == IDNO)
throw UserAbort (SRC_POS);
confirmed = true;
@@ -2022,7 +2022,7 @@ namespace VeraCrypt + GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION")
+ L"\n\n\n"
+ GetString ("RESTRICT_PAGING_FILES_TO_SYS_PARTITION")
- ).c_str()) == IDYES)
+ ).c_str(), ParentWindow) == IDYES)
{
RestrictPagingFilesToSystemPartition();
RestartComputer();
@@ -2209,7 +2209,7 @@ namespace VeraCrypt {
PCRYPTO_INFO tmpCryptoInfo = NULL;
- status = CreateVolumeHeaderInMemory (!encStatus.HiddenSystem,
+ status = CreateVolumeHeaderInMemory (ParentWindow, !encStatus.HiddenSystem,
header,
cryptoInfo->ea,
cryptoInfo->mode,
@@ -2346,7 +2346,7 @@ namespace VeraCrypt if (e.ErrorCode != ERROR_CRC)
{
e.Show (ParentWindow);
- Error ("WHOLE_DRIVE_ENCRYPTION_PREVENTED_BY_DRIVERS");
+ Error ("WHOLE_DRIVE_ENCRYPTION_PREVENTED_BY_DRIVERS", ParentWindow);
throw UserAbort (SRC_POS);
}
}
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 21998368..3eb4e69d 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -538,7 +538,7 @@ DWORD handleWin32Error (HWND hwndDlg) // Access denied
if (dwError == ERROR_ACCESS_DENIED && !IsAdmin ())
{
- Error ("ERR_ACCESS_DENIED");
+ Error ("ERR_ACCESS_DENIED", hwndDlg);
SetLastError (dwError); // Preserve the original error code
return dwError;
}
@@ -558,11 +558,11 @@ DWORD handleWin32Error (HWND hwndDlg) // User-friendly hardware error explanation
if (IsDiskError (dwError))
- Error ("ERR_HARDWARE_ERROR");
+ Error ("ERR_HARDWARE_ERROR", hwndDlg);
// Device not ready
if (dwError == ERROR_NOT_READY)
- HandleDriveNotReadyError();
+ HandleDriveNotReadyError(hwndDlg);
SetLastError (dwError); // Preserve the original error code
@@ -2269,13 +2269,13 @@ void SavePostInstallTasksSettings (int command) }
-void DoPostInstallTasks (void)
+void DoPostInstallTasks (HWND hwndDlg)
{
BOOL bDone = FALSE;
if (FileExists (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_TUTORIAL)))
{
- if (AskYesNo ("AFTER_INSTALL_TUTORIAL") == IDYES)
+ if (AskYesNo ("AFTER_INSTALL_TUTORIAL", hwndDlg) == IDYES)
Applink ("beginnerstutorial", TRUE, "");
bDone = TRUE;
@@ -2283,7 +2283,7 @@ void DoPostInstallTasks (void) if (FileExists (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_RELEASE_NOTES)))
{
- if (AskYesNo ("AFTER_UPGRADE_RELEASE_NOTES") == IDYES)
+ if (AskYesNo ("AFTER_UPGRADE_RELEASE_NOTES", hwndDlg) == IDYES)
Applink ("releasenotes", TRUE, "");
bDone = TRUE;
@@ -2396,7 +2396,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine) if (strstr (lpszCommandLine, "/q UAC ") == lpszCommandLine)
{
- Error ("UAC_INIT_ERROR");
+ Error ("UAC_INIT_ERROR", NULL);
exit (1);
}
@@ -2454,7 +2454,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine) {
case WIN_2000:
if (osEx.wServicePackMajor < 3)
- Warning ("LARGE_IDE_WARNING_2K");
+ Warning ("LARGE_IDE_WARNING_2K", NULL);
else
{
DWORD val = 0, size = sizeof(val);
@@ -2465,7 +2465,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine) if (RegQueryValueEx (hkey, "EnableBigLba", 0, 0, (LPBYTE) &val, &size) != ERROR_SUCCESS
|| val != 1)
{
- Warning ("LARGE_IDE_WARNING_2K_REGISTRY");
+ Warning ("LARGE_IDE_WARNING_2K_REGISTRY", NULL);
}
RegCloseKey (hkey);
}
@@ -2478,7 +2478,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine) HKEY k;
// PE environment does not report version of SP
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\minint", 0, KEY_READ, &k) != ERROR_SUCCESS)
- Warning ("LARGE_IDE_WARNING_XP");
+ Warning ("LARGE_IDE_WARNING_XP", NULL);
else
RegCloseKey (k);
}
@@ -3133,7 +3133,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l {
if (WizardMode != WIZARD_MODE_SYS_DEVICE)
{
- if (AskYesNo ("CONFIRM_SYSTEM_ENCRYPTION_MODE") == IDNO)
+ if (AskYesNo ("CONFIRM_SYSTEM_ENCRYPTION_MODE", hwndDlg) == IDNO)
{
EndDialog (hwndDlg, IDCANCEL);
return 1;
@@ -3165,9 +3165,9 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l {
if (bWarnDeviceFormatAdvanced
&& !bHiddenVolDirect
- && AskWarnNoYes("FORMAT_DEVICE_FOR_ADVANCED_ONLY") == IDNO)
+ && AskWarnNoYes("FORMAT_DEVICE_FOR_ADVANCED_ONLY", hwndDlg) == IDNO)
{
- if (AskNoYes("CONFIRM_CHANGE_WIZARD_MODE_TO_FILE_CONTAINER") == IDYES)
+ if (AskNoYes("CONFIRM_CHANGE_WIZARD_MODE_TO_FILE_CONTAINER", hwndDlg) == IDYES)
{
SwitchWizardToFileContainerMode ();
}
@@ -3195,7 +3195,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l {
if (WizardMode != WIZARD_MODE_SYS_DEVICE)
{
- if (AskYesNo ("CONFIRM_SYSTEM_ENCRYPTION_MODE") == IDNO)
+ if (AskYesNo ("CONFIRM_SYSTEM_ENCRYPTION_MODE", hwndDlg) == IDNO)
{
NormalCursor ();
EndDialog (hwndDlg, IDCANCEL);
@@ -3231,11 +3231,11 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (!selectedDevice.Partitions.empty())
{
EnableWindow (GetDlgItem (hwndDlg, IDOK), FALSE);
- Error ("DEVICE_PARTITIONS_ERR_W_INPLACE_ENC_NOTE");
+ Error ("DEVICE_PARTITIONS_ERR_W_INPLACE_ENC_NOTE", hwndDlg);
return 1;
}
- if (AskWarnNoYes ("WHOLE_NONSYS_DEVICE_ENC_CONFIRM") == IDNO)
+ if (AskWarnNoYes ("WHOLE_NONSYS_DEVICE_ENC_CONFIRM", hwndDlg) == IDNO)
return 1;
}
#else // #ifdef VOLFORMAT
@@ -3994,7 +3994,7 @@ void handleError (HWND hwndDlg, int code) break;
case ERR_DRIVER_VERSION:
- Error ("DRIVER_VERSION");
+ Error ("DRIVER_VERSION", hwndDlg);
break;
case ERR_NEW_VERSION_REQUIRED:
@@ -4002,27 +4002,27 @@ void handleError (HWND hwndDlg, int code) break;
case ERR_SELF_TESTS_FAILED:
- Error ("ERR_SELF_TESTS_FAILED");
+ Error ("ERR_SELF_TESTS_FAILED", hwndDlg);
break;
case ERR_VOL_FORMAT_BAD:
- Error ("ERR_VOL_FORMAT_BAD");
+ Error ("ERR_VOL_FORMAT_BAD", hwndDlg);
break;
case ERR_ENCRYPTION_NOT_COMPLETED:
- Error ("ERR_ENCRYPTION_NOT_COMPLETED");
+ Error ("ERR_ENCRYPTION_NOT_COMPLETED", hwndDlg);
break;
case ERR_NONSYS_INPLACE_ENC_INCOMPLETE:
- Error ("ERR_NONSYS_INPLACE_ENC_INCOMPLETE");
+ Error ("ERR_NONSYS_INPLACE_ENC_INCOMPLETE", hwndDlg);
break;
case ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG:
- Error ("ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG");
+ Error ("ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG", hwndDlg);
break;
case ERR_PARAMETER_INCORRECT:
- Error ("ERR_PARAMETER_INCORRECT");
+ Error ("ERR_PARAMETER_INCORRECT", hwndDlg);
break;
case ERR_USER_ABORT:
@@ -4037,13 +4037,13 @@ void handleError (HWND hwndDlg, int code) }
-BOOL CheckFileStreamWriteErrors (FILE *file, const char *fileName)
+BOOL CheckFileStreamWriteErrors (HWND hwndDlg, FILE *file, const char *fileName)
{
if (ferror (file))
{
wchar_t s[TC_MAX_PATH];
StringCbPrintfW (s, sizeof (s), GetString ("CANNOT_WRITE_FILE_X"), fileName);
- ErrorDirect (s);
+ ErrorDirect (s, hwndDlg);
return FALSE;
}
@@ -4713,7 +4713,7 @@ BOOL CALLBACK BenchmarkDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (is_aes_hw_cpu_supported() && (driverConfig & TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION))
{
- Warning ("DISABLED_HW_AES_AFFECTS_PERFORMANCE");
+ Warning ("DISABLED_HW_AES_AFFECTS_PERFORMANCE", hwndDlg);
}
SYSTEM_INFO sysInfo;
@@ -4742,7 +4742,7 @@ BOOL CALLBACK BenchmarkDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (nbrThreads < min (sysInfo.dwNumberOfProcessors, GetMaxEncryptionThreadCount())
&& sysInfo.dwNumberOfProcessors > 1)
{
- Warning ("LIMITED_THREAD_COUNT_AFFECTS_PERFORMANCE");
+ Warning ("LIMITED_THREAD_COUNT_AFFECTS_PERFORMANCE", hwndDlg);
}
return 1;
@@ -4852,7 +4852,7 @@ static BOOL CALLBACK RandomPoolEnrichementDlgProc (HWND hwndDlg, UINT msg, WPARA if (bDisplayPoolContents)
{
- RandpeekBytes (randPool, sizeof (randPool));
+ RandpeekBytes (hwndDlg, randPool, sizeof (randPool));
if (memcmp (lastRandPool, randPool, sizeof(lastRandPool)) != 0)
{
@@ -4989,7 +4989,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP #ifndef VOLFORMAT
if (Randinit ())
{
- Error ("INIT_RAND");
+ Error ("INIT_RAND", hwndDlg);
EndDialog (hwndDlg, IDCLOSE);
}
#endif
@@ -5014,7 +5014,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP if (bDisplayPoolContents)
{
- RandpeekBytes (randPool, sizeof (randPool));
+ RandpeekBytes (hwndDlg, randPool, sizeof (randPool));
if (memcmp (lastRandPool, randPool, sizeof(lastRandPool)) != 0)
{
@@ -5091,7 +5091,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP keyfilesCount = strtoul(szNumber, NULL, 0);
if (keyfilesCount <= 0 || keyfilesCount == LONG_MAX)
{
- Warning("KEYFILE_INCORRECT_NUMBER");
+ Warning("KEYFILE_INCORRECT_NUMBER", hwndDlg);
SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM) GetDlgItem (hwndDlg, IDC_NUMBER_KEYFILES), TRUE);
return 1;
}
@@ -5104,7 +5104,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP keyfilesSize = strtoul(szNumber, NULL, 0);
if (keyfilesSize < 64 || keyfilesSize > 1024*1024)
{
- Warning("KEYFILE_INCORRECT_SIZE");
+ Warning("KEYFILE_INCORRECT_SIZE", hwndDlg);
SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM) GetDlgItem (hwndDlg, IDC_KEYFILES_SIZE), TRUE);
return 1;
}
@@ -5116,14 +5116,14 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP // Trim trailing space
if (TrimWhiteSpace(szFileBaseName) == 0)
{
- Warning("KEYFILE_EMPTY_BASE_NAME");
+ Warning("KEYFILE_EMPTY_BASE_NAME", hwndDlg);
SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM) GetDlgItem (hwndDlg, IDC_KEYFILES_BASE_NAME), TRUE);
return 1;
}
if (!IsValidFileName(szFileBaseName))
{
- Warning("KEYFILE_INVALID_BASE_NAME");
+ Warning("KEYFILE_INVALID_BASE_NAME", hwndDlg);
SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM) GetDlgItem (hwndDlg, IDC_KEYFILES_BASE_NAME), TRUE);
return 1;
}
@@ -5175,7 +5175,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP MultiByteToWideChar(CP_ACP, 0, szFileName, -1, wszFileName, sizeof(wszFileName) / sizeof(WCHAR));
StringCbPrintfW (s, sizeof(s), GetString ("KEYFILE_ALREADY_EXISTS"), wszFileName);
- status = AskWarnNoYesString (s);
+ status = AskWarnNoYesString (s, hwndDlg);
if (status == IDNO)
{
TCfree(keyfile);
@@ -5196,7 +5196,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP if (bRandomSize)
{
/* Generate a random size */
- if (!RandgetBytes ((unsigned char*) &keyfilesSize, sizeof(keyfilesSize), FALSE))
+ if (!RandgetBytes (hwndDlg, (unsigned char*) &keyfilesSize, sizeof(keyfilesSize), FALSE))
{
_close (fhKeyfile);
DeleteFile (szFileName);
@@ -5213,7 +5213,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP }
/* Generate the keyfile */
- if (!RandgetBytesFull (keyfile, keyfilesSize, TRUE, TRUE))
+ if (!RandgetBytesFull (hwndDlg, keyfile, keyfilesSize, TRUE, TRUE))
{
_close (fhKeyfile);
DeleteFile (szFileName);
@@ -5239,7 +5239,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP TCfree(keyfile);
NormalCursor();
- Info("KEYFILE_CREATED");
+ Info("KEYFILE_CREATED", hwndDlg);
return 1;
}
@@ -5410,7 +5410,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) n = GetWindowText(GetDlgItem(hwndDlg, IDC_KEY), szTmp, sizeof(szTmp));
if (n != ks * 2)
{
- Warning ("TEST_KEY_SIZE");
+ Warning ("TEST_KEY_SIZE", hwndDlg);
return 1;
}
@@ -5446,12 +5446,12 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
if (bEncrypt)
{
- Warning ("TEST_PLAINTEXT_SIZE");
+ Warning ("TEST_PLAINTEXT_SIZE", hwndDlg);
return 1;
}
else
{
- Warning ("TEST_CIPHERTEXT_SIZE");
+ Warning ("TEST_CIPHERTEXT_SIZE", hwndDlg);
return 1;
}
}
@@ -5477,7 +5477,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) if (GetWindowText(GetDlgItem(hwndDlg, IDC_SECONDARY_KEY), szTmp, sizeof(szTmp)) != 64)
{
- Warning ("TEST_INCORRECT_SECONDARY_KEY_SIZE");
+ Warning ("TEST_INCORRECT_SECONDARY_KEY_SIZE", hwndDlg);
return 1;
}
@@ -5501,7 +5501,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) if (tlen > 16 || tlen < 1)
{
- Warning ("TEST_INCORRECT_TEST_DATA_UNIT_SIZE");
+ Warning ("TEST_INCORRECT_TEST_DATA_UNIT_SIZE", hwndDlg);
return 1;
}
@@ -6283,7 +6283,7 @@ int MountVolume (HWND hwndDlg, #ifdef TCMOUNT
if (mountOptions->PartitionInInactiveSysEncScope)
{
- if (!CheckSysEncMountWithoutPBA (volumePath, quiet))
+ if (!CheckSysEncMountWithoutPBA (hwndDlg, volumePath, quiet))
return -1;
}
#endif
@@ -6291,14 +6291,14 @@ int MountVolume (HWND hwndDlg, if (IsMountedVolume (volumePath))
{
if (!quiet)
- Error ("VOL_ALREADY_MOUNTED");
+ Error ("VOL_ALREADY_MOUNTED", hwndDlg);
return -1;
}
if (!IsDriveAvailable (driveNo))
{
if (!quiet)
- Error ("DRIVE_LETTER_UNAVAILABLE");
+ Error ("DRIVE_LETTER_UNAVAILABLE", hwndDlg);
return -1;
}
@@ -6431,7 +6431,7 @@ retry: if (mount.bExclusiveAccess == FALSE)
{
if (!quiet)
- Error ("FILE_IN_USE_FAILED");
+ Error ("FILE_IN_USE_FAILED", hwndDlg);
return -1;
}
@@ -6444,7 +6444,7 @@ retry: }
// Ask user
- if (IDYES == AskWarnNoYes ("FILE_IN_USE"))
+ if (IDYES == AskWarnNoYes ("FILE_IN_USE", hwndDlg))
{
mount.bExclusiveAccess = FALSE;
goto retry;
@@ -6491,7 +6491,7 @@ retry: DWORD dwResult;
if (DeviceIoControl (hDriver, TC_IOCTL_OPEN_TEST, &openTestStruct, sizeof (OPEN_TEST_STRUCT), &openTestStruct, sizeof (OPEN_TEST_STRUCT), &dwResult, NULL) && openTestStruct.TCBootLoaderDetected)
- WarningDirect ((GetWrongPasswordErrorMessage (hwndDlg) + L"\n\n" + GetString ("HIDDEN_VOL_PROT_PASSWORD_US_KEYB_LAYOUT")).c_str());
+ WarningDirect ((GetWrongPasswordErrorMessage (hwndDlg) + L"\n\n" + GetString ("HIDDEN_VOL_PROT_PASSWORD_US_KEYB_LAYOUT")).c_str(), hwndDlg);
else
handleError (hwndDlg, mount.nReturnCode);
}
@@ -6515,7 +6515,7 @@ retry: && mount.UseBackupHeader)
{
if (bReportWrongPassword && !Silent)
- Warning ("HEADER_DAMAGED_AUTO_USED_HEADER_BAK");
+ Warning ("HEADER_DAMAGED_AUTO_USED_HEADER_BAK", hwndDlg);
}
LastMountedVolumeDirty = mount.FilesystemDirty;
@@ -6526,8 +6526,8 @@ retry: wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_VOLUME_DIRTY"), mountPoint);
- if (AskWarnYesNoStringTopmost (msg) == IDYES)
- CheckFilesystem (driveNo, TRUE);
+ if (AskWarnYesNoStringTopmost (msg, hwndDlg) == IDYES)
+ CheckFilesystem (hwndDlg, driveNo, TRUE);
}
if (mount.VolumeMountedReadOnlyAfterAccessDenied
@@ -6540,7 +6540,7 @@ retry: wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_CONTAINER_FORCED_READ_ONLY"), mountPoint);
- WarningDirect (msg);
+ WarningDirect (msg, hwndDlg);
}
if (mount.VolumeMountedReadOnlyAfterAccessDenied
@@ -6551,7 +6551,7 @@ retry: wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY"), mountPoint);
- WarningDirect (msg);
+ WarningDirect (msg, hwndDlg);
}
if (mount.VolumeMountedReadOnlyAfterDeviceWriteProtected
@@ -6562,11 +6562,11 @@ retry: wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY_WRITE_PROTECTION"), mountPoint);
- WarningDirect (msg);
+ WarningDirect (msg, hwndDlg);
if (CurrentOSMajor >= 6
&& strstr (volumePath, "\\Device\\HarddiskVolume") != volumePath
- && AskNoYes ("ASK_REMOVE_DEVICE_WRITE_PROTECTION") == IDYES)
+ && AskNoYes ("ASK_REMOVE_DEVICE_WRITE_PROTECTION", hwndDlg) == IDYES)
{
RemoveDeviceWriteProtection (hwndDlg, volumePath);
}
@@ -6607,7 +6607,7 @@ retry: {
if (result == ERR_FILES_OPEN && !Silent)
{
- if (IDYES == AskWarnYesNoTopmost ("UNMOUNT_LOCK_FAILED"))
+ if (IDYES == AskWarnYesNoTopmost ("UNMOUNT_LOCK_FAILED", hwndDlg))
{
forced = TRUE;
goto retry;
@@ -6623,7 +6623,7 @@ retry: return FALSE;
}
- Error ("UNMOUNT_FAILED");
+ Error ("UNMOUNT_FAILED", hwndDlg);
return FALSE;
}
@@ -6897,7 +6897,7 @@ __int64 GetStatsFreeSpaceOnPartition (const char *devicePath, float *percentFree if (!silent)
{
handleWin32Error (MainDlg);
- Error ("CANNOT_CALC_SPACE");
+ Error ("CANNOT_CALC_SPACE", MainDlg);
}
return -1;
@@ -6915,7 +6915,7 @@ __int64 GetStatsFreeSpaceOnPartition (const char *devicePath, float *percentFree if (!silent)
{
handleWin32Error (MainDlg);
- Error ("CANT_GET_VOLSIZE");
+ Error ("CANT_GET_VOLSIZE", MainDlg);
}
return -1;
}
@@ -7958,12 +7958,12 @@ void TaskBarIconDisplayBalloonTooltip (HWND hwnd, wchar_t *headline, wchar_t *te // Either of the pointers may be NULL
-void InfoBalloon (char *headingStringId, char *textStringId)
+void InfoBalloon (char *headingStringId, char *textStringId, HWND hwnd)
{
if (Silent)
return;
- TaskBarIconDisplayBalloonTooltip (MainDlg,
+ TaskBarIconDisplayBalloonTooltip (hwnd,
headingStringId == NULL ? L"VeraCrypt" : GetString (headingStringId),
textStringId == NULL ? L" " : GetString (textStringId),
FALSE);
@@ -7971,12 +7971,12 @@ void InfoBalloon (char *headingStringId, char *textStringId) // Either of the pointers may be NULL
-void InfoBalloonDirect (wchar_t *headingString, wchar_t *textString)
+void InfoBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd)
{
if (Silent)
return;
- TaskBarIconDisplayBalloonTooltip (MainDlg,
+ TaskBarIconDisplayBalloonTooltip (hwnd,
headingString == NULL ? L"VeraCrypt" : headingString,
textString == NULL ? L" " : textString,
FALSE);
@@ -7984,12 +7984,12 @@ void InfoBalloonDirect (wchar_t *headingString, wchar_t *textString) // Either of the pointers may be NULL
-void WarningBalloon (char *headingStringId, char *textStringId)
+void WarningBalloon (char *headingStringId, char *textStringId, HWND hwnd)
{
if (Silent)
return;
- TaskBarIconDisplayBalloonTooltip (MainDlg,
+ TaskBarIconDisplayBalloonTooltip (hwnd,
headingStringId == NULL ? L"VeraCrypt" : GetString (headingStringId),
textStringId == NULL ? L" " : GetString (textStringId),
TRUE);
@@ -7997,190 +7997,190 @@ void WarningBalloon (char *headingStringId, char *textStringId) // Either of the pointers may be NULL
-void WarningBalloonDirect (wchar_t *headingString, wchar_t *textString)
+void WarningBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd)
{
if (Silent)
return;
- TaskBarIconDisplayBalloonTooltip (MainDlg,
+ TaskBarIconDisplayBalloonTooltip (hwnd,
headingString == NULL ? L"VeraCrypt" : headingString,
textString == NULL ? L" " : textString,
TRUE);
}
-int Info (char *stringId)
+int Info (char *stringId, HWND hwnd)
{
if (Silent) return 0;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONINFORMATION);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONINFORMATION);
}
-int InfoTopMost (char *stringId)
+int InfoTopMost (char *stringId, HWND hwnd)
{
if (Silent) return 0;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TOPMOST);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TOPMOST);
}
-int InfoDirect (const wchar_t *msg)
+int InfoDirect (const wchar_t *msg, HWND hwnd)
{
if (Silent) return 0;
- return MessageBoxW (MainDlg, msg, lpszTitle, MB_ICONINFORMATION);
+ return MessageBoxW (hwnd, msg, lpszTitle, MB_ICONINFORMATION);
}
-int Warning (char *stringId)
+int Warning (char *stringId, HWND hwnd)
{
if (Silent) return 0;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONWARNING);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONWARNING);
}
-int WarningTopMost (char *stringId)
+int WarningTopMost (char *stringId, HWND hwnd)
{
if (Silent) return 0;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
}
-int WarningDirect (const wchar_t *warnMsg)
+int WarningDirect (const wchar_t *warnMsg, HWND hwnd)
{
if (Silent) return 0;
- return MessageBoxW (MainDlg, warnMsg, lpszTitle, MB_ICONWARNING);
+ return MessageBoxW (hwnd, warnMsg, lpszTitle, MB_ICONWARNING);
}
-int Error (char *stringId)
+int Error (char *stringId, HWND hwnd)
{
if (Silent) return 0;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONERROR);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONERROR);
}
-int ErrorTopMost (char *stringId)
+int ErrorTopMost (char *stringId, HWND hwnd)
{
if (Silent) return 0;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST);
}
-int ErrorDirect (const wchar_t *errMsg)
+int ErrorDirect (const wchar_t *errMsg, HWND hwnd)
{
if (Silent) return 0;
- return MessageBoxW (MainDlg, errMsg, lpszTitle, MB_ICONERROR);
+ return MessageBoxW (hwnd, errMsg, lpszTitle, MB_ICONERROR);
}
-int AskYesNo (char *stringId)
+int AskYesNo (char *stringId, HWND hwnd)
{
if (Silent) return IDNO;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1);
}
-int AskYesNoString (const wchar_t *str)
+int AskYesNoString (const wchar_t *str, HWND hwnd)
{
if (Silent) return IDNO;
- return MessageBoxW (MainDlg, str, lpszTitle, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1);
+ return MessageBoxW (hwnd, str, lpszTitle, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1);
}
-int AskYesNoTopmost (char *stringId)
+int AskYesNoTopmost (char *stringId, HWND hwnd)
{
if (Silent) return IDNO;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1 | MB_SETFOREGROUND | MB_TOPMOST);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON1 | MB_SETFOREGROUND | MB_TOPMOST);
}
-int AskNoYes (char *stringId)
+int AskNoYes (char *stringId, HWND hwnd)
{
if (Silent) return IDNO;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2);
}
-int AskOkCancel (char *stringId)
+int AskOkCancel (char *stringId, HWND hwnd)
{
if (Silent) return IDCANCEL;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONQUESTION | MB_OKCANCEL | MB_DEFBUTTON1);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONQUESTION | MB_OKCANCEL | MB_DEFBUTTON1);
}
-int AskWarnYesNo (char *stringId)
+int AskWarnYesNo (char *stringId, HWND hwnd)
{
if (Silent) return IDNO;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1);
}
-int AskWarnYesNoString (const wchar_t *string)
+int AskWarnYesNoString (const wchar_t *string, HWND hwnd)
{
if (Silent) return IDNO;
- return MessageBoxW (MainDlg, string, lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1);
+ return MessageBoxW (hwnd, string, lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1);
}
-int AskWarnYesNoTopmost (char *stringId)
+int AskWarnYesNoTopmost (char *stringId, HWND hwnd)
{
if (Silent) return IDNO;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1 | MB_SETFOREGROUND | MB_TOPMOST);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1 | MB_SETFOREGROUND | MB_TOPMOST);
}
-int AskWarnYesNoStringTopmost (const wchar_t *string)
+int AskWarnYesNoStringTopmost (const wchar_t *string, HWND hwnd)
{
if (Silent) return IDNO;
- return MessageBoxW (MainDlg, string, lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1 | MB_SETFOREGROUND | MB_TOPMOST);
+ return MessageBoxW (hwnd, string, lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1 | MB_SETFOREGROUND | MB_TOPMOST);
}
-int AskWarnNoYes (char *stringId)
+int AskWarnNoYes (char *stringId, HWND hwnd)
{
if (Silent) return IDNO;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2);
}
-int AskWarnNoYesString (const wchar_t *string)
+int AskWarnNoYesString (const wchar_t *string, HWND hwnd)
{
if (Silent) return IDNO;
- return MessageBoxW (MainDlg, string, lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2);
+ return MessageBoxW (hwnd, string, lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2);
}
-int AskWarnNoYesTopmost (char *stringId)
+int AskWarnNoYesTopmost (char *stringId, HWND hwnd)
{
if (Silent) return IDNO;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2 | MB_SETFOREGROUND | MB_TOPMOST);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2 | MB_SETFOREGROUND | MB_TOPMOST);
}
-int AskWarnOkCancel (char *stringId)
+int AskWarnOkCancel (char *stringId, HWND hwnd)
{
if (Silent) return IDCANCEL;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1);
}
-int AskWarnCancelOk (char *stringId)
+int AskWarnCancelOk (char *stringId, HWND hwnd)
{
if (Silent) return IDCANCEL;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON2);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON2);
}
-int AskErrYesNo (char *stringId)
+int AskErrYesNo (char *stringId, HWND hwnd)
{
if (Silent) return IDNO;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONERROR | MB_YESNO | MB_DEFBUTTON1);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONERROR | MB_YESNO | MB_DEFBUTTON1);
}
-int AskErrNoYes (char *stringId)
+int AskErrNoYes (char *stringId, HWND hwnd)
{
if (Silent) return IDNO;
- return MessageBoxW (MainDlg, GetString (stringId), lpszTitle, MB_ICONERROR | MB_YESNO | MB_DEFBUTTON2);
+ return MessageBoxW (hwnd, GetString (stringId), lpszTitle, MB_ICONERROR | MB_YESNO | MB_DEFBUTTON2);
}
@@ -8191,7 +8191,7 @@ int AskErrNoYes (char *stringId) // in any other cases where a string needs to be resolved before calling this function.
// If the returned value is 0, the user closed the dialog window without making a choice.
// If the user made a choice, the returned value is the ordinal number of the choice (1..MAX_MULTI_CHOICES)
-int AskMultiChoice (void *strings[], BOOL bBold)
+int AskMultiChoice (void *strings[], BOOL bBold, HWND hwnd)
{
MULTI_CHOICE_DLGPROC_PARAMS params;
@@ -8199,7 +8199,7 @@ int AskMultiChoice (void *strings[], BOOL bBold) params.bold = bBold;
return DialogBoxParamW (hInst,
- MAKEINTRESOURCEW (IDD_MULTI_CHOICE_DLG), MainDlg,
+ MAKEINTRESOURCEW (IDD_MULTI_CHOICE_DLG), hwnd,
(DLGPROC) MultiChoiceDialogProc, (LPARAM) ¶ms);
}
@@ -8227,7 +8227,7 @@ BOOL ConfigWriteBegin () }
-BOOL ConfigWriteEnd ()
+BOOL ConfigWriteEnd (HWND hwnd)
{
char *xml = ConfigBuffer;
char key[128], value[2048];
@@ -8249,7 +8249,7 @@ BOOL ConfigWriteEnd () TCFlushFile (ConfigFileHandle);
- CheckFileStreamWriteErrors (ConfigFileHandle, TC_APPD_FILENAME_CONFIGURATION);
+ CheckFileStreamWriteErrors (hwnd, ConfigFileHandle, TC_APPD_FILENAME_CONFIGURATION);
fclose (ConfigFileHandle);
ConfigFileHandle = NULL;
@@ -8354,7 +8354,7 @@ void OpenPageHelp (HWND hwndDlg, int nPage) if (r == SE_ERR_NOASSOC)
{
- if (AskYesNo ("HELP_READER_ERROR") == IDYES)
+ if (AskYesNo ("HELP_READER_ERROR", MainDlg) == IDYES)
OpenOnlineHelp ();
}
}
@@ -8835,7 +8835,7 @@ char *RelativePath2Absolute (char *szFileName) }
-void HandleDriveNotReadyError ()
+void HandleDriveNotReadyError (HWND hwnd)
{
HKEY hkey = 0;
DWORD value = 0, size = sizeof (DWORD);
@@ -8847,12 +8847,12 @@ void HandleDriveNotReadyError () if (RegQueryValueEx (hkey, "NoAutoMount", 0, 0, (LPBYTE) &value, &size) == ERROR_SUCCESS
&& value != 0)
{
- Warning ("SYS_AUTOMOUNT_DISABLED");
+ Warning ("SYS_AUTOMOUNT_DISABLED", hwnd);
}
else if (nCurrentOS == WIN_VISTA && CurrentOSServicePack < 1)
- Warning ("SYS_ASSIGN_DRIVE_LETTER");
+ Warning ("SYS_ASSIGN_DRIVE_LETTER", hwnd);
else
- Warning ("DEVICE_NOT_READY_ERROR");
+ Warning ("DEVICE_NOT_READY_ERROR", hwnd);
RegCloseKey (hkey);
}
@@ -9128,7 +9128,7 @@ void CloseVolume (OpenVolumeContext *context) }
-int ReEncryptVolumeHeader (char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, BOOL wipeMode)
+int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, BOOL wipeMode)
{
CRYPTO_INFO *newCryptoInfo = NULL;
@@ -9139,7 +9139,7 @@ int ReEncryptVolumeHeader (char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Pa UserEnrichRandomPool (NULL);
- int status = CreateVolumeHeaderInMemory (bBoot,
+ int status = CreateVolumeHeaderInMemory (hwndDlg, bBoot,
buffer,
cryptoInfo->ea,
cryptoInfo->mode,
@@ -9413,7 +9413,7 @@ static BOOL CALLBACK NewSecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPA if (tokens.empty())
{
- Error ("NO_TOKENS_FOUND");
+ Error ("NO_TOKENS_FOUND", hwndDlg);
EndDialog (hwndDlg, IDCANCEL);
return 1;
}
@@ -9711,7 +9711,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam throw SystemException ();
}
- Info ("KEYFILE_EXPORTED");
+ Info ("KEYFILE_EXPORTED", hwndDlg);
}
}
catch (Exception &e)
@@ -9724,7 +9724,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam case IDC_DELETE:
{
- if (AskNoYes ("CONFIRM_SEL_FILES_DELETE") == IDNO)
+ if (AskNoYes ("CONFIRM_SEL_FILES_DELETE", hwndDlg) == IDNO)
return 1;
try
@@ -9755,19 +9755,21 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam }
-BOOL InitSecurityTokenLibrary ()
+BOOL InitSecurityTokenLibrary (HWND hwndDlg)
{
if (SecurityTokenLibraryPath[0] == 0)
{
- Error ("NO_PKCS11_MODULE_SPECIFIED");
+ Error ("NO_PKCS11_MODULE_SPECIFIED", hwndDlg);
return FALSE;
}
struct PinRequestHandler : public GetPinFunctor
{
+ HWND m_hwnd;
+ PinRequestHandler(HWND hwnd) : m_hwnd(hwnd) {}
virtual void operator() (string &str)
{
- if (DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_TOKEN_PASSWORD), MainDlg, (DLGPROC) SecurityTokenPasswordDlgProc, (LPARAM) &str) == IDCANCEL)
+ if (DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_TOKEN_PASSWORD), m_hwnd, (DLGPROC) SecurityTokenPasswordDlgProc, (LPARAM) &str) == IDCANCEL)
throw UserAbort (SRC_POS);
if (hCursor != NULL)
@@ -9777,20 +9779,22 @@ BOOL InitSecurityTokenLibrary () struct WarningHandler : public SendExceptionFunctor
{
+ HWND m_hwnd;
+ WarningHandler(HWND hwnd) : m_hwnd(hwnd) {}
virtual void operator() (const Exception &e)
{
- e.Show (NULL);
+ e.Show (m_hwnd);
}
};
try
{
- SecurityToken::InitLibrary (SecurityTokenLibraryPath, auto_ptr <GetPinFunctor> (new PinRequestHandler), auto_ptr <SendExceptionFunctor> (new WarningHandler));
+ SecurityToken::InitLibrary (SecurityTokenLibraryPath, auto_ptr <GetPinFunctor> (new PinRequestHandler(hwndDlg)), auto_ptr <SendExceptionFunctor> (new WarningHandler(hwndDlg)));
}
catch (Exception &e)
{
- e.Show (NULL);
- Error ("PKCS11_MODULE_INIT_FAILED");
+ e.Show (hwndDlg);
+ Error ("PKCS11_MODULE_INIT_FAILED", hwndDlg);
return FALSE;
}
@@ -9973,12 +9977,12 @@ BOOL IsFileOnReadOnlyFilesystem (const char *path) }
-void CheckFilesystem (int driveNo, BOOL fixErrors)
+void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors)
{
wchar_t msg[1024], param[1024], cmdPath[MAX_PATH];
char driveRoot[] = { 'A' + (char) driveNo, ':', 0 };
- if (fixErrors && AskWarnYesNo ("FILESYS_REPAIR_CONFIRM_BACKUP") == IDNO)
+ if (fixErrors && AskWarnYesNo ("FILESYS_REPAIR_CONFIRM_BACKUP", hwndDlg) == IDNO)
return;
StringCbPrintfW (msg, sizeof(msg), GetString (fixErrors ? "REPAIRING_FS" : "CHECKING_FS"), driveRoot);
@@ -10016,18 +10020,18 @@ BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *st #ifndef SETUP
-int AskNonSysInPlaceEncryptionResume ()
+int AskNonSysInPlaceEncryptionResume (HWND hwndDlg)
{
- if (AskWarnYesNo ("NONSYS_INPLACE_ENC_RESUME_PROMPT") == IDYES)
+ if (AskWarnYesNo ("NONSYS_INPLACE_ENC_RESUME_PROMPT", hwndDlg) == IDYES)
return IDYES;
char *multiChoiceStr[] = { 0, "ASK_NONSYS_INPLACE_ENC_NOTIFICATION_REMOVAL", "DO_NOT_PROMPT_ME", "KEEP_PROMPTING_ME", 0 };
- switch (AskMultiChoice ((void **) multiChoiceStr, FALSE))
+ switch (AskMultiChoice ((void **) multiChoiceStr, FALSE, hwndDlg))
{
case 1:
RemoveNonSysInPlaceEncNotifications();
- Warning ("NONSYS_INPLACE_ENC_NOTIFICATION_REMOVAL_NOTE");
+ Warning ("NONSYS_INPLACE_ENC_NOTIFICATION_REMOVAL_NOTE", hwndDlg);
break;
default:
@@ -10068,7 +10072,7 @@ BOOL RemoveDeviceWriteProtection (HWND hwndDlg, char *devicePath) fprintf (f, "@diskpart /s \"%s\"\n@pause\n@del \"%s\" \"%s\"", diskpartScript, diskpartScript, cmdBatch);
- CheckFileStreamWriteErrors (f, cmdBatch);
+ CheckFileStreamWriteErrors (hwndDlg, f, cmdBatch);
fclose (f);
f = fopen (diskpartScript, "w");
@@ -10086,7 +10090,7 @@ BOOL RemoveDeviceWriteProtection (HWND hwndDlg, char *devicePath) fprintf (f, "exit\n");
- CheckFileStreamWriteErrors (f, diskpartScript);
+ CheckFileStreamWriteErrors (hwndDlg, f, diskpartScript);
fclose (f);
ShellExecute (NULL, (!IsAdmin() && IsUacSupported()) ? "runas" : "open", cmdBatch, NULL, NULL, SW_SHOW);
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h index b3ec7501..5af52b15 100644 --- a/src/Common/Dlgcode.h +++ b/src/Common/Dlgcode.h @@ -285,7 +285,7 @@ BOOL LoadSysEncSettings (HWND hwndDlg); int LoadNonSysInPlaceEncSettings (WipeAlgorithmId *wipeAlgorithm);
void RemoveNonSysInPlaceEncNotifications (void);
void SavePostInstallTasksSettings (int command);
-void DoPostInstallTasks (void);
+void DoPostInstallTasks (HWND hwndDlg);
void InitOSVersionInfo ();
void InitApp ( HINSTANCE hInstance, char *lpszCommandLine );
void InitHelpFileName (void);
@@ -309,7 +309,7 @@ void ResetCurrentDirectory (); BOOL BrowseFiles (HWND hwndDlg, char *stringId, char *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter);
BOOL BrowseDirectories (HWND hWnd, char *lpszTitle, char *dirName);
void handleError ( HWND hwndDlg , int code );
-BOOL CheckFileStreamWriteErrors (FILE *file, const char *fileName);
+BOOL CheckFileStreamWriteErrors (HWND hwndDlg, FILE *file, const char *fileName);
void LocalizeDialog ( HWND hwnd, char *stringId );
void OpenVolumeExplorerWindow (int driveNo);
static BOOL CALLBACK CloseVolumeExplorerWindowsEnum( HWND hwnd, LPARAM driveNo);
@@ -374,38 +374,38 @@ char *GetProgramConfigPath (char *fileName); char GetSystemDriveLetter (void);
void OpenPageHelp (HWND hwndDlg, int nPage);
void TaskBarIconDisplayBalloonTooltip (HWND hwnd, wchar_t *headline, wchar_t *text, BOOL warning);
-void InfoBalloon (char *headingStringId, char *textStringId);
-void InfoBalloonDirect (wchar_t *headingString, wchar_t *textString);
-void WarningBalloon (char *headingStringId, char *textStringId);
-void WarningBalloonDirect (wchar_t *headingString, wchar_t *textString);
-int Info (char *stringId);
-int InfoTopMost (char *stringId);
-int InfoDirect (const wchar_t *msg);
-int Warning (char *stringId);
-int WarningTopMost (char *stringId);
-int WarningDirect (const wchar_t *warnMsg);
-int Error (char *stringId);
-int ErrorDirect (const wchar_t *errMsg);
-int ErrorTopMost (char *stringId);
-int AskYesNo (char *stringId);
-int AskYesNoString (const wchar_t *str);
-int AskYesNoTopmost (char *stringId);
-int AskNoYes (char *stringId);
-int AskOkCancel (char *stringId);
-int AskWarnYesNo (char *stringId);
-int AskWarnYesNoString (const wchar_t *string);
-int AskWarnYesNoTopmost (char *stringId);
-int AskWarnYesNoStringTopmost (const wchar_t *string);
-int AskWarnNoYes (char *stringId);
-int AskWarnNoYesString (const wchar_t *string);
-int AskWarnNoYesTopmost (char *stringId);
-int AskWarnOkCancel (char *stringId);
-int AskWarnCancelOk (char *stringId);
-int AskErrYesNo (char *stringId);
-int AskErrNoYes (char *stringId);
-int AskMultiChoice (void *strings[], BOOL bBold);
+void InfoBalloon (char *headingStringId, char *textStringId, HWND hwnd);
+void InfoBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd);
+void WarningBalloon (char *headingStringId, char *textStringId, HWND hwnd);
+void WarningBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd);
+int Info (char *stringId, HWND hwnd);
+int InfoTopMost (char *stringId, HWND hwnd);
+int InfoDirect (const wchar_t *msg, HWND hwnd);
+int Warning (char *stringId, HWND hwnd);
+int WarningTopMost (char *stringId, HWND hwnd);
+int WarningDirect (const wchar_t *warnMsg, HWND hwnd);
+int Error (char *stringId, HWND hwnd);
+int ErrorDirect (const wchar_t *errMsg, HWND hwnd);
+int ErrorTopMost (char *stringId, HWND hwnd);
+int AskYesNo (char *stringId, HWND hwnd);
+int AskYesNoString (const wchar_t *str, HWND hwnd);
+int AskYesNoTopmost (char *stringId, HWND hwnd);
+int AskNoYes (char *stringId, HWND hwnd);
+int AskOkCancel (char *stringId, HWND hwnd);
+int AskWarnYesNo (char *stringId, HWND hwnd);
+int AskWarnYesNoString (const wchar_t *string, HWND hwnd);
+int AskWarnYesNoTopmost (char *stringId, HWND hwnd);
+int AskWarnYesNoStringTopmost (const wchar_t *string, HWND hwnd);
+int AskWarnNoYes (char *stringId, HWND hwnd);
+int AskWarnNoYesString (const wchar_t *string, HWND hwnd);
+int AskWarnNoYesTopmost (char *stringId, HWND hwnd);
+int AskWarnOkCancel (char *stringId, HWND hwnd);
+int AskWarnCancelOk (char *stringId, HWND hwnd);
+int AskErrYesNo (char *stringId, HWND hwnd);
+int AskErrNoYes (char *stringId, HWND hwnd);
+int AskMultiChoice (void *strings[], BOOL bBold, HWND hwnd);
BOOL ConfigWriteBegin ();
-BOOL ConfigWriteEnd ();
+BOOL ConfigWriteEnd (HWND hwnd);
BOOL ConfigWriteString (char *configKey, char *configValue);
BOOL ConfigWriteInt (char *configKey, int configValue);
int ConfigReadInt (char *configKey, int defaultValue);
@@ -423,7 +423,7 @@ BOOL EnableWow64FsRedirection (BOOL enable); BOOL RestartComputer (void);
void Applink (char *dest, BOOL bSendOS, char *extraOutput);
char *RelativePath2Absolute (char *szFileName);
-void HandleDriveNotReadyError ();
+void HandleDriveNotReadyError (HWND hwnd);
BOOL CALLBACK CloseTCWindowsEnum( HWND hwnd, LPARAM lParam);
BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam);
BYTE *MapResource (char *resourceType, int resourceId, PDWORD size);
@@ -449,18 +449,18 @@ BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize); BOOL DoDriverInstall (HWND hwndDlg);
int OpenVolume (OpenVolumeContext *context, const char *volumePath, Password *password, int pkcs5_prf, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader);
void CloseVolume (OpenVolumeContext *context);
-int ReEncryptVolumeHeader (char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, BOOL wipeMode);
+int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, BOOL wipeMode);
BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
BOOL IsPagingFileWildcardActive ();
BOOL DisablePagingFile ();
BOOL CALLBACK SecurityTokenPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-BOOL InitSecurityTokenLibrary ();
+BOOL InitSecurityTokenLibrary (HWND hwndDlg);
BOOL FileHasReadOnlyAttribute (const char *path);
BOOL IsFileOnReadOnlyFilesystem (const char *path);
-void CheckFilesystem (int driveNo, BOOL fixErrors);
+void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors);
BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str);
-int AskNonSysInPlaceEncryptionResume ();
+int AskNonSysInPlaceEncryptionResume (HWND hwndDlg);
BOOL RemoveDeviceWriteProtection (HWND hwndDlg, char *devicePath);
void EnableElevatedCursorChange (HWND parent);
BOOL DisableFileCompression (HANDLE file);
diff --git a/src/Common/Exception.h b/src/Common/Exception.h index e034404b..e5d4fd4c 100644 --- a/src/Common/Exception.h +++ b/src/Common/Exception.h @@ -40,9 +40,9 @@ namespace VeraCrypt void Show (HWND parent) const
{
if (ErrMsg.empty())
- ::Error (ErrLangId? ErrLangId : "");
+ ::Error (ErrLangId? ErrLangId : "", parent);
else
- ::ErrorDirect (ErrMsg.c_str());
+ ::ErrorDirect (ErrMsg.c_str(), parent);
}
char *ErrLangId;
@@ -65,7 +65,7 @@ namespace VeraCrypt struct TimeOut : public Exception
{
TimeOut (const char *srcPos) { }
- void Show (HWND parent) const { ErrorDirect (L"Timeout"); }
+ void Show (HWND parent) const { ErrorDirect (L"Timeout", parent); }
};
struct UserAbort : public Exception
diff --git a/src/Common/Fat.c b/src/Common/Fat.c index 6a2c77db..b6138528 100644 --- a/src/Common/Fat.c +++ b/src/Common/Fat.c @@ -253,7 +253,7 @@ static void PutFSInfo (unsigned char *sector, fatparams *ft) int
-FormatFat (unsigned __int64 startSector, fatparams * ft, void * dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat)
+FormatFat (void* hwndDlgPtr, unsigned __int64 startSector, fatparams * ft, void * dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat)
{
int write_buf_cnt = 0;
char sector[TC_MAX_VOLUME_SECTOR_SIZE], *write_buf;
@@ -261,6 +261,7 @@ FormatFat (unsigned __int64 startSector, fatparams * ft, void * dev, PCRYPTO_INF int x, n;
int retVal;
char temporaryKey[MASTER_KEYDATA_SIZE];
+ HWND hwndDlg = (HWND) hwndDlgPtr;
LARGE_INTEGER startOffset;
LARGE_INTEGER newOffset;
@@ -281,7 +282,7 @@ FormatFat (unsigned __int64 startSector, fatparams * ft, void * dev, PCRYPTO_INF memset (sector, 0, ft->sector_size);
- RandgetBytes (ft->volume_id, sizeof (ft->volume_id), FALSE);
+ RandgetBytes (hwndDlg, ft->volume_id, sizeof (ft->volume_id), FALSE);
PutBoot (ft, (unsigned char *) sector);
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
@@ -399,11 +400,11 @@ FormatFat (unsigned __int64 startSector, fatparams * ft, void * dev, PCRYPTO_INF within the volume). */
// Temporary master key
- if (!RandgetBytes (temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE))
+ if (!RandgetBytes (hwndDlg, temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE))
goto fail;
// Temporary secondary key (XTS mode)
- if (!RandgetBytes (cryptoInfo->k2, sizeof cryptoInfo->k2, FALSE))
+ if (!RandgetBytes (hwndDlg, cryptoInfo->k2, sizeof cryptoInfo->k2, FALSE))
goto fail;
retVal = EAInit (cryptoInfo->ea, temporaryKey, cryptoInfo->ks);
diff --git a/src/Common/Fat.h b/src/Common/Fat.h index 164fe855..59c993b3 100644 --- a/src/Common/Fat.h +++ b/src/Common/Fat.h @@ -64,4 +64,4 @@ struct msdos_boot_sector void GetFatParams ( fatparams *ft );
void PutBoot ( fatparams *ft , unsigned char *boot );
-int FormatFat (unsigned __int64 startSector, fatparams * ft, void * dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat);
+int FormatFat (void* hwndDlg, unsigned __int64 startSector, fatparams * ft, void * dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat);
diff --git a/src/Common/Format.c b/src/Common/Format.c index c7198f60..3b7a8127 100644 --- a/src/Common/Format.c +++ b/src/Common/Format.c @@ -93,6 +93,7 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams) uint64 dataOffset, dataAreaSize;
LARGE_INTEGER offset;
BOOL bFailedRequiredDASD = FALSE;
+ HWND hwndDlg = volParams->hwndDlg;
FormatSectorSize = volParams->sectorSize;
@@ -100,7 +101,7 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams) || FormatSectorSize > TC_MAX_VOLUME_SECTOR_SIZE
|| FormatSectorSize % ENCRYPTION_DATA_UNIT_SIZE != 0)
{
- Error ("SECTOR_SIZE_UNSUPPORTED");
+ Error ("SECTOR_SIZE_UNSUPPORTED", hwndDlg);
return ERR_DONT_REPORT;
}
@@ -139,7 +140,7 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams) VirtualLock (header, sizeof (header));
- nStatus = CreateVolumeHeaderInMemory (FALSE,
+ nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
header,
volParams->ea,
FIRST_MODE_OF_OPERATION_ID,
@@ -179,7 +180,7 @@ begin_format: {
if ((dev = DismountDrive (devName, volParams->volumePath)) == INVALID_HANDLE_VALUE)
{
- Error ("FORMAT_CANT_DISMOUNT_FILESYS");
+ Error ("FORMAT_CANT_DISMOUNT_FILESYS", hwndDlg);
nStatus = ERR_DONT_REPORT;
goto error;
}
@@ -285,7 +286,7 @@ begin_format: else
{
handleWin32Error (volParams->hwndDlg);
- Error ("CANT_ACCESS_VOL");
+ Error ("CANT_ACCESS_VOL", hwndDlg);
nStatus = ERR_DONT_REPORT;
goto error;
}
@@ -317,7 +318,7 @@ begin_format: if (DeviceIoControl (dev, FSCTL_IS_VOLUME_MOUNTED, NULL, 0, NULL, 0, &dwResult, NULL))
{
- Error ("FORMAT_CANT_DISMOUNT_FILESYS");
+ Error ("FORMAT_CANT_DISMOUNT_FILESYS", hwndDlg);
nStatus = ERR_DONT_REPORT;
goto error;
}
@@ -474,7 +475,7 @@ begin_format: goto error;
}
- nStatus = FormatNoFs (startSector, num_sectors, dev, cryptoInfo, volParams->quickFormat);
+ nStatus = FormatNoFs (hwndDlg, startSector, num_sectors, dev, cryptoInfo, volParams->quickFormat);
if (volParams->bDevice)
StopFormatWriteThread();
@@ -507,7 +508,7 @@ begin_format: goto error;
}
- nStatus = FormatFat (startSector, &ft, (void *) dev, cryptoInfo, volParams->quickFormat);
+ nStatus = FormatFat (hwndDlg, startSector, &ft, (void *) dev, cryptoInfo, volParams->quickFormat);
if (volParams->bDevice)
StopFormatWriteThread();
@@ -531,7 +532,7 @@ begin_format: goto error;
}
- nStatus = CreateVolumeHeaderInMemory (FALSE,
+ nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
header,
volParams->ea,
FIRST_MODE_OF_OPERATION_ID,
@@ -557,7 +558,7 @@ begin_format: // Fill reserved header sectors (including the backup header area) with random data
if (!volParams->hiddenVol)
{
- nStatus = WriteRandomDataToReservedHeaderAreas (dev, cryptoInfo, dataAreaSize, FALSE, FALSE);
+ nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, cryptoInfo, dataAreaSize, FALSE, FALSE);
if (nStatus != ERR_SUCCESS)
goto error;
@@ -643,7 +644,7 @@ error: if (dataAreaSize <= TC_MAX_FAT_SECTOR_COUNT * FormatSectorSize)
{
- if (AskErrYesNo ("FORMAT_NTFS_FAILED_ASK_FAT") == IDYES)
+ if (AskErrYesNo ("FORMAT_NTFS_FAILED_ASK_FAT", hwndDlg) == IDYES)
{
// NTFS format failed and the user wants to try FAT format immediately
volParams->fileSystem = FILESYS_FAT;
@@ -654,7 +655,7 @@ error: }
}
else
- Error ("FORMAT_NTFS_FAILED");
+ Error ("FORMAT_NTFS_FAILED", hwndDlg);
nStatus = ERR_DONT_REPORT;
goto fv_end;
@@ -677,7 +678,7 @@ fv_end: }
-int FormatNoFs (unsigned __int64 startSector, __int64 num_sectors, void * dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat)
+int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, __int64 num_sectors, void * dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat)
{
int write_buf_cnt = 0;
char sector[TC_MAX_VOLUME_SECTOR_SIZE], *write_buf;
@@ -719,11 +720,11 @@ int FormatNoFs (unsigned __int64 startSector, __int64 num_sectors, void * dev, P deniability of hidden volumes. */
// Temporary master key
- if (!RandgetBytes (temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE))
+ if (!RandgetBytes (hwndDlg, temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE))
goto fail;
// Temporary secondary key (XTS mode)
- if (!RandgetBytes (cryptoInfo->k2, sizeof cryptoInfo->k2, FALSE))
+ if (!RandgetBytes (hwndDlg, cryptoInfo->k2, sizeof cryptoInfo->k2, FALSE))
goto fail;
retVal = EAInit (cryptoInfo->ea, temporaryKey, cryptoInfo->ks);
diff --git a/src/Common/Format.h b/src/Common/Format.h index 9de90025..3422fecf 100644 --- a/src/Common/Format.h +++ b/src/Common/Format.h @@ -51,7 +51,7 @@ extern int FormatWriteBufferSize; int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams);
BOOL FormatNtfs (int driveNo, int clusterSize);
uint64 GetVolumeDataAreaSize (BOOL hiddenVolume, uint64 volumeSize);
-int FormatNoFs (unsigned __int64 startSector, __int64 num_sectors, void *dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat);
+int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, __int64 num_sectors, void *dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat);
BOOL WriteSector ( void *dev , char *sector , char *write_buf , int *write_buf_cnt , __int64 *nSecNo , PCRYPTO_INFO cryptoInfo );
BOOL FlushFormatWriteBuffer (void *dev, char *write_buf, int *write_buf_cnt, __int64 *nSecNo, PCRYPTO_INFO cryptoInfo);
static BOOL StartFormatWriteThread ();
diff --git a/src/Common/Keyfiles.c b/src/Common/Keyfiles.c index 88ab5ece..cb36a146 100644 --- a/src/Common/Keyfiles.c +++ b/src/Common/Keyfiles.c @@ -218,7 +218,7 @@ close: }
-BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile)
+BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile)
{
BOOL status = TRUE;
KeyFile kfSubStruct;
@@ -252,8 +252,8 @@ BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile) if (keyfileData.empty())
{
SetLastError (ERROR_HANDLE_EOF);
- handleWin32Error (MainDlg);
- Error ("ERR_PROCESS_KEYFILE");
+ handleWin32Error (hwndDlg);
+ Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE;
continue;
}
@@ -291,8 +291,8 @@ BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile) // Determine whether it's a path or a file
if (stat (kf->FileName, &statStruct) != 0)
{
- handleWin32Error (MainDlg);
- Error ("ERR_PROCESS_KEYFILE");
+ handleWin32Error (hwndDlg);
+ Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE;
continue;
}
@@ -305,8 +305,8 @@ BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile) StringCbPrintfA (searchPath, sizeof (searchPath), "%s\\*.*", kf->FileName);
if ((searchHandle = _findfirst (searchPath, &fBuf)) == -1)
{
- handleWin32Error (MainDlg);
- Error ("ERR_PROCESS_KEYFILE_PATH");
+ handleWin32Error (hwndDlg);
+ Error ("ERR_PROCESS_KEYFILE_PATH", hwndDlg);
status = FALSE;
continue;
}
@@ -323,8 +323,8 @@ BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile) // Determine whether it's a path or a file
if (stat (kfSub->FileName, &statStruct) != 0)
{
- handleWin32Error (MainDlg);
- Error ("ERR_PROCESS_KEYFILE");
+ handleWin32Error (hwndDlg);
+ Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE;
continue;
}
@@ -347,8 +347,8 @@ BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile) // Apply keyfile to the pool
if (!KeyFileProcess (keyPool, kfSub))
{
- handleWin32Error (MainDlg);
- Error ("ERR_PROCESS_KEYFILE");
+ handleWin32Error (hwndDlg);
+ Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE;
}
@@ -359,15 +359,15 @@ BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile) if (keyfileCount == 0)
{
- ErrorDirect ((wstring (GetString ("ERR_KEYFILE_PATH_EMPTY")) + L"\n\n" + SingleStringToWide (kf->FileName)).c_str());
+ ErrorDirect ((wstring (GetString ("ERR_KEYFILE_PATH_EMPTY")) + L"\n\n" + SingleStringToWide (kf->FileName)).c_str(), hwndDlg);
status = FALSE;
}
}
// Apply keyfile to the pool
else if (!KeyFileProcess (keyPool, kf))
{
- handleWin32Error (MainDlg);
- Error ("ERR_PROCESS_KEYFILE");
+ handleWin32Error (hwndDlg);
+ Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE;
}
}
diff --git a/src/Common/Keyfiles.h b/src/Common/Keyfiles.h index 9ba5b6e8..40441141 100644 --- a/src/Common/Keyfiles.h +++ b/src/Common/Keyfiles.h @@ -34,7 +34,7 @@ KeyFile *KeyFileAdd (KeyFile *firstKeyFile, KeyFile *keyFile); void KeyFileRemoveAll (KeyFile **firstKeyFile);
KeyFile *KeyFileClone (KeyFile *keyFile);
KeyFile *KeyFileCloneAll (KeyFile *firstKeyFile);
-BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile);
+BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile);
BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL KeyfilesPopupMenu (HWND hwndDlg, POINT popupPosition, KeyFilesDlgParam *dialogParam);
diff --git a/src/Common/Password.c b/src/Common/Password.c index e5e9f9d8..db7ad7f7 100644 --- a/src/Common/Password.c +++ b/src/Common/Password.c @@ -341,7 +341,7 @@ int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, Pas for (wipePass = 0; wipePass < wipePassCount; wipePass++)
{
// Prepare new volume header
- nStatus = CreateVolumeHeaderInMemory (FALSE,
+ nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
buffer,
cryptoInfo->ea,
cryptoInfo->mode,
@@ -383,7 +383,7 @@ int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, Pas && (cryptoInfo->HeaderFlags & TC_HEADER_FLAG_NONSYS_INPLACE_ENC) != 0
&& (cryptoInfo->HeaderFlags & ~TC_HEADER_FLAG_NONSYS_INPLACE_ENC) == 0)
{
- nStatus = WriteRandomDataToReservedHeaderAreas (dev, cryptoInfo, cryptoInfo->VolumeSize.Value, !backupHeader, backupHeader);
+ nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, cryptoInfo, cryptoInfo->VolumeSize.Value, !backupHeader, backupHeader);
if (nStatus != ERR_SUCCESS)
goto error;
}
diff --git a/src/Common/Random.c b/src/Common/Random.c index f7379685..cd85957f 100644 --- a/src/Common/Random.c +++ b/src/Common/Random.c @@ -317,14 +317,14 @@ void RandaddBuf (void *buf, int len) }
}
-BOOL RandpeekBytes (unsigned char *buf, int len)
+BOOL RandpeekBytes (void* hwndDlg, unsigned char *buf, int len)
{
if (!bRandDidInit)
return FALSE;
if (len > RNG_POOL_SIZE)
{
- Error ("ERR_NOT_ENOUGH_RANDOM_DATA");
+ Error ("ERR_NOT_ENOUGH_RANDOM_DATA", (HWND) hwndDlg);
len = RNG_POOL_SIZE;
}
@@ -337,16 +337,16 @@ BOOL RandpeekBytes (unsigned char *buf, int len) /* Get len random bytes from the pool (max. RNG_POOL_SIZE bytes per a single call) */
-BOOL RandgetBytes (unsigned char *buf, int len, BOOL forceSlowPoll)
+BOOL RandgetBytes (void* hwndDlg, unsigned char *buf, int len, BOOL forceSlowPoll)
{
- return RandgetBytesFull (buf, len, forceSlowPoll, FALSE);
+ return RandgetBytesFull (hwndDlg, buf, len, forceSlowPoll, FALSE);
}
/* Get len random bytes from the pool.
* If allowAnyLength is FALSE, then len must be less or equal to RNG_POOL_SIZE
* If allowAnyLength is TRUE, then len can have any positive value
*/
-BOOL RandgetBytesFull ( unsigned char *buf , int len, BOOL forceSlowPoll , BOOL allowAnyLength)
+BOOL RandgetBytesFull ( void* hwndDlg, unsigned char *buf , int len, BOOL forceSlowPoll , BOOL allowAnyLength)
{
int i, looplen;
BOOL ret = TRUE;
@@ -370,7 +370,7 @@ BOOL RandgetBytesFull ( unsigned char *buf , int len, BOOL forceSlowPoll , BOOL /* There's never more than RNG_POOL_SIZE worth of randomess */
if ( (!allowAnyLength) && (len > RNG_POOL_SIZE))
{
- Error ("ERR_NOT_ENOUGH_RANDOM_DATA");
+ Error ("ERR_NOT_ENOUGH_RANDOM_DATA", (HWND) hwndDlg);
len = RNG_POOL_SIZE;
LeaveCriticalSection (&critRandProt);
return FALSE;
diff --git a/src/Common/Random.h b/src/Common/Random.h index 1a3a51d8..72427e07 100644 --- a/src/Common/Random.h +++ b/src/Common/Random.h @@ -43,16 +43,16 @@ BOOL Randmix ( void ); void RandaddBuf ( void *buf , int len );
BOOL FastPoll ( void );
BOOL SlowPoll ( void );
-BOOL RandpeekBytes ( unsigned char *buf , int len );
+BOOL RandpeekBytes ( void* hwndDlg, unsigned char *buf , int len );
/* Get len random bytes from the pool (max. RNG_POOL_SIZE bytes per a single call) */
-BOOL RandgetBytes ( unsigned char *buf , int len, BOOL forceSlowPoll );
+BOOL RandgetBytes ( void* hwndDlg, unsigned char *buf , int len, BOOL forceSlowPoll );
/* Get len random bytes from the pool.
* If allowAnyLength is FALSE, then len must be less or equal to RNG_POOL_SIZE
* If allowAnyLength is TRUE, then len can have any positive value
*/
-BOOL RandgetBytesFull ( unsigned char *buf , int len, BOOL forceSlowPoll , BOOL allowAnyLength);
+BOOL RandgetBytesFull ( void* hwndDlg, unsigned char *buf , int len, BOOL forceSlowPoll , BOOL allowAnyLength);
#ifdef _WIN32
diff --git a/src/Common/SecurityToken.cpp b/src/Common/SecurityToken.cpp index 061d96fe..e8fb275b 100644 --- a/src/Common/SecurityToken.cpp +++ b/src/Common/SecurityToken.cpp @@ -701,7 +701,7 @@ namespace VeraCrypt }
wchar_t err[8192];
wsprintfW (err, L"%s:\n\n%hs%s", GetString ("SECURITY_TOKEN_ERROR"), errorString.c_str(), subjectErrorCode.str().c_str());
- ErrorDirect (err);
+ ErrorDirect (err, parent);
}
else
{
@@ -710,7 +710,7 @@ namespace VeraCrypt if (SubjectErrorCodeValid)
err += L"\n\nError code" + subjectErrorCode.str();
- ErrorDirect (err.c_str());
+ ErrorDirect (err.c_str(), parent);
}
}
}
diff --git a/src/Common/SecurityToken.h b/src/Common/SecurityToken.h index 8cad17c1..074bc1b9 100644 --- a/src/Common/SecurityToken.h +++ b/src/Common/SecurityToken.h @@ -133,22 +133,22 @@ namespace VeraCrypt struct SecurityTokenLibraryNotInitialized : public Exception
{
- void Show (HWND parent) const { Error (SecurityTokenLibraryPath[0] == 0 ? "NO_PKCS11_MODULE_SPECIFIED" : "PKCS11_MODULE_INIT_FAILED"); }
+ void Show (HWND parent) const { Error (SecurityTokenLibraryPath[0] == 0 ? "NO_PKCS11_MODULE_SPECIFIED" : "PKCS11_MODULE_INIT_FAILED", parent); }
};
struct InvalidSecurityTokenKeyfilePath : public Exception
{
- void Show (HWND parent) const { Error ("INVALID_TOKEN_KEYFILE_PATH"); }
+ void Show (HWND parent) const { Error ("INVALID_TOKEN_KEYFILE_PATH", parent); }
};
struct SecurityTokenKeyfileAlreadyExists : public Exception
{
- void Show (HWND parent) const { Error ("TOKEN_KEYFILE_ALREADY_EXISTS"); }
+ void Show (HWND parent) const { Error ("TOKEN_KEYFILE_ALREADY_EXISTS", parent); }
};
struct SecurityTokenKeyfileNotFound : public Exception
{
- void Show (HWND parent) const { Error ("TOKEN_KEYFILE_NOT_FOUND"); }
+ void Show (HWND parent) const { Error ("TOKEN_KEYFILE_NOT_FOUND", parent); }
};
#endif // !TC_HEADER_Platform_Exception
diff --git a/src/Common/Volumes.c b/src/Common/Volumes.c index c88e81d8..4e7bd0e3 100644 --- a/src/Common/Volumes.c +++ b/src/Common/Volumes.c @@ -718,7 +718,7 @@ ret: #endif
// Creates a volume header in memory
-int CreateVolumeHeaderInMemory (BOOL bBoot, char *header, int ea, int mode, Password *password,
+int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea, int mode, Password *password,
int pkcs5_prf, char *masterKeydata, PCRYPTO_INFO *retInfo,
unsigned __int64 volumeSize, unsigned __int64 hiddenVolumeSize,
unsigned __int64 encryptedAreaStart, unsigned __int64 encryptedAreaLength, uint16 requiredProgramVersion, uint32 headerFlags, uint32 sectorSize, BOOL bWipeMode)
@@ -756,7 +756,7 @@ int CreateVolumeHeaderInMemory (BOOL bBoot, char *header, int ea, int mode, Pass bytesNeeded = EAGetKeySize (ea) * 2; // Size of primary + secondary key(s)
}
- if (!RandgetBytes (keyInfo.master_keydata, bytesNeeded, TRUE))
+ if (!RandgetBytes (hwndDlg, keyInfo.master_keydata, bytesNeeded, TRUE))
return ERR_CIPHER_INIT_WEAK_KEY;
}
else
@@ -780,7 +780,7 @@ int CreateVolumeHeaderInMemory (BOOL bBoot, char *header, int ea, int mode, Pass cryptoInfo->mode = mode;
// Salt for header key derivation
- if (!RandgetBytes (keyInfo.salt, PKCS5_SALT_SIZE, !bWipeMode))
+ if (!RandgetBytes (hwndDlg, keyInfo.salt, PKCS5_SALT_SIZE, !bWipeMode))
return ERR_CIPHER_INIT_WEAK_KEY;
// PBKDF2 (PKCS5) is used to derive primary header key(s) and secondary header key(s) (XTS) from the password/keyfiles
@@ -1075,7 +1075,7 @@ BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header) // Writes randomly generated data to unused/reserved header areas.
// When bPrimaryOnly is TRUE, then only the primary header area (not the backup header area) is filled with random data.
// When bBackupOnly is TRUE, only the backup header area (not the primary header area) is filled with random data.
-int WriteRandomDataToReservedHeaderAreas (HANDLE dev, CRYPTO_INFO *cryptoInfo, uint64 dataAreaSize, BOOL bPrimaryOnly, BOOL bBackupOnly)
+int WriteRandomDataToReservedHeaderAreas (HWND hwndDlg, HANDLE dev, CRYPTO_INFO *cryptoInfo, uint64 dataAreaSize, BOOL bPrimaryOnly, BOOL bBackupOnly)
{
char temporaryKey[MASTER_KEYDATA_SIZE];
char originalK2[MASTER_KEYDATA_SIZE];
@@ -1096,8 +1096,8 @@ int WriteRandomDataToReservedHeaderAreas (HANDLE dev, CRYPTO_INFO *cryptoInfo, u while (TRUE)
{
// Temporary keys
- if (!RandgetBytes (temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE)
- || !RandgetBytes (cryptoInfo->k2, sizeof (cryptoInfo->k2), FALSE))
+ if (!RandgetBytes (hwndDlg, temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE)
+ || !RandgetBytes (hwndDlg, cryptoInfo->k2, sizeof (cryptoInfo->k2), FALSE))
{
nStatus = ERR_PARAMETER_INCORRECT;
goto final_seq;
diff --git a/src/Common/Volumes.h b/src/Common/Volumes.h index 18a52692..2d0b7d5d 100644 --- a/src/Common/Volumes.h +++ b/src/Common/Volumes.h @@ -133,10 +133,10 @@ int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int #endif
#if !defined (DEVICE_DRIVER) && !defined (TC_WINDOWS_BOOT)
-int CreateVolumeHeaderInMemory (BOOL bBoot, char *encryptedHeader, int ea, int mode, Password *password, int pkcs5_prf, char *masterKeydata, PCRYPTO_INFO *retInfo, unsigned __int64 volumeSize, unsigned __int64 hiddenVolumeSize, unsigned __int64 encryptedAreaStart, unsigned __int64 encryptedAreaLength, uint16 requiredProgramVersion, uint32 headerFlags, uint32 sectorSize, BOOL bWipeMode);
+int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *encryptedHeader, int ea, int mode, Password *password, int pkcs5_prf, char *masterKeydata, PCRYPTO_INFO *retInfo, unsigned __int64 volumeSize, unsigned __int64 hiddenVolumeSize, unsigned __int64 encryptedAreaStart, unsigned __int64 encryptedAreaLength, uint16 requiredProgramVersion, uint32 headerFlags, uint32 sectorSize, BOOL bWipeMode);
BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DWORD *bytesRead);
BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header);
-int WriteRandomDataToReservedHeaderAreas (HANDLE dev, CRYPTO_INFO *cryptoInfo, uint64 dataAreaSize, BOOL bPrimaryOnly, BOOL bBackupOnly);
+int WriteRandomDataToReservedHeaderAreas (HWND hwndDlg, HANDLE dev, CRYPTO_INFO *cryptoInfo, uint64 dataAreaSize, BOOL bPrimaryOnly, BOOL bBackupOnly);
#endif
#endif // !TC_HEADER_Volume_VolumeHeader
|