Annotation of truecrypt/common/basecom.cpp, revision 1.1.1.2

1.1       root        1: /*
                      2:  Copyright (c) TrueCrypt Foundation. All rights reserved.
                      3: 
1.1.1.2 ! root        4:  Covered by the TrueCrypt License 2.3 the full text of which is contained
1.1       root        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: {
1.1.1.2 ! root       18:     WCHAR monikerName[1024];
        !            19:     WCHAR clsid[1024];
1.1       root       20:     BIND_OPTS3 bo;
                     21: 
1.1.1.2 ! root       22:     StringFromGUID2 (guid, clsid, sizeof (clsid) / 2);
        !            23:        swprintf_s (monikerName, sizeof (monikerName) / 2, L"Elevation:Administrator!new:%s", clsid);
1.1       root       24: 
                     25:     memset (&bo, 0, sizeof (bo));
                     26:     bo.cbStruct = sizeof (bo);
                     27:     bo.hwnd = hwnd;
                     28:     bo.dwClassContext = CLSCTX_LOCAL_SERVER;
                     29: 
1.1.1.2 ! root       30:     return CoGetObject (monikerName, &bo, iid, ppv);
1.1       root       31: }
                     32: 
                     33: 
                     34: BOOL ComGetInstanceBase (HWND hWnd, REFCLSID clsid, REFIID iid, void **tcServer)
                     35: {
                     36:        BOOL r;
                     37: 
                     38:        if (IsUacSupported ())
                     39:                r = CreateElevatedComObject (hWnd, clsid, iid, tcServer) == S_OK;
                     40:        else
                     41:                r = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, iid, tcServer) == S_OK;
                     42: 
                     43:        if (!r)
                     44:                Error ("UAC_INIT_ERROR");
                     45: 
                     46:        return r;
                     47: }
                     48: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.