Einzelnen Beitrag anzeigen

WorstNightmare

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

HookHop von PostMessage geht nicht

  Alt 16. Jun 2010, 18:11
Hallo,

ich versuche jetzt seit einer Stunde einen Hook von PostMessage zu umgehen.
Dazu teste ich erstmal am Editor:

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;
begin
  asm
    push ebp
    mov ebp, esp
    jmp dword ptr ds:[PostMessageReal]
  end;

  Result := True;
end;

procedure TForm1.ToolButton1Click(Sender: TObject);
var
  wnd: hwnd;
begin
  wnd := FindWindowEx(hauptwnd, 0, 'Edit', '');
  _PostMessage(Wnd, WM_CHAR, Ord('A'), 0);
end;
Es kommt immer: Externe Exception C000001E.
In C++ scheint dieser Code zu laufen, muss ich in Delphi dabei was besonderes beachten?

Code:
DWORD _PMA = (DWORD)GetProcAddress(LoadLibrary("user32.dll"), "PostMessageA") + 5;

__declspec(naked) BOOL WINAPI _PostMessageA(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    __asm
    {
        push  ebp
        mov   ebp, esp
        jmp   dword ptr ds:[_PMA]
   }
   return 0;
}

Geändert von WorstNightmare (16. Jun 2010 um 18:13 Uhr)
  Mit Zitat antworten Zitat