Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] Send Hook

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Wed Feb 11, 2009 9:22 pm    Post subject: [C++] Send Hook Reply with quote

Code:
SOCKET pSocket = NULL;
DWORD Sendaddr = NULL;
DWORD SendJmp = NULL;
DWORD OldProtection;
//---------------------------------------------------------------------------
void __declspec(naked) __stdcall  SendHook()
{
   __asm
   {
            mov  edi,edi
            push ebp
            mov ebp, esp
            push [ebp+0x08]
            push [ebp+0x0C]
            call LogHandler
            jmp SendJmp
   }
}

void __stdcall LogHandler( char* buf, SOCKET sock ) { // cut rapion said so
   pSocket = sock;
   //Log buf here
   return;
}

void HookHandler( bool isHook ) {
   if( isHook ) {
      Sendaddr = (DWORD)GetProcAddress( LoadLibrary( "ws2_32.dll" ), "send" );
      SendJmp = Sendaddr + 5;
      VirtualProtect( &Sendaddr, 0x05, PAGE_READWRITE , &OldProtection );
      *(BYTE*)Sendaddr = 0xe9;
      *(int*)(Sendaddr+1) = JMP( Sendaddr, (DWORD*)SendHook );
   }
   if( !isHook ) {
      *(WORD*)Sendaddr = 0xFF8B;
      *(BYTE*)(Sendaddr+2) = 0x55;
      *(WORD*)(Sendaddrs+3) = 0xEC8B;
      VirtualProtect( &Sendaddr, 0x05, OldProtection, &OldProtection );
   }
}



Last edited by slippppppppp on Fri Feb 13, 2009 5:10 pm; edited 1 time in total
Back to top
View user's profile Send private message AIM Address MSN Messenger
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Wed Feb 11, 2009 9:39 pm    Post subject: Reply with quote

Um... what about it?
_________________
Back to top
View user's profile Send private message
AlbanainRetard
Master Cheater
Reputation: 0

Joined: 02 Nov 2008
Posts: 494
Location: Canada eh?

PostPosted: Wed Feb 11, 2009 9:41 pm    Post subject: Reply with quote

Maybe its better in a script bin?
_________________
Back to top
View user's profile Send private message Send e-mail
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Wed Feb 11, 2009 9:42 pm    Post subject: Reply with quote

Maybe some people may want to know how to hook send or just hook in general?
Back to top
View user's profile Send private message AIM Address MSN Messenger
AlbanainRetard
Master Cheater
Reputation: 0

Joined: 02 Nov 2008
Posts: 494
Location: Canada eh?

PostPosted: Wed Feb 11, 2009 9:44 pm    Post subject: Reply with quote

slippppppppp wrote:
Maybe some people may want to know how to hook send or just hook in general?


I am not attacking you, and thus will not get into a flame war.

@offtopic

There are tutorials on this.

_________________
Back to top
View user's profile Send private message Send e-mail
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Wed Feb 11, 2009 9:48 pm    Post subject: Reply with quote

I know, but most tutorials use the Detours lib, this doesnt
Back to top
View user's profile Send private message AIM Address MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Wed Feb 11, 2009 11:39 pm    Post subject: Reply with quote

... what is the point of posting this other than to say: "Oh look at what I can do!"

This isn't even a tutorial, it's a posted source sample that doesn't even have commenting. Please find some other forum to attempt to boost your ego.

[Edit: My bad, it seems there is ONE whole comment that I seem to have overlooked.]
Back to top
View user's profile Send private message
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Thu Feb 12, 2009 5:46 am    Post subject: Reply with quote

Pretty nice code actually Wink, thanks!
Back to top
View user's profile Send private message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Thu Feb 12, 2009 8:33 am    Post subject: Reply with quote

__inline plz.
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Thu Feb 12, 2009 1:34 pm    Post subject: Reply with quote

Fail. The function "LogHandler" must be __stdcall because it has to clean up the stack. Visual C++ default calling convention is __cdecl. That hook will crash as soon as Send() is called.
Back to top
View user's profile Send private message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Thu Feb 12, 2009 8:59 pm    Post subject: Reply with quote

Apparently it doesnt crash.
Back to top
View user's profile Send private message AIM Address MSN Messenger
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Fri Feb 13, 2009 1:45 pm    Post subject: Reply with quote

slippppppppp wrote:
Apparently it doesnt crash.


Then your default calling convention is set to __stdcall. If someone else's was set to something else, it would crash.
Back to top
View user's profile Send private message
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Sat Feb 14, 2009 2:21 pm    Post subject: Reply with quote

Pointless.

http://somebastardstolemyname.wordpress.com/2008/07/27/c-send-hook/

You were beat to it Slipp(add about 200 more p's).

_________________
Blog

Quote:
Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that
Back to top
View user's profile Send private message MSN Messenger
the_undead
Expert Cheater
Reputation: 1

Joined: 12 Nov 2006
Posts: 235
Location: Johannesburg, South Africa

PostPosted: Tue Jun 12, 2012 9:32 am    Post subject: Reply with quote

haha. didn't even ever realize this. oddly similar to my code. hmm.
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites