Note that there are some explanatory texts on larger screens.

plurals
  1. POHook the method whose parameters contain unknown object
    primarykey
    data
    text
    <p>I hooked a C++ member method via detours.</p> <p>The method's declaration is retrieved from Symbol file (*.pdb) in IDA</p> <pre><code>LPVOID __thiscall Foo(class UnknownClass, unsigned int, int) </code></pre> <p>The following is my method replacing the real one</p> <pre><code>// the first parameter of the method is an unknown class to me // I don't know its implementation, don't know its size // so I just declare a dummy class with a enough size class UnknownClass { public: CHAR dummy[1024]; }; typedef LPVOID (__thiscall MyDummyClass::*PFN_Foo)( UnknownClass, unsigned int, int ); class MyDummyClass { public: // The address of the real method PFN_Foo m_pfnFoo; // My method to replace the real one LPVOID MyFoo( UnknownClass p1, unsigned int p2, int p3) { MyDummyClass * pThis = (MyDummyClass*)this; // call the real one. // and here the error happens return (pThis-&gt;*m_pfnFoo)( p1, p2, p3 ); } }; </code></pre> <p>The hook works and <code>MyFoo</code> is called instead of the real method. but I get an error when calling the real method:</p> <blockquote> <p><code>Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.</code></p> </blockquote> <p>Do you have any suggestion to me? How to handle this kind of hook when one of the parameter is passed as object, but its implementation is unknown to me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload