Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 899 Bytes

readme.adoc

File metadata and controls

44 lines (31 loc) · 899 Bytes

CodeRedirect

TCodeRedirect is a class that allow to patch method defined Delphi classes or procedures.

It provide runtime patch without modifying the original source code or redistibuted libraries (.bpl, .dcu).

The class shall works in both Win32 and Win64 platform only.

Example

The example attempt to patch `CurrentYear` method in unit `System.SystUtils.pas`.
uses
  System.SysUtils,
  CodeRedirect;

function CurrentYear_Patch: Word;
begin
  Result := 1999;
end;

begin
  WriteLn('Before patch: ', CurrentYear);

  var o := TCodeRedirect.CreateWithMethod(@CurrentYear, @CurrentYear_Patch);
  WriteLn('After patch: ', CurrentYear);
  o.Free;

  WriteLn('Remove patch: ', CurrentYear);
end.

Output Result

Before patch: 2021
After patch: 1999
Remove patch: 2021