• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

Output a PVOID?

headedtomexico

New member
Joined
Dec 9, 2008
RedCents
dealing with onsendpacket, and i want to display the Packet data. I'm pretty unfamiliar with C++, but I did do some my research before I turned to you guys =)

From what I understand PVOID is just a pointer to an address of an undetermined structure. I want to output the packet data to the EQ screen in HEX. I get how to recast the PVOID as an int or char or whatever i want to use. And I get how to load a value out of the address with something like value = *Packet. I don't get what kind of structure I would jam the data in since it can be upwards of several hundred character in the event of it being a chat command.


BOOL OnSendPacket(DWORD Type, PVOID Packet, DWORD Size)
{
blahblah pktTemp;
CHAR fmtTemp[MAX_STRING] = {0};
blah
blah
blah
sprintf(fmtTemp, "Data: %0*X", Size, pktTemp);
WriteChatColor(fmtTemp,4,0);
 
This is what I do.

Header File Includes:
[highlight=cpp]#include <string> //needed yar
#include <stdio.h> //needed for standard I/O
#include <time.h> //needed for packet timestamp
#include <sys/timeb.h> //needed for millisecond timestamp
#include <fstream> //needed for file streaming
#include <iomanip> //needed for dec to hex conversion[/highlight]

Replace the inside of your function with this:

[highlight=cpp] char tmpbuf[128], ampm[] = "AM";
_tzset();
_strtime( tmpbuf );
struct _timeb timebuffer;
char *timeline;

_ftime( &timebuffer );
timeline = ctime( & ( timebuffer.time ) );

if (Type != 4277 && Type != 28770 && Type != 3732 && Type != 4279) {
CHAR szTextBuffer[MAX_STRING];
CHAR szBuffer[MAX_STRING];
ZeroMemory(szTextBuffer,MAX_STRING);

int i = Size;

for (int j = 0; i > j; j++) {
sprintf(szBuffer,"%02X ",*(((LPBYTE)Packet) + j));
strcat(szTextBuffer,szBuffer);
}

WriteChatf("[%s.%d] %d (%d)",tmpbuf,timebuffer.millitm,Type,Size);

// Print to a log file
ofstream outfile;
outfile.open("C:\\MQ2SendPkt.csv", ios::app);
outfile << tmpbuf << "." << timebuffer.millitm << ",0x"
<< setiosflags(ios::uppercase) << hex
<< Type << dec << "," << Type << ",0x"
<< hex << Size << dec << "," << Size << "," << hex << szTextBuffer << endl;
outfile.close();
}
return true;[/highlight]



This will output the OPCODE and Packet size to your MQ2 window, while outputing verbose information to a CSV file that can be analyzed using a Microsoft Excel like program. I prefer this method because you can line up all the packet data to identify what changes.

-Alatyami
 
Last edited:
Very sexy makes perfect sence. I'm makin up a little sniffer for eqemu that displays parsed packet data, but I needed a way to dump raw hex data out when I got a packet that I don't have the struct for yet.

Thanks sir.
 
In that case I guess the csv file will help you out :D

-alatyami
 
Output a PVOID?

Users who are viewing this thread

Back
Top
Cart