1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 19:08:26 -06:00

Windows: use the correct window handle for creating message boxes. This became important after the introduction of the wait dialog in order to avoid having message boxes behind the wait dialog.

This commit is contained in:
Mounir IDRASSI
2014-12-27 11:18:58 +01:00
parent 2dbbd6b9d2
commit a8112b8373
30 changed files with 793 additions and 785 deletions

View File

@@ -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; r = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, iid, tcServer) == S_OK;
if (!r) if (!r)
Error ("UAC_INIT_ERROR"); Error ("UAC_INIT_ERROR", hWnd);
return r; return r;
} }

View File

@@ -1295,7 +1295,7 @@ namespace VeraCrypt
UserEnrichRandomPool (ParentWindow); UserEnrichRandomPool (ParentWindow);
if (!RandgetBytes (request.WipeKey, sizeof (request.WipeKey), TRUE)) if (!RandgetBytes (ParentWindow, request.WipeKey, sizeof (request.WipeKey), TRUE))
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
CallDriver (TC_IOCTL_START_DECOY_SYSTEM_WIPE, &request, sizeof (request), NULL, 0); CallDriver (TC_IOCTL_START_DECOY_SYSTEM_WIPE, &request, sizeof (request), NULL, 0);
@@ -1348,7 +1348,7 @@ namespace VeraCrypt
#endif #endif
byte randData[PRAND_DISK_WIPE_PASSES]; byte randData[PRAND_DISK_WIPE_PASSES];
if (!RandgetBytes (randData, sizeof (randData), FALSE)) if (!RandgetBytes (ParentWindow, randData, sizeof (randData), FALSE))
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
for (int wipePass = 0; wipePass < PRAND_DISK_WIPE_PASSES; wipePass++) for (int wipePass = 0; wipePass < PRAND_DISK_WIPE_PASSES; wipePass++)
@@ -1557,7 +1557,7 @@ namespace VeraCrypt
catch (Exception &e) catch (Exception &e)
{ {
e.Show (ParentWindow); e.Show (ParentWindow);
Warning ("SYS_LOADER_UNAVAILABLE_FOR_RESCUE_DISK"); Warning ("SYS_LOADER_UNAVAILABLE_FOR_RESCUE_DISK", ParentWindow);
} }
// Boot loader backup // Boot loader backup
@@ -1631,7 +1631,7 @@ namespace VeraCrypt
if (!IsRandomNumberGeneratorStarted()) if (!IsRandomNumberGeneratorStarted())
throw ParameterIncorrect (SRC_POS); 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); 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); }); 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 (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); throw UserAbort (SRC_POS);
return; return;
} }
@@ -1974,7 +1974,7 @@ namespace VeraCrypt
{ {
static bool confirmed = false; 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); throw UserAbort (SRC_POS);
confirmed = true; confirmed = true;
@@ -2022,7 +2022,7 @@ namespace VeraCrypt
+ GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION") + GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION")
+ L"\n\n\n" + L"\n\n\n"
+ GetString ("RESTRICT_PAGING_FILES_TO_SYS_PARTITION") + GetString ("RESTRICT_PAGING_FILES_TO_SYS_PARTITION")
).c_str()) == IDYES) ).c_str(), ParentWindow) == IDYES)
{ {
RestrictPagingFilesToSystemPartition(); RestrictPagingFilesToSystemPartition();
RestartComputer(); RestartComputer();
@@ -2209,7 +2209,7 @@ namespace VeraCrypt
{ {
PCRYPTO_INFO tmpCryptoInfo = NULL; PCRYPTO_INFO tmpCryptoInfo = NULL;
status = CreateVolumeHeaderInMemory (!encStatus.HiddenSystem, status = CreateVolumeHeaderInMemory (ParentWindow, !encStatus.HiddenSystem,
header, header,
cryptoInfo->ea, cryptoInfo->ea,
cryptoInfo->mode, cryptoInfo->mode,
@@ -2346,7 +2346,7 @@ namespace VeraCrypt
if (e.ErrorCode != ERROR_CRC) if (e.ErrorCode != ERROR_CRC)
{ {
e.Show (ParentWindow); e.Show (ParentWindow);
Error ("WHOLE_DRIVE_ENCRYPTION_PREVENTED_BY_DRIVERS"); Error ("WHOLE_DRIVE_ENCRYPTION_PREVENTED_BY_DRIVERS", ParentWindow);
throw UserAbort (SRC_POS); throw UserAbort (SRC_POS);
} }
} }

View File

@@ -538,7 +538,7 @@ DWORD handleWin32Error (HWND hwndDlg)
// Access denied // Access denied
if (dwError == ERROR_ACCESS_DENIED && !IsAdmin ()) if (dwError == ERROR_ACCESS_DENIED && !IsAdmin ())
{ {
Error ("ERR_ACCESS_DENIED"); Error ("ERR_ACCESS_DENIED", hwndDlg);
SetLastError (dwError); // Preserve the original error code SetLastError (dwError); // Preserve the original error code
return dwError; return dwError;
} }
@@ -558,11 +558,11 @@ DWORD handleWin32Error (HWND hwndDlg)
// User-friendly hardware error explanation // User-friendly hardware error explanation
if (IsDiskError (dwError)) if (IsDiskError (dwError))
Error ("ERR_HARDWARE_ERROR"); Error ("ERR_HARDWARE_ERROR", hwndDlg);
// Device not ready // Device not ready
if (dwError == ERROR_NOT_READY) if (dwError == ERROR_NOT_READY)
HandleDriveNotReadyError(); HandleDriveNotReadyError(hwndDlg);
SetLastError (dwError); // Preserve the original error code 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; BOOL bDone = FALSE;
if (FileExists (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_TUTORIAL))) 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, ""); Applink ("beginnerstutorial", TRUE, "");
bDone = TRUE; bDone = TRUE;
@@ -2283,7 +2283,7 @@ void DoPostInstallTasks (void)
if (FileExists (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_RELEASE_NOTES))) 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, ""); Applink ("releasenotes", TRUE, "");
bDone = TRUE; bDone = TRUE;
@@ -2396,7 +2396,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
if (strstr (lpszCommandLine, "/q UAC ") == lpszCommandLine) if (strstr (lpszCommandLine, "/q UAC ") == lpszCommandLine)
{ {
Error ("UAC_INIT_ERROR"); Error ("UAC_INIT_ERROR", NULL);
exit (1); exit (1);
} }
@@ -2454,7 +2454,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
{ {
case WIN_2000: case WIN_2000:
if (osEx.wServicePackMajor < 3) if (osEx.wServicePackMajor < 3)
Warning ("LARGE_IDE_WARNING_2K"); Warning ("LARGE_IDE_WARNING_2K", NULL);
else else
{ {
DWORD val = 0, size = sizeof(val); 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 if (RegQueryValueEx (hkey, "EnableBigLba", 0, 0, (LPBYTE) &val, &size) != ERROR_SUCCESS
|| val != 1) || val != 1)
{ {
Warning ("LARGE_IDE_WARNING_2K_REGISTRY"); Warning ("LARGE_IDE_WARNING_2K_REGISTRY", NULL);
} }
RegCloseKey (hkey); RegCloseKey (hkey);
} }
@@ -2478,7 +2478,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
HKEY k; HKEY k;
// PE environment does not report version of SP // PE environment does not report version of SP
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\minint", 0, KEY_READ, &k) != ERROR_SUCCESS) 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 else
RegCloseKey (k); RegCloseKey (k);
} }
@@ -3133,7 +3133,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
{ {
if (WizardMode != WIZARD_MODE_SYS_DEVICE) if (WizardMode != WIZARD_MODE_SYS_DEVICE)
{ {
if (AskYesNo ("CONFIRM_SYSTEM_ENCRYPTION_MODE") == IDNO) if (AskYesNo ("CONFIRM_SYSTEM_ENCRYPTION_MODE", hwndDlg) == IDNO)
{ {
EndDialog (hwndDlg, IDCANCEL); EndDialog (hwndDlg, IDCANCEL);
return 1; return 1;
@@ -3165,9 +3165,9 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
{ {
if (bWarnDeviceFormatAdvanced if (bWarnDeviceFormatAdvanced
&& !bHiddenVolDirect && !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 (); SwitchWizardToFileContainerMode ();
} }
@@ -3195,7 +3195,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
{ {
if (WizardMode != WIZARD_MODE_SYS_DEVICE) if (WizardMode != WIZARD_MODE_SYS_DEVICE)
{ {
if (AskYesNo ("CONFIRM_SYSTEM_ENCRYPTION_MODE") == IDNO) if (AskYesNo ("CONFIRM_SYSTEM_ENCRYPTION_MODE", hwndDlg) == IDNO)
{ {
NormalCursor (); NormalCursor ();
EndDialog (hwndDlg, IDCANCEL); EndDialog (hwndDlg, IDCANCEL);
@@ -3231,11 +3231,11 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
if (!selectedDevice.Partitions.empty()) if (!selectedDevice.Partitions.empty())
{ {
EnableWindow (GetDlgItem (hwndDlg, IDOK), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDOK), FALSE);
Error ("DEVICE_PARTITIONS_ERR_W_INPLACE_ENC_NOTE"); Error ("DEVICE_PARTITIONS_ERR_W_INPLACE_ENC_NOTE", hwndDlg);
return 1; return 1;
} }
if (AskWarnNoYes ("WHOLE_NONSYS_DEVICE_ENC_CONFIRM") == IDNO) if (AskWarnNoYes ("WHOLE_NONSYS_DEVICE_ENC_CONFIRM", hwndDlg) == IDNO)
return 1; return 1;
} }
#else // #ifdef VOLFORMAT #else // #ifdef VOLFORMAT
@@ -3994,7 +3994,7 @@ void handleError (HWND hwndDlg, int code)
break; break;
case ERR_DRIVER_VERSION: case ERR_DRIVER_VERSION:
Error ("DRIVER_VERSION"); Error ("DRIVER_VERSION", hwndDlg);
break; break;
case ERR_NEW_VERSION_REQUIRED: case ERR_NEW_VERSION_REQUIRED:
@@ -4002,27 +4002,27 @@ void handleError (HWND hwndDlg, int code)
break; break;
case ERR_SELF_TESTS_FAILED: case ERR_SELF_TESTS_FAILED:
Error ("ERR_SELF_TESTS_FAILED"); Error ("ERR_SELF_TESTS_FAILED", hwndDlg);
break; break;
case ERR_VOL_FORMAT_BAD: case ERR_VOL_FORMAT_BAD:
Error ("ERR_VOL_FORMAT_BAD"); Error ("ERR_VOL_FORMAT_BAD", hwndDlg);
break; break;
case ERR_ENCRYPTION_NOT_COMPLETED: case ERR_ENCRYPTION_NOT_COMPLETED:
Error ("ERR_ENCRYPTION_NOT_COMPLETED"); Error ("ERR_ENCRYPTION_NOT_COMPLETED", hwndDlg);
break; break;
case ERR_NONSYS_INPLACE_ENC_INCOMPLETE: case ERR_NONSYS_INPLACE_ENC_INCOMPLETE:
Error ("ERR_NONSYS_INPLACE_ENC_INCOMPLETE"); Error ("ERR_NONSYS_INPLACE_ENC_INCOMPLETE", hwndDlg);
break; break;
case ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG: 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; break;
case ERR_PARAMETER_INCORRECT: case ERR_PARAMETER_INCORRECT:
Error ("ERR_PARAMETER_INCORRECT"); Error ("ERR_PARAMETER_INCORRECT", hwndDlg);
break; break;
case ERR_USER_ABORT: 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)) if (ferror (file))
{ {
wchar_t s[TC_MAX_PATH]; wchar_t s[TC_MAX_PATH];
StringCbPrintfW (s, sizeof (s), GetString ("CANNOT_WRITE_FILE_X"), fileName); StringCbPrintfW (s, sizeof (s), GetString ("CANNOT_WRITE_FILE_X"), fileName);
ErrorDirect (s); ErrorDirect (s, hwndDlg);
return FALSE; 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)) 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; SYSTEM_INFO sysInfo;
@@ -4742,7 +4742,7 @@ BOOL CALLBACK BenchmarkDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (nbrThreads < min (sysInfo.dwNumberOfProcessors, GetMaxEncryptionThreadCount()) if (nbrThreads < min (sysInfo.dwNumberOfProcessors, GetMaxEncryptionThreadCount())
&& sysInfo.dwNumberOfProcessors > 1) && sysInfo.dwNumberOfProcessors > 1)
{ {
Warning ("LIMITED_THREAD_COUNT_AFFECTS_PERFORMANCE"); Warning ("LIMITED_THREAD_COUNT_AFFECTS_PERFORMANCE", hwndDlg);
} }
return 1; return 1;
@@ -4852,7 +4852,7 @@ static BOOL CALLBACK RandomPoolEnrichementDlgProc (HWND hwndDlg, UINT msg, WPARA
if (bDisplayPoolContents) if (bDisplayPoolContents)
{ {
RandpeekBytes (randPool, sizeof (randPool)); RandpeekBytes (hwndDlg, randPool, sizeof (randPool));
if (memcmp (lastRandPool, randPool, sizeof(lastRandPool)) != 0) if (memcmp (lastRandPool, randPool, sizeof(lastRandPool)) != 0)
{ {
@@ -4989,7 +4989,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
#ifndef VOLFORMAT #ifndef VOLFORMAT
if (Randinit ()) if (Randinit ())
{ {
Error ("INIT_RAND"); Error ("INIT_RAND", hwndDlg);
EndDialog (hwndDlg, IDCLOSE); EndDialog (hwndDlg, IDCLOSE);
} }
#endif #endif
@@ -5014,7 +5014,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
if (bDisplayPoolContents) if (bDisplayPoolContents)
{ {
RandpeekBytes (randPool, sizeof (randPool)); RandpeekBytes (hwndDlg, randPool, sizeof (randPool));
if (memcmp (lastRandPool, randPool, sizeof(lastRandPool)) != 0) 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); keyfilesCount = strtoul(szNumber, NULL, 0);
if (keyfilesCount <= 0 || keyfilesCount == LONG_MAX) 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); SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM) GetDlgItem (hwndDlg, IDC_NUMBER_KEYFILES), TRUE);
return 1; return 1;
} }
@@ -5104,7 +5104,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
keyfilesSize = strtoul(szNumber, NULL, 0); keyfilesSize = strtoul(szNumber, NULL, 0);
if (keyfilesSize < 64 || keyfilesSize > 1024*1024) 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); SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM) GetDlgItem (hwndDlg, IDC_KEYFILES_SIZE), TRUE);
return 1; return 1;
} }
@@ -5116,14 +5116,14 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
// Trim trailing space // Trim trailing space
if (TrimWhiteSpace(szFileBaseName) == 0) 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); SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM) GetDlgItem (hwndDlg, IDC_KEYFILES_BASE_NAME), TRUE);
return 1; return 1;
} }
if (!IsValidFileName(szFileBaseName)) 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); SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM) GetDlgItem (hwndDlg, IDC_KEYFILES_BASE_NAME), TRUE);
return 1; 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)); MultiByteToWideChar(CP_ACP, 0, szFileName, -1, wszFileName, sizeof(wszFileName) / sizeof(WCHAR));
StringCbPrintfW (s, sizeof(s), GetString ("KEYFILE_ALREADY_EXISTS"), wszFileName); StringCbPrintfW (s, sizeof(s), GetString ("KEYFILE_ALREADY_EXISTS"), wszFileName);
status = AskWarnNoYesString (s); status = AskWarnNoYesString (s, hwndDlg);
if (status == IDNO) if (status == IDNO)
{ {
TCfree(keyfile); TCfree(keyfile);
@@ -5196,7 +5196,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
if (bRandomSize) if (bRandomSize)
{ {
/* Generate a random size */ /* Generate a random size */
if (!RandgetBytes ((unsigned char*) &keyfilesSize, sizeof(keyfilesSize), FALSE)) if (!RandgetBytes (hwndDlg, (unsigned char*) &keyfilesSize, sizeof(keyfilesSize), FALSE))
{ {
_close (fhKeyfile); _close (fhKeyfile);
DeleteFile (szFileName); DeleteFile (szFileName);
@@ -5213,7 +5213,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
} }
/* Generate the keyfile */ /* Generate the keyfile */
if (!RandgetBytesFull (keyfile, keyfilesSize, TRUE, TRUE)) if (!RandgetBytesFull (hwndDlg, keyfile, keyfilesSize, TRUE, TRUE))
{ {
_close (fhKeyfile); _close (fhKeyfile);
DeleteFile (szFileName); DeleteFile (szFileName);
@@ -5239,7 +5239,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
TCfree(keyfile); TCfree(keyfile);
NormalCursor(); NormalCursor();
Info("KEYFILE_CREATED"); Info("KEYFILE_CREATED", hwndDlg);
return 1; return 1;
} }
@@ -5410,7 +5410,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
n = GetWindowText(GetDlgItem(hwndDlg, IDC_KEY), szTmp, sizeof(szTmp)); n = GetWindowText(GetDlgItem(hwndDlg, IDC_KEY), szTmp, sizeof(szTmp));
if (n != ks * 2) if (n != ks * 2)
{ {
Warning ("TEST_KEY_SIZE"); Warning ("TEST_KEY_SIZE", hwndDlg);
return 1; return 1;
} }
@@ -5446,12 +5446,12 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
if (bEncrypt) if (bEncrypt)
{ {
Warning ("TEST_PLAINTEXT_SIZE"); Warning ("TEST_PLAINTEXT_SIZE", hwndDlg);
return 1; return 1;
} }
else else
{ {
Warning ("TEST_CIPHERTEXT_SIZE"); Warning ("TEST_CIPHERTEXT_SIZE", hwndDlg);
return 1; 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) 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; return 1;
} }
@@ -5501,7 +5501,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (tlen > 16 || tlen < 1) if (tlen > 16 || tlen < 1)
{ {
Warning ("TEST_INCORRECT_TEST_DATA_UNIT_SIZE"); Warning ("TEST_INCORRECT_TEST_DATA_UNIT_SIZE", hwndDlg);
return 1; return 1;
} }
@@ -6283,7 +6283,7 @@ int MountVolume (HWND hwndDlg,
#ifdef TCMOUNT #ifdef TCMOUNT
if (mountOptions->PartitionInInactiveSysEncScope) if (mountOptions->PartitionInInactiveSysEncScope)
{ {
if (!CheckSysEncMountWithoutPBA (volumePath, quiet)) if (!CheckSysEncMountWithoutPBA (hwndDlg, volumePath, quiet))
return -1; return -1;
} }
#endif #endif
@@ -6291,14 +6291,14 @@ int MountVolume (HWND hwndDlg,
if (IsMountedVolume (volumePath)) if (IsMountedVolume (volumePath))
{ {
if (!quiet) if (!quiet)
Error ("VOL_ALREADY_MOUNTED"); Error ("VOL_ALREADY_MOUNTED", hwndDlg);
return -1; return -1;
} }
if (!IsDriveAvailable (driveNo)) if (!IsDriveAvailable (driveNo))
{ {
if (!quiet) if (!quiet)
Error ("DRIVE_LETTER_UNAVAILABLE"); Error ("DRIVE_LETTER_UNAVAILABLE", hwndDlg);
return -1; return -1;
} }
@@ -6431,7 +6431,7 @@ retry:
if (mount.bExclusiveAccess == FALSE) if (mount.bExclusiveAccess == FALSE)
{ {
if (!quiet) if (!quiet)
Error ("FILE_IN_USE_FAILED"); Error ("FILE_IN_USE_FAILED", hwndDlg);
return -1; return -1;
} }
@@ -6444,7 +6444,7 @@ retry:
} }
// Ask user // Ask user
if (IDYES == AskWarnNoYes ("FILE_IN_USE")) if (IDYES == AskWarnNoYes ("FILE_IN_USE", hwndDlg))
{ {
mount.bExclusiveAccess = FALSE; mount.bExclusiveAccess = FALSE;
goto retry; goto retry;
@@ -6491,7 +6491,7 @@ retry:
DWORD dwResult; DWORD dwResult;
if (DeviceIoControl (hDriver, TC_IOCTL_OPEN_TEST, &openTestStruct, sizeof (OPEN_TEST_STRUCT), &openTestStruct, sizeof (OPEN_TEST_STRUCT), &dwResult, NULL) && openTestStruct.TCBootLoaderDetected) 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 else
handleError (hwndDlg, mount.nReturnCode); handleError (hwndDlg, mount.nReturnCode);
} }
@@ -6515,7 +6515,7 @@ retry:
&& mount.UseBackupHeader) && mount.UseBackupHeader)
{ {
if (bReportWrongPassword && !Silent) if (bReportWrongPassword && !Silent)
Warning ("HEADER_DAMAGED_AUTO_USED_HEADER_BAK"); Warning ("HEADER_DAMAGED_AUTO_USED_HEADER_BAK", hwndDlg);
} }
LastMountedVolumeDirty = mount.FilesystemDirty; LastMountedVolumeDirty = mount.FilesystemDirty;
@@ -6526,8 +6526,8 @@ retry:
wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_VOLUME_DIRTY"), mountPoint); StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_VOLUME_DIRTY"), mountPoint);
if (AskWarnYesNoStringTopmost (msg) == IDYES) if (AskWarnYesNoStringTopmost (msg, hwndDlg) == IDYES)
CheckFilesystem (driveNo, TRUE); CheckFilesystem (hwndDlg, driveNo, TRUE);
} }
if (mount.VolumeMountedReadOnlyAfterAccessDenied if (mount.VolumeMountedReadOnlyAfterAccessDenied
@@ -6540,7 +6540,7 @@ retry:
wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_CONTAINER_FORCED_READ_ONLY"), mountPoint); StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_CONTAINER_FORCED_READ_ONLY"), mountPoint);
WarningDirect (msg); WarningDirect (msg, hwndDlg);
} }
if (mount.VolumeMountedReadOnlyAfterAccessDenied if (mount.VolumeMountedReadOnlyAfterAccessDenied
@@ -6551,7 +6551,7 @@ retry:
wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY"), mountPoint); StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY"), mountPoint);
WarningDirect (msg); WarningDirect (msg, hwndDlg);
} }
if (mount.VolumeMountedReadOnlyAfterDeviceWriteProtected if (mount.VolumeMountedReadOnlyAfterDeviceWriteProtected
@@ -6562,11 +6562,11 @@ retry:
wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY_WRITE_PROTECTION"), mountPoint); StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY_WRITE_PROTECTION"), mountPoint);
WarningDirect (msg); WarningDirect (msg, hwndDlg);
if (CurrentOSMajor >= 6 if (CurrentOSMajor >= 6
&& strstr (volumePath, "\\Device\\HarddiskVolume") != volumePath && strstr (volumePath, "\\Device\\HarddiskVolume") != volumePath
&& AskNoYes ("ASK_REMOVE_DEVICE_WRITE_PROTECTION") == IDYES) && AskNoYes ("ASK_REMOVE_DEVICE_WRITE_PROTECTION", hwndDlg) == IDYES)
{ {
RemoveDeviceWriteProtection (hwndDlg, volumePath); RemoveDeviceWriteProtection (hwndDlg, volumePath);
} }
@@ -6607,7 +6607,7 @@ retry:
{ {
if (result == ERR_FILES_OPEN && !Silent) if (result == ERR_FILES_OPEN && !Silent)
{ {
if (IDYES == AskWarnYesNoTopmost ("UNMOUNT_LOCK_FAILED")) if (IDYES == AskWarnYesNoTopmost ("UNMOUNT_LOCK_FAILED", hwndDlg))
{ {
forced = TRUE; forced = TRUE;
goto retry; goto retry;
@@ -6623,7 +6623,7 @@ retry:
return FALSE; return FALSE;
} }
Error ("UNMOUNT_FAILED"); Error ("UNMOUNT_FAILED", hwndDlg);
return FALSE; return FALSE;
} }
@@ -6897,7 +6897,7 @@ __int64 GetStatsFreeSpaceOnPartition (const char *devicePath, float *percentFree
if (!silent) if (!silent)
{ {
handleWin32Error (MainDlg); handleWin32Error (MainDlg);
Error ("CANNOT_CALC_SPACE"); Error ("CANNOT_CALC_SPACE", MainDlg);
} }
return -1; return -1;
@@ -6915,7 +6915,7 @@ __int64 GetStatsFreeSpaceOnPartition (const char *devicePath, float *percentFree
if (!silent) if (!silent)
{ {
handleWin32Error (MainDlg); handleWin32Error (MainDlg);
Error ("CANT_GET_VOLSIZE"); Error ("CANT_GET_VOLSIZE", MainDlg);
} }
return -1; return -1;
} }
@@ -7958,12 +7958,12 @@ void TaskBarIconDisplayBalloonTooltip (HWND hwnd, wchar_t *headline, wchar_t *te
// Either of the pointers may be NULL // Either of the pointers may be NULL
void InfoBalloon (char *headingStringId, char *textStringId) void InfoBalloon (char *headingStringId, char *textStringId, HWND hwnd)
{ {
if (Silent) if (Silent)
return; return;
TaskBarIconDisplayBalloonTooltip (MainDlg, TaskBarIconDisplayBalloonTooltip (hwnd,
headingStringId == NULL ? L"VeraCrypt" : GetString (headingStringId), headingStringId == NULL ? L"VeraCrypt" : GetString (headingStringId),
textStringId == NULL ? L" " : GetString (textStringId), textStringId == NULL ? L" " : GetString (textStringId),
FALSE); FALSE);
@@ -7971,12 +7971,12 @@ void InfoBalloon (char *headingStringId, char *textStringId)
// Either of the pointers may be NULL // 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) if (Silent)
return; return;
TaskBarIconDisplayBalloonTooltip (MainDlg, TaskBarIconDisplayBalloonTooltip (hwnd,
headingString == NULL ? L"VeraCrypt" : headingString, headingString == NULL ? L"VeraCrypt" : headingString,
textString == NULL ? L" " : textString, textString == NULL ? L" " : textString,
FALSE); FALSE);
@@ -7984,12 +7984,12 @@ void InfoBalloonDirect (wchar_t *headingString, wchar_t *textString)
// Either of the pointers may be NULL // Either of the pointers may be NULL
void WarningBalloon (char *headingStringId, char *textStringId) void WarningBalloon (char *headingStringId, char *textStringId, HWND hwnd)
{ {
if (Silent) if (Silent)
return; return;
TaskBarIconDisplayBalloonTooltip (MainDlg, TaskBarIconDisplayBalloonTooltip (hwnd,
headingStringId == NULL ? L"VeraCrypt" : GetString (headingStringId), headingStringId == NULL ? L"VeraCrypt" : GetString (headingStringId),
textStringId == NULL ? L" " : GetString (textStringId), textStringId == NULL ? L" " : GetString (textStringId),
TRUE); TRUE);
@@ -7997,190 +7997,190 @@ void WarningBalloon (char *headingStringId, char *textStringId)
// Either of the pointers may be NULL // 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) if (Silent)
return; return;
TaskBarIconDisplayBalloonTooltip (MainDlg, TaskBarIconDisplayBalloonTooltip (hwnd,
headingString == NULL ? L"VeraCrypt" : headingString, headingString == NULL ? L"VeraCrypt" : headingString,
textString == NULL ? L" " : textString, textString == NULL ? L" " : textString,
TRUE); TRUE);
} }
int Info (char *stringId) int Info (char *stringId, HWND hwnd)
{ {
if (Silent) return 0; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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. // 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 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) // 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; MULTI_CHOICE_DLGPROC_PARAMS params;
@@ -8199,7 +8199,7 @@ int AskMultiChoice (void *strings[], BOOL bBold)
params.bold = bBold; params.bold = bBold;
return DialogBoxParamW (hInst, return DialogBoxParamW (hInst,
MAKEINTRESOURCEW (IDD_MULTI_CHOICE_DLG), MainDlg, MAKEINTRESOURCEW (IDD_MULTI_CHOICE_DLG), hwnd,
(DLGPROC) MultiChoiceDialogProc, (LPARAM) &params); (DLGPROC) MultiChoiceDialogProc, (LPARAM) &params);
} }
@@ -8227,7 +8227,7 @@ BOOL ConfigWriteBegin ()
} }
BOOL ConfigWriteEnd () BOOL ConfigWriteEnd (HWND hwnd)
{ {
char *xml = ConfigBuffer; char *xml = ConfigBuffer;
char key[128], value[2048]; char key[128], value[2048];
@@ -8249,7 +8249,7 @@ BOOL ConfigWriteEnd ()
TCFlushFile (ConfigFileHandle); TCFlushFile (ConfigFileHandle);
CheckFileStreamWriteErrors (ConfigFileHandle, TC_APPD_FILENAME_CONFIGURATION); CheckFileStreamWriteErrors (hwnd, ConfigFileHandle, TC_APPD_FILENAME_CONFIGURATION);
fclose (ConfigFileHandle); fclose (ConfigFileHandle);
ConfigFileHandle = NULL; ConfigFileHandle = NULL;
@@ -8354,7 +8354,7 @@ void OpenPageHelp (HWND hwndDlg, int nPage)
if (r == SE_ERR_NOASSOC) if (r == SE_ERR_NOASSOC)
{ {
if (AskYesNo ("HELP_READER_ERROR") == IDYES) if (AskYesNo ("HELP_READER_ERROR", MainDlg) == IDYES)
OpenOnlineHelp (); OpenOnlineHelp ();
} }
} }
@@ -8835,7 +8835,7 @@ char *RelativePath2Absolute (char *szFileName)
} }
void HandleDriveNotReadyError () void HandleDriveNotReadyError (HWND hwnd)
{ {
HKEY hkey = 0; HKEY hkey = 0;
DWORD value = 0, size = sizeof (DWORD); DWORD value = 0, size = sizeof (DWORD);
@@ -8847,12 +8847,12 @@ void HandleDriveNotReadyError ()
if (RegQueryValueEx (hkey, "NoAutoMount", 0, 0, (LPBYTE) &value, &size) == ERROR_SUCCESS if (RegQueryValueEx (hkey, "NoAutoMount", 0, 0, (LPBYTE) &value, &size) == ERROR_SUCCESS
&& value != 0) && value != 0)
{ {
Warning ("SYS_AUTOMOUNT_DISABLED"); Warning ("SYS_AUTOMOUNT_DISABLED", hwnd);
} }
else if (nCurrentOS == WIN_VISTA && CurrentOSServicePack < 1) else if (nCurrentOS == WIN_VISTA && CurrentOSServicePack < 1)
Warning ("SYS_ASSIGN_DRIVE_LETTER"); Warning ("SYS_ASSIGN_DRIVE_LETTER", hwnd);
else else
Warning ("DEVICE_NOT_READY_ERROR"); Warning ("DEVICE_NOT_READY_ERROR", hwnd);
RegCloseKey (hkey); 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; CRYPTO_INFO *newCryptoInfo = NULL;
@@ -9139,7 +9139,7 @@ int ReEncryptVolumeHeader (char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Pa
UserEnrichRandomPool (NULL); UserEnrichRandomPool (NULL);
int status = CreateVolumeHeaderInMemory (bBoot, int status = CreateVolumeHeaderInMemory (hwndDlg, bBoot,
buffer, buffer,
cryptoInfo->ea, cryptoInfo->ea,
cryptoInfo->mode, cryptoInfo->mode,
@@ -9413,7 +9413,7 @@ static BOOL CALLBACK NewSecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPA
if (tokens.empty()) if (tokens.empty())
{ {
Error ("NO_TOKENS_FOUND"); Error ("NO_TOKENS_FOUND", hwndDlg);
EndDialog (hwndDlg, IDCANCEL); EndDialog (hwndDlg, IDCANCEL);
return 1; return 1;
} }
@@ -9711,7 +9711,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
throw SystemException (); throw SystemException ();
} }
Info ("KEYFILE_EXPORTED"); Info ("KEYFILE_EXPORTED", hwndDlg);
} }
} }
catch (Exception &e) catch (Exception &e)
@@ -9724,7 +9724,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
case IDC_DELETE: case IDC_DELETE:
{ {
if (AskNoYes ("CONFIRM_SEL_FILES_DELETE") == IDNO) if (AskNoYes ("CONFIRM_SEL_FILES_DELETE", hwndDlg) == IDNO)
return 1; return 1;
try try
@@ -9755,19 +9755,21 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
} }
BOOL InitSecurityTokenLibrary () BOOL InitSecurityTokenLibrary (HWND hwndDlg)
{ {
if (SecurityTokenLibraryPath[0] == 0) if (SecurityTokenLibraryPath[0] == 0)
{ {
Error ("NO_PKCS11_MODULE_SPECIFIED"); Error ("NO_PKCS11_MODULE_SPECIFIED", hwndDlg);
return FALSE; return FALSE;
} }
struct PinRequestHandler : public GetPinFunctor struct PinRequestHandler : public GetPinFunctor
{ {
HWND m_hwnd;
PinRequestHandler(HWND hwnd) : m_hwnd(hwnd) {}
virtual void operator() (string &str) 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); throw UserAbort (SRC_POS);
if (hCursor != NULL) if (hCursor != NULL)
@@ -9777,20 +9779,22 @@ BOOL InitSecurityTokenLibrary ()
struct WarningHandler : public SendExceptionFunctor struct WarningHandler : public SendExceptionFunctor
{ {
HWND m_hwnd;
WarningHandler(HWND hwnd) : m_hwnd(hwnd) {}
virtual void operator() (const Exception &e) virtual void operator() (const Exception &e)
{ {
e.Show (NULL); e.Show (m_hwnd);
} }
}; };
try 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) catch (Exception &e)
{ {
e.Show (NULL); e.Show (hwndDlg);
Error ("PKCS11_MODULE_INIT_FAILED"); Error ("PKCS11_MODULE_INIT_FAILED", hwndDlg);
return FALSE; 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]; wchar_t msg[1024], param[1024], cmdPath[MAX_PATH];
char driveRoot[] = { 'A' + (char) driveNo, ':', 0 }; char driveRoot[] = { 'A' + (char) driveNo, ':', 0 };
if (fixErrors && AskWarnYesNo ("FILESYS_REPAIR_CONFIRM_BACKUP") == IDNO) if (fixErrors && AskWarnYesNo ("FILESYS_REPAIR_CONFIRM_BACKUP", hwndDlg) == IDNO)
return; return;
StringCbPrintfW (msg, sizeof(msg), GetString (fixErrors ? "REPAIRING_FS" : "CHECKING_FS"), driveRoot); 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 #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; return IDYES;
char *multiChoiceStr[] = { 0, "ASK_NONSYS_INPLACE_ENC_NOTIFICATION_REMOVAL", "DO_NOT_PROMPT_ME", "KEEP_PROMPTING_ME", 0 }; 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: case 1:
RemoveNonSysInPlaceEncNotifications(); RemoveNonSysInPlaceEncNotifications();
Warning ("NONSYS_INPLACE_ENC_NOTIFICATION_REMOVAL_NOTE"); Warning ("NONSYS_INPLACE_ENC_NOTIFICATION_REMOVAL_NOTE", hwndDlg);
break; break;
default: 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); fprintf (f, "@diskpart /s \"%s\"\n@pause\n@del \"%s\" \"%s\"", diskpartScript, diskpartScript, cmdBatch);
CheckFileStreamWriteErrors (f, cmdBatch); CheckFileStreamWriteErrors (hwndDlg, f, cmdBatch);
fclose (f); fclose (f);
f = fopen (diskpartScript, "w"); f = fopen (diskpartScript, "w");
@@ -10086,7 +10090,7 @@ BOOL RemoveDeviceWriteProtection (HWND hwndDlg, char *devicePath)
fprintf (f, "exit\n"); fprintf (f, "exit\n");
CheckFileStreamWriteErrors (f, diskpartScript); CheckFileStreamWriteErrors (hwndDlg, f, diskpartScript);
fclose (f); fclose (f);
ShellExecute (NULL, (!IsAdmin() && IsUacSupported()) ? "runas" : "open", cmdBatch, NULL, NULL, SW_SHOW); ShellExecute (NULL, (!IsAdmin() && IsUacSupported()) ? "runas" : "open", cmdBatch, NULL, NULL, SW_SHOW);

View File

@@ -285,7 +285,7 @@ BOOL LoadSysEncSettings (HWND hwndDlg);
int LoadNonSysInPlaceEncSettings (WipeAlgorithmId *wipeAlgorithm); int LoadNonSysInPlaceEncSettings (WipeAlgorithmId *wipeAlgorithm);
void RemoveNonSysInPlaceEncNotifications (void); void RemoveNonSysInPlaceEncNotifications (void);
void SavePostInstallTasksSettings (int command); void SavePostInstallTasksSettings (int command);
void DoPostInstallTasks (void); void DoPostInstallTasks (HWND hwndDlg);
void InitOSVersionInfo (); void InitOSVersionInfo ();
void InitApp ( HINSTANCE hInstance, char *lpszCommandLine ); void InitApp ( HINSTANCE hInstance, char *lpszCommandLine );
void InitHelpFileName (void); 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 BrowseFiles (HWND hwndDlg, char *stringId, char *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter);
BOOL BrowseDirectories (HWND hWnd, char *lpszTitle, char *dirName); BOOL BrowseDirectories (HWND hWnd, char *lpszTitle, char *dirName);
void handleError ( HWND hwndDlg , int code ); 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 LocalizeDialog ( HWND hwnd, char *stringId );
void OpenVolumeExplorerWindow (int driveNo); void OpenVolumeExplorerWindow (int driveNo);
static BOOL CALLBACK CloseVolumeExplorerWindowsEnum( HWND hwnd, LPARAM driveNo); static BOOL CALLBACK CloseVolumeExplorerWindowsEnum( HWND hwnd, LPARAM driveNo);
@@ -374,38 +374,38 @@ char *GetProgramConfigPath (char *fileName);
char GetSystemDriveLetter (void); char GetSystemDriveLetter (void);
void OpenPageHelp (HWND hwndDlg, int nPage); void OpenPageHelp (HWND hwndDlg, int nPage);
void TaskBarIconDisplayBalloonTooltip (HWND hwnd, wchar_t *headline, wchar_t *text, BOOL warning); void TaskBarIconDisplayBalloonTooltip (HWND hwnd, wchar_t *headline, wchar_t *text, BOOL warning);
void InfoBalloon (char *headingStringId, char *textStringId); void InfoBalloon (char *headingStringId, char *textStringId, HWND hwnd);
void InfoBalloonDirect (wchar_t *headingString, wchar_t *textString); void InfoBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd);
void WarningBalloon (char *headingStringId, char *textStringId); void WarningBalloon (char *headingStringId, char *textStringId, HWND hwnd);
void WarningBalloonDirect (wchar_t *headingString, wchar_t *textString); void WarningBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd);
int Info (char *stringId); int Info (char *stringId, HWND hwnd);
int InfoTopMost (char *stringId); int InfoTopMost (char *stringId, HWND hwnd);
int InfoDirect (const wchar_t *msg); int InfoDirect (const wchar_t *msg, HWND hwnd);
int Warning (char *stringId); int Warning (char *stringId, HWND hwnd);
int WarningTopMost (char *stringId); int WarningTopMost (char *stringId, HWND hwnd);
int WarningDirect (const wchar_t *warnMsg); int WarningDirect (const wchar_t *warnMsg, HWND hwnd);
int Error (char *stringId); int Error (char *stringId, HWND hwnd);
int ErrorDirect (const wchar_t *errMsg); int ErrorDirect (const wchar_t *errMsg, HWND hwnd);
int ErrorTopMost (char *stringId); int ErrorTopMost (char *stringId, HWND hwnd);
int AskYesNo (char *stringId); int AskYesNo (char *stringId, HWND hwnd);
int AskYesNoString (const wchar_t *str); int AskYesNoString (const wchar_t *str, HWND hwnd);
int AskYesNoTopmost (char *stringId); int AskYesNoTopmost (char *stringId, HWND hwnd);
int AskNoYes (char *stringId); int AskNoYes (char *stringId, HWND hwnd);
int AskOkCancel (char *stringId); int AskOkCancel (char *stringId, HWND hwnd);
int AskWarnYesNo (char *stringId); int AskWarnYesNo (char *stringId, HWND hwnd);
int AskWarnYesNoString (const wchar_t *string); int AskWarnYesNoString (const wchar_t *string, HWND hwnd);
int AskWarnYesNoTopmost (char *stringId); int AskWarnYesNoTopmost (char *stringId, HWND hwnd);
int AskWarnYesNoStringTopmost (const wchar_t *string); int AskWarnYesNoStringTopmost (const wchar_t *string, HWND hwnd);
int AskWarnNoYes (char *stringId); int AskWarnNoYes (char *stringId, HWND hwnd);
int AskWarnNoYesString (const wchar_t *string); int AskWarnNoYesString (const wchar_t *string, HWND hwnd);
int AskWarnNoYesTopmost (char *stringId); int AskWarnNoYesTopmost (char *stringId, HWND hwnd);
int AskWarnOkCancel (char *stringId); int AskWarnOkCancel (char *stringId, HWND hwnd);
int AskWarnCancelOk (char *stringId); int AskWarnCancelOk (char *stringId, HWND hwnd);
int AskErrYesNo (char *stringId); int AskErrYesNo (char *stringId, HWND hwnd);
int AskErrNoYes (char *stringId); int AskErrNoYes (char *stringId, HWND hwnd);
int AskMultiChoice (void *strings[], BOOL bBold); int AskMultiChoice (void *strings[], BOOL bBold, HWND hwnd);
BOOL ConfigWriteBegin (); BOOL ConfigWriteBegin ();
BOOL ConfigWriteEnd (); BOOL ConfigWriteEnd (HWND hwnd);
BOOL ConfigWriteString (char *configKey, char *configValue); BOOL ConfigWriteString (char *configKey, char *configValue);
BOOL ConfigWriteInt (char *configKey, int configValue); BOOL ConfigWriteInt (char *configKey, int configValue);
int ConfigReadInt (char *configKey, int defaultValue); int ConfigReadInt (char *configKey, int defaultValue);
@@ -423,7 +423,7 @@ BOOL EnableWow64FsRedirection (BOOL enable);
BOOL RestartComputer (void); BOOL RestartComputer (void);
void Applink (char *dest, BOOL bSendOS, char *extraOutput); void Applink (char *dest, BOOL bSendOS, char *extraOutput);
char *RelativePath2Absolute (char *szFileName); char *RelativePath2Absolute (char *szFileName);
void HandleDriveNotReadyError (); void HandleDriveNotReadyError (HWND hwnd);
BOOL CALLBACK CloseTCWindowsEnum( HWND hwnd, LPARAM lParam); BOOL CALLBACK CloseTCWindowsEnum( HWND hwnd, LPARAM lParam);
BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam); BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam);
BYTE *MapResource (char *resourceType, int resourceId, PDWORD size); 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); BOOL DoDriverInstall (HWND hwndDlg);
int OpenVolume (OpenVolumeContext *context, const char *volumePath, Password *password, int pkcs5_prf, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader); int OpenVolume (OpenVolumeContext *context, const char *volumePath, Password *password, int pkcs5_prf, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader);
void CloseVolume (OpenVolumeContext *context); 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 IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
BOOL IsPagingFileWildcardActive (); BOOL IsPagingFileWildcardActive ();
BOOL DisablePagingFile (); BOOL DisablePagingFile ();
BOOL CALLBACK SecurityTokenPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); BOOL CALLBACK SecurityTokenPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK SecurityTokenKeyfileDlgProc (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 FileHasReadOnlyAttribute (const char *path);
BOOL IsFileOnReadOnlyFilesystem (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); BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str);
int AskNonSysInPlaceEncryptionResume (); int AskNonSysInPlaceEncryptionResume (HWND hwndDlg);
BOOL RemoveDeviceWriteProtection (HWND hwndDlg, char *devicePath); BOOL RemoveDeviceWriteProtection (HWND hwndDlg, char *devicePath);
void EnableElevatedCursorChange (HWND parent); void EnableElevatedCursorChange (HWND parent);
BOOL DisableFileCompression (HANDLE file); BOOL DisableFileCompression (HANDLE file);

View File

@@ -40,9 +40,9 @@ namespace VeraCrypt
void Show (HWND parent) const void Show (HWND parent) const
{ {
if (ErrMsg.empty()) if (ErrMsg.empty())
::Error (ErrLangId? ErrLangId : ""); ::Error (ErrLangId? ErrLangId : "", parent);
else else
::ErrorDirect (ErrMsg.c_str()); ::ErrorDirect (ErrMsg.c_str(), parent);
} }
char *ErrLangId; char *ErrLangId;
@@ -65,7 +65,7 @@ namespace VeraCrypt
struct TimeOut : public Exception struct TimeOut : public Exception
{ {
TimeOut (const char *srcPos) { } 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 struct UserAbort : public Exception

View File

@@ -253,7 +253,7 @@ static void PutFSInfo (unsigned char *sector, fatparams *ft)
int 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; int write_buf_cnt = 0;
char sector[TC_MAX_VOLUME_SECTOR_SIZE], *write_buf; 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 x, n;
int retVal; int retVal;
char temporaryKey[MASTER_KEYDATA_SIZE]; char temporaryKey[MASTER_KEYDATA_SIZE];
HWND hwndDlg = (HWND) hwndDlgPtr;
LARGE_INTEGER startOffset; LARGE_INTEGER startOffset;
LARGE_INTEGER newOffset; LARGE_INTEGER newOffset;
@@ -281,7 +282,7 @@ FormatFat (unsigned __int64 startSector, fatparams * ft, void * dev, PCRYPTO_INF
memset (sector, 0, ft->sector_size); 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); PutBoot (ft, (unsigned char *) sector);
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo, 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). */ within the volume). */
// Temporary master key // Temporary master key
if (!RandgetBytes (temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE)) if (!RandgetBytes (hwndDlg, temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE))
goto fail; goto fail;
// Temporary secondary key (XTS mode) // Temporary secondary key (XTS mode)
if (!RandgetBytes (cryptoInfo->k2, sizeof cryptoInfo->k2, FALSE)) if (!RandgetBytes (hwndDlg, cryptoInfo->k2, sizeof cryptoInfo->k2, FALSE))
goto fail; goto fail;
retVal = EAInit (cryptoInfo->ea, temporaryKey, cryptoInfo->ks); retVal = EAInit (cryptoInfo->ea, temporaryKey, cryptoInfo->ks);

View File

@@ -64,4 +64,4 @@ struct msdos_boot_sector
void GetFatParams ( fatparams *ft ); void GetFatParams ( fatparams *ft );
void PutBoot ( fatparams *ft , unsigned char *boot ); 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);

View File

@@ -93,6 +93,7 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams)
uint64 dataOffset, dataAreaSize; uint64 dataOffset, dataAreaSize;
LARGE_INTEGER offset; LARGE_INTEGER offset;
BOOL bFailedRequiredDASD = FALSE; BOOL bFailedRequiredDASD = FALSE;
HWND hwndDlg = volParams->hwndDlg;
FormatSectorSize = volParams->sectorSize; FormatSectorSize = volParams->sectorSize;
@@ -100,7 +101,7 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams)
|| FormatSectorSize > TC_MAX_VOLUME_SECTOR_SIZE || FormatSectorSize > TC_MAX_VOLUME_SECTOR_SIZE
|| FormatSectorSize % ENCRYPTION_DATA_UNIT_SIZE != 0) || FormatSectorSize % ENCRYPTION_DATA_UNIT_SIZE != 0)
{ {
Error ("SECTOR_SIZE_UNSUPPORTED"); Error ("SECTOR_SIZE_UNSUPPORTED", hwndDlg);
return ERR_DONT_REPORT; return ERR_DONT_REPORT;
} }
@@ -139,7 +140,7 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams)
VirtualLock (header, sizeof (header)); VirtualLock (header, sizeof (header));
nStatus = CreateVolumeHeaderInMemory (FALSE, nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
header, header,
volParams->ea, volParams->ea,
FIRST_MODE_OF_OPERATION_ID, FIRST_MODE_OF_OPERATION_ID,
@@ -179,7 +180,7 @@ begin_format:
{ {
if ((dev = DismountDrive (devName, volParams->volumePath)) == INVALID_HANDLE_VALUE) if ((dev = DismountDrive (devName, volParams->volumePath)) == INVALID_HANDLE_VALUE)
{ {
Error ("FORMAT_CANT_DISMOUNT_FILESYS"); Error ("FORMAT_CANT_DISMOUNT_FILESYS", hwndDlg);
nStatus = ERR_DONT_REPORT; nStatus = ERR_DONT_REPORT;
goto error; goto error;
} }
@@ -285,7 +286,7 @@ begin_format:
else else
{ {
handleWin32Error (volParams->hwndDlg); handleWin32Error (volParams->hwndDlg);
Error ("CANT_ACCESS_VOL"); Error ("CANT_ACCESS_VOL", hwndDlg);
nStatus = ERR_DONT_REPORT; nStatus = ERR_DONT_REPORT;
goto error; goto error;
} }
@@ -317,7 +318,7 @@ begin_format:
if (DeviceIoControl (dev, FSCTL_IS_VOLUME_MOUNTED, NULL, 0, NULL, 0, &dwResult, NULL)) 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; nStatus = ERR_DONT_REPORT;
goto error; goto error;
} }
@@ -474,7 +475,7 @@ begin_format:
goto error; goto error;
} }
nStatus = FormatNoFs (startSector, num_sectors, dev, cryptoInfo, volParams->quickFormat); nStatus = FormatNoFs (hwndDlg, startSector, num_sectors, dev, cryptoInfo, volParams->quickFormat);
if (volParams->bDevice) if (volParams->bDevice)
StopFormatWriteThread(); StopFormatWriteThread();
@@ -507,7 +508,7 @@ begin_format:
goto error; goto error;
} }
nStatus = FormatFat (startSector, &ft, (void *) dev, cryptoInfo, volParams->quickFormat); nStatus = FormatFat (hwndDlg, startSector, &ft, (void *) dev, cryptoInfo, volParams->quickFormat);
if (volParams->bDevice) if (volParams->bDevice)
StopFormatWriteThread(); StopFormatWriteThread();
@@ -531,7 +532,7 @@ begin_format:
goto error; goto error;
} }
nStatus = CreateVolumeHeaderInMemory (FALSE, nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
header, header,
volParams->ea, volParams->ea,
FIRST_MODE_OF_OPERATION_ID, FIRST_MODE_OF_OPERATION_ID,
@@ -557,7 +558,7 @@ begin_format:
// Fill reserved header sectors (including the backup header area) with random data // Fill reserved header sectors (including the backup header area) with random data
if (!volParams->hiddenVol) if (!volParams->hiddenVol)
{ {
nStatus = WriteRandomDataToReservedHeaderAreas (dev, cryptoInfo, dataAreaSize, FALSE, FALSE); nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, cryptoInfo, dataAreaSize, FALSE, FALSE);
if (nStatus != ERR_SUCCESS) if (nStatus != ERR_SUCCESS)
goto error; goto error;
@@ -643,7 +644,7 @@ error:
if (dataAreaSize <= TC_MAX_FAT_SECTOR_COUNT * FormatSectorSize) 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 // NTFS format failed and the user wants to try FAT format immediately
volParams->fileSystem = FILESYS_FAT; volParams->fileSystem = FILESYS_FAT;
@@ -654,7 +655,7 @@ error:
} }
} }
else else
Error ("FORMAT_NTFS_FAILED"); Error ("FORMAT_NTFS_FAILED", hwndDlg);
nStatus = ERR_DONT_REPORT; nStatus = ERR_DONT_REPORT;
goto fv_end; 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; int write_buf_cnt = 0;
char sector[TC_MAX_VOLUME_SECTOR_SIZE], *write_buf; 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. */ deniability of hidden volumes. */
// Temporary master key // Temporary master key
if (!RandgetBytes (temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE)) if (!RandgetBytes (hwndDlg, temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE))
goto fail; goto fail;
// Temporary secondary key (XTS mode) // Temporary secondary key (XTS mode)
if (!RandgetBytes (cryptoInfo->k2, sizeof cryptoInfo->k2, FALSE)) if (!RandgetBytes (hwndDlg, cryptoInfo->k2, sizeof cryptoInfo->k2, FALSE))
goto fail; goto fail;
retVal = EAInit (cryptoInfo->ea, temporaryKey, cryptoInfo->ks); retVal = EAInit (cryptoInfo->ea, temporaryKey, cryptoInfo->ks);

View File

@@ -51,7 +51,7 @@ extern int FormatWriteBufferSize;
int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams); int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams);
BOOL FormatNtfs (int driveNo, int clusterSize); BOOL FormatNtfs (int driveNo, int clusterSize);
uint64 GetVolumeDataAreaSize (BOOL hiddenVolume, uint64 volumeSize); 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 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); BOOL FlushFormatWriteBuffer (void *dev, char *write_buf, int *write_buf_cnt, __int64 *nSecNo, PCRYPTO_INFO cryptoInfo);
static BOOL StartFormatWriteThread (); static BOOL StartFormatWriteThread ();

View File

@@ -218,7 +218,7 @@ close:
} }
BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile) BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile)
{ {
BOOL status = TRUE; BOOL status = TRUE;
KeyFile kfSubStruct; KeyFile kfSubStruct;
@@ -252,8 +252,8 @@ BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile)
if (keyfileData.empty()) if (keyfileData.empty())
{ {
SetLastError (ERROR_HANDLE_EOF); SetLastError (ERROR_HANDLE_EOF);
handleWin32Error (MainDlg); handleWin32Error (hwndDlg);
Error ("ERR_PROCESS_KEYFILE"); Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE; status = FALSE;
continue; continue;
} }
@@ -291,8 +291,8 @@ BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile)
// Determine whether it's a path or a file // Determine whether it's a path or a file
if (stat (kf->FileName, &statStruct) != 0) if (stat (kf->FileName, &statStruct) != 0)
{ {
handleWin32Error (MainDlg); handleWin32Error (hwndDlg);
Error ("ERR_PROCESS_KEYFILE"); Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE; status = FALSE;
continue; continue;
} }
@@ -305,8 +305,8 @@ BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile)
StringCbPrintfA (searchPath, sizeof (searchPath), "%s\\*.*", kf->FileName); StringCbPrintfA (searchPath, sizeof (searchPath), "%s\\*.*", kf->FileName);
if ((searchHandle = _findfirst (searchPath, &fBuf)) == -1) if ((searchHandle = _findfirst (searchPath, &fBuf)) == -1)
{ {
handleWin32Error (MainDlg); handleWin32Error (hwndDlg);
Error ("ERR_PROCESS_KEYFILE_PATH"); Error ("ERR_PROCESS_KEYFILE_PATH", hwndDlg);
status = FALSE; status = FALSE;
continue; continue;
} }
@@ -323,8 +323,8 @@ BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile)
// Determine whether it's a path or a file // Determine whether it's a path or a file
if (stat (kfSub->FileName, &statStruct) != 0) if (stat (kfSub->FileName, &statStruct) != 0)
{ {
handleWin32Error (MainDlg); handleWin32Error (hwndDlg);
Error ("ERR_PROCESS_KEYFILE"); Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE; status = FALSE;
continue; continue;
} }
@@ -347,8 +347,8 @@ BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile)
// Apply keyfile to the pool // Apply keyfile to the pool
if (!KeyFileProcess (keyPool, kfSub)) if (!KeyFileProcess (keyPool, kfSub))
{ {
handleWin32Error (MainDlg); handleWin32Error (hwndDlg);
Error ("ERR_PROCESS_KEYFILE"); Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE; status = FALSE;
} }
@@ -359,15 +359,15 @@ BOOL KeyFilesApply (Password *password, KeyFile *firstKeyFile)
if (keyfileCount == 0) 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; status = FALSE;
} }
} }
// Apply keyfile to the pool // Apply keyfile to the pool
else if (!KeyFileProcess (keyPool, kf)) else if (!KeyFileProcess (keyPool, kf))
{ {
handleWin32Error (MainDlg); handleWin32Error (hwndDlg);
Error ("ERR_PROCESS_KEYFILE"); Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE; status = FALSE;
} }
} }

View File

@@ -34,7 +34,7 @@ KeyFile *KeyFileAdd (KeyFile *firstKeyFile, KeyFile *keyFile);
void KeyFileRemoveAll (KeyFile **firstKeyFile); void KeyFileRemoveAll (KeyFile **firstKeyFile);
KeyFile *KeyFileClone (KeyFile *keyFile); KeyFile *KeyFileClone (KeyFile *keyFile);
KeyFile *KeyFileCloneAll (KeyFile *firstKeyFile); 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 CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL KeyfilesPopupMenu (HWND hwndDlg, POINT popupPosition, KeyFilesDlgParam *dialogParam); BOOL KeyfilesPopupMenu (HWND hwndDlg, POINT popupPosition, KeyFilesDlgParam *dialogParam);

View File

@@ -341,7 +341,7 @@ int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, Pas
for (wipePass = 0; wipePass < wipePassCount; wipePass++) for (wipePass = 0; wipePass < wipePassCount; wipePass++)
{ {
// Prepare new volume header // Prepare new volume header
nStatus = CreateVolumeHeaderInMemory (FALSE, nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
buffer, buffer,
cryptoInfo->ea, cryptoInfo->ea,
cryptoInfo->mode, 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
&& (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) if (nStatus != ERR_SUCCESS)
goto error; goto error;
} }

View File

@@ -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) if (!bRandDidInit)
return FALSE; return FALSE;
if (len > RNG_POOL_SIZE) if (len > RNG_POOL_SIZE)
{ {
Error ("ERR_NOT_ENOUGH_RANDOM_DATA"); Error ("ERR_NOT_ENOUGH_RANDOM_DATA", (HWND) hwndDlg);
len = RNG_POOL_SIZE; 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) */ /* 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. /* 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 FALSE, then len must be less or equal to RNG_POOL_SIZE
* If allowAnyLength is TRUE, then len can have any positive value * 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; int i, looplen;
BOOL ret = TRUE; 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 */ /* There's never more than RNG_POOL_SIZE worth of randomess */
if ( (!allowAnyLength) && (len > RNG_POOL_SIZE)) if ( (!allowAnyLength) && (len > RNG_POOL_SIZE))
{ {
Error ("ERR_NOT_ENOUGH_RANDOM_DATA"); Error ("ERR_NOT_ENOUGH_RANDOM_DATA", (HWND) hwndDlg);
len = RNG_POOL_SIZE; len = RNG_POOL_SIZE;
LeaveCriticalSection (&critRandProt); LeaveCriticalSection (&critRandProt);
return FALSE; return FALSE;

View File

@@ -43,16 +43,16 @@ BOOL Randmix ( void );
void RandaddBuf ( void *buf , int len ); void RandaddBuf ( void *buf , int len );
BOOL FastPoll ( void ); BOOL FastPoll ( void );
BOOL SlowPoll ( 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) */ /* 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. /* 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 FALSE, then len must be less or equal to RNG_POOL_SIZE
* If allowAnyLength is TRUE, then len can have any positive value * 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 #ifdef _WIN32

View File

@@ -701,7 +701,7 @@ namespace VeraCrypt
} }
wchar_t err[8192]; wchar_t err[8192];
wsprintfW (err, L"%s:\n\n%hs%s", GetString ("SECURITY_TOKEN_ERROR"), errorString.c_str(), subjectErrorCode.str().c_str()); 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 else
{ {
@@ -710,7 +710,7 @@ namespace VeraCrypt
if (SubjectErrorCodeValid) if (SubjectErrorCodeValid)
err += L"\n\nError code" + subjectErrorCode.str(); err += L"\n\nError code" + subjectErrorCode.str();
ErrorDirect (err.c_str()); ErrorDirect (err.c_str(), parent);
} }
} }
} }

View File

@@ -133,22 +133,22 @@ namespace VeraCrypt
struct SecurityTokenLibraryNotInitialized : public Exception 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 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 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 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 #endif // !TC_HEADER_Platform_Exception

View File

@@ -718,7 +718,7 @@ ret:
#endif #endif
// Creates a volume header in memory // 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, int pkcs5_prf, char *masterKeydata, PCRYPTO_INFO *retInfo,
unsigned __int64 volumeSize, unsigned __int64 hiddenVolumeSize, unsigned __int64 volumeSize, unsigned __int64 hiddenVolumeSize,
unsigned __int64 encryptedAreaStart, unsigned __int64 encryptedAreaLength, uint16 requiredProgramVersion, uint32 headerFlags, uint32 sectorSize, BOOL bWipeMode) 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) 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; return ERR_CIPHER_INIT_WEAK_KEY;
} }
else else
@@ -780,7 +780,7 @@ int CreateVolumeHeaderInMemory (BOOL bBoot, char *header, int ea, int mode, Pass
cryptoInfo->mode = mode; cryptoInfo->mode = mode;
// Salt for header key derivation // 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; 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 // 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. // 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 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. // 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 temporaryKey[MASTER_KEYDATA_SIZE];
char originalK2[MASTER_KEYDATA_SIZE]; char originalK2[MASTER_KEYDATA_SIZE];
@@ -1096,8 +1096,8 @@ int WriteRandomDataToReservedHeaderAreas (HANDLE dev, CRYPTO_INFO *cryptoInfo, u
while (TRUE) while (TRUE)
{ {
// Temporary keys // Temporary keys
if (!RandgetBytes (temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE) if (!RandgetBytes (hwndDlg, temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE)
|| !RandgetBytes (cryptoInfo->k2, sizeof (cryptoInfo->k2), FALSE)) || !RandgetBytes (hwndDlg, cryptoInfo->k2, sizeof (cryptoInfo->k2), FALSE))
{ {
nStatus = ERR_PARAMETER_INCORRECT; nStatus = ERR_PARAMETER_INCORRECT;
goto final_seq; goto final_seq;

View File

@@ -133,10 +133,10 @@ int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int
#endif #endif
#if !defined (DEVICE_DRIVER) && !defined (TC_WINDOWS_BOOT) #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 ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DWORD *bytesRead);
BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header); 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
#endif // !TC_HEADER_Volume_VolumeHeader #endif // !TC_HEADER_Volume_VolumeHeader

View File

@@ -87,7 +87,7 @@ static __int64 NewFileSysSizeAfterShrink (HANDLE dev, const char *devicePath, in
} }
BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent) BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const char *devicePath, BOOL silent)
{ {
NTFS_VOLUME_DATA_BUFFER ntfsVolData; NTFS_VOLUME_DATA_BUFFER ntfsVolData;
DWORD nBytesReturned; DWORD nBytesReturned;
@@ -110,7 +110,7 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent)
if (CurrentOSMajor < 6) if (CurrentOSMajor < 6)
{ {
if (!silent) if (!silent)
ShowInPlaceEncErrMsgWAltSteps ("OS_NOT_SUPPORTED_FOR_NONSYS_INPLACE_ENC", FALSE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "OS_NOT_SUPPORTED_FOR_NONSYS_INPLACE_ENC", FALSE);
return FALSE; return FALSE;
} }
@@ -122,7 +122,7 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent)
&& sscanf (devicePath, "\\Device\\Harddisk%d\\Partition%d", &driveNumber, &partitionNumber) != 2) && sscanf (devicePath, "\\Device\\Harddisk%d\\Partition%d", &driveNumber, &partitionNumber) != 2)
{ {
if (!silent) if (!silent)
Error ("INPLACE_ENC_INVALID_PATH"); Error ("INPLACE_ENC_INVALID_PATH", hwndDlg);
return FALSE; return FALSE;
} }
@@ -130,7 +130,7 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent)
if (partitionNumber == 0) if (partitionNumber == 0)
{ {
if (!silent) if (!silent)
Warning ("RAW_DEV_NOT_SUPPORTED_FOR_INPLACE_ENC"); Warning ("RAW_DEV_NOT_SUPPORTED_FOR_INPLACE_ENC", hwndDlg);
return FALSE; return FALSE;
} }
@@ -144,7 +144,7 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent)
// status can be ignored). In case the IsAdmin() detection somehow fails, we allow the user to continue. // status can be ignored). In case the IsAdmin() detection somehow fails, we allow the user to continue.
if (!silent) if (!silent)
Warning ("ADMIN_PRIVILEGES_WARN_DEVICES"); Warning ("ADMIN_PRIVILEGES_WARN_DEVICES", hwndDlg);
} }
@@ -165,13 +165,13 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent)
{ {
if (!silent) if (!silent)
{ {
handleWin32Error (MainDlg); handleWin32Error (hwndDlg);
Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL"); Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", hwndDlg);
} }
return FALSE; return FALSE;
} }
dev = OpenPartitionVolume (devName, dev = OpenPartitionVolume (hwndDlg, devName,
FALSE, // Do not require exclusive access FALSE, // Do not require exclusive access
TRUE, // Require shared access (must be TRUE; otherwise, volume properties will not be possible to obtain) TRUE, // Require shared access (must be TRUE; otherwise, volume properties will not be possible to obtain)
FALSE, // Do not ask the user to confirm shared access (if exclusive fails) FALSE, // Do not ask the user to confirm shared access (if exclusive fails)
@@ -205,9 +205,9 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent)
// is dismounted). // is dismounted).
if (IsDeviceMounted (devName)) if (IsDeviceMounted (devName))
ShowInPlaceEncErrMsgWAltSteps ("ONLY_NTFS_SUPPORTED_FOR_NONSYS_INPLACE_ENC", FALSE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "ONLY_NTFS_SUPPORTED_FOR_NONSYS_INPLACE_ENC", FALSE);
else else
Warning ("ONLY_MOUNTED_VOL_SUPPORTED_FOR_NONSYS_INPLACE_ENC"); Warning ("ONLY_MOUNTED_VOL_SUPPORTED_FOR_NONSYS_INPLACE_ENC", hwndDlg);
} }
CloseHandle (dev); CloseHandle (dev);
@@ -222,7 +222,7 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent)
{ {
// Cannot determine whether shrinking is required // Cannot determine whether shrinking is required
if (!silent) if (!silent)
ShowInPlaceEncErrMsgWAltSteps ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
CloseHandle (dev); CloseHandle (dev);
return FALSE; return FALSE;
@@ -236,7 +236,7 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent)
{ {
// Cannot determine the size of the partition // Cannot determine the size of the partition
if (!silent) if (!silent)
Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL"); Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", hwndDlg);
CloseHandle (dev); CloseHandle (dev);
return FALSE; return FALSE;
@@ -247,7 +247,7 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent)
// The partition is too small // The partition is too small
if (!silent) if (!silent)
{ {
ShowInPlaceEncErrMsgWAltSteps ("PARTITION_TOO_SMALL_FOR_NONSYS_INPLACE_ENC", FALSE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "PARTITION_TOO_SMALL_FOR_NONSYS_INPLACE_ENC", FALSE);
} }
CloseHandle (dev); CloseHandle (dev);
@@ -267,7 +267,7 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent)
NULL)) NULL))
{ {
if (!silent) if (!silent)
ShowInPlaceEncErrMsgWAltSteps ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", TRUE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", TRUE);
CloseHandle (dev); CloseHandle (dev);
return FALSE; return FALSE;
@@ -276,7 +276,7 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent)
if (ntfsVolData.FreeClusters.QuadPart * ntfsVolData.BytesPerCluster < TC_TOTAL_VOLUME_HEADERS_SIZE) if (ntfsVolData.FreeClusters.QuadPart * ntfsVolData.BytesPerCluster < TC_TOTAL_VOLUME_HEADERS_SIZE)
{ {
if (!silent) if (!silent)
ShowInPlaceEncErrMsgWAltSteps ("NOT_ENOUGH_FREE_FILESYS_SPACE_FOR_SHRINK", TRUE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "NOT_ENOUGH_FREE_FILESYS_SPACE_FOR_SHRINK", TRUE);
CloseHandle (dev); CloseHandle (dev);
return FALSE; return FALSE;
@@ -289,7 +289,7 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent)
|| ntfsVolData.BytesPerSector % ENCRYPTION_DATA_UNIT_SIZE != 0) || ntfsVolData.BytesPerSector % ENCRYPTION_DATA_UNIT_SIZE != 0)
{ {
if (!silent) if (!silent)
ShowInPlaceEncErrMsgWAltSteps ("SECTOR_SIZE_UNSUPPORTED", TRUE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "SECTOR_SIZE_UNSUPPORTED", TRUE);
CloseHandle (dev); CloseHandle (dev);
return FALSE; return FALSE;
@@ -319,11 +319,12 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
__int64 deviceSize; __int64 deviceSize;
LARGE_INTEGER offset; LARGE_INTEGER offset;
DWORD dwResult; DWORD dwResult;
HWND hwndDlg = volParams->hwndDlg;
SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PREPARING); SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PREPARING);
if (!CheckRequirementsForNonSysInPlaceEnc (volParams->volumePath, FALSE)) if (!CheckRequirementsForNonSysInPlaceEnc (hwndDlg, volParams->volumePath, FALSE))
return ERR_DONT_REPORT; return ERR_DONT_REPORT;
@@ -343,7 +344,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
if (deviceSize < TC_NONSYS_INPLACE_ENC_MIN_VOL_SIZE) if (deviceSize < TC_NONSYS_INPLACE_ENC_MIN_VOL_SIZE)
{ {
ShowInPlaceEncErrMsgWAltSteps ("PARTITION_TOO_SMALL_FOR_NONSYS_INPLACE_ENC", TRUE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "PARTITION_TOO_SMALL_FOR_NONSYS_INPLACE_ENC", TRUE);
nStatus = ERR_DONT_REPORT; nStatus = ERR_DONT_REPORT;
goto closing_seq; goto closing_seq;
} }
@@ -364,7 +365,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
if (IsDeviceMounted (devName)) if (IsDeviceMounted (devName))
{ {
dev = OpenPartitionVolume (devName, dev = OpenPartitionVolume (hwndDlg, devName,
FALSE, // Do not require exclusive access (must be FALSE; otherwise, it will not be possible to dismount the volume or obtain its properties and FSCTL_ALLOW_EXTENDED_DASD_IO will fail too) FALSE, // Do not require exclusive access (must be FALSE; otherwise, it will not be possible to dismount the volume or obtain its properties and FSCTL_ALLOW_EXTENDED_DASD_IO will fail too)
TRUE, // Require shared access (must be TRUE; otherwise, it will not be possible to dismount the volume or obtain its properties and FSCTL_ALLOW_EXTENDED_DASD_IO will fail too) TRUE, // Require shared access (must be TRUE; otherwise, it will not be possible to dismount the volume or obtain its properties and FSCTL_ALLOW_EXTENDED_DASD_IO will fail too)
FALSE, // Do not ask the user to confirm shared access (if exclusive fails) FALSE, // Do not ask the user to confirm shared access (if exclusive fails)
@@ -380,7 +381,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
else else
{ {
// The volume is not mounted so we can't work with the filesystem. // The volume is not mounted so we can't work with the filesystem.
Error ("ONLY_MOUNTED_VOL_SUPPORTED_FOR_NONSYS_INPLACE_ENC"); Error ("ONLY_MOUNTED_VOL_SUPPORTED_FOR_NONSYS_INPLACE_ENC", hwndDlg);
nStatus = ERR_DONT_REPORT; nStatus = ERR_DONT_REPORT;
goto closing_seq; goto closing_seq;
} }
@@ -398,7 +399,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
NULL)) NULL))
{ {
handleWin32Error (MainDlg); handleWin32Error (MainDlg);
ShowInPlaceEncErrMsgWAltSteps ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
nStatus = ERR_DONT_REPORT; nStatus = ERR_DONT_REPORT;
goto closing_seq; goto closing_seq;
} }
@@ -414,7 +415,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
if (sizeToShrinkTo == -1) if (sizeToShrinkTo == -1)
{ {
ShowInPlaceEncErrMsgWAltSteps ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
nStatus = ERR_DONT_REPORT; nStatus = ERR_DONT_REPORT;
goto closing_seq; goto closing_seq;
} }
@@ -435,8 +436,8 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
&dwResult, &dwResult,
NULL)) NULL))
{ {
handleWin32Error (MainDlg); handleWin32Error (hwndDlg);
ShowInPlaceEncErrMsgWAltSteps ("CANNOT_RESIZE_FILESYS", TRUE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "CANNOT_RESIZE_FILESYS", TRUE);
nStatus = ERR_DONT_REPORT; nStatus = ERR_DONT_REPORT;
goto closing_seq; goto closing_seq;
} }
@@ -462,13 +463,13 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
continue; continue;
} }
handleWin32Error (MainDlg); handleWin32Error (hwndDlg);
} }
} }
else else
handleWin32Error (MainDlg); handleWin32Error (hwndDlg);
ShowInPlaceEncErrMsgWAltSteps ("CANNOT_RESIZE_FILESYS", TRUE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "CANNOT_RESIZE_FILESYS", TRUE);
nStatus = ERR_DONT_REPORT; nStatus = ERR_DONT_REPORT;
goto closing_seq; goto closing_seq;
} }
@@ -481,7 +482,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
/* Gain exclusive access to the volume */ /* Gain exclusive access to the volume */
nStatus = DismountFileSystem (dev, nStatus = DismountFileSystem (hwndDlg, dev,
driveLetter, driveLetter,
TRUE, TRUE,
TRUE, TRUE,
@@ -503,7 +504,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
// Prepare the backup header // Prepare the backup header
for (int wipePass = 0; wipePass < (wipeAlgorithm == TC_WIPE_NONE ? 1 : PRAND_HEADER_WIPE_PASSES); wipePass++) for (int wipePass = 0; wipePass < (wipeAlgorithm == TC_WIPE_NONE ? 1 : PRAND_HEADER_WIPE_PASSES); wipePass++)
{ {
nStatus = CreateVolumeHeaderInMemory (FALSE, nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
header, header,
volParams->ea, volParams->ea,
FIRST_MODE_OF_OPERATION_ID, FIRST_MODE_OF_OPERATION_ID,
@@ -539,7 +540,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
} }
// Fill the reserved sectors of the backup header area with random data // Fill the reserved sectors of the backup header area with random data
nStatus = WriteRandomDataToReservedHeaderAreas (dev, cryptoInfo, dataAreaSize, FALSE, TRUE); nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, cryptoInfo, dataAreaSize, FALSE, TRUE);
if (nStatus != ERR_SUCCESS) if (nStatus != ERR_SUCCESS)
goto closing_seq; goto closing_seq;
@@ -665,6 +666,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
Password *password = volParams->password; Password *password = volParams->password;
int pkcs5_prf = volParams->pkcs5; int pkcs5_prf = volParams->pkcs5;
DISK_GEOMETRY driveGeometry; DISK_GEOMETRY driveGeometry;
HWND hwndDlg = volParams->hwndDlg;
bInPlaceEncNonSysResumed = TRUE; bInPlaceEncNonSysResumed = TRUE;
@@ -722,7 +724,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
goto closing_seq; goto closing_seq;
} }
dev = OpenPartitionVolume (devName, dev = OpenPartitionVolume (hwndDlg, devName,
FALSE, // Do not require exclusive access FALSE, // Do not require exclusive access
FALSE, // Do not require shared access FALSE, // Do not require shared access
TRUE, // Ask the user to confirm shared access (if exclusive fails) TRUE, // Ask the user to confirm shared access (if exclusive fails)
@@ -814,7 +816,7 @@ inplace_enc_read:
if (!*bTryToCorrectReadErrors) if (!*bTryToCorrectReadErrors)
{ {
*bTryToCorrectReadErrors = (AskWarnYesNo ("ENABLE_BAD_SECTOR_ZEROING") == IDYES); *bTryToCorrectReadErrors = (AskWarnYesNo ("ENABLE_BAD_SECTOR_ZEROING", hwndDlg) == IDYES);
} }
if (*bTryToCorrectReadErrors) if (*bTryToCorrectReadErrors)
@@ -980,7 +982,7 @@ inplace_enc_read:
for (int wipePass = 0; wipePass < (wipeAlgorithm == TC_WIPE_NONE ? 1 : PRAND_HEADER_WIPE_PASSES); wipePass++) for (int wipePass = 0; wipePass < (wipeAlgorithm == TC_WIPE_NONE ? 1 : PRAND_HEADER_WIPE_PASSES); wipePass++)
{ {
nStatus = CreateVolumeHeaderInMemory (FALSE, nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
header, header,
headerCryptoInfo->ea, headerCryptoInfo->ea,
headerCryptoInfo->mode, headerCryptoInfo->mode,
@@ -1011,7 +1013,7 @@ inplace_enc_read:
} }
// Fill the reserved sectors of the header area with random data // Fill the reserved sectors of the header area with random data
nStatus = WriteRandomDataToReservedHeaderAreas (dev, headerCryptoInfo, masterCryptoInfo->VolumeSize.Value, TRUE, FALSE); nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, headerCryptoInfo, masterCryptoInfo->VolumeSize.Value, TRUE, FALSE);
if (nStatus != ERR_SUCCESS) if (nStatus != ERR_SUCCESS)
goto closing_seq; goto closing_seq;
@@ -1103,7 +1105,7 @@ closing_seq:
zeroedSectorCount, zeroedSectorCount,
sizeStr); sizeStr);
WarningDirect (msg); WarningDirect (msg, hwndDlg);
} }
if (nStatus != ERR_SUCCESS && nStatus != ERR_USER_ABORT) if (nStatus != ERR_SUCCESS && nStatus != ERR_USER_ABORT)
@@ -1185,7 +1187,7 @@ closing_seq:
} }
static HANDLE OpenPartitionVolume (const char *devName, static HANDLE OpenPartitionVolume (HWND hwndDlg, const char *devName,
BOOL bExclusiveRequired, BOOL bExclusiveRequired,
BOOL bSharedRequired, BOOL bSharedRequired,
BOOL bSharedRequiresConfirmation, BOOL bSharedRequiresConfirmation,
@@ -1217,12 +1219,12 @@ static HANDLE OpenPartitionVolume (const char *devName,
{ {
if (!bSilent) if (!bSilent)
{ {
handleWin32Error (MainDlg); handleWin32Error (hwndDlg);
if (bShowAlternativeSteps) if (bShowAlternativeSteps)
ShowInPlaceEncErrMsgWAltSteps ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
else else
Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL"); Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", hwndDlg);
} }
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} }
@@ -1233,7 +1235,7 @@ static HANDLE OpenPartitionVolume (const char *devName,
{ {
if (bSharedRequiresConfirmation if (bSharedRequiresConfirmation
&& !bSilent && !bSilent
&& AskWarnNoYes ("DEVICE_IN_USE_INPLACE_ENC") == IDNO) && AskWarnNoYes ("DEVICE_IN_USE_INPLACE_ENC", hwndDlg) == IDNO)
{ {
CloseHandle (dev); CloseHandle (dev);
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
@@ -1246,9 +1248,9 @@ static HANDLE OpenPartitionVolume (const char *devName,
handleWin32Error (MainDlg); handleWin32Error (MainDlg);
if (bShowAlternativeSteps) if (bShowAlternativeSteps)
ShowInPlaceEncErrMsgWAltSteps ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
else else
Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL"); Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", hwndDlg);
} }
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} }
@@ -1258,7 +1260,7 @@ static HANDLE OpenPartitionVolume (const char *devName,
} }
static int DismountFileSystem (HANDLE dev, static int DismountFileSystem (HWND hwndDlg, HANDLE dev,
int driveLetter, int driveLetter,
BOOL bForcedAllowed, BOOL bForcedAllowed,
BOOL bForcedRequiresConfirmation, BOOL bForcedRequiresConfirmation,
@@ -1284,14 +1286,14 @@ static int DismountFileSystem (HANDLE dev,
if (!bForcedAllowed) if (!bForcedAllowed)
{ {
if (!bSilent) if (!bSilent)
ShowInPlaceEncErrMsgWAltSteps ("INPLACE_ENC_CANT_LOCK_OR_DISMOUNT_FILESYS", TRUE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_LOCK_OR_DISMOUNT_FILESYS", TRUE);
return ERR_DONT_REPORT; return ERR_DONT_REPORT;
} }
if (bForcedRequiresConfirmation if (bForcedRequiresConfirmation
&& !bSilent && !bSilent
&& AskWarnYesNo ("VOL_LOCK_FAILED_OFFER_FORCED_DISMOUNT") == IDNO) && AskWarnYesNo ("VOL_LOCK_FAILED_OFFER_FORCED_DISMOUNT", hwndDlg) == IDNO)
{ {
return ERR_DONT_REPORT; return ERR_DONT_REPORT;
} }
@@ -1311,7 +1313,7 @@ static int DismountFileSystem (HANDLE dev,
if (!bResult) if (!bResult)
{ {
if (!bSilent) if (!bSilent)
ShowInPlaceEncErrMsgWAltSteps ("INPLACE_ENC_CANT_LOCK_OR_DISMOUNT_FILESYS", TRUE); ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_LOCK_OR_DISMOUNT_FILESYS", TRUE);
return ERR_DONT_REPORT; return ERR_DONT_REPORT;
} }
@@ -1376,7 +1378,7 @@ static int ConcealNTFS (HANDLE dev)
} }
void ShowInPlaceEncErrMsgWAltSteps (char *iniStrId, BOOL bErr) void ShowInPlaceEncErrMsgWAltSteps (HWND hwndDlg, char *iniStrId, BOOL bErr)
{ {
wchar_t msg[30000]; wchar_t msg[30000];
@@ -1386,9 +1388,9 @@ void ShowInPlaceEncErrMsgWAltSteps (char *iniStrId, BOOL bErr)
StringCbCatW (msg, sizeof(msg), GetString ("INPLACE_ENC_ALTERNATIVE_STEPS")); StringCbCatW (msg, sizeof(msg), GetString ("INPLACE_ENC_ALTERNATIVE_STEPS"));
if (bErr) if (bErr)
ErrorDirect (msg); ErrorDirect (msg, hwndDlg);
else else
WarningDirect (msg); WarningDirect (msg, hwndDlg);
} }

View File

@@ -24,15 +24,15 @@ enum nonsys_inplace_enc_status
NONSYS_INPLACE_ENC_STATUS_ERROR NONSYS_INPLACE_ENC_STATUS_ERROR
}; };
BOOL CheckRequirementsForNonSysInPlaceEnc (const char *devicePath, BOOL silent); BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const char *devicePath, BOOL silent);
int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, volatile HANDLE *outHandle, WipeAlgorithmId wipeAlgorithm); int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, volatile HANDLE *outHandle, WipeAlgorithmId wipeAlgorithm);
int EncryptPartitionInPlaceResume (HANDLE dev, volatile FORMAT_VOL_PARAMETERS *volParams, WipeAlgorithmId wipeAlgorithm, volatile BOOL *bTryToCorrectReadErrors); int EncryptPartitionInPlaceResume (HANDLE dev, volatile FORMAT_VOL_PARAMETERS *volParams, WipeAlgorithmId wipeAlgorithm, volatile BOOL *bTryToCorrectReadErrors);
void ShowInPlaceEncErrMsgWAltSteps (char *iniStrId, BOOL bErr); void ShowInPlaceEncErrMsgWAltSteps (HWND hwndDlg, char *iniStrId, BOOL bErr);
void SetNonSysInplaceEncUIStatus (int nonSysInplaceEncStatus); void SetNonSysInplaceEncUIStatus (int nonSysInplaceEncStatus);
int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_INFO *masterCryptoInfo, __int64 deviceSize); int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_INFO *masterCryptoInfo, __int64 deviceSize);
static HANDLE OpenPartitionVolume (const char *devName, BOOL bExclusiveRequired, BOOL bSharedRequired, BOOL bSharedRequiresConfirmation, BOOL bShowAlternativeSteps, BOOL bSilent); static HANDLE OpenPartitionVolume (HWND hwndDlg, const char *devName, BOOL bExclusiveRequired, BOOL bSharedRequired, BOOL bSharedRequiresConfirmation, BOOL bShowAlternativeSteps, BOOL bSilent);
static int DismountFileSystem (HANDLE dev, int driveLetter, BOOL bForcedAllowed, BOOL bForcedRequiresConfirmation, BOOL bSilent); static int DismountFileSystem (HWND hwndDlg, HANDLE dev, int driveLetter, BOOL bForcedAllowed, BOOL bForcedRequiresConfirmation, BOOL bSilent);
static int ConcealNTFS (HANDLE dev); static int ConcealNTFS (HANDLE dev);
BOOL SaveNonSysInPlaceEncSettings (int delta, WipeAlgorithmId wipeAlgorithm); BOOL SaveNonSysInPlaceEncSettings (int delta, WipeAlgorithmId wipeAlgorithm);
static void ExportProgressStats (__int64 bytesDone, __int64 totalSize); static void ExportProgressStats (__int64 bytesDone, __int64 totalSize);

File diff suppressed because it is too large Load Diff

View File

@@ -47,7 +47,7 @@ void AddCipher ( HWND hComboBox , char *lpszCipher , int nCipher );
BOOL CALLBACK PageDialogProc ( HWND hwndDlg , UINT uMsg , WPARAM wParam , LPARAM lParam ); BOOL CALLBACK PageDialogProc ( HWND hwndDlg , UINT uMsg , WPARAM wParam , LPARAM lParam );
BOOL CALLBACK MainDialogProc ( HWND hwndDlg , UINT uMsg , WPARAM wParam , LPARAM lParam ); BOOL CALLBACK MainDialogProc ( HWND hwndDlg , UINT uMsg , WPARAM wParam , LPARAM lParam );
void ExtractCommandLine ( HWND hwndDlg , char *lpszCommandLine ); void ExtractCommandLine ( HWND hwndDlg , char *lpszCommandLine );
void DisplayRandPool (HWND hPoolDisplay, BOOL bShow); void DisplayRandPool (HWND hwndDlg, HWND hPoolDisplay, BOOL bShow);
void DisplayPortionsOfKeys (HWND headerKeyHandle, HWND masterKeyHandle, char *headerKeyStr, char *masterKeyStr, BOOL hideKeys); void DisplayPortionsOfKeys (HWND headerKeyHandle, HWND masterKeyHandle, char *headerKeyStr, char *masterKeyStr, BOOL hideKeys);
int DetermineMaxHiddenVolSize (HWND hwndDlg); int DetermineMaxHiddenVolSize (HWND hwndDlg);
BOOL IsSparseFile (HWND hwndDlg); BOOL IsSparseFile (HWND hwndDlg);

View File

@@ -91,7 +91,7 @@ namespace VeraCrypt
&& IsVolumeDeviceHosted (favorite.Path.c_str()) && IsVolumeDeviceHosted (favorite.Path.c_str())
&& favorite.Path.find ("\\\\?\\Volume{") != 0) && favorite.Path.find ("\\\\?\\Volume{") != 0)
{ {
Warning (favorite.Path.find ("\\Partition0") == string::npos ? "FAVORITE_ADD_PARTITION_TYPE_WARNING" : "FAVORITE_ADD_DRIVE_DEV_WARNING"); Warning (favorite.Path.find ("\\Partition0") == string::npos ? "FAVORITE_ADD_PARTITION_TYPE_WARNING" : "FAVORITE_ADD_DRIVE_DEV_WARNING", hwndDlg);
} }
return OrganizeFavoriteVolumes (hwndDlg, systemFavorites, favorite); return OrganizeFavoriteVolumes (hwndDlg, systemFavorites, favorite);
@@ -255,7 +255,7 @@ namespace VeraCrypt
if (SelectedItem != -1 && !Favorites.empty()) if (SelectedItem != -1 && !Favorites.empty())
SetFavoriteVolume (hwndDlg, Favorites[SelectedItem], SystemFavoritesMode); SetFavoriteVolume (hwndDlg, Favorites[SelectedItem], SystemFavoritesMode);
if (SaveFavoriteVolumes (Favorites, SystemFavoritesMode)) if (SaveFavoriteVolumes (hwndDlg, Favorites, SystemFavoritesMode))
{ {
if (!SystemFavoritesMode) if (!SystemFavoritesMode)
{ {
@@ -276,7 +276,7 @@ namespace VeraCrypt
{ {
if (favorite.MountOnArrival) if (favorite.MountOnArrival)
{ {
Warning ("FAVORITE_ARRIVAL_MOUNT_BACKGROUND_TASK_ERR"); Warning ("FAVORITE_ARRIVAL_MOUNT_BACKGROUND_TASK_ERR", hwndDlg);
break; break;
} }
} }
@@ -291,7 +291,7 @@ namespace VeraCrypt
SystemFavoriteVolumes = Favorites; SystemFavoriteVolumes = Favorites;
OnFavoriteVolumesUpdated(); OnFavoriteVolumesUpdated();
LoadDriveLetters (GetDlgItem (MainDlg, IDC_DRIVELIST), 0); LoadDriveLetters (hwndDlg, GetDlgItem (MainDlg, IDC_DRIVELIST), 0);
EndDialog (hwndDlg, IDOK); EndDialog (hwndDlg, IDOK);
} }
@@ -344,10 +344,10 @@ namespace VeraCrypt
if (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_OPEN_EXPLORER_WIN_ON_MOUNT)) if (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_OPEN_EXPLORER_WIN_ON_MOUNT))
{ {
WarningDirect ((wstring (GetString ("SYS_FAVORITES_KEYBOARD_WARNING")) + L"\n\n" + GetString ("BOOT_PASSWORD_CACHE_KEYBOARD_WARNING")).c_str()); WarningDirect ((wstring (GetString ("SYS_FAVORITES_KEYBOARD_WARNING")) + L"\n\n" + GetString ("BOOT_PASSWORD_CACHE_KEYBOARD_WARNING")).c_str(), hwndDlg);
if (!IsServerOS() && !IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_DISABLE_HOTKEY)) if (!IsServerOS() && !IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_DISABLE_HOTKEY))
Info ("SYS_FAVORITES_ADMIN_ONLY_INFO"); Info ("SYS_FAVORITES_ADMIN_ONLY_INFO", hwndDlg);
} }
} }
return 1; return 1;
@@ -358,9 +358,9 @@ namespace VeraCrypt
// DISABLE_NONADMIN_SYS_FAVORITES_ACCESS // DISABLE_NONADMIN_SYS_FAVORITES_ACCESS
if (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_DISABLE_HOTKEY)) if (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_DISABLE_HOTKEY))
WarningDirect ((wstring (GetString ("SYS_FAVORITES_ADMIN_ONLY_WARNING")) + L"\n\n" + GetString ("SETTING_REQUIRES_REBOOT")).c_str()); WarningDirect ((wstring (GetString ("SYS_FAVORITES_ADMIN_ONLY_WARNING")) + L"\n\n" + GetString ("SETTING_REQUIRES_REBOOT")).c_str(), hwndDlg);
else else
Warning ("SETTING_REQUIRES_REBOOT"); Warning ("SETTING_REQUIRES_REBOOT", hwndDlg);
} }
return 1; return 1;
@@ -647,7 +647,7 @@ namespace VeraCrypt
} }
static bool SaveFavoriteVolumes (const vector <FavoriteVolume> &favorites, bool systemFavorites) static bool SaveFavoriteVolumes (HWND hwndDlg, const vector <FavoriteVolume> &favorites, bool systemFavorites)
{ {
FILE *f; FILE *f;
int cnt = 0; int cnt = 0;
@@ -667,7 +667,7 @@ namespace VeraCrypt
char tq[2048]; char tq[2048];
if (systemFavorites && favorite.Path.find ("\\\\") == 0 && favorite.Path.find ("Volume{") == string::npos) if (systemFavorites && favorite.Path.find ("\\\\") == 0 && favorite.Path.find ("Volume{") == string::npos)
Warning ("SYSTEM_FAVORITE_NETWORK_PATH_ERR"); Warning ("SYSTEM_FAVORITE_NETWORK_PATH_ERR", hwndDlg);
XmlQuoteText (!favorite.VolumePathId.empty() ? favorite.VolumePathId.c_str() : favorite.Path.c_str(), tq, sizeof (tq)); XmlQuoteText (!favorite.VolumePathId.empty() ? favorite.VolumePathId.c_str() : favorite.Path.c_str(), tq, sizeof (tq));
@@ -706,7 +706,7 @@ namespace VeraCrypt
fputws (L"\n\t</favorites>", f); fputws (L"\n\t</favorites>", f);
XmlWriteFooterW (f); XmlWriteFooterW (f);
if (!CheckFileStreamWriteErrors (f, systemFavorites ? TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES : TC_APPD_FILENAME_FAVORITE_VOLUMES)) if (!CheckFileStreamWriteErrors (hwndDlg, f, systemFavorites ? TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES : TC_APPD_FILENAME_FAVORITE_VOLUMES))
{ {
fclose (f); fclose (f);
return false; return false;
@@ -734,7 +734,7 @@ namespace VeraCrypt
bootEnc.CopyFileAdmin (GetConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES), GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES).c_str()); bootEnc.CopyFileAdmin (GetConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES), GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES).c_str());
if (!(ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES)) if (!(ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES))
Info ("SYS_FAVORITE_VOLUMES_SAVED"); Info ("SYS_FAVORITE_VOLUMES_SAVED", hwndDlg);
} }
} }
catch (Exception &e) catch (Exception &e)
@@ -834,20 +834,20 @@ namespace VeraCrypt
if (!favorite.Label.empty()) if (!favorite.Label.empty())
{ {
ErrorDirect ((GetString (partition ? "FAVORITE_LABEL_PARTITION_TYPE_ERR" : "FAVORITE_LABEL_DEVICE_PATH_ERR") + wstring (L"\n\n") + SingleStringToWide (favorite.Path)).c_str()); ErrorDirect ((GetString (partition ? "FAVORITE_LABEL_PARTITION_TYPE_ERR" : "FAVORITE_LABEL_DEVICE_PATH_ERR") + wstring (L"\n\n") + SingleStringToWide (favorite.Path)).c_str(), hwndDlg);
favorite.Label.clear(); favorite.Label.clear();
} }
if (favorite.MountOnArrival) if (favorite.MountOnArrival)
{ {
ErrorDirect ((GetString (partition ? "FAVORITE_ARRIVAL_MOUNT_PARTITION_TYPE_ERR" : "FAVORITE_ARRIVAL_MOUNT_DEVICE_PATH_ERR") + wstring (L"\n\n") + SingleStringToWide (favorite.Path)).c_str()); ErrorDirect ((GetString (partition ? "FAVORITE_ARRIVAL_MOUNT_PARTITION_TYPE_ERR" : "FAVORITE_ARRIVAL_MOUNT_DEVICE_PATH_ERR") + wstring (L"\n\n") + SingleStringToWide (favorite.Path)).c_str(), hwndDlg);
favorite.MountOnArrival = false; favorite.MountOnArrival = false;
} }
} }
if (favorite.MountOnArrival && favorite.Path.find ("\\\\") == 0 && favorite.Path.find ("Volume{") == string::npos) if (favorite.MountOnArrival && favorite.Path.find ("\\\\") == 0 && favorite.Path.find ("Volume{") == string::npos)
{ {
Error ("FAVORITE_ARRIVAL_MOUNT_NETWORK_PATH_ERR"); Error ("FAVORITE_ARRIVAL_MOUNT_NETWORK_PATH_ERR", hwndDlg);
favorite.MountOnArrival = false; favorite.MountOnArrival = false;
} }
} }

View File

@@ -65,7 +65,7 @@ namespace VeraCrypt
void LoadFavoriteVolumes (vector <FavoriteVolume> &favorites, bool systemFavorites, bool noUacElevation = false); void LoadFavoriteVolumes (vector <FavoriteVolume> &favorites, bool systemFavorites, bool noUacElevation = false);
static void OnFavoriteVolumesUpdated (); static void OnFavoriteVolumesUpdated ();
BOOL OrganizeFavoriteVolumes (HWND hwndDlg, bool systemFavorites, const FavoriteVolume &newFavorite = FavoriteVolume()); BOOL OrganizeFavoriteVolumes (HWND hwndDlg, bool systemFavorites, const FavoriteVolume &newFavorite = FavoriteVolume());
static bool SaveFavoriteVolumes (const vector <FavoriteVolume> &favorites, bool systemFavorites); static bool SaveFavoriteVolumes (HWND hwndDlg, const vector <FavoriteVolume> &favorites, bool systemFavorites);
static void SetControls (HWND hwndDlg, const FavoriteVolume &favorite, bool systemFavoritesMode, bool enable = true); static void SetControls (HWND hwndDlg, const FavoriteVolume &favorite, bool systemFavoritesMode, bool enable = true);
static void SetFavoriteVolume (HWND hwndDlg, FavoriteVolume &favorite, bool systemFavoritesMode); static void SetFavoriteVolume (HWND hwndDlg, FavoriteVolume &favorite, bool systemFavoritesMode);
void UpdateDeviceHostedFavoriteVolumes (); void UpdateDeviceHostedFavoriteVolumes ();

View File

@@ -398,7 +398,7 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
// Check if it's not already assigned // Check if it's not already assigned
if (ShortcutInUse (currentVKeyCode, modifiers, tmpHotkeys)) if (ShortcutInUse (currentVKeyCode, modifiers, tmpHotkeys))
{ {
Error ("SHORTCUT_ALREADY_IN_USE"); Error ("SHORTCUT_ALREADY_IN_USE", hwndDlg);
return 1; return 1;
} }
@@ -410,7 +410,7 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
/* F1 is help and F12 is reserved for use by the debugger at all times */ /* F1 is help and F12 is reserved for use by the debugger at all times */
if (modifiers == 0) if (modifiers == 0)
{ {
Error ("CANNOT_USE_RESERVED_KEY"); Error ("CANNOT_USE_RESERVED_KEY", hwndDlg);
return 1; return 1;
} }
break; break;

File diff suppressed because it is too large Load Diff

View File

@@ -69,11 +69,11 @@ BOOL VolumeSelected (HWND hwndDlg );
void LoadSettings ( HWND hwndDlg ); void LoadSettings ( HWND hwndDlg );
void SaveSettings ( HWND hwndDlg ); void SaveSettings ( HWND hwndDlg );
BOOL SelectItem ( HWND hTree , char nLetter ); BOOL SelectItem ( HWND hTree , char nLetter );
void LoadDriveLetters ( HWND hTree, int drive ); void LoadDriveLetters ( HWND hwndDlg, HWND hTree, int drive );
BOOL CALLBACK PasswordChangeDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam ); BOOL CALLBACK PasswordChangeDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
BOOL CALLBACK PasswordDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam ); BOOL CALLBACK PasswordDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
void BuildTree ( HWND hTree ); void BuildTree ( HWND hwndDlg, HWND hTree );
LPARAM GetSelectedLong ( HWND hTree ); LPARAM GetSelectedLong ( HWND hTree );
LPARAM GetItemLong ( HWND hTree, int itemNo ); LPARAM GetItemLong ( HWND hTree, int itemNo );
BOOL CALLBACK CommandHelpDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam ); BOOL CALLBACK CommandHelpDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
@@ -85,20 +85,20 @@ BOOL TaskBarIconAdd (HWND hwnd);
BOOL TaskBarIconRemove (HWND hwnd); BOOL TaskBarIconRemove (HWND hwnd);
BOOL TaskBarIconChange (HWND hwnd, int iconId); BOOL TaskBarIconChange (HWND hwnd, int iconId);
void DismountIdleVolumes (); void DismountIdleVolumes ();
static void SaveDefaultKeyFilesParam (void); static void SaveDefaultKeyFilesParam (HWND hwnd);
static BOOL Dismount (HWND hwndDlg, int nDosDriveNo); static BOOL Dismount (HWND hwndDlg, int nDosDriveNo);
static BOOL DismountAll (HWND hwndDlg, BOOL forceUnmount, BOOL interact, int dismountMaxRetries, int dismountAutoRetryDelay); static BOOL DismountAll (HWND hwndDlg, BOOL forceUnmount, BOOL interact, int dismountMaxRetries, int dismountAutoRetryDelay);
static void KeyfileDefaultsDlg (HWND hwndDlg); static void KeyfileDefaultsDlg (HWND hwndDlg);
static void HandleHotKey (HWND hwndDlg, WPARAM wParam); static void HandleHotKey (HWND hwndDlg, WPARAM wParam);
static BOOL CheckMountList (BOOL bForceTaskBarUpdate); static BOOL CheckMountList (HWND hwndDlg, BOOL bForceTaskBarUpdate);
int GetCipherBlockSizeByDriveNo (int nDosDriveNo); int GetCipherBlockSizeByDriveNo (int nDosDriveNo);
int GetModeOfOperationByDriveNo (int nDosDriveNo); int GetModeOfOperationByDriveNo (int nDosDriveNo);
void ChangeMainWindowVisibility (); void ChangeMainWindowVisibility ();
void LaunchVolCreationWizard (HWND hwndDlg); void LaunchVolCreationWizard (HWND hwndDlg);
BOOL WholeSysDriveEncryption (BOOL bSilent); BOOL WholeSysDriveEncryption (BOOL bSilent);
BOOL CheckSysEncMountWithoutPBA (const char *devicePath, BOOL quiet); BOOL CheckSysEncMountWithoutPBA (HWND hwndDlg, const char *devicePath, BOOL quiet);
BOOL TCBootLoaderOnInactiveSysEncDrive (void); BOOL TCBootLoaderOnInactiveSysEncDrive (void);
void CreateRescueDisk (void); void CreateRescueDisk (HWND hwndDlg);
int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, const char *lpszVolume); int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, const char *lpszVolume);
int RestoreVolumeHeader (HWND hwndDlg, const char *lpszVolume); int RestoreVolumeHeader (HWND hwndDlg, const char *lpszVolume);
void SecurityTokenPreferencesDialog (HWND hwndDlg); void SecurityTokenPreferencesDialog (HWND hwndDlg);

View File

@@ -466,7 +466,7 @@ BOOL VerifyPackageIntegrity (void)
fileDataEndPos = (int) FindStringInFile (path, MagEndMarker, strlen (MagEndMarker)); fileDataEndPos = (int) FindStringInFile (path, MagEndMarker, strlen (MagEndMarker));
if (fileDataEndPos < 0) if (fileDataEndPos < 0)
{ {
Error ("DIST_PACKAGE_CORRUPTED"); Error ("DIST_PACKAGE_CORRUPTED", NULL);
return FALSE; return FALSE;
} }
fileDataEndPos--; fileDataEndPos--;
@@ -474,7 +474,7 @@ BOOL VerifyPackageIntegrity (void)
fileDataStartPos = (int) FindStringInFile (path, MAG_START_MARKER, strlen (MAG_START_MARKER)); fileDataStartPos = (int) FindStringInFile (path, MAG_START_MARKER, strlen (MAG_START_MARKER));
if (fileDataStartPos < 0) if (fileDataStartPos < 0)
{ {
Error ("DIST_PACKAGE_CORRUPTED"); Error ("DIST_PACKAGE_CORRUPTED", NULL);
return FALSE; return FALSE;
} }
fileDataStartPos += strlen (MAG_START_MARKER); fileDataStartPos += strlen (MAG_START_MARKER);
@@ -482,7 +482,7 @@ BOOL VerifyPackageIntegrity (void)
if (!LoadInt32 (path, &crc, fileDataEndPos + strlen (MagEndMarker) + 1)) if (!LoadInt32 (path, &crc, fileDataEndPos + strlen (MagEndMarker) + 1))
{ {
Error ("CANT_VERIFY_PACKAGE_INTEGRITY"); Error ("CANT_VERIFY_PACKAGE_INTEGRITY", NULL);
return FALSE; return FALSE;
} }
@@ -491,7 +491,7 @@ BOOL VerifyPackageIntegrity (void)
if (tmpBuffer == NULL) if (tmpBuffer == NULL)
{ {
Error ("CANT_VERIFY_PACKAGE_INTEGRITY"); Error ("CANT_VERIFY_PACKAGE_INTEGRITY", NULL);
return FALSE; return FALSE;
} }
@@ -501,7 +501,7 @@ BOOL VerifyPackageIntegrity (void)
if (crc != GetCrc32 (tmpBuffer, fileDataEndPos + 1 + strlen (MagEndMarker))) if (crc != GetCrc32 (tmpBuffer, fileDataEndPos + 1 + strlen (MagEndMarker)))
{ {
free (tmpBuffer); free (tmpBuffer);
Error ("DIST_PACKAGE_CORRUPTED"); Error ("DIST_PACKAGE_CORRUPTED", NULL);
return FALSE; return FALSE;
} }
@@ -562,7 +562,7 @@ BOOL SelfExtractInMemory (char *path)
fileDataEndPos = (int) FindStringInFile (path, MagEndMarker, strlen (MagEndMarker)); fileDataEndPos = (int) FindStringInFile (path, MagEndMarker, strlen (MagEndMarker));
if (fileDataEndPos < 0) if (fileDataEndPos < 0)
{ {
Error ("CANNOT_READ_FROM_PACKAGE"); Error ("CANNOT_READ_FROM_PACKAGE", NULL);
return FALSE; return FALSE;
} }
@@ -571,7 +571,7 @@ BOOL SelfExtractInMemory (char *path)
fileDataStartPos = (int) FindStringInFile (path, MAG_START_MARKER, strlen (MAG_START_MARKER)); fileDataStartPos = (int) FindStringInFile (path, MAG_START_MARKER, strlen (MAG_START_MARKER));
if (fileDataStartPos < 0) if (fileDataStartPos < 0)
{ {
Error ("CANNOT_READ_FROM_PACKAGE"); Error ("CANNOT_READ_FROM_PACKAGE", NULL);
return FALSE; return FALSE;
} }
@@ -582,7 +582,7 @@ BOOL SelfExtractInMemory (char *path)
// Read the stored total size of the uncompressed data // Read the stored total size of the uncompressed data
if (!LoadInt32 (path, &uncompressedLen, filePos)) if (!LoadInt32 (path, &uncompressedLen, filePos))
{ {
Error ("CANNOT_READ_FROM_PACKAGE"); Error ("CANNOT_READ_FROM_PACKAGE", NULL);
return FALSE; return FALSE;
} }
@@ -591,7 +591,7 @@ BOOL SelfExtractInMemory (char *path)
// Read the stored total size of the compressed data // Read the stored total size of the compressed data
if (!LoadInt32 (path, &compressedLen, filePos)) if (!LoadInt32 (path, &compressedLen, filePos))
{ {
Error ("CANNOT_READ_FROM_PACKAGE"); Error ("CANNOT_READ_FROM_PACKAGE", NULL);
return FALSE; return FALSE;
} }
@@ -599,13 +599,13 @@ BOOL SelfExtractInMemory (char *path)
if (compressedLen != fileDataEndPos - fileDataStartPos - 8 + 1) if (compressedLen != fileDataEndPos - fileDataStartPos - 8 + 1)
{ {
Error ("DIST_PACKAGE_CORRUPTED"); Error ("DIST_PACKAGE_CORRUPTED", NULL);
} }
DecompressedData = malloc (uncompressedLen + 524288); // + 512K reserve DecompressedData = malloc (uncompressedLen + 524288); // + 512K reserve
if (DecompressedData == NULL) if (DecompressedData == NULL)
{ {
Error ("ERR_MEM_ALLOC"); Error ("ERR_MEM_ALLOC", NULL);
return FALSE; return FALSE;
} }
@@ -619,14 +619,14 @@ BOOL SelfExtractInMemory (char *path)
free (DecompressedData); free (DecompressedData);
DecompressedData = NULL; DecompressedData = NULL;
Error ("CANNOT_READ_FROM_PACKAGE"); Error ("CANNOT_READ_FROM_PACKAGE", NULL);
return FALSE; return FALSE;
} }
// Decompress the data // Decompress the data
if (DecompressBuffer (DecompressedData, compressedData, compressedLen) != uncompressedLen) if (DecompressBuffer (DecompressedData, compressedData, compressedLen) != uncompressedLen)
{ {
Error ("DIST_PACKAGE_CORRUPTED"); Error ("DIST_PACKAGE_CORRUPTED", NULL);
goto sem_end; goto sem_end;
} }
@@ -653,7 +653,7 @@ BOOL SelfExtractInMemory (char *path)
if (Decompressed_Files[fileNo].crc if (Decompressed_Files[fileNo].crc
!= GetCrc32 (Decompressed_Files[fileNo].fileContent, Decompressed_Files[fileNo].fileLength)) != GetCrc32 (Decompressed_Files[fileNo].fileContent, Decompressed_Files[fileNo].fileLength))
{ {
Error ("DIST_PACKAGE_CORRUPTED"); Error ("DIST_PACKAGE_CORRUPTED", NULL);
goto sem_end; goto sem_end;
} }
@@ -662,7 +662,7 @@ BOOL SelfExtractInMemory (char *path)
if (fileNo < NBR_COMPRESSED_FILES) if (fileNo < NBR_COMPRESSED_FILES)
{ {
Error ("DIST_PACKAGE_CORRUPTED"); Error ("DIST_PACKAGE_CORRUPTED", NULL);
goto sem_end; goto sem_end;
} }

View File

@@ -661,7 +661,7 @@ error:
if (bOK == FALSE) if (bOK == FALSE)
{ {
handleWin32Error (hwndDlg); handleWin32Error (hwndDlg);
Error ("REG_INSTALL_FAILED"); Error ("REG_INSTALL_FAILED", hwndDlg);
} }
// Register COM servers for UAC // Register COM servers for UAC
@@ -669,7 +669,7 @@ error:
{ {
if (!RegisterComServers (szDir)) if (!RegisterComServers (szDir))
{ {
Error ("COM_REG_FAILED"); Error ("COM_REG_FAILED", hwndDlg);
return FALSE; return FALSE;
} }
} }
@@ -955,7 +955,7 @@ BOOL DoDriverUnload (HWND hwndDlg)
{ {
if (bootEnc.GetInstalledBootLoaderVersion() != VERSION_NUM) if (bootEnc.GetInstalledBootLoaderVersion() != VERSION_NUM)
{ {
if (AskWarnNoYes ("UPDATE_TC_IN_DECOY_OS_FIRST") == IDNO) if (AskWarnNoYes ("UPDATE_TC_IN_DECOY_OS_FIRST", hwndDlg) == IDNO)
AbortProcessSilent (); AbortProcessSilent ();
} }
} }
@@ -971,7 +971,7 @@ BOOL DoDriverUnload (HWND hwndDlg)
} }
else if (bUninstallInProgress || bDowngrade) else if (bUninstallInProgress || bDowngrade)
{ {
Error (bDowngrade ? "SETUP_FAILED_BOOT_DRIVE_ENCRYPTED_DOWNGRADE" : "SETUP_FAILED_BOOT_DRIVE_ENCRYPTED"); Error (bDowngrade ? "SETUP_FAILED_BOOT_DRIVE_ENCRYPTED_DOWNGRADE" : "SETUP_FAILED_BOOT_DRIVE_ENCRYPTED", hwndDlg);
return FALSE; return FALSE;
} }
else else
@@ -1083,7 +1083,7 @@ BOOL UpgradeBootLoader (HWND hwndDlg)
bootEnc.InstallBootLoader (true); bootEnc.InstallBootLoader (true);
if (bootEnc.GetInstalledBootLoaderVersion() <= TC_RESCUE_DISK_UPGRADE_NOTICE_MAX_VERSION) if (bootEnc.GetInstalledBootLoaderVersion() <= TC_RESCUE_DISK_UPGRADE_NOTICE_MAX_VERSION)
Info (IsHiddenOSRunning() ? "BOOT_LOADER_UPGRADE_OK_HIDDEN_OS" : "BOOT_LOADER_UPGRADE_OK"); Info (IsHiddenOSRunning() ? "BOOT_LOADER_UPGRADE_OK_HIDDEN_OS" : "BOOT_LOADER_UPGRADE_OK", hwndDlg);
} }
return TRUE; return TRUE;
} }
@@ -1093,7 +1093,7 @@ BOOL UpgradeBootLoader (HWND hwndDlg)
} }
catch (...) { } catch (...) { }
Error ("BOOT_LOADER_UPGRADE_FAILED"); Error ("BOOT_LOADER_UPGRADE_FAILED", hwndDlg);
return FALSE; return FALSE;
} }
@@ -1249,7 +1249,7 @@ BOOL DoShortcutsInstall (HWND hwndDlg, char *szDestDir, BOOL bProgGroup, BOOL bD
{ {
fprintf (f, "[InternetShortcut]\nURL=%s\n", TC_APPLINK); fprintf (f, "[InternetShortcut]\nURL=%s\n", TC_APPLINK);
CheckFileStreamWriteErrors (f, szTmp2); CheckFileStreamWriteErrors (hwndDlg, f, szTmp2);
fclose (f); fclose (f);
} }
else else
@@ -1315,9 +1315,9 @@ void OutcomePrompt (HWND hwndDlg, BOOL bOK)
if (bDevm) if (bDevm)
PostMessage (MainDlg, WM_CLOSE, 0, 0); PostMessage (MainDlg, WM_CLOSE, 0, 0);
else if (bPossiblyFirstTimeInstall || bRepairMode || (!bUpgrade && !bDowngrade)) else if (bPossiblyFirstTimeInstall || bRepairMode || (!bUpgrade && !bDowngrade))
Info ("INSTALL_OK"); Info ("INSTALL_OK", hwndDlg);
else else
Info ("SETUP_UPDATE_OK"); Info ("SETUP_UPDATE_OK", hwndDlg);
} }
else else
{ {
@@ -1330,9 +1330,9 @@ void OutcomePrompt (HWND hwndDlg, BOOL bOK)
else else
{ {
if (bUninstall == FALSE) if (bUninstall == FALSE)
Error ("INSTALL_FAILED"); Error ("INSTALL_FAILED", hwndDlg);
else else
Error ("UNINSTALL_FAILED"); Error ("UNINSTALL_FAILED", hwndDlg);
} }
} }
@@ -1456,7 +1456,7 @@ void DoUninstall (void *arg)
UninstallBatch UninstallBatch
); );
CheckFileStreamWriteErrors (f, UninstallBatch); CheckFileStreamWriteErrors (hwndDlg, f, UninstallBatch);
fclose (f); fclose (f);
} }
} }
@@ -1501,7 +1501,7 @@ void DoInstall (void *arg)
handleWin32Error (hwndDlg); handleWin32Error (hwndDlg);
StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("CANT_CREATE_FOLDER"), InstallationPath); StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("CANT_CREATE_FOLDER"), InstallationPath);
MessageBoxW (hwndDlg, szTmp, lpszTitle, MB_ICONHAND); MessageBoxW (hwndDlg, szTmp, lpszTitle, MB_ICONHAND);
Error ("INSTALL_FAILED"); Error ("INSTALL_FAILED", hwndDlg);
PostMessage (MainDlg, TC_APPMSG_INSTALL_FAILURE, 0, 0); PostMessage (MainDlg, TC_APPMSG_INSTALL_FAILURE, 0, 0);
return; return;
} }
@@ -1524,7 +1524,7 @@ void DoInstall (void *arg)
) )
{ {
NormalCursor (); NormalCursor ();
Error ("CLOSE_TC_FIRST"); Error ("CLOSE_TC_FIRST", hwndDlg);
PostMessage (MainDlg, TC_APPMSG_INSTALL_FAILURE, 0, 0); PostMessage (MainDlg, TC_APPMSG_INSTALL_FAILURE, 0, 0);
return; return;
} }
@@ -1542,7 +1542,7 @@ void DoInstall (void *arg)
if (!DisablePagingFile()) if (!DisablePagingFile())
{ {
handleWin32Error (hwndDlg); handleWin32Error (hwndDlg);
Error ("FAILED_TO_DISABLE_PAGING_FILES"); Error ("FAILED_TO_DISABLE_PAGING_FILES", hwndDlg);
} }
else else
bRestartRequired = TRUE; bRestartRequired = TRUE;
@@ -1630,7 +1630,7 @@ void DoInstall (void *arg)
} }
else else
{ {
Warning ("SYS_ENC_UPGRADE_FAILED"); Warning ("SYS_ENC_UPGRADE_FAILED", hwndDlg);
} }
} }
@@ -1750,7 +1750,7 @@ void SetInstallationPath (HWND hwndDlg)
// We know that VeraCrypt is installed but don't know where. It's not safe to continue installing // We know that VeraCrypt is installed but don't know where. It's not safe to continue installing
// over the old version. // over the old version.
Error ("UNINSTALL_OLD_VERSION_FIRST"); Error ("UNINSTALL_OLD_VERSION_FIRST", hwndDlg);
len = strrchr (rv, '/') - rv - 1; len = strrchr (rv, '/') - rv - 1;
StringCbCopyNA (InstallationPath, sizeof(InstallationPath), rv, len); // Path and filename of the uninstaller StringCbCopyNA (InstallationPath, sizeof(InstallationPath), rv, len); // Path and filename of the uninstaller
@@ -1896,7 +1896,7 @@ BOOL CALLBACK UninstallDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (bUninstallInProgress) if (bUninstallInProgress)
{ {
NormalCursor(); NormalCursor();
if (AskNoYes("CONFIRM_EXIT_UNIVERSAL") == IDNO) if (AskNoYes("CONFIRM_EXIT_UNIVERSAL", hwndDlg) == IDNO)
{ {
return 1; return 1;
} }
@@ -2001,7 +2001,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszComm
char *tmpStr[] = {0, "SELECT_AN_ACTION", "REPAIR_REINSTALL", "UNINSTALL", "EXIT", 0}; char *tmpStr[] = {0, "SELECT_AN_ACTION", "REPAIR_REINSTALL", "UNINSTALL", "EXIT", 0};
// Ask the user to select either Repair or Unistallation // Ask the user to select either Repair or Unistallation
switch (AskMultiChoice ((void **) tmpStr, FALSE)) switch (AskMultiChoice ((void **) tmpStr, FALSE, NULL))
{ {
case 1: case 1:
bRepairMode = TRUE; bRepairMode = TRUE;

View File

@@ -231,7 +231,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
} }
else else
{ {
Error("CANNOT_DISPLAY_LICENSE"); Error("CANNOT_DISPLAY_LICENSE", hwndDlg);
exit (1); exit (1);
} }
@@ -904,14 +904,14 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (nCurrentOS == WIN_2000) if (nCurrentOS == WIN_2000)
{ {
WarningDirect (L"Warning: Please note that this may be the last version of VeraCrypt that supports Windows 2000. If you want to be able to upgrade to future versions of VeraCrypt (which is highly recommended), you will need to upgrade to Windows XP or a later version of Windows.\n\nNote: Microsoft stopped issuing security updates for Windows 2000 to the general public on 7/13/2010 (the last non-security update for Windows 2000 was issued to the general public in 2005)."); WarningDirect (L"Warning: Please note that this may be the last version of VeraCrypt that supports Windows 2000. If you want to be able to upgrade to future versions of VeraCrypt (which is highly recommended), you will need to upgrade to Windows XP or a later version of Windows.\n\nNote: Microsoft stopped issuing security updates for Windows 2000 to the general public on 7/13/2010 (the last non-security update for Windows 2000 was issued to the general public in 2005).", hwndDlg);
HKEY hkey; HKEY hkey;
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Updates\\Windows 2000\\SP5\\Update Rollup 1", 0, KEY_READ, &hkey) != ERROR_SUCCESS) if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Updates\\Windows 2000\\SP5\\Update Rollup 1", 0, KEY_READ, &hkey) != ERROR_SUCCESS)
{ {
ErrorDirect (L"VeraCrypt requires Update Rollup 1 for Windows 2000 SP4 to be installed.\n\nFor more information, see http://support.microsoft.com/kb/891861"); ErrorDirect (L"VeraCrypt requires Update Rollup 1 for Windows 2000 SP4 to be installed.\n\nFor more information, see http://support.microsoft.com/kb/891861", hwndDlg);
AbortProcessSilent (); AbortProcessSilent ();
} }
@@ -923,10 +923,10 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
{ {
if (IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY))) if (IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY)))
{ {
Info ("TRAVELER_LIMITATIONS_NOTE"); Info ("TRAVELER_LIMITATIONS_NOTE", hwndDlg);
if (IsUacSupported() if (IsUacSupported()
&& AskWarnYesNo ("TRAVELER_UAC_NOTE") == IDNO) && AskWarnYesNo ("TRAVELER_UAC_NOTE", hwndDlg) == IDNO)
{ {
return 1; return 1;
} }
@@ -1114,7 +1114,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
RefreshUIGFX (); RefreshUIGFX ();
Info ("EXTRACTION_FINISHED_INFO"); Info ("EXTRACTION_FINISHED_INFO", hwndDlg);
SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE")); SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE"));
@@ -1146,7 +1146,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
RefreshUIGFX(); RefreshUIGFX();
Error ("EXTRACTION_FAILED"); Error ("EXTRACTION_FAILED", hwndDlg);
return 1; return 1;
@@ -1157,7 +1157,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (bInProgress) if (bInProgress)
{ {
NormalCursor(); NormalCursor();
if (AskNoYes("CONFIRM_EXIT_UNIVERSAL") == IDNO) if (AskNoYes("CONFIRM_EXIT_UNIVERSAL", hwndDlg) == IDNO)
{ {
return 1; return 1;
} }
@@ -1171,7 +1171,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
else else
{ {
if (bPromptReleaseNotes if (bPromptReleaseNotes
&& AskYesNo ("AFTER_UPGRADE_RELEASE_NOTES") == IDYES) && AskYesNo ("AFTER_UPGRADE_RELEASE_NOTES", hwndDlg) == IDYES)
{ {
Applink ("releasenotes", TRUE, ""); Applink ("releasenotes", TRUE, "");
} }
@@ -1179,7 +1179,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
bPromptReleaseNotes = FALSE; bPromptReleaseNotes = FALSE;
if (bPromptTutorial if (bPromptTutorial
&& AskYesNo ("AFTER_INSTALL_TUTORIAL") == IDYES) && AskYesNo ("AFTER_INSTALL_TUTORIAL", hwndDlg) == IDYES)
{ {
Applink ("beginnerstutorial", TRUE, ""); Applink ("beginnerstutorial", TRUE, "");
} }
@@ -1188,7 +1188,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
} }
if (bRestartRequired if (bRestartRequired
&& AskYesNo (bUpgrade ? "UPGRADE_OK_REBOOT_REQUIRED" : "CONFIRM_RESTART") == IDYES) && AskYesNo (bUpgrade ? "UPGRADE_OK_REBOOT_REQUIRED" : "CONFIRM_RESTART", hwndDlg) == IDYES)
{ {
RestartComputer(); RestartComputer();
} }