猴子補丁 delphi monkey patch
https://marc.durdin.net/category/delphi/ https://marc.durdin.net/category/delphi/ procedure MonkeyPatch(OldProc, NewProc: PBYTE); var pBase, p: PBYTE; oldProtect: Cardinal; begin p := OldProc; pBase := p; // Allow writes to this small bit of the code section VirtualProtect(pBase, 5, PAGE_EXECUTE_WRITECOPY, oldProtect); // First write the long jmp instruction. p := pBase; p^ := $E9; // long jmp opcode Inc(p); PDWord(p)^ := DWORD(NewProc) - DWORD(p) - 4; // address to jump to, relative to EIP // Finally, protect that memory again now that we are finished with it VirtualProtect(pBase, 5, oldProtect, oldProtect); end; function GetUStrCatAddr: Pointer; assembler; asm lea eax, System.@UStrCat end; initialization MonkeyPatch(GetUStrCatAddr, @_UStrCatMonkey); end. delphi memory virtualprotect Effective Address Inline Assembler in Delphi (III) - Static Arrays ...