 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Mon Jan 12, 2009 4:27 pm Post subject: Hooking SendTo |
|
|
Hi,
I have a few problems. I am trying to hook the ingame SendTo function ( not ws2_32.dll) . This is the function ( IDA pro) :
| Code: |
int __cdecl sub_474B1D(SOCKET s,char *buf,int len,int flags,u_long hostlong,__int16); |
This is my hook:
| Code: |
int (__cdecl *SendTo_o)(SOCKET s, char *buf, int len, int flags, unsigned long hostlong,__int16);
int __cdecl SendTo_t(SOCKET s,char *buf,int len,int flags,unsigned long hostlong,__int16)
{
MessageBoxA(NULL, "SendTO is called!", "info", MB_OK);
return SendTo_o(SOCKET s, char *buf, int len, int flags, unsigned long hostlong,__int16);
}
SendTo_o = (int (__cdecl *)(SOCKET,char *,int,int,unsigned long,short))DetourFunction((PBYTE)0x00474B1D,(PBYTE)SendTo_t);
|
Now is my first question:
1. How can i put the bytes that get send, into a .txt file?
You can just read the buf and the bytes are in there i think, but how to log them?
2. I get a compile error: error C2275: 'SOCKET' : illegal use of this type as an expression, cant really figure out how to fix it...
All my other hooks worked.
(I hooked IsDebuggerPresent, GetModuleFileNameA, RPM, for anti anticheat.) |
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Mon Jan 12, 2009 4:33 pm Post subject: |
|
|
| sprintf the bytes into a char buffer. |
|
| Back to top |
|
 |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Mon Jan 12, 2009 6:42 pm Post subject: |
|
|
Add this to the beginning of your header file:
| Code: |
#include <winsock2.h>
|
Also, even if you do manage to hook the API, it will crash because you screwed up the calling convention. winsock2.h defines ws2_32.dll APIs as WSAPI. |
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Mon Jan 12, 2009 10:05 pm Post subject: Re: Hooking SendTo |
|
|
| blackmorpheus wrote: | Hi,
I have a few problems. I am trying to hook the ingame SendTo function ( not ws2_32.dll) . This is the function ( IDA pro) :
| Code: |
int __cdecl sub_474B1D(SOCKET s,char *buf,int len,int flags,u_long hostlong,__int16); |
This is my hook:
| Code: |
int (__cdecl *SendTo_o)(SOCKET s, char *buf, int len, int flags, unsigned long hostlong,__int16);
int __cdecl SendTo_t(SOCKET s,char *buf,int len,int flags,unsigned long hostlong,__int16)
{
MessageBoxA(NULL, "SendTO is called!", "info", MB_OK);
return SendTo_o(SOCKET s, char *buf, int len, int flags, unsigned long hostlong,__int16);
}
SendTo_o = (int (__cdecl *)(SOCKET,char *,int,int,unsigned long,short))DetourFunction((PBYTE)0x00474B1D,(PBYTE)SendTo_t);
|
Now is my first question:
1. How can i put the bytes that get send, into a .txt file?
You can just read the buf and the bytes are in there i think, but how to log them?
2. I get a compile error: error C2275: 'SOCKET' : illegal use of this type as an expression, cant really figure out how to fix it...
All my other hooks worked.
(I hooked IsDebuggerPresent, GetModuleFileNameA, RPM, for anti anticheat.) |
just WriteFile buf to a text file.
CreateFile(Create new if not existant)
WriteFile(buf) _________________
|
|
| Back to top |
|
 |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Tue Jan 13, 2009 3:52 am Post subject: |
|
|
| rapion124 wrote: | Add this to the beginning of your header file:
| Code: |
#include <winsock2.h>
|
Also, even if you do manage to hook the API, it will crash because you screwed up the calling convention. winsock2.h defines ws2_32.dll APIs as WSAPI. |
I told you, it's not a ws2_32.dll function... It's an ingame function.
And if I add winsock2.h , it creates a shitload of errors, all redefinitions from original winsock.h.. Don't know why :O |
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Tue Jan 13, 2009 6:12 am Post subject: |
|
|
| blackmorpheus wrote: | | rapion124 wrote: | Add this to the beginning of your header file:
| Code: |
#include <winsock2.h>
|
Also, even if you do manage to hook the API, it will crash because you screwed up the calling convention. winsock2.h defines ws2_32.dll APIs as WSAPI. |
I told you, it's not a ws2_32.dll function... It's an ingame function.
And if I add winsock2.h , it creates a shitload of errors, all redefinitions from original winsock.h.. Don't know why :O |
Is this all of the code where an instance of SOCKET is used?
Also make sure the source is .cpp not .c. apparently it doesn't work as a C file _________________
|
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Tue Jan 13, 2009 6:41 am Post subject: |
|
|
| Put winsock2.h above windows.h in the list. |
|
| Back to top |
|
 |
|
|
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
|
|