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 6
C# - Reading Chats
Results 1 to 3 of 3

Thread: C# - Reading Chats

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    3

    C# - Reading Chats

    Hello guys, here is a function for read chat in C#
    you need GUI_POINTER address, you can get this in
    http://www.blackdtools.net/showthrea...ddresses-10-71
    "tibiachatlog_selchannel" is this.

    so, Now, the function..

    Code:
           public static uint GUI_POINTER= 0x8353A0 - 0x400000 + Kernel.Client.BaseAddress;
           public List<List<string>> readChatMessages(System.IntPtr handle, string channel)
            {
            List<string> mensagens = new List<string>();
            List<string> senders = new List<string>();
    
    		List<List<string>> ret = new List<List<string>>();
    		uint pointer;
    		bool foundChannel = false;
    
            pointer = Memory.ReadUInt32(handle, GUI_POINTER);
            if (pointer == 0)
            {
    	        return ret; // GUI Pointer is returning 0. Reasons could be that the character is not logged in.
            }
    
    		pointer = Memory.ReadUInt32(handle, pointer + 0x40);
            pointer = Memory.ReadUInt32(handle, pointer + 0x38);	
    		while (pointer > 0)
    		{
    				uint channelPointer;
    				string channelName;
                    channelPointer = Memory.ReadUInt32(handle, pointer + 0x24);
                    channelPointer = Memory.ReadUInt32(handle, channelPointer + 0x10);
                    
    
                    channelName = Memory.ReadString(handle, Memory.ReadUInt32(handle, pointer + 0x2C));
                if (string.Compare(Convert.ToString(channelName), Convert.ToString(channel)) == 0)
    				{
    						foundChannel = true;
    
    						while (channelPointer > 0)
    						{
    								/* We have found our desired channel pointer. We will retrieve all data for demonstration but only storing the actual messages */
    								string sender;
    								string message;
    								string level;
    								string time;
    								byte type;
    							    type = Memory.ReadByte(handle, channelPointer + 0x4);
                                    sender = Memory.ReadString(handle, channelPointer + 0x14);
                                    message = Memory.ReadString(handle, Memory.ReadUInt32(handle, channelPointer + 0x4C));
                                    level = Memory.ReadString(handle, channelPointer + 0x3c);
                                    time = Memory.ReadString(handle, channelPointer + 0x8);
    
    
                                    mensagens.Add(message);//aqui
                                    senders.Add(sender);
    								//ret.push_back(message); // Store the message
    
    								channelPointer = Memory.ReadUInt32(handle, channelPointer + 0x5C);
    						}
    				}
                    if (foundChannel)
                        break;
    
                    pointer = Memory.ReadUInt32(handle, pointer + 0x10);
                    
            }
            ret.Add(mensagens);
            ret.Add(senders);
            return ret;
            }
    (sorry for this identation, in my Visual studio, all is correctly)


    this function returns two lists inside of an other list..
    for use this function, i'm using like this:
    Code:
                // this functions is the name of class where is located the readChatMessages
                functions read = new functions();
    
                List<List<string>> retorno = read.readChatMessages(Client.Handle, "Local Chat");
                List<string> mensagens = retorno[0];
                List<string> senders = retorno[1];
                if (mensagens.Count != 0 && senders.Count != 0)
                {
                       //do whatever you want here
                       for(int i = 0; i < mensagens.Count; i++)
                           Console.WriteLine("sender: " + senders[i] + " - full message: " +mensagens[i]);
                }


    Credits: ottizy (he created all this functions in C++ and give it to me, so all the credits going to him! I just converted to C#.

  2. #2
    Senior Member
    Join Date
    Mar 2009
    Location
    Brazil
    Posts
    266
    Draky, thanks for posting it!

    I'm not into Pointers yet, but its nice to have this code in C#. Thanks again!

    But if you allow me, i'd like to make some comments about your C# code.

    A List<List<>> is basically a matrix, which is one of the worst programming techniques that you can use. It turns the code into a bloody mess.

    As C# allows OOP, you definately should use it to make your code faster and readable.

    Eg.:

    I've created a class called Channel which stores:
    -Name of the Channel (eg.: "Server Log")
    -A List<Message> with every message read from this Channel

    Code:
    public class Channel
        {
            public string Name { get; set; }
            public List<Message> Messages { get; set; }
        }
    On the other hand, Message class has the following properties:
    Code:
    public class Message
        {
            public Channel Channel { get; set; }
    
            public byte Type { get; set; }
    
            public string Sender { get; set; }
    
            public string Text { get; set; }
    
            public string Level { get; set; }
    
            public string Time { get; set; }
    
        }
    Finally, my ReadChannels function returns a List<Channel>, which makes it fareasier to read the channels and it's messages.

    Code:
    List<Channel> result = _client.ReadChannels();
    
    foreach (Channel _channel in result)
    {
         Console.WriteLine(String.Concat("[", _channel.Name, "]"));
     
         foreach (Message _msg in _channel.Messages)
         {
              Console.WriteLine(_msg.Text);
          }
    }
    So, if you got interested on the improvements i've made, take a look at the project attached. I've create it on Visual Studio 2010.
    Attached Files Attached Files
    Last edited by Ash Katchup; 01-03-2015 at 07:35 PM.

  3. #3
    Junior Member
    Join Date
    Nov 2014
    Posts
    2
    Quote Originally Posted by Ash Katchup View Post
    Draky, thanks for posting it!

    I'm not into Pointers yet, but its nice to have this code in C#. Thanks again!

    But if you allow me, i'd like to make some comments about your C# code.

    A List<List<>> is basically a matrix, which is one of the worst programming techniques that you can use. It turns the code into a bloody mess.

    As C# allows OOP, you definately should use it to make your code faster and readable.

    Eg.:

    I've created a class called Channel which stores:
    -Name of the Channel (eg.: "Server Log")
    -A List<Message> with every message read from this Channel

    Code:
    public class Channel
        {
            public string Name { get; set; }
            public List<Message> Messages { get; set; }
        }
    On the other hand, Message class has the following properties:
    Code:
    public class Message
        {
            public Channel Channel { get; set; }
    
            public byte Type { get; set; }
    
            public string Sender { get; set; }
    
            public string Text { get; set; }
    
            public string Level { get; set; }
    
            public string Time { get; set; }
    
        }
    Finally, my ReadChannels function returns a List<Channel>, which makes it fareasier to read the channels and it's messages.

    Code:
    List<Channel> result = _client.ReadChannels();
    
    foreach (Channel _channel in result)
    {
         Console.WriteLine(String.Concat("[", _channel.Name, "]"));
     
         foreach (Message _msg in _channel.Messages)
         {
              Console.WriteLine(_msg.Text);
          }
    }
    So, if you got interested on the improvements i've made, take a look at the project attached. I've create it on Visual Studio 2010.
    nice code, i am having problems disecting the chatlog structure, could you explain how you got the offsets in your code? the first 2 changes to the pointer in your code add 0x40 and 0x38 to gui pointer, then goes on to find channel pointer/offsets for message ect, but when i manually add this in cheat engine it just comes up with 0's, but the solution loads fine so i know the gui pointer is correct, any ideas?

Posting Permissions

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