Register for your free account! | Forgot your password?

You last visited: Today at 18:25

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[HELP] Reading Packets

Discussion on [HELP] Reading Packets within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old   #1
 
Isoline*'s Avatar
 
elite*gold: 0
Join Date: May 2006
Posts: 667
Received Thanks: 345
[HELP] Reading Packets

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.
Isoline* is offline  
Old 09/22/2015, 18:41   #2
 
elite*gold: 0
Join Date: Feb 2008
Posts: 961
Received Thanks: 648
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..
magicanoo is offline  
Old 09/22/2015, 18:53   #3
 
Isoline*'s Avatar
 
elite*gold: 0
Join Date: May 2006
Posts: 667
Received Thanks: 345
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.
Isoline* is offline  
Old 09/22/2015, 19:37   #4

 
sarkoplata's Avatar
 
elite*gold: 166
Join Date: Apr 2009
Posts: 2,339
Received Thanks: 2,654
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();
}
sarkoplata is offline  
Old 09/22/2015, 20:29   #5
 
Isoline*'s Avatar
 
elite*gold: 0
Join Date: May 2006
Posts: 667
Received Thanks: 345
Cool

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.
Isoline* is offline  
Old 09/22/2015, 22:00   #6
 
elite*gold: 0
Join Date: Feb 2009
Posts: 43
Received Thanks: 5
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 ?
theking200051 is offline  
Old 09/22/2015, 22:01   #7

 
sarkoplata's Avatar
 
elite*gold: 166
Join Date: Apr 2009
Posts: 2,339
Received Thanks: 2,654
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.
sarkoplata is offline  
Old 09/22/2015, 22:03   #8
 
Isoline*'s Avatar
 
elite*gold: 0
Join Date: May 2006
Posts: 667
Received Thanks: 345
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
Isoline* is offline  
Reply


Similar Threads Similar Threads
[Release] +5500 Packets structure , client/packets constants
10/07/2012 - CO2 PServer Guides & Releases - 10 Replies
edit : if u know nothing about packets go to this post first explaining what is packets , and explaining a packet with details and everything http://www.elitepvpers.com/forum/co2-pserver-disc ussions-questions/2162344-packets-packets-packets. html#post19074533 i start making my very own packet structure to use them on my new proxy but i thought of ripping them from the source so yeah the following packets is ripped of trinity base source right now im just providing the packets structure...
[Packets] Wie änder ich flyff packets?
07/16/2011 - Flyff Private Server - 19 Replies
HeyHo, Ich würde sehr gerne wissen wie man die Flyff Packets ändert... ich denke mal Zahlen ändern werden nicht ausreichen oder?
[Question] Reading Game Server Packets
08/16/2009 - CO2 Programming - 12 Replies
What is the packet structure of the FIRST packet sent from the game server to the client? I'm referring to the packet that is sent before receiving the client's handshake and that includes a random key used by the client to decrypt future packets. Ultimately this information will be used to find out the structure of the individual packets that the server sends. Any help is appreciated.



All times are GMT +2. The time now is 18:25.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.