Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Creepman

#1
Diablo 3 / need help, with packet sending(diablo3)
September 12, 2011, 10:04:52 AM
hello peoples,

i made a tcp server which can send messages with send and recv in c++

int startWinsock(void);
int handling(int c);


int main(int argc, char *argv[])
{
long rc;
int s, c, cli_size;
struct sockaddr_in srv, cli;

if (argc != 2)
{
fprintf(stderr, "usage: %s port\n", argv[0]);
return 1;
}

rc=startWinsock();
if(rc!=0)
{
perror("startWinsock failed()");
return -1;
}
printf("Winsock gestartet\n");

s = socket(AF_INET, SOCK_STREAM, 0);
if (s == -1)
{
perror("socket() failed");
return 2;
}
printf("Socket erstellt\n");

memset(&srv,0,sizeof(SOCKADDR_IN));
memset(&cli,0,sizeof(SOCKADDR_IN));

srv.sin_addr.s_addr = INADDR_ANY;
srv.sin_port = htons( (unsigned short int) atol(argv[1]));
srv.sin_family = AF_INET;

if (bind(s, (SOCKADDR*)&srv, sizeof(srv)) == -1)
{
perror("bind() failed");
return 3;
}
printf("bind erstellt\n");

if (listen(s, 3) == -1)
{
perror("listen() failed");
return 4;
}
printf("listen erstellt\n");
for(;;)
{
cli_size = sizeof(cli);
c = accept(s, (SOCKADDR*)&cli, &cli_size);
if (c == -1)
{
perror("accept() failed");
return 5;
}

printf("client from %s\n", inet_ntoa(cli.sin_addr));
if (handling(c) == -1)
{
fprintf(stderr, "%s: handling() failed", argv[0]);
return -1;
}



closesocket(c);
}

return 0;
}

int startWinsock(void)
{
WSADATA wsa;
return WSAStartup(MAKEWORD(2,0),&wsa);
}


it works to send standart messages
with this function
int handling(int c)
{
char buffer[BUFFER_SIZE];
char Pstring[BUFFER_SIZE]="hello";
int bytes;

strcpy_s(buffer, Pstring);
bytes = send(c, buffer, strlen(buffer), 0);
if(bytes == -1)
return -1;
return 0;
}


but i dont know how to send this packet dump, which i got from wireshark when i log in d3
char Pstring[6]=".OOOC";

can you help me please, which functions i need to simulate the bnet packets, i only want pass to char screen :-)