Hook COM Interface BUG #46

Closed
wyd1520 opened this Issue Sep 14, 2015 · 0 comments

Comments

Projects
None yet
2 participants
@wyd1520

wyd1520 commented Sep 14, 2015

I use COMClassInfo Navigate2 hook method (Microsoft.mshtml.dll WebBrowserClass, IWebBrowser2), I found that using new COMClassInfo (typeof (WebBrowserClass), typeof (IWebBrowser2), "Navigate2") correctly hooked Navigate2 method, but using new COMClassInfo (typeof (WebBrowserClass) .GUID, typeof (IWebBrowser2) .GUID, 52) can not be hooked. The reason is COMClassInfo the Query method has a BUG

 IntPtr interfaceIntPtr = IntPtr.Zero;
            if (InterfaceType! = null)
                interfaceIntPtr = Marshal.GetComInterfaceForObject (classInstance, InterfaceType);
            else
                interfaceIntPtr = Marshal.GetIUnknownForObject (classInstance);

Change the Code

IntPtr interfaceIntPtr = IntPtr.Zero;
if (InterfaceType! = null)
{
      interfaceIntPtr = Marshal.GetComInterfaceForObject (classInstance, InterfaceType);
 }
else
{
                
    interfaceIntPtr = Marshal.GetIUnknownForObject (classInstance);
    Marshal.QueryInterface (interfaceIntPtr, ref interfaceGuid, out interfaceIntPtr);
  }

@spazzarama spazzarama added the bug label Sep 15, 2015

@spazzarama spazzarama added this to the 2.7 Stable milestone Sep 15, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment