Hey, I'm new here. I've been a memory editing hobbyist for a while, and recently got into WoW (1.12.1 especially). A friend of mine told me I should make an account and post some of my memory editing things. Hope someone finds some use!
-WoW 1.12.1 External Chat Class-
(For reading your in-game chat externally)
How the chat seems to be stored:
In 1.12.1, the client holds up to 60 messages in a buffer as it receives them. When a new message is received, its added to the end of the buffer. Upon reaching 60 messages, the buffer restarts at 0. The client uses this buffer to fill your chat log.
How I read it:
- Check in an interval to see when the current position in the chat buffer changes, indicating a new message was sent.
- When this happens ^, read the buffer from the last read position (default 0) until the current buffer position. This will get all the messages between the last one we read, and the most recent one.
- When the current chat buffer position hits 60, read from where we are until position 60 and then restart reading at position 0.
- Save the current position and reference that as the "last read position" in step 2.
Chat Offsets:
Code:
using System;
public static class Offsets
{
//...
internal static class Chat
{
internal static IntPtr chatBufferStart = (IntPtr)0xB50580; //Where our first message of the buffer is stored.
internal static IntPtr NextMessage = (IntPtr)0x800; //Offset for next message.
internal static IntPtr chatBufferPos = (IntPtr)0xB6E5D4; //Where the current chat buffer position is stored.
}
//...
}
Chat Enums:
Code:
using System;
public static class Enums
{
//....
public enum ChatType //ill find more later
{
Say = 0,
Group = 1,
Guild = 3,
Yell = 5,
Whisper = 6,
Channel = 14
}
//....
}
ChatMessage Class
- We will parse the messages into instances of this object. Contains a variable for all the parts of the message.
- Can parse raw messages from the buffer, or you can create custom ones. (see below)
- Custom ChatMessage Example
Code:
ChatMessage cm = new ChatMessage(Enums.ChatType.Channel, "DumbChannel", "Me", "Hello World.");
cm.ToString();
--Output--
"[DumbChannel] Me: Hello World."
- You can also see from this example ^, there is a nice ToString() method.
Code:
using System;
public class ChatMessage
{
public Enums.ChatType type = Enums.ChatType.Say;
public string channel = "";
public string sender = "";
public string text = "";
public ChatMessage(Enums.ChatType type, string channel, string sender, string text)
{
this.type = type;
this.channel = channel;
this.sender = sender;
this.text = text;
}
public ChatMessage(string rawChatString)
{
rawChatString = rawChatString.Substring(7);
int pFrom = 0;
int pTo = rawChatString.IndexOf("], ");
this.type = (Enums.ChatType)Int32.Parse(rawChatString.Substring(pFrom, pTo - pFrom));
rawChatString = rawChatString.Substring(pTo + 13);
pTo = rawChatString.IndexOf("], ");
this.channel = rawChatString.Substring(pFrom, pTo - pFrom);
rawChatString = rawChatString.Substring(pTo + 3);
pFrom = rawChatString.IndexOf(": [") + 3;
pTo = rawChatString.IndexOf("], ");
this.sender = rawChatString.Substring(pFrom, pTo - pFrom);
rawChatString = rawChatString.Substring(pTo + 10);
this.text = rawChatString.Substring(0, rawChatString.Length - 1);
}
public override string ToString()
{
if (this.type == Enums.ChatType.Channel)
{
return String.Format("[{0}] {1}: {2}", this.channel, this.sender, this.text);
}
else if (this.type == Enums.ChatType.Group)
{
return String.Format("[Party] {0}: {1}", this.sender, this.text);
}
else if (this.type == Enums.ChatType.Guild)
{
return String.Format("[Guild] {0}: {1}", this.sender, this.text);
}
else if (this.type == Enums.ChatType.Say)
{
return String.Format("{0}: {1}", this.sender, this.text);
}
else if (this.type == Enums.ChatType.Whisper)
{
return String.Format("[Whisper] {0}: {1}", this.sender, this.text);
}
else if (this.type == Enums.ChatType.Yell)
{
return String.Format("<Yell>{0}: {1}", this.sender, this.text);
}
else
{
return "T:" + ((int)this.type).ToString() + ",C:" + this.channel + ",S:" + this.sender + ",M:" + this.text;
}
}
}
Chat Class:
- The variable "wowReader" is an example memory reader with GreyMagic syntax, change this to whatever you read with.
- The List<ChatMessage> "messageLog" holds your chatlog since your first use of UpdateLog().
- Run "UpdateLog()" while logged in to add new chat messages, do it on a timer for auto chat-logging.
Code:
using System.Collections.Generic;
using System;
public static class Chat
{
public static int lastLoggedBuffer = 0;
public static List<ChatMessage> chatLog = new List<ChatMessage>();
public static string GetMessage(int pos) // start at 1
{
if (pos == 0)
{
return wowReader.ReadString(Offsets.Chat.chatBufferStart,Encoding.ASCII, 512); //replace this with whatever you read with
}
return wowReader.ReadString(IntPtr.Add(Offsets.Chat.chatBufferStart, ((int)Offsets.Chat.NextMessage * (pos - 1))),Encoding.ASCII, 512); //replace this with whatever you read with
}
public static string GetLastMessage()
{
int bufferPos = wowReader.Read<int>(Offsets.Chat.chatBufferPos); //current buffer pos
if (bufferPos == 0)
{
return wowReader.ReadString(Offsets.Chat.chatBufferStart,Encoding.ASCII, 512); //replace this with whatever you read with
}
return wowReader.ReadString(IntPtr.Add(Offsets.Chat.chatBufferStart, ((int)Offsets.Chat.NextMessage * (bufferPos - 1))),Encoding.ASCII, 512); //replace this with whatever you read with
}
public static void UpdateLog() //<---- Run this in short intervals to update your chatLog varaible.
{
int currBuffer = wowReader.Read<int>(Offsets.Chat.chatBufferPos); //current buffer pos
if (currBuffer == lastLoggedBuffer) //no change
{
return;
}
int tmpBuffer = lastLoggedBuffer; //set temp buffer
if (currBuffer < lastLoggedBuffer) //past 60
{
for (int i = lastLoggedBuffer + 1; i <= 60; i += 1) //add until 60
{
chatLog.Add(new ChatMessage(GetMessage(i)));
}
tmpBuffer = 0; //reset to 0;
}
for (int i = tmpBuffer + 1; i <= currBuffer; i +=1)//add until last logged buffer
{
chatLog.Add(new ChatMessage(GetMessage(i)));
}
lastLoggedBuffer = currBuffer; //done
}
}
(Sorry if the forums broke any alignment in the code previews.)
Github Gist: WoW 1.12.1 External Chat Reader Class . GitHub (Thanks Corthezz :P)
I hope someone can find use of this!
Enjoy