Posted: Fri Apr 24, 2009 1:25 am Post subject: [C++] How to get IP information from SOCKET?
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. _________________
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