读书人

codehook.pas代码在IDE中运行正常直

发布时间: 2012-02-16 21:30:36 作者: rapoo

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

Delphi(Pascal) code
//全部代码:http://read.pudn.com/downloads138/sourcecode/internet/browser/592800/CodeHook.pas__.htmfunction 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

读书人网 >.NET

热点推荐