L'unità FastCodePatch.pas funziona con la piattaforma Win32. Delphi XE2 supporta la piattaforma Win64, qualche idea su come far funzionare FastCodePatch nella piattaforma Win64?Come far funzionare FastCodePatch nella piattaforma Delphi XE2 Win64?
unit FastcodePatch;
interface
function FastcodeGetAddress(AStub: Pointer): Pointer;
procedure FastcodeAddressPatch(const ASource, ADestination: Pointer);
implementation
uses
Windows;
type
PJump = ^TJump;
TJump = packed record
OpCode: Byte;
Distance: Pointer;
end;
function FastcodeGetAddress(AStub: Pointer): Pointer;
begin
if PBYTE(AStub)^ = $E8 then
begin
Inc(Integer(AStub));
Result := Pointer(Integer(AStub) + SizeOf(Pointer) + PInteger(AStub)^);
end
else
Result := nil;
end;
procedure FastcodeAddressPatch(const ASource, ADestination: Pointer);
const
Size = SizeOf(TJump);
var
NewJump: PJump;
OldProtect: Cardinal;
begin
if VirtualProtect(ASource, Size, PAGE_EXECUTE_READWRITE, OldProtect) then
begin
NewJump := PJump(ASource);
NewJump.OpCode := $E9;
NewJump.Distance := Pointer(Integer(ADestination) - Integer(ASource) - 5);
FlushInstructionCache(GetCurrentProcess, ASource, SizeOf(TJump));
VirtualProtect(ASource, Size, OldProtect, @OldProtect);
end;
end;
end.
La soluzione fornita da Ville Krumlinde non funziona su 64 bit pacchetto. Funziona solo con l'applicazione .exe standalone.
Questo è in realtà la risposta a una domanda diversa. Ville ha risposto alla tua domanda originale.Il patching delle funzioni nei pacchetti è un gioco diverso.Il codice che presenti è necessario anche su target a 32 bit. –
Great code ! Confermo che funziona perfettamente con 'Delphi 10.1' (Berlin) con' Windows 7' a 32/64 bit, anche con 'DEP' abilitato. –