缥缈止盈
我使用以下代码:procedure PatchCode(Address: Pointer; const NewCode; Size: Integer);var OldProtect: DWORD;begin if VirtualProtect(Address, Size, PAGE_EXECUTE_READWRITE, OldProtect) then begin Move(NewCode, Address^, Size); FlushInstructionCache(GetCurrentProcess, Address, Size); VirtualProtect(Address, Size, OldProtect, @OldProtect); end;end;type PInstruction = ^TInstruction; TInstruction = packed record Opcode: Byte; Offset: Integer; end;procedure RedirectProcedure(OldAddress, NewAddress: Pointer);var NewCode: TInstruction;begin NewCode.Opcode := $E9;//jump relative NewCode.Offset := NativeInt(NewAddress)-NativeInt(OldAddress)-SizeOf(NewCode); PatchCode(OldAddress, NewCode, SizeOf(NewCode));end;您可以通过调用来实现钩子/补丁/绕行RedirectProcedure:RedirectProcedure(@LoadResourceModule, @MyLoadResourceModule);这将适用于32位代码。如果旧功能和新功能都位于同一可执行模块中,则它也适用于64位代码。否则,跳转距离可能会超出32位整数的范围。如果有人可以提供一种适用于64位地址