100 solve the problem of madcodehook hook send and Recv. Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiAPI/html/delphi_20061124075201178.html
Currently, the hook window can be normally called out, but the packets cannot be recorded ....
All Code As follows ....
I have also tried hookapi ('wsock32. dll ....
Unit mainunit;
Interface
Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs;
Type
Tfrmmain = Class (tform)
Procedure formcreate (Sender: tobject );
Private
Public
End;
VaR
Frmmain: tfrmmain;
Function hookin (bhook: Boolean): longint; stdcall; External 'hook. dll ';
Implementation
{$ R *. DFM}
Procedure tfrmmain. formcreate (Sender: tobject );
Begin
Hookin (true );
End;
End.
--------------------------------------------------------------------------
Library hook;
Uses
Windows,
Winsock2,
Messages,
Sysutils,
Madcodehook,
Frmunit in 'frmunit. pa' {frm };
Type
Tsock = function (s: tsocket; var Buf; Len, flags: integer): integer; stdcall;
VaR
Oldsend, oldrecv: tsock;
Hmeshwnd: hwnd;
Function pchartohex (BUF: pchar; Len: integer): string;
VaR
I: integer;
Begin
For I: = 0 to Len-1 do
Result: = Result + inttohex (ord (BUF [I]), 2) + '';
End;
Function mysend (S: tsocket; var Buf; Len, flags: integer): integer; stdcall;
Begin
FRM. Logs. lines. Add ('send: '+ pchartohex (@ Buf, Len ));
Result: = oldsend (S, Buf, Len, flags );
End;
Function myrecv (S: tsocket; var Buf; Len, flags: integer): integer; stdcall;
Begin
Result: = oldrecv (S, Buf, Len, flags );
FRM. Logs. lines. Add ('reav: '+ pchartohex (@ Buf, Len ));
End;
Function meshook (ncode: integer; wparam: wparam; lparam: lparam): lresult; stdcall;
VaR
MSG: PMSG;
// TID: DWORD;
Begin
If (ncode = hc_action) then begin
If (getmodulehandlea(' I %e.exe ')> 0) then begin
MSG: = PMSG (lparam );
Case MSG. Message
Wm_keyup: Case msg. wparam
Vk_f12: Begin
If (FRM = nil) then begin
FRM: = tfrm. Create (NiL );
Hookapi ('ws2 _ 32. dll ', 'send', @ mysend, @ oldsend );
Hookapi ('ws2 _ 32. dll ', 'recv', @ myrecv, @ oldrecv );
// Hookcode (@ send, @ mysend, @ oldsend );
// Hookcode (@ Recv, @ myrecv, @ oldrecv );
End;
FRM. show;
End;
End; // case msg. wparam
End; // case MSG. Message
End; // If getmodulehandlea
End; // If ncode
Result: = callnexthookex (hmeshwnd, ncode, wparam, lparam );
End;
Function hookin (bhook: Boolean): longint; stdcall;
Begin
If bhook then begin
Hmeshwnd: = setwindowshookex (wh_getmessage, @ meshook, hinstance, 0 );
End else begin
If (hmeshwnd <> 0) Then unhookwindowshookex (hmeshwnd );
Hmeshwnd: = 0;
End;
Result: = hmeshwnd;
End;
{$ R *. Res}
Exports
Hookin;
Begin
End.
--------------------------------------------------------------------------
It's not going to work for one night...
Cainiao, I want to go to bed first... 55555
I already know the problem... it is because there is no madchook. dll file...