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++] How to get IP information from SOCKET?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Fri Apr 24, 2009 1:25 am    Post subject: [C++] How to get IP information from SOCKET? Reply with quote

Well first of all I'd like to explain im making a winsock hook, hooked send/recv functions and I can modify and see packets but I get packets from so much different IP's I want to limit them to a certain IP.

I know that sockaddr_in structure holds the ip and to get it I would do

Code:

sockaddr_in Information;

printf("IP is %s\n", inet_ntoa(Information.sin_addr));



Now how can I extract Information structure from a SOCKET?

Code:

int WINAPI custom_send(SOCKET sock, char* buf, int len, int flags)
{
   struct sockaddr_in socketClient = (struct sockaddr_in)&sock;
   printf("ip = %s\n", inet_ntoa(socketClient .sin_addr));
   ShowPacket('S',len,buf);

    return osend(sock, buf, len, flags); //detour to original send function
}


But that doesn't work and I was a fool to try it tbh.

But how is it possible? I'm making a Winsock Packet Editor Clone but with a feature WPE PRO is lacking deeply and that is filter data without overwriting bytes but append bytes.

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
sphere90
Grandmaster Cheater
Reputation: 0

Joined: 24 Jun 2006
Posts: 912

PostPosted: Fri Apr 24, 2009 1:42 am    Post subject: Reply with quote

Don't be lazy. http://msdn.microsoft.com/en-us/library/ms741394(VS.85).aspx
_________________
Give a hungry man a fish and he'll be full for a day. Teach a hungry man how to fish and he'll be full for the rest of his life.
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Fri Apr 24, 2009 2:26 am    Post subject: Reply with quote

all i got is the SOCKET pointer to work with nothing else.. I searched google heavily couldn't find any examples. Shocked
_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
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