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

Windows: Better way to enable required privileges for FastCreate Options

If we can set required privilege, we ask the user using UAC to enable them.
This commit is contained in:
Mounir IDRASSI
2023-08-13 00:56:49 +02:00
parent eb2f5f33c9
commit 8c7962bda7
10 changed files with 183 additions and 8 deletions

View File

@@ -187,6 +187,11 @@ public:
return BaseCom::NotifyService (dwNotifyCode);
}
virtual DWORD STDMETHODCALLTYPE FastFileResize (BSTR filePath, __int64 fileSize)
{
return BaseCom::FastFileResize (filePath, fileSize);
}
protected:
DWORD MessageThreadId;
LONG RefCount;
@@ -335,3 +340,29 @@ extern "C" BOOL UacWriteLocalMachineRegistryDword (HWND hwndDlg, wchar_t *keyPat
}
}
extern "C" DWORD UacFastFileCreation (HWND hWnd, wchar_t* filePath, __int64 fileSize)
{
CComPtr<ITrueCryptFormatCom> tc;
DWORD r;
CoInitialize (NULL);
if (ComGetInstance (hWnd, &tc))
{
CComBSTR filePathBstr;
BSTR bstr = W2BSTR(filePath);
if (bstr)
{
filePathBstr.Attach (bstr);
r = tc->FastFileResize (filePathBstr, fileSize);
}
else
r = ERROR_OUTOFMEMORY;
}
else
r = GetLastError();
CoUninitialize ();
return r;
}

View File

@@ -30,6 +30,7 @@ int UacAnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHos
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);
DWORD UacFastFileCreation (HWND hWnd, wchar_t* filePath, __int64 fileSize);
#ifdef __cplusplus
}

View File

@@ -50,6 +50,7 @@ library TrueCryptFormatCom
DWORD UpdateSetupConfigFile (BOOL bForInstall);
DWORD GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded);
DWORD NotifyService (DWORD dwNotifyCode);
DWORD FastFileResize (BSTR filePath, __int64 fileSize);
};
[