|
|
1.1 ! root 1: /* ! 2: Copyright (c) TrueCrypt Foundation. All rights reserved. ! 3: ! 4: Covered by the TrueCrypt License 2.2 the full text of which is contained ! 5: in the file License.txt included in TrueCrypt binary and source code ! 6: distribution packages. ! 7: */ ! 8: ! 9: #include <atlcomcli.h> ! 10: #include <strsafe.h> ! 11: #include <windows.h> ! 12: #include "BaseCom.h" ! 13: #include "Dlgcode.h" ! 14: ! 15: ! 16: HRESULT CreateElevatedComObject (HWND hwnd, REFGUID guid, REFIID iid, void **ppv) ! 17: { ! 18: BIND_OPTS3 bo; ! 19: WCHAR wszCLSID[50]; ! 20: WCHAR wszMonikerName[300]; ! 21: ! 22: StringFromGUID2 (guid, wszCLSID, sizeof (wszCLSID) / sizeof (wszCLSID[0])); ! 23: ! 24: HRESULT hr = StringCchPrintfW ( ! 25: wszMonikerName, sizeof (wszMonikerName) / sizeof (wszMonikerName[0]), ! 26: L"Elevation:Administrator!new:%s", wszCLSID); ! 27: ! 28: if (FAILED(hr)) ! 29: return hr; ! 30: ! 31: memset (&bo, 0, sizeof (bo)); ! 32: bo.cbStruct = sizeof (bo); ! 33: bo.hwnd = hwnd; ! 34: bo.dwClassContext = CLSCTX_LOCAL_SERVER; ! 35: ! 36: return CoGetObject (wszMonikerName, &bo, iid, ppv); ! 37: } ! 38: ! 39: ! 40: BOOL ComGetInstanceBase (HWND hWnd, REFCLSID clsid, REFIID iid, void **tcServer) ! 41: { ! 42: BOOL r; ! 43: ! 44: if (IsUacSupported ()) ! 45: r = CreateElevatedComObject (hWnd, clsid, iid, tcServer) == S_OK; ! 46: else ! 47: r = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, iid, tcServer) == S_OK; ! 48: ! 49: if (!r) ! 50: Error ("UAC_INIT_ERROR"); ! 51: ! 52: return r; ! 53: } ! 54:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.