I need to get the address of a Win APi method (FindWindowW
) , I'm using the @
operator and the GetProcAddress
but both returns differents results.
var
p1, p2 : Pointer;
begin
p1:= @Winapi.Windows.FindWindowW;
p2:=GetProcAddress(GetModuleHandle('user32.dll'), 'FindWindowW');
ShowMessage(Format('p1 %p p2 %p ', [p1, p2]));
end;
Why the values returned are different?
Because static linking uses a thunk jump table to call a DLL function.
p2
in your example is the correct address of the FindWindowW
function in your process, while p1
is the address of a jump instruction like this
jmp dword ptr [SomeAddress]
where SomeAddress
points to the actual address of the FindWindowW
function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With