diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2023-08-13 00:56:49 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2023-08-13 00:56:49 +0200 |
commit | 8c7962bda7ea260049226fe99a351675fd0780a2 (patch) | |
tree | 388930f0c2f6ae19ea673b1b0faeedc9f4c805d0 /src/Format/FormatCom.cpp | |
parent | eb2f5f33c96840efef46e97d994182a25540bb17 (diff) | |
download | VeraCrypt-8c7962bda7ea260049226fe99a351675fd0780a2.tar.gz VeraCrypt-8c7962bda7ea260049226fe99a351675fd0780a2.zip |
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.
Diffstat (limited to 'src/Format/FormatCom.cpp')
-rw-r--r-- | src/Format/FormatCom.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Format/FormatCom.cpp b/src/Format/FormatCom.cpp index 18653761..d696f00f 100644 --- a/src/Format/FormatCom.cpp +++ b/src/Format/FormatCom.cpp @@ -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; +} |