100 solve the issue of using madcodehook hook send and Recv

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.