PostMessageA has the stdcall calling convention but your function _PostMessage does not!
You should declare _PostMessage as stdcall and remove the begin and end (then delphi doesn't create a stackframe):
Delphi-Quellcode:
function _PostMessage(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): BOOL;
stdcall;
asm
jmp dword ptr ds:[PostMessageReal];
mov eax, 1;
end;
end;
procedure TForm1.ToolButton1Click(Sender: TObject);
var
wnd: hwnd;
begin
wnd := FindWindowEx(hauptwnd, 0, '
Edit', '
');
_PostMessage(Wnd, WM_CHAR, Ord('
A'), 0);
end;
It's not clear to me though why you are incrementing the function pointer by 5 (or why the c code does that), also are you supposed to increment by 5 bytes or by 5 dword's ?