function GetEntryPoint(fName: string) : pointer;
begin
with TMemoryStream.Create do
try
LoadFromFile(fName);
dword(result) := GetModuleNtHeaders(dword(Memory)).OptionalHeader.AddressOfEntryPoint;
finally Free end;
end;
procedure SetEntryPoint(fName: string; newEntryPoint: pointer);
begin
with TMemoryStream.Create do
try
LoadFromFile(fName);
GetModuleNtHeaders(dword(Memory)).OptionalHeader.AddressOfEntryPoint := newEntryPoint;
SaveToFile(fName);
finally Free end;
end;