четверг, 15 ноября 2007 г.

How to get Entry Point of Method Address Dynamically? No problem

In some cases (may be some sort of code injecting for constructive needs) there is a necessity for getting Method Entry Point Dynamically.

Here is my method

TMethodAddres=class
public
//Compile time binding method
procedure Method;
end;

procedure TMethodAddres.Method;
begin
//Compile time binding method
asm
mov eax,[ebp+04];
add eax,[eax-4]; //Now in eax the Entry point of this method
end;
end;

But there is some restrictions to work this code properly. This trick is based on Method stack frame existence.
To archive this, set the optimization flag of the project to unchecked state, and the stack frames flag to checked state.
And what about virtual methods address?

May be in the next time.

Комментариев нет: