View Single Post
Old 19.06.2006, 23:21   #25
mcrabben7
Архивный участник
 
Join Date: Apr 2006
Posts: 461
Default

The code I posted already gets the packet headers for you. If you want to get a specific part of the packet, set header (I renamed it to pBuffer now) to + x bytes, depending where the data you want is. Then read a DWORD (4 bytes) worth of data and store it for your use.

Here is a packet dump function which I will share:
Code:
// Allows for the complete dump of a packet to the log file
//
// Parameters:
// DWORD * packet - the address of the start of the packet (pBuffer)
// DWORD bytes - how many bytes to dump to the log file
//
void DumpPacket(DWORD * packet, DWORD bytes)
{
	WORD temp = 0;
	DWORD * packetAddr = 0;
	packetAddr = packet;
	file << ">>>>>>>>> Packet Dump: ";
	for(unsigned int i=0; i < bytes; ++i)
	{
		temp = (BYTE)*(packetAddr);
		if(temp<16) {
			file << "0" << temp << " ";
		} else {
			file << temp << " ";
		}
		__asm { add	packetAddr, 1 }
	}
	file << "\n";
	file.flush();
}
Send it the address of the start of the packet. In my code I uploaded, send it header. I have since then renamed header to pBuffer, packet to pSocket, and changed packetStart in all functions to pSocket. Those names make more sense about what the pointer points to.

Also, here is how you access the SystemMessage functionality in L2Server. See L2J for an idea of all the possible combinations and values. It is a pretty robust packet format.

Code:
//SystemMessage
format = "cdddd";
__asm
{
	push	itemID			//itemID
	push	3				//??
	push	1				//??
	push	msgID			//system message ID
	push	0x7A			//packet header
	push	format			//packet format 'cdddd'
	push	pSocket			//pushes the address of the start of the packet
	call	fCUserSocketSend
	add		esp, 0x1C		//fix our stack pointer (7 * 0x04 = 0x1C)
}
Take careful note of how the packet format is cddd + however many parameters you give it extra. That will have to be accounted for. Like I said, see L2J for the outline of how that is structured.

Enishi: I am not sure exactly which packet handles healing. It might be an internal call to send a SystemMessage packet that will need to be hooked and changed to show the HP healed. I'm not sure on this yet. if it is a specific packet for healing, then hook it, call your own function, and write the code to handle it.
mcrabben7 is offline