Ticket #5392: win32_api.hpp.#5392.patch

File win32_api.hpp.#5392.patch, 2.2 KB (added by Kai K., 11 years ago)

fixes WBEM_ACCESS_DENIED problem

  • win32_api.hpp

     
    160160static unsigned long key_query_value    = 0x0001;
    161161
    162162//COM API
     163const long RPC_C_AUTHZ_NONE_IG = 0;
     164const long RPC_C_AUTHN_LEVEL_CALL_IG = 3;
    163165const long RPC_C_AUTHN_LEVEL_PKT_IG = 4;
     166const long RPC_C_AUTHN_WINNT_IG = 10;
    164167const long RPC_C_IMP_LEVEL_IMPERSONATE_IG = 3;
    165168const long EOAC_NONE_IG = 0;
    166169const long CLSCTX_INPROC_SERVER_IG   = 0x1;
     
    858861extern "C" __declspec(dllimport) long __stdcall CoCreateInstance(const GUID_IG & rclsid, IUnknown_IG *pUnkOuter,
    859862                    unsigned long dwClsContext, const GUID_IG & riid, void** ppv);
    860863extern "C" __declspec(dllimport) void __stdcall CoUninitialize(void);
     864extern "C" __declspec(dllimport) long __stdcall CoSetProxyBlanket(
     865                                                                                                        IUnknown_IG *pProxy,
     866                                                                                                        DWORD dwAuthnSvc,
     867                                                                                                        DWORD dwAuthzSvc,
     868                                                                                                        OLECHAR *pServerPrincName,
     869                                                                                                        DWORD dwAuthnLevel,
     870                                                                                                        DWORD dwImpLevel,
     871                                                                                                        RPC_AUTH_IDENTITY_HANDLE pAuthInfo,
     872                                                                                                        DWORD dwCapabilities
     873                                                                                                        );
    861874
    862875
    863 
    864876//API function typedefs
    865877//Pointer to functions
    866878typedef long (__stdcall *NtDeleteFile_t)(object_attributes_t *ObjectAttributes);
     
    15161528
    15171529      com_releaser<IWbemServices_IG> IWbemServices_releaser(pWbemServices);
    15181530
     1531                        // addition to fix ticket #5392
     1532                        // @see http://support.microsoft.com/kb/948829
     1533                        // @see http://msdn.microsoft.com/en-us/library/ms692692%28v=vs.85%29.aspx                     
     1534                        // ignoring the return value, because the following lines may work anyway
     1535                        CoSetProxyBlanket(
     1536                                pWbemServices,                  // Indicates the proxy to set
     1537                                RPC_C_AUTHN_WINNT_IG,                                           // RPC_C_AUTHN_xxx
     1538                                RPC_C_AUTHZ_NONE_IG,                                            // RPC_C_AUTHZ_xxx
     1539                                NULL,                                                                                                           // Server principal name
     1540                                RPC_C_AUTHN_LEVEL_CALL_IG,                      // RPC_C_AUTHN_LEVEL_xxx
     1541                                RPC_C_IMP_LEVEL_IMPERSONATE_IG, // RPC_C_IMP_LEVEL_xxx
     1542                                NULL,                                                                                                           // client identity
     1543                                EOAC_NONE_IG                                                                            // proxy capabilities
     1544                                );
     1545
    15191546      strValue.clear();
    15201547      strValue += L"Select ";
    15211548      strValue += wmi_class_var;