Skip to content

Delphi runtime patch without modifying source code or runtime libraries files

Notifications You must be signed in to change notification settings

eStreamSoftware/CodeRedirect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

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

About

Delphi runtime patch without modifying source code or runtime libraries files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages