How to look up vtable index of a method on the IWinHttpRequest interface?

StackOverflow https://stackoverflow.com/questions/20294838

  •  06-08-2022
  •  | 
  •  

Question

I assume it's in winhttp.dll somewhere, but I can't find any reference to it by dumping the DLL using bindump. Anyone have any suggestions on how I can find the vtable index of a method?

Était-ce utile?

La solution

The information is in the IDL file, httprequest.idl.

interface IWinHttpRequest : IDispatch
{
    [id(DISPID_HTTPREQUEST_SETPROXY), helpstring("Specify proxy configuration")]
    HRESULT SetProxy([in] HTTPREQUEST_PROXY_SETTING ProxySetting,
                     [in, optional] VARIANT ProxyServer,
                     [in, optional] VARIANT BypassList);

    [id(DISPID_HTTPREQUEST_SETCREDENTIALS), helpstring("Specify authentication credentials")]
    HRESULT SetCredentials([in] BSTR UserName,
                     [in] BSTR Password,
         [in] HTTPREQUEST_SETCREDENTIALS_FLAGS Flags);

    ....

From this you can read off the method indices. It's a bit tricky because you first have to count the method indices of the base interface IDispatch.

// IUnknown
0: QueryInterface
1: AddRef
2: Release
// IDispatch
3: GetTypeInfoCount
4: GetTypeInfo
5: GetIDsOfNames
6: Invoke
// IWinHttpRequest
7: SetProxy
8: SetCredentials
... etc. ...

You can remove the tedium by using theoffsetof macro.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top