codehook.pas代码在IDE中运行正常,直接运行生成的exe就错误是什么问题???
//全部代码: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;