VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2020-07-22 15:04:32 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2020-07-22 15:27:59 (GMT)
commit587e6db4f16291d8b6f22d0937a4bff87bc8ffc0 (patch)
treec60a12b021182324b9d741981bf8b45b621ee742
parent1c3e4fd0ee235ac2cf7cee2c2f6db2ac74ba21c8 (diff)
downloadVeraCrypt-587e6db4f16291d8b6f22d0937a4bff87bc8ffc0.zip
VeraCrypt-587e6db4f16291d8b6f22d0937a4bff87bc8ffc0.tar.gz
Windows: Warn about Fast Startup if it is enabled during system encryption or volume creation and propose to disable it
-rw-r--r--src/Common/BootEncryption.cpp10
-rw-r--r--src/Format/FormatCom.cpp39
-rw-r--r--src/Format/FormatCom.h1
-rw-r--r--src/Format/Tcformat.c18
4 files changed, 68 insertions, 0 deletions
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp
index 502b4e0..0f41539 100644
--- a/src/Common/BootEncryption.cpp
+++ b/src/Common/BootEncryption.cpp
@@ -5673,6 +5673,16 @@ namespace VeraCrypt
if (!rescueIsoImagePath.empty())
CreateRescueIsoImage (true, rescueIsoImagePath);
+
+ // check if Fast Startup is enabled and if yes then offer to disable it
+ BOOL bHibernateEnabled = FALSE, bHiberbootEnabled = FALSE;
+ if (GetHibernateStatus (bHibernateEnabled, bHiberbootEnabled) && bHiberbootEnabled)
+ {
+ if (AskWarnYesNo ("CONFIRM_DISABLE_FAST_STARTUP", ParentWindow) == IDYES)
+ {
+ WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power", L"HiberbootEnabled", 0);
+ }
+ }
}
bool BootEncryption::IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly)
diff --git a/src/Format/FormatCom.cpp b/src/Format/FormatCom.cpp
index 1075776..4acf7a3 100644
--- a/src/Format/FormatCom.cpp
+++ b/src/Format/FormatCom.cpp
@@ -291,3 +291,42 @@ extern "C" int UacAnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 h
return r;
}
+
+extern "C" BOOL UacWriteLocalMachineRegistryDword (HWND hwndDlg, wchar_t *keyPath, wchar_t *valueName, DWORD value)
+{
+ CComPtr<ITrueCryptFormatCom> tc;
+ int r = 0;
+
+ CoInitialize (NULL);
+
+ if (ComGetInstance (hwndDlg, &tc))
+ {
+ CComBSTR keyPathBstr, valueNameBstr;
+ BSTR bstr = W2BSTR(keyPath);
+ if (bstr)
+ {
+ keyPathBstr.Attach (bstr);
+ bstr = W2BSTR(valueName);
+ if (bstr)
+ {
+ valueNameBstr.Attach (bstr);
+ r = tc->WriteLocalMachineRegistryDwordValue (keyPathBstr, valueNameBstr, value);
+ }
+ else
+ r = ERROR_OUTOFMEMORY;
+ }
+ else
+ r = ERROR_OUTOFMEMORY;
+ }
+
+ CoUninitialize ();
+
+ if (r == ERROR_SUCCESS)
+ return TRUE;
+ else
+ {
+ SetLastError (r);
+ return FALSE;
+ }
+}
+
diff --git a/src/Format/FormatCom.h b/src/Format/FormatCom.h
index 5f03961..5ab6bd5 100644
--- a/src/Format/FormatCom.h
+++ b/src/Format/FormatCom.h
@@ -29,6 +29,7 @@ int UacFormatFs (HWND hWnd, int driveNo, int clusterSize, int fsType);
int UacAnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters);
int UacFormatVolume (char *cvolumePath , BOOL bDevice , unsigned __int64 size , unsigned __int64 hiddenVolHostSize , Password *password , int cipher , int pkcs5 , BOOL quickFormat, BOOL sparseFileSwitch, int fileSystem , int clusterSize, HWND hwndDlg , BOOL hiddenVol , int *realClusterSize);
BOOL UacUpdateProgressBar (__int64 nSecNo, BOOL *bVolTransformThreadCancel);
+BOOL UacWriteLocalMachineRegistryDword (HWND hwndDlg, wchar_t *keyPath, wchar_t *valueName, DWORD value);
#ifdef __cplusplus
}
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index 6a31883..6911866 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -8453,6 +8453,7 @@ retryCDDriveCheck:
else if (nCurPageNo == FORMAT_PAGE)
{
/* Format start (the 'Next' button has been clicked on the Format page) */
+ static BOOL g_bFastStartupCheckDone = FALSE;
if (bVolTransformThreadRunning || bVolTransformThreadToRun)
return 1;
@@ -8461,6 +8462,23 @@ retryCDDriveCheck:
bVolTransformThreadToRun = TRUE;
+ // check if Fast Startup is enabled and if yes then offer to disable it
+ if (!g_bFastStartupCheckDone)
+ {
+ BOOL bHibernateEnabled = FALSE, bHiberbootEnabled = FALSE;
+ if (GetHibernateStatus (bHibernateEnabled, bHiberbootEnabled) && bHiberbootEnabled)
+ {
+ if (AskWarnYesNo ("CONFIRM_DISABLE_FAST_STARTUP", hwndDlg) == IDYES)
+ {
+ if (!IsAdmin () && IsUacSupported ())
+ UacWriteLocalMachineRegistryDword (hwndDlg, L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power", L"HiberbootEnabled", 0);
+ else
+ WriteLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power", L"HiberbootEnabled", 0);
+ }
+ }
+ g_bFastStartupCheckDone = true;
+ }
+
fileSystem = (int) SendMessage (GetDlgItem (hCurPage, IDC_FILESYS), CB_GETITEMDATA,
SendMessage (GetDlgItem (hCurPage, IDC_FILESYS), CB_GETCURSEL, 0, 0) , 0);