What's new

Solved Finding IP Address from Socket

  • Thread starter Fire30
  • Start date
  • Views 596
Fire30

Fire30

Seasoned Member
Messages
7,222
Reaction score
2,364
Hey so I am trying to find the ip address of a server that a game I am reversing connects to. I thought that the easiest way would be to use the XNetInAddrToXnAddr function, but I believe that I am passing the wrong parameters.

I am getting the warning [XNET] Warning: XNetInAddrToXnAddr failed: 10022

Anyways this is basically what I am doing and the above warning prints out.

C:
//assume that there is a socket declared as s that is connected
sockaddr client_info = {0};
sockaddr server_address = {0};
XNADDR xn;
int namelen = sizeof(client_info);
getpeername(s, &server_address, &namelen);
sockaddr_in *addr = ((sockaddr_in *)&server_address);
//The call below throws the warning
XNetInAddrToXnAddr(addr->sin_addr,&xn,NULL);
//This will print out IP = 0
DbgPrint("IP = %u\n",xn.ina);

I am just wondering if there is something wrong with the code or if there is a better way to do this.

Thanks for the help.
 
Top Bottom