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++] Intercept send hook

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
spyware293
Newbie cheater
Reputation: 0

Joined: 28 Jun 2012
Posts: 13

PostPosted: Thu Jun 28, 2012 11:17 am    Post subject: [C++] Intercept send hook Reply with quote

i create a dll that hook to send() function of a game client. now im able to log the packets, but i want to know how to change what my client send. (e.g if client send A then output is send C, if client send D then output is send B) btw, im using detours
Back to top
View user's profile Send private message Yahoo Messenger
Innovation
Grandmaster Cheater
Reputation: 12

Joined: 14 Aug 2008
Posts: 617

PostPosted: Thu Jun 28, 2012 12:15 pm    Post subject: Reply with quote

What's your code?
Back to top
View user's profile Send private message
spyware293
Newbie cheater
Reputation: 0

Joined: 28 Jun 2012
Posts: 13

PostPosted: Thu Jun 28, 2012 12:48 pm    Post subject: Reply with quote

Code:
#pragma comment(lib, "Ws2_32.lib")

#undef UNICODE

typedef int (WINAPI *SendPtr)(SOCKET s, const char* buf, int len, int flags);
HMODULE hLib = LoadLibrary("ws2_32.dll");
SendPtr pSend = (SendPtr)GetProcAddress(hLib, "send");
int WINAPI MySend(SOCKET s, const char* buf, int len, int flags);

INT APIENTRY DllMain(HMODULE hDLL, DWORD Reason, LPVOID Reserved)
{
   switch(Reason)
   {
   case DLL_PROCESS_ATTACH:
      DisableThreadLibraryCalls(hDLL);
      DetourTransactionBegin();
      DetourUpdateThread(GetCurrentThread());
      DetourAttach(&(PVOID&)pSend, MySend);
      break;
   case DLL_PROCESS_DETACH:
   case DLL_THREAD_ATTACH:
   case DLL_THREAD_DETACH:
      break;
   }
   return TRUE;
}

int WINAPI MySend(SOCKET s, const char* buf, int len, int flags)
{
   return pSend(s, buf, len, flags);
}
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25819
Location: The netherlands

PostPosted: Thu Jun 28, 2012 1:48 pm    Post subject: Reply with quote

Just do you r filter in your MySend function

e.g:
instead of
Code:

return pSend(s, buf, len, flags);


do:
Code:

  if (buf[0]==0xgg)
    buf[0]=0xhh;

  return pSend(s, buf, len, flags);

Or copy the buffer first and change that and then pass that copy to pSend instead of the original

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
spyware293
Newbie cheater
Reputation: 0

Joined: 28 Jun 2012
Posts: 13

PostPosted: Thu Jun 28, 2012 8:18 pm    Post subject: Reply with quote

i've tried this

Code:
if (buf[0]==0x01)
   {   
      buf[0]=0x02;
   MessageBox(HWND_DESKTOP,"TEST","TEST",MB_OK);
      return pSend(s, buf, len, flags);
   }
   else
      return pSend(s, buf, len, flags);


but when i tried to sent a packet which contain 01, it doesn't trigger the filter even the messagebox didn't pop up
Back to top
View user's profile Send private message Yahoo Messenger
spyware293
Newbie cheater
Reputation: 0

Joined: 28 Jun 2012
Posts: 13

PostPosted: Fri Jun 29, 2012 4:10 pm    Post subject: Reply with quote

haha thx dark byte, my problem is solved Very Happy Very Happy
Back to top
View user's profile Send private message Yahoo 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