[C++] Looping through object manager not working menu

User Tag List

Results 1 to 7 of 7
  1. #1
    halcynthis's Avatar Member
    Reputation
    1
    Join Date
    Feb 2012
    Posts
    6
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [C++] Looping through object manager not working

    I'm currently working on small codes to experiment with WoW and came to a snag trying to loop through the object manager to find my current target.

    Offsets declared at the start of the code:
    Code:
    DWORD GameBase = 0x0100000;
    DWORD isLooting = 0xE54980;
    DWORD LocalPlayer = 0xDC0BC8;
    DWORD EntityList = GameBase+0xD3B358;
    DWORD FirstObj = 0x0C;
    DWORD NextObj = 0x3C;
    DWORD TargetGuid = GameBase+0xE35F20;
    DWORD MoneyPointer = 0x1804;
    DWORD Money = 0x18CC;
    
    HANDLE hProc;
    DWORD proc_id;
    Function to find my target:
    Code:
    DWORD findTarget()
    {
        DWORD list = ReadDword(EntityList);
        DWORD firstObj = ReadDword(list+FirstObj);
        unsigned long long TargetId = ReadUInt(TargetGuid);
        DWORD curObj = firstObj;
        while(curObj != 0)
        {
            unsigned long long GlobalId = ReadUInt(curObj);
            if(GlobalId == TargetId)
            {
                return curObj;
            }
            DWORD nextObj = ReadDword(curObj+NextObj);
            if(nextObj == curObj)
            {
                break;
            }
            else
            {
                curObj = nextObj;
            }
        }
        return 0;
    }
    Reading functions; (UInt is what I was originally using to store GUIDs, I just haven't renamed the function to suit using a long long now)
    Code:
    long ReadUInt(DWORD addr)
    {
        unsigned long long read;
        ReadProcessMemory(hProc, (LPVOID)(addr), (LPVOID) &read, sizeof(read), 0);
        return read;
    }
    
    DWORD ReadDword(DWORD addr)
    {
        DWORD read;
        ReadProcessMemory(hProc, (LPVOID)(addr), (LPVOID) &read, sizeof(read), 0);
        return read;
    }
    Code I'm calling the findTarget function from:
    Code:
    void MainWindow::on_pushButton_clicked()
    {
        HWND hwnd = FindWindowA(NULL, "World of Warcraft");
        if(hwnd != NULL)
        {
            ui->output->addItem("Found window");
            GetWindowThreadProcessId(hwnd, &proc_id);
            hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proc_id);
            char buf[64];
            sprintf_s(buf, "Target obj; %x", findTarget());
            ui->output->addItem(buf);
            char targGuid[128];
            sprintf_s(targGuid, "Target GUID; %d", ReadUInt(TargetGuid));
            ui->output->addItem(targGuid);
        }
    }
    I've done my best to try finding a solution to the problem and can't seem to find anything. Im assuming its either because im handing GUIDs incorrectly(using long long currently), or because im just doing something wrong in my loop in general. The program starts just fine, but upon pressing the button which I showed the code it calls, it freezes and crashes.

    I'm aware that there is probably much better and cleaner ways of what I've done, but I'm just looking to start simple and work my way up. I've managed to read stuff such as my gold/copper/silver, health, etc just fine, I just can't seem to understand what im doing wrong with the object manager.

    Any help would be greatly appreciated

    [C++] Looping through object manager not working
  2. #2
    Evansbee's Avatar Active Member
    Reputation
    31
    Join Date
    Jul 2009
    Posts
    24
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gamebase changes every time WoW is loaded due to ASLR.

    Amend your process class to compute the base address of the process you're trying to read from. Hint: the "module name" will be the same as the executable name.

  3. #3
    halcynthis's Avatar Member
    Reputation
    1
    Join Date
    Feb 2012
    Posts
    6
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Evansbee View Post
    Gamebase changes every time WoW is loaded due to ASLR.

    Amend your process class to compute the base address of the process you're trying to read from. Hint: the "module name" will be the same as the executable name.
    I understand what your saying and I do plan on adding that, though that's not the issue here. I use CE to get the base address of WoW each time I mess with it and change it in the code. Ive successfully managed to read my health and such so I know that its correct, but when I try to use the findTarget function I made the program crashes.

  4. #4
    Evansbee's Avatar Active Member
    Reputation
    31
    Join Date
    Jul 2009
    Posts
    24
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After drinking a bottle of wine I don't feel like going through your code, and your base pointer bit doesn't seem like we have the pieces we need, in that vein, here's how I get to the object list:

    auto basePtr = wowProcess.GetBaseAddress();
    auto entityListPtr = wowProcess.ReadMemory<intptr_t>(basePtr + OFFSETS::EntityList);
    auto entity = wowProcess.ReadMemory<intptr_t>(entityListPtr + OFFSETS::FirstEntity);

    while (entity != 0x00000000 && entity % 2 == 0)
    {
    ...
    }
    Ignore my all caps OFFSETS garbage, that's a using statement that just references my 64bit offset section. If your offsets are right, this will work.

  5. #5
    halcynthis's Avatar Member
    Reputation
    1
    Join Date
    Feb 2012
    Posts
    6
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After messing with my code more I noticed that the problem is most likely with how I'm reading guids. If I loop through object manager and output the entity ID instead of guid it works just fine. What data type should I use for guids? (int, long, etc). Also thanks for helping with what you can Evan.

  6. #6
    Evansbee's Avatar Active Member
    Reputation
    31
    Join Date
    Jul 2009
    Posts
    24
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's 128 bits, so you could use cstdint.h and do something cute with a struct and anonymous union like:

    struct GUID
    {
    union
    {
    struct
    {
    uint64_t high;
    uint64_t low;
    };
    struct
    {
    uint8_t bytes[16];
    };
    __m128 data;
    };
    };

    so sizeof(GUID); is always going to be 16 bytes, but you get a couple cute ways to access it.

    -e

    [edit]
    your compiler has to support the __m128 intrinsic, which is used for SSE/SIMD work, but it's equally as functional here.

  7. #7
    halcynthis's Avatar Member
    Reputation
    1
    Join Date
    Feb 2012
    Posts
    6
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I ended up looking at the source of a 3d radar posted here (http://www.ownedcore.com/forums/worl...116-32bit.html (3D WoW Radar for 6.03.19116 32bit)) to get an idea of how all this worked and managed to get everything working. I was in fact handling guids wrong and fixed it. Thanks for your help

Similar Threads

  1. Looping through object manager crash
    By zdohdds in forum WoW Memory Editing
    Replies: 4
    Last Post: 11-27-2016, 10:09 AM
  2. [Bot] Object Manager - Loop through objects
    By WiNiFiX in forum WoW Memory Editing
    Replies: 12
    Last Post: 09-18-2014, 12:45 PM
  3. Pointing to each Object from Object Manager Loop
    By ShoniShilent in forum WoW Memory Editing
    Replies: 4
    Last Post: 10-17-2012, 09:25 PM
  4. Replies: 9
    Last Post: 04-16-2010, 02:52 PM
  5. Object ID's not working
    By Druaide in forum World of Warcraft Emulator Servers
    Replies: 8
    Last Post: 08-05-2008, 06:44 PM
All times are GMT -5. The time now is 06:40 AM. 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