[fpc-devel] Quick question on VMT / writeable or protected memory

Jonas Maebe jonas at freepascal.org
Wed Apr 14 18:33:31 CEST 2021


On 14/04/2021 17:49, Alfred via fpc-devel wrote:
> The mORMot[1] sources could give you some info.
> During runtime, it patches the exe-memory to redirect function calls.
> Hard part was to get around the W^X memory protection on some BSD's.
> 
> Look at:
> 
> procedure PatchCode(Old,New: pointer; Size: integer; Backup: pointer;
> inside SynCommons.pas
> 
> function TInterfaceFactory.GetMethodsVirtualTable: pointer;
> inside mORMot.pas

Please don't use that kind of hacks. It also breaks in case WPO is used
and some calls get devirtualised at compile time.


Jonas


More information about the fpc-devel mailing list