I managed to solve the problem in 5 minutes after reading the article provided by Dark Falcon. I totally recommend reading it! Therefore, all credit for the answer goes to him!
Handling the hook function
Question
I'm trying to use EasyHook in C# to properly hook into a method from a COM object (unmanaged).
I was able to determine the address of the method of the COM object and I can properly trigger my hook function. I did it this way, being the rest of the code pretty much similar to the one in the tutorial:
SendHook = LocalHook.Create(0x12345678, new DMyFunc(MyFunc_Hooked), this);
However, once inside my hook, all parameters are scrambled (they do not equal those that I'm originally passing).
Also, I'm not able to return anything (please note that I also tried hooking another function that returns a short and the value doesn't properly return).
When I open eXescope, this is one of the function signatures:
function MyFunc(out ParamA:^BSTR; out ParamB:^bool): ^TypeA;
And this function has the following signature when I use the COM object normally in C#:
TypeA MyFunc(ref string ParamA, ref bool ParamB);
Any ideas? Thanks in advance!
Solution