diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2023-07-01 22:46:01 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2023-07-01 22:46:01 +0200 |
commit | 7a3daa389cf74d7a2439d943c63a888b62abfeb9 (patch) | |
tree | 00116f5e858f7ded8ae47a0f0505430bc4ea475c /src/Common/BaseCom.cpp | |
parent | e28de414e0fbf1d7983c5edd3c91c83ea04fecbd (diff) | |
download | VeraCrypt-7a3daa389cf74d7a2439d943c63a888b62abfeb9.tar.gz VeraCrypt-7a3daa389cf74d7a2439d943c63a888b62abfeb9.zip |
Windows: Make API formatting fallback to format.com in case of elevation. remove dead code from ExternalFormatFs
We also modify UacFormatNtfs/UacFormatFs to return actual error code in case of failure
Diffstat (limited to 'src/Common/BaseCom.cpp')
-rw-r--r-- | src/Common/BaseCom.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Common/BaseCom.cpp b/src/Common/BaseCom.cpp index 32859b11..a9ece557 100644 --- a/src/Common/BaseCom.cpp +++ b/src/Common/BaseCom.cpp @@ -45,12 +45,13 @@ HRESULT CreateElevatedComObject (HWND hwnd, REFGUID guid, REFIID iid, void **ppv BOOL ComGetInstanceBase (HWND hWnd, REFCLSID clsid, REFIID iid, void **tcServer) { BOOL r; + HRESULT hr; if (IsUacSupported ()) { while (true) { - r = CreateElevatedComObject (hWnd, clsid, iid, tcServer) == S_OK; + r = (hr = CreateElevatedComObject (hWnd, clsid, iid, tcServer)) == S_OK; if (r) break; else @@ -64,11 +65,16 @@ BOOL ComGetInstanceBase (HWND hWnd, REFCLSID clsid, REFIID iid, void **tcServer) } else { - r = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, iid, tcServer) == S_OK; + r = (hr = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, iid, tcServer)) == S_OK; if (!r) Error ("UAC_INIT_ERROR", hWnd); } + if (!r) + { + SetLastError((DWORD) hr); + } + return r; } |