[HELP] Reading Packets

09/22/2015 17:53 Isoline*#1
well, i always had difficulties while trying to read packets.
for example:
Code:
0x704C
0000000000           1D EC 11
how can i read it? ReadUint8()...
should i read each part indvidualy, 1d or ec or 11...?
how does it work? cuas everytime i try to read them with the readfunction it cuases the client to disconnect.
would be happy if someone will explain about this once and for all.
09/22/2015 18:41 magicanoo#2
1D = 1 byte => use ReadUInt8() to read. (in this case, this represents the slot number)
EC11 = 2 bytes => use ReadUInt16() to read. (in thie case, this represents the used item type)
and so on..
09/22/2015 18:53 Isoline*#3
Quote:
Originally Posted by magicanoo View Post
1D = 1 byte => use ReadUInt8() to read. (in this case, this represents the slot number)
EC11 = 2 bytes => use ReadUInt16() to read. (in thie case, this represents the used item type)
and so on..
Code:
                                else  if (_pck.Opcode == 0x704C)//item usage.
                                {
                                    short firstbyte = _pck.ReadUInt8();
                                    ushort secondbyte = _pck.ReadUInt16();
                                    uint thirdbyte = _pck.ReadUInt32();
sadly, when i use the item, char getting dced again.
09/22/2015 19:37 sarkoplata#4
Quote:
Originally Posted by eitai123 View Post
Code:
                                else  if (_pck.Opcode == 0x704C)//item usage.
                                {
                                    short firstbyte = _pck.ReadUInt8();
                                    ushort secondbyte = _pck.ReadUInt16();
                                    uint thirdbyte = _pck.ReadUInt32();
sadly, when i use the item, char getting dced again.
Because you are reading 7 BYTES total (uint8 + uint16 + uint32) when there are only 3 bytes in the packet. Your proxy can't read through the end of stream therefore throws an exception, your connection is lost and thus you get DC.

this should work;
Code:
else  if (_pck.Opcode == 0x704C)//item usage.
{
        byte slot = _pck.ReadUInt8();
         short itemtype = _pck.ReadUInt16();
}
09/22/2015 20:29 Isoline*#5
Quote:
Originally Posted by sarkoplata View Post
Because you are reading 7 BYTES total (uint8 + uint16 + uint32) when there are only 3 bytes in the packet. Your proxy can't read through the end of stream therefore throws an exception, your connection is lost and thus you get DC.

this should work;
Code:
else  if (_pck.Opcode == 0x704C)//item usage.
{
        byte slot = _pck.ReadUInt8();
         short itemtype = _pck.ReadUInt16();
}
actually it doesnt work either :S
so by what ur saying this should work as well:
HTML Code:
byte slot1 = _pck.ReadUInt8();
byte slot2 = _pck.ReadUInt8();
byte slot3 = _pck.ReadUInt8();
//edit:

here is the strangest thing:
Code:
                                if (_pck.Opcode == 0x704C)//item usage.
                                {
                                    int count = packet_bytes.Length;
                                    for (int x = 0; x < count; ++x)
                                    {
                                        byte first = _pck.ReadUInt8();
                                        Console.WriteLine(first); 
                                    }

                                }
made this littile loop so the packet reads itself until the max bytes length is reached, this way it will print all the data from the packet, but here is the strange part, it seems like it gets stuck after reading the first byte, it never goes beyond it even though the packet contains 3/4 bytes.
09/22/2015 22:00 theking200051#6
As i know 0x704c is send by the client if u want to use any thing in your inventory like HP or MP or Return scrolls and its structure is :-
0x704c
1D item position
EC 11 the item ID

so the question is this packet is Client to server side so u want your proxy to read it when the client send it? or u working in a little bot tool so u want to send it by the tool ?
09/22/2015 22:01 sarkoplata#7
Yeah, this should also work:
Code:
byte slot1 = _pck.ReadUInt8();
byte slot2 = _pck.ReadUInt8();
byte slot3 = _pck.ReadUInt8();
I can't know whats the problem with these amount of information. Maybe it's a problem of your overall proxy. Or maybe you're not relaying the packet to the client/server after you read it.
09/22/2015 22:03 Isoline*#8
Quote:
Originally Posted by sarkoplata View Post
Yeah, this should also work:
Code:
byte slot1 = _pck.ReadUInt8();
byte slot2 = _pck.ReadUInt8();
byte slot3 = _pck.ReadUInt8();
I can't know whats the problem with these amount of information. Maybe it's a problem of your overall proxy. Or maybe you're not relaying the packet to the client/server after you read it.
deleted as irrelevenacy occur