VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/BaseCom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/BaseCom.cpp')
-rw-r--r--src/Common/BaseCom.cpp10
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;
}