#include "main.h" //The processing must return 0 to continue packet capturing //Any negative value will end capturing, negative values below ERROR_THERSHOLD are //errors within the packet capturing system. int packetcount=0; int NormalPacketDump(DATA *d) { char file[300]; strcpy(file,"Dump"); strcat(file,"/"); //Construct the filename char pc[20]; sprintf(pc,"%d-~-",packetcount); strcat(file,pc); if(d->encrypted) { strcat(file,"From Server-~-"); } else { strcat(file,"From Client-~-"); } char ds[60]; sprintf(ds,"%db -~- %dms",d->dataSize,d->timeSinceLastPck); strcat(file,ds); strcat(file,".gwd"); //Output the file std::ofstream fout(file,std::ios::binary); fout.write((char*)d->data,d->dataSize); fout.close(); //Make sure the file was written std::ifstream fin(file,std::ios::binary); if(fin.fail()) { char mess[300]; sprintf(mess,"Could not write packet dump file: %s",file); MessageBox(0,mess,"Fatal Error", MB_OK | MB_ICONSTOP); return -99999; } fin.close(); packetcount++; return 0; } int NormalPacketDump2(DATA *d) { char file[300]; strcpy(file,"Dump"); strcat(file,"/"); //Construct the filename char pc[20]; sprintf(pc,"%d-~-",packetcount); strcat(file,pc); if(d->encrypted) { strcat(file,"From Server-~-"); } else { strcat(file,"From Client-~-"); } char ds[20]; sprintf(ds,"%db",d->dataSize); strcat(file,ds); strcat(file,".gwd"); //Output the file std::ofstream fout(file,std::ios::binary); fout.write((char*)d->data,d->dataSize); fout.close(); file[strlen(file)-1]='k'; fout.open(file,std::ios::binary); fout.write((char*)d->key,264); fout.close(); //Make sure the file was written std::ifstream fin(file,std::ios::binary); if(fin.fail()) { char mess[300]; sprintf(mess,"Could not write packet dump file: %s",file); MessageBox(0,mess,"Fatal Error", MB_OK | MB_ICONSTOP); return -99999; } fin.close(); packetcount++; return 0; }