Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 85

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 85

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Reading packets
Results 1 to 5 of 5

Thread: Reading packets

  1. #1

    Reading packets

    Hello, I've been trying to read packets from the server directly from the memory, I saw some project in here made by klusbert if I'm not wrong, where it was reading the "Incoming Data" address.

    Anyway, I got it working good, it is reading the loot messages packets from the address ok, the problem is when my internet freezes a little bit(or a lot) I saw that it was missing some messages, after some tests watching a TibiaCast record in the "speed 15", I saw that happening too, so I confirmed that the problem is the speed to read the specific address, looks like the packets overrite the address too fast, so I lose some "blocks" of the server log.

    Since my "packet reader" has no delay in a while loop, there is no way to improve its speed I guess, I'm almost sure that it's not the speed it reads, but the speed tibia writes to the address, idk, I still noob in that part yet, so I was thinking, there is a way to hook the "recv" address to not miss anything? I don't want to use a proxy or something related to that, cuz I want to avoid get a debug in my tibia client with a simple program, I just want to find a way to improve this kind of read.

    This is a simple code about it:

    PHP Code:
    private void Reader()
            {
                while (
    true)
                {
                        try
                        {
                             
    ParsePacket(Data());
                        }
                        catch { }

                        
    Thread.Sleep(1);
                }
            }

    private 
    void ParsePacket(byte[] data)
            {
                
    //From TibiaAPI
                
    NetworkMessage msg = new NetworkMessage(data);
                
    msg.Position 8;//point directly to the packet type

                
    while (msg.Position <= msg.Data.Length)
                {
                    
    Enums.IncomingPacketType type = (Enums.IncomingPacketType)msg.GetByte(); //Get the packet type

                    
    if (type != 0)
                    {
                        switch (
    type)
                        {
                            case 
    Enums.IncomingPacketType.TextMessage:
                                
    GetMessage(msg);
                                break;
                            case default:
                                break;
                        }
                    }
                }
            }

    private 
    void GetMessage(NetworkMessage msg)
            {
                try
                {
                    
    byte type msg.GetByte();
                    if (
    type == 0x1F//Loot message
                    
    {
                        
    string message msg.GetString();
                        
    Console.WriteLine(message);
                    }
                }
                catch { }
            } 

  2. #2
    Super Moderator klusbert's Avatar
    Join Date
    Dec 2007
    Posts
    1,201
    I am not sure how you settup the reading of packets, I am using a codecave that freezes tibias thread when It recives a packet.

    I hook Getnextpacket function to my codecave, and when my cave is called It let my program know. Than I can read the full packet and resume to thread.

    This methód should not miss any packets.
    Check out here: https://github.com/klusbert/MemorySc...cketListner.cs
    How to find battlelist address --> http://tpforums.org/forum/thread-8146.html
    Updating addresses --> http://tpforums.org/forum/thread-8625.html
    DataReader --> http://tpforums.org/forum/thread-10387.html

  3. #3
    Thanks for you answer klusbert, but its too advanced for me, I have no idea how to update that system in case of tibia update, also I would like to avoid "write" to tibia memory for now, since a small mistake can fuckup everything.

  4. #4
    Super Moderator klusbert's Avatar
    Join Date
    Dec 2007
    Posts
    1,201
    you will need 2 addresses only.

    And reading packets your way can't ever be 100% acurate. thats my opinion
    How to find battlelist address --> http://tpforums.org/forum/thread-8146.html
    Updating addresses --> http://tpforums.org/forum/thread-8625.html
    DataReader --> http://tpforums.org/forum/thread-10387.html

  5. #5
    Quote Originally Posted by klusbert View Post
    you will need 2 addresses only.

    And reading packets your way can't ever be 100% acurate. thats my opinion
    Yeah, that's what I tought, well, I'm gonna wait a little bit to see if I get any other ideas, and also study your code xD

    Thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •