[2.4.3] TLS Memory Reading Framework in C# menu

User Tag List

Results 1 to 7 of 7
  1. #1
    hypnodok's Avatar Member
    Reputation
    19
    Join Date
    Nov 2007
    Posts
    65
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [2.4.3] TLS Memory Reading Framework in C#

    With the 3.0 patch around the corner I might as well just release this, it's probably inferior to wowbasic but maybe someone can still put this code to some use.

    For the most part I used flobot and this forum for reference, kudos to you guys.

    The code is open source and GPLed, because I can.

    RapidShare: Easy Filehosting

    Example usage (untested):
    Code:
            static void Main(string[] args)
            {
                memReader = new WowMemoryReader();
                memReader.GetBaseOffset();
                //get current map id
                uint currentMapID = memReader.GetMapID();
                //get player object
                WowStructs.WowUnitObject playerunitobject = memReader.GetPlayerUnitObject();
                WowStructs.WowUnitObjectData playerunitobjectdata = memReader.GetUnitObjectData(playerunitobject);
                Console.WriteLine("Player GUID: " + playerunitobject.GUID + " X: " + playerunitobject.X + " Y: " + playerunitobject.Y + " Z: " + playerunitobject.Z);
                Console.WriteLine("Faction: "+WowEnum.FactionToString(playerunitobjectdata.Faction)+" Level: "+playerunitobjectdata.Level+" MapID: "+currentMapID);
                //etcetc    
                //if you zone call getbaseoffset again
    
                //get all objects
                Hashtable allobjects = memReader.GetAllWowObjects();
                foreach (IntPtr key in allobjects.Keys)
                {
                    uint objecttype = (uint)allobjects[key];
                    switch (objecttype)
                    {
                        case (uint)WowEnum.ObjectType.NPC:
                        case (uint)WowEnum.ObjectType.Player:
                            WowStructs.WowUnitObject wowUnitObject = memReader.GetWowUnitObject(key);
                            Console.WriteLine("Player or NPC: "+wowUnitObject.GUID);
                            break;
                        case (uint)WowEnum.ObjectType.GameObject:
                            WowStructs.WowObject wowGameObject = memReader.GetWowObject(key);
                            WowStructs.WowGameObjectData gameObjectData = memReader.GetGameObjectData(wowGameObject);
                            Console.WriteLine("GameObject: " + wowGameObject.GUID + " X: " + gameObjectData.X); //etc etc
                            break;
                    }
                }
                Console.ReadKey();
            }

    [2.4.3] TLS Memory Reading Framework in C#
  2. #2
    kynox's Avatar Account not activated by Email
    Reputation
    830
    Join Date
    Dec 2006
    Posts
    888
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, i noticed you used thread enumeration to get to the TLS. An alternative, and imo superior solution is to use to g_clientConnection pointer. [[0x00D43318 + 0x2218]

  3. #3
    dalgreens's Avatar Member
    Reputation
    1
    Join Date
    Feb 2008
    Posts
    29
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the framework Hypno, I was able to understand it except for one part.

    For the code block:

    Code:
            public void GetBaseOffset()
            {
                Program.Log("GetBaseOffset()");
                IntPtr threadHandle, TEBHandle;
                ThreadEntry32 threadStruct = Kernel32.CreateThreadEntry32();
                ThreadBasicInformation threadbasicinfo = new ThreadBasicInformation();
    
                UInt32 TLSSlotNumer = Kernel32.ReadUInt32(WowProcessHandle, TLSIndex,true);// gets the number of the tls-slot (usually 0) - 0 means the first tls entry points to the struct
                IntPtr threadSnapshotHandle = Kernel32.CreateToolhelp32Snapshot(Kernel32.SnapshotFlags.Thread, 0); // makes a snapshot of all !! open threads#
                Kernel32.Thread32First(threadSnapshotHandle, ref threadStruct);//now contains information about the first ! thread
                do
                {
                    if (threadStruct.the32OwnerProcessID == processID)//thread belongs to wow
                    {
                        threadHandle = Kernel32.OpenThread(Kernel32.ThreadAccess.QUERY_INFORMATION, false, threadStruct.th32ThreadID);//open the thread
                        UInt32 threadQueryResult = ntdlll.NtQueryInformationThread(threadHandle , 0, ref threadbasicinfo, (uint)Marshal.SizeOf(threadbasicinfo), IntPtr.Zero);//check for the operation's result
                        if (threadQueryResult == 0)//STATUS_SUCCESS                   
                        {
                            TEBHandle = threadbasicinfo.TebBaseAdress;// Thread Environment Block
                            UInt32 TLSOffset = Kernel32.ReadUInt32(WowProcessHandle, (IntPtr)((UInt32)TEBHandle + 0x2c),true);//gets the TLS_OFFSET from (teb + offset 2C)
                            if (TLSOffset != 0)
                            {
                                IntPtr TLSSlot = (IntPtr)Kernel32.ReadInt32(WowProcessHandle, (IntPtr)(TLSOffset + TLSSlotNumer * 4), true); // gets the tls-slot - multiplied by 4 bcaseu each tls_slot is 4 bytes long
                                IntPtr WowObjectPointer = (IntPtr)Kernel32.ReadInt32(WowProcessHandle, (IntPtr)((Int32)TLSSlot + 8), true);  //add 8 to get the wow object pointer (this is int, not hex !)
                                Program.Log("Wowobject Pointer: " + WowObjectPointer);
                                if (WowObjectPointer != IntPtr.Zero)//discard nullpointers
                                {
                                    WowFirstObjectPointer = (IntPtr)Kernel32.ReadInt32(WowProcessHandle, (IntPtr)((Int32)WowObjectPointer + 0xC), true);
                                    Program.Log("First Object Pointer: " + WowFirstObjectPointer);
                                    WowPlayerGUID = Kernel32.ReadUInt64(WowProcessHandle, (IntPtr)((Int32)TLSSlot + 16), true);
                                    Program.Log("Player GUID: " + WowPlayerGUID);
                                    WowFirstUnitPointer = GetFirstUnitPointer();
                                    WowPlayerPointer = GetPlayerPointer();
    
                                    if (!Kernel32.CloseHandle(threadHandle))
                                        Program.Log("Failed to close thread handle. " + threadHandle);
                                    if (!Kernel32.CloseHandle(threadSnapshotHandle))
                                        Program.Log("Failed to close thread snapshop handle. " + threadSnapshotHandle); 
                                }
                            }
                            else
                                Program.Log("TLS Offset was null");
    Specifically this line:

    Code:
                                    WowFirstObjectPointer = (IntPtr)Kernel32.ReadInt32(WowProcessHandle, (IntPtr)((Int32)WowObjectPointer + 0xC), true);
    Where / How did you figure out the 0xC offset from?

  4. #4
    hypnodok's Avatar Member
    Reputation
    19
    Join Date
    Nov 2007
    Posts
    65
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by kynox View Post
    Hi, i noticed you used thread enumeration to get to the TLS. An alternative, and imo superior solution is to use to g_clientConnection pointer. [[0x00D43318 + 0x2218]
    I believe you're right about this, thread enumeration has lead to some problems if it gets called too early or at the wrong time. Maybe I'll update this for Wotlk (if the TLS method still works for the addon that is), for now I dont feel like touching the code again.
    Originally Posted by dalgreens
    Where / How did you figure out the 0xC offset from?
    Honestly I don't know, it's not like I invented this. I merely looked at the various sources that were availible and ported the code to C#.

  5. #5
    Xarg0's Avatar Member
    Reputation
    61
    Join Date
    Jan 2008
    Posts
    389
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice work hypnodok and it's in a C style language, may the source be with you young padawan.
    I hacked 127.0.0.1

  6. #6
    Nesox's Avatar ★ Elder ★
    Reputation
    1280
    Join Date
    Mar 2007
    Posts
    1,238
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    niceley done

  7. #7
    hypnodok's Avatar Member
    Reputation
    19
    Join Date
    Nov 2007
    Posts
    65
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont know if Im allowed to say this but I would appriciate some rep to get rid of that silly leecher title
    Edit: Thanks
    Last edited by hypnodok; 10-07-2008 at 01:12 AM.

Similar Threads

  1. [AUTO IT] Diablo 3 Memory READ "framework". Including 4 sample bots.
    By joxxe87 in forum Diablo 3 Memory Editing
    Replies: 10
    Last Post: 02-25-2013, 02:48 AM
  2. White Paper : Memory reading
    By tttommeke in forum WoW Memory Editing
    Replies: 41
    Last Post: 06-19-2008, 02:30 AM
  3. VB .Net Memory Reading Project
    By Glitchy in forum WoW Memory Editing
    Replies: 4
    Last Post: 01-22-2008, 12:37 PM
  4. [AutoIT3] WoW Cordinator (X,Y,MapID and rotation memory reading)
    By Vladinator in forum World of Warcraft Bots and Programs
    Replies: 22
    Last Post: 05-15-2007, 03:26 AM
All times are GMT -5. The time now is 12:41 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search