codehook.pas代码在IDE中运行正常,直接运行生成的exe就异常是什么有关问题?

codehook.pas代码在IDE中运行正常,直接运行生成的exe就错误是什么问题???
Delphi(Pascal) code

//全部代码:http://read.pudn.com/downloads138/sourcecode/internet/browser/592800/CodeHook.pas__.htm

function HookCode(TargetModule, TargetProc: string; NewProc: pointer; var OldProc: pointer): boolean; 
var 
  Address: longword; 
  OldProtect: longword; 
  OldFunction: pointer; 
  Proc: pointer; 
  hModule: longword; 
begin 
  Result := False; 
  try 
    hModule := LoadLibrary(pchar(TargetModule)); 
    Proc := GetProcAddress(hModule, pchar(TargetProc)); 
    if byte(Proc^) = $e9 then Exit; 
    if byte(Proc^) = $ff then Exit; 
    Address := longword(NewProc) - longword(Proc) - 5; 
    VirtualProtect(Proc, 5, PAGE_EXECUTE_READWRITE, OldProtect); 
    GetMem(OldFunction, 255); 
    longword(OldFunction^) := longword(Proc); 
    byte(pointer(longword(OldFunction) + 4)^) := SaveOldFunction(Proc, pointer(longword(OldFunction) + 5)); 
    byte(pointer(Proc)^) := $e9;//这行开始错误!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    longword(pointer(longword(Proc) + 1)^) := Address; 
    VirtualProtect(Proc, 5, OldProtect, OldProtect); 
    OldProc := pointer(longword(OldFunction) + 5); 
    FreeLibrary(hModule); 
  except 
    Exit; 
  end; 
  Result := True; 
end; 




Delphi 7
IDE中运行一切正常
点击生成的exe就跳出错误如下
delphi xe2运行在哪都出错

Exception EAccessViolation in module Project1.exe at 00B32D11.
Access violation at address 00B33D11. Write of address 00B33D11.

---------------------------
Runtime error 216 at 1314335A


------解决方案--------------------
试一下这个http://download.csdn.net/detail/lactoferrin/3351392