Can anyone tell me what is wrong with this please (removed all I could to make it simpler read)
var msgPtr = IntPtr.Add(_imageBase, (int)ChatOffsets.ChatBase + (int)ChatOffsets.ChatMsgSize*_position);
var msg = Memory.Read<WoWChatMsg>(msgPtr);
var msgStr = msg.Text;
I keep getting blank values for the fields in the struct.
I must be missing something silly. This was working a while ago.
My Offsets are here (I think they are OK)
Code:
// 6.03
public enum ChatOffsets
{
ChatBase = 0xDEE8DC,
ChatBufferPos = 0xD94560,
ChatMsgSize = 0x17E8,
// Message
ChatMsgSenderGuid = 0x0000,
ChatMsgSenderName = 0x0034,
ChatMsgFullMessage = 0x0065,
ChatMsgOnlyMessage = 0x0C1D,
ChatMsgChannelNum = 0x17D8,
ChatMsgTimeStamp = 0x17E4
}
Here is my chat struct (I may have messed up here):
Code:
[StructLayout(LayoutKind.Sequential)]
public struct WoWChatMsg
{
public WoWGuid SenderGuid;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x0024)]
private readonly byte[] _unk1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x30)]
private readonly byte[] _senderName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0xBB8)]
private readonly byte[] _formattedMessage;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0xBB8)]
internal readonly byte[] _text;
public uint MessageType;
public uint ChannelNumber;
public uint Sequence;
internal readonly uint _unk2;
internal readonly uint _time;
internal static readonly DateTime UnixEpochStart = new DateTime(1970, 1, 1, 0, 0, 0, 0);
public string SenderName
{
get { return Encoding.UTF8.GetString(_senderName.TakeWhile(b => b != 0).ToArray()); }
}
public string FormattedMessage
{
get { return Encoding.UTF8.GetString(_formattedMessage.TakeWhile(b => b != 0).ToArray()); }
}
public string Text
{
get
{
return _text == null ? null : Encoding.UTF8.GetString(_text.TakeWhile(b => b != 0).ToArray());
}
}
public DateTime Time
{
get { return UnixEpochStart.AddSeconds(_time); }
}
public static int Size
{
get { return (int)ChatOffsets.ChatMsgSize; }
}
}
Thanks a lot.