• Welcome to Valhalla Legends Archive.
 

D2GS Splitting packet problems

Started by Tejjoj, September 21, 2007, 02:28 PM

Previous topic - Next topic

Tejjoj

I have problems splitting the packets


BOOL Success = TRUE;
while(Success) {
if(*(BYTE*)&Buffer[0] != 0xAF || *(BYTE*)&Buffer[0] == 0x02) {
BYTE outdata[3000] = {0};
unsigned int Size,PacketSize,Offset,outsize;
BYTE* H1 = GamePacketSize((BYTE*)Buffer,&Size,&Offset);
DWORD H2 = GamePacketDecode((BYTE*)(Buffer + Offset), Size, (BYTE*)outdata,sizeof(outdata),&outsize);
// printf("[D2GS] Packet Size: %d Decompressed: %d\n",dwSize,outsize);
Packet_IncomeGS(outdata,outsize);

if(outsize + Offset > dwSize || Size == -1) {
Success = FALSE;
} else {
dwSize = dwSize - (outsize + Offset);
// printf("[D2GS] Compressed Size of the Packet: %d\n",Size + Offset);
Buffer = (CHAR*) Buffer + Offset + Size;
// printf("new dwSize = %d\n",dwSize);
Sleep(100);
}
}
else {
unsigned int newdwSize,PacketSize,DecompressedSize;
BYTE* Packet = GamePacketSize((BYTE*)Buffer,&newdwSize,&DecompressedSize);
// printf("[D2GS] 0xAF Packet Size: %d\n",DecompressedSize);
Packet_IncomeGS((BYTE*)Buffer,dwSize);
Buffer = (CHAR*) Buffer + dwSize;
dwSize = 0;
Sleep(100);
}
}



It doesn't split them correctly up :/