- Joined
- Jul 11, 2006
- Messages
- 188
- Reaction score
- 185
Well I was playing with c++ and packets of MuOnline
But i have some troubles when trying to copy the memory of the structure to the buffer
example:
this is the packet data:
on the packet builder i have this code:
at this point, the buffer will store C1 05 80 FF 1C E8 ... and its wrong
it must be C1 05 80 1C E8
unsigned chars have length of 1 byte on memory
unsigned shorts have length of 2 bytes
so that structure must be size 3
and i dont know why that structure have size of 4
after some time i found some protocol files of mu, writed by someone named Evolver (i think)
and the code of on file is:
i think this PDMC fix my problem, but i dont have de #define of it
this PDMC, is a Packet Dynamic Cast (i see this in the readme file)
and i dont know de definition of this _PDMC, and how it works, i googled everything, dynamic casting, c++ casting, c++ memory structure, everything and i still dont know how to make the size correct.
sorry about my english, i dont like translators, i do my best hah :eek6:
But i have some troubles when trying to copy the memory of the structure to the buffer
example:
this is the packet data:
Code:
struct Packet01
{
unsigned char op1;
unsigned short op2;
};
on the packet builder i have this code:
Code:
Packet01 PacketInfo;
PacketInfo.op1 = 128;
PacketInfo.op2 = htons(7400);
unsigned char buff[255];
buff[0] = 0xC1;
buff[1] = 0x05;
memcpy(&buff[2], &PacketInfo, sizeof(Packet01));
at this point, the buffer will store C1 05 80 FF 1C E8 ... and its wrong
it must be C1 05 80 1C E8
unsigned chars have length of 1 byte on memory
unsigned shorts have length of 2 bytes
so that structure must be size 3
and i dont know why that structure have size of 4
after some time i found some protocol files of mu, writed by someone named Evolver (i think)
and the code of on file is:
Code:
struct _OP30
{
unsigned char op;
_PDMC(npc_id, 2, unsigned short);
};
i think this PDMC fix my problem, but i dont have de #define of it
this PDMC, is a Packet Dynamic Cast (i see this in the readme file)
and i dont know de definition of this _PDMC, and how it works, i googled everything, dynamic casting, c++ casting, c++ memory structure, everything and i still dont know how to make the size correct.
sorry about my english, i dont like translators, i do my best hah :eek6:

