• Hail, we're RedGuides. We want you to play six (yes, 6!) EverQuest characters at once. We have scripts and a friendly community to help, please join our playstyle and say hello! 👋
  • We've added LLM sections to our Terms & Rules and Resource Rules, for everyone's sanity & in-game safety.
    Read more
    a. Do not replace your voice with an LLM. This goes for your posts and your scripts. Drafting and editing with a tool is fine, but don't take you out of what you share.
    b. Do not replace your EQ character's voice with an LLM. We don't want scripts that speak over /ooc, /shout or other public channels. This has been an unwritten rule that's kept casino scripts off the site for decades, but we're now compelled to make it clear: keep automated communication private.

    Why Does RG Review Scripts?
    Nearly every LLM-written Lua script we see is making your character do impossible things, and rarely in a way that's beneficial to you. We've seen heavy server hammering, /target over impossible distances when /nav spawn would passively accomplish the same thing, a spawn search that fires 20+ times per second, and other pointless actions that are likely annoying GMs.

    You are welcome to use LLMs as a tool to structure, draft, and edit your work, but please read critically before hitting /lua run

Output a PVOID?

headedtomexico

New member
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:
C++:
#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

Replace the inside of your function with this:

C++:
	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;



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.
 
Output a PVOID?

Users who are viewing this thread

Back
Top
Cart