caion90 Posted December 21, 2011 Report Share Posted December 21, 2011 library Hook; uses SysUtils, Windows, afxcodehook, winsock2, Classes; var o_recv: function( const s: TSocket; var Buf; len, flags: Integer ): Integer; stdcall; o_send: function( const s: TSocket; var Buf; len, flags: Integer ): Integer; stdcall; dwThreadID: Cardinal = 0; function fwrite(fname: string; var buf; len: integer):bool; var fhandle: hwnd; w,fsize: cardinal; begin result := false; fhandle := createfile(pchar(fname), GENERIC_WRITE, 0, nil, OPEN_ALWAYS, 0, 0); if fhandle = INVALID_HANDLE_VALUE then exit; fsize := GetFileSize(fhandle, nil); SetFilePointer(fhandle, fsize, nil, FILE_BEGIN); result := WriteFile(fhandle, buf, len, w, nil); end; function n_send( const s: TSocket; var Buf; len, flags: Integer ): Integer; stdcall; begin result := -1; //fwrite('c:\teste\send.txt', buf, len); //result := o_send(s, buf, len, flags); // <--- o_send (erro) end; function n_recv( const s: TSocket; var Buf; len, flags: Integer ): Integer; stdcall; begin result := -1; //result := o_recv(s, buf, len, flags); //fwrite('c:\teste\recv.txt', buf, len); // <---- o_recv (erro) end; procedure HookThread; begin while GetModuleHandle('Ws2_32.dll') = 0 do Sleep(10); HookCode(GetProcAddress(GetModuleHandle('Ws2_32.dll'), 'recv'), @n_recv, @o_recv); HookCode(GetProcAddress(GetModuleHandle('Ws2_32.dll'), 'send'), @n_send, @o_send); end; procedure DllMain(fdwReason: Cardinal); begin case fdwReason of DLL_PROCESS_ATTACH: begin CreateThread(nil, 0, @HookThread, nil, 0, dwThreadID); end; DLL_PROCESS_DETACH: begin //Code end; end; end; begin DllProc := @DllMain; DllMain(DLL_PROCESS_ATTACH); end.então, o erro é justo quando vou pegar e fazer a chamada pra api normal do windows... alguém se habilita a me ajudar? ;) Quote Link to comment Share on other sites More sharing options...
0 Jhonas Posted December 31, 2011 Report Share Posted December 31, 2011 o erro é justo quando vou pegar e fazer a chamada pra api normal do windowse qual é o erro ? sempre coloque o erro como ele aparece na sua telaabraço Quote Link to comment Share on other sites More sharing options...
Question
caion90
então, o erro é justo quando vou pegar e fazer a chamada pra api normal do windows... alguém se habilita a me ajudar? ;)
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.