Einzelnen Beitrag anzeigen

WorstNightmare

Registriert seit: 6. Okt 2008
159 Beiträge
 
RAD-Studio 2010 Arc
 
#5

AW: HookHop von PostMessage geht nicht

  Alt 16. Jun 2010, 19:27
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
  u32 := LoadLibrary(user32);
  PostMessageReal := DWORD(GetProcAddress(u32, 'PostMessageA')) + 5;
end;

function _PostMessage(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): BOOL; stdcall;
asm
  jmp dword ptr ds:[PostMessageReal]
  mov eax, 0
end;

procedure TForm1.ToolButton1Click(Sender: TObject);
var
  wnd: hwnd;
begin
  wnd := FindWindowEx(hauptwnd, 0, 'Edit', '');
  _PostMessage(Wnd, WM_CHAR, Ord('A'), 0);
end;
Thanks, this works now.
I add 5 bytes, because I want to avoid calling a hook that might have been installed.
E.g. the first 5 bytes of PostMessageA could look like this:
Code:
mov edi, edi
push ebp
mov ebp, esp
These can be overwritten with a jmp which calls the redirection, which I want to avoid.

But I don't get why I can leave away the other assembler commands in Delphi.
  Mit Zitat antworten Zitat