Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#18

Re: Globaler API-Hook funktioniert nicht

  Alt 17. Mai 2008, 12:28
Hi brechi,

Ok ich habe es mal so gemacht:

Delphi-Quellcode:
procedure NextHook;
asm
  nop
  nop
  nop
  nop
  nop
  add FindNextOld,5
  call FindNextOld
end;

procedure FindNextHooked;
asm
  push [esp+8] // Sonst kommen die falschen parameter in FindNextOld an
  push [esp+8] // ...
  call nexthook
  sub FindNextOld,5
  ret
end;
mein TestCode sieht so aus:

Delphi-Quellcode:
procedure TForm1.Button3Click(Sender: TObject);
var sr: TSearchRec;
begin
  FindFirst('C:\*.*',faAnyFile,sr);
  FindNext(sr);
end;
FindNext sieht so aus:

Delphi-Quellcode:
push ebx
mov ebx,eax
lea eax,[ebx+$18]
push eax
mov eax,[ebx+$14]
push eax
call FindNextFile // <--- springt zu FindNextFileA, ist gehooked
// hier macht er weiter wenn das ret aus FindNextHooked aufgerufen wird
test eax,eax
jz +$09
mov eax,ebx
call FindMatchingFile
pop ebx
ret // <--- hier,
call GetLastError
pop ebx
ret // oder hier müsste er wieder in Button3Click springen, er springt aber (soweit ich das beurteilen kann) irgendwo in die pampa
... und das gibt dann eine AV.

Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat