HookUnit.pas
function PatchAddress(OldFunc, NewFunc: Pointer): integer;
var
BeenDone: TList;
function PatchAddressInModule(hModule: THandle; OldFunc, NewFunc: Pointer): integer;
var
Dos: PImageDosHeader;
NT: PImageNTHeaders;
ImportDesc: PImage_Import_Entry;
rva: DWORD;
Func: PPointer;
DLL: LPCSTR;
f: Pointer;
written: Size_T;
begin
Result := 0;
Dos := Pointer(hModule);
if BeenDone.IndexOf(Dos) >= 0 then Exit;
BeenDone.Add(Dos);
OldFunc := FinalFunctionAddress(OldFunc);
if IsBadReadPtr(Dos, SizeOf(TImageDosHeader)) then Exit;
if Dos.e_magic <> IMAGE_DOS_SIGNATURE then Exit;
NT := Pointer(integer(Dos) + dos._lfanew);
// if IsBadReadPtr(NT,SizeOf(TImageNtHeaders)) then exit;
RVA := NT^.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
{------------------------------------------------------------------------}
{ unter 64 bit NVA ist immer 0 ! Und hier kommt die function nicht weiter}
{------------------------------------------------------------------------}
if RVA = 0 then Exit; { Hier endet die funktion immer }
{------------------------------------------------------------------------}
ImportDesc := Pointer(integer(Dos) + RVA);
...