Code: Select all
?Log@Output@@QAAXPBGZZ
Code: Select all
void __cdecl Output::Log(unsigned short const*,...)
Code: Select all
?Log@Output@@QAAXPBGZZ
Code: Select all
void __cdecl Output::Log(unsigned short const*,...)
Me, too!klumsy wrote:man i love dephi
Yes.klumsy wrote:on the delphi front hooking "@TSomeClass.SomeMethod" would hook every call that that method of every instance right?
Sounds interesting. Would you mind posting here if you find a working solution?klumsy wrote:as for C++, i'm working on a framework now to do it, (we can already do it for static methods), but i'm using inline assembler to do the equivilent of "@TSomeClass.SomeMethod" since C++ compiler doesn't let such a thing to do done..
its working our well, other than you can't make a function with the same calling convetion of nonstatic methods (THISCALL calling convention(which is basically like STDCALL, but with pointer to the class instance (this) is passed in ECX register) in C, other than inside classes, so my hooked functions will also have to have at least ASM prolog and epilog headers to deal with the parameter calling, so thinking of the best way to make a generic solution for this at the moment.
Code: Select all
PVOID doitptr;
PVOID hookdoitptr;
PVOID NextHook;
...
//declaration of method function that will be hooked
long Test::DoIt(long x)
{
...
}
//code to get pointers needed for hooking
_asm {
mov eax,DWORD PTR Test::DoIt;
mov doitptr,eax
}
_asm {
mov eax,DWORD PTR TestHook::HookDoIt;
mov hookdoitptr,eax
}
//install the hook
if (!HookCode(doitptr, hookdoitptr, (PVOID*) &NextHook))
MessageBox("did not hook right");
//until it is unhooked whenever Test::Doit is called, TestHook::HookDoIt will be called
instead.
..
//and actually what does TestHook::HookDoIt contains?
long TestHook::HookDoIt(long x)
{
long retvalue;
Test * testptr = (Test *) this;
//now do whatever we want here
CString tmpstr;
tmpstr.Format("inside the hook x: %d this.z : %d",x,testptr->z);
MessageBox(0,tmpstr,"",0);
//now we are done, call the original simulating thiscall calling technique
_asm {
push x
mov ecx,this
call NextHook;
mov retvalue,eax
}
return retvalue;
};
...
//and we might want to uninstall the hook sometime
UnhookCode((PVOID*) &NextHook);
Thanks for the code! Well, in Delphi the "Self" pointer is stored just as any other parameter, so there's no problem.klumsy wrote:ok here are some snippets
Hmmmmm... Might be possible, I'm not sure... I'm glad that things are so much easier in Delphi...klumsy wrote:maybe another way we could do this
madshi wrote:It should be possible to hook that function, but you must make sure that both your hook callback function and the next-function-variable have exactly the same parameters and calling convention as the to-be-hooked function. They also need to be part of a class, because the to-be-hooked function is also part of a class.