Object Manager - Loop through objects menu

User Tag List

Results 1 to 13 of 13
  1. #1
    WiNiFiX's Avatar Banned
    Reputation
    242
    Join Date
    Jun 2008
    Posts
    447
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Object Manager - Loop through objects

    I am having difficulty in understanding where I am going wrong with the below code to loop through objects and locate my character amongst them.
    Below is the code I have

    Offsets 18414 x86
    Code:
    enum Offsets : uint
    {
        PlayerName = 0xEC4668,
    
        ObjMgr = 0xEC4628,
        CurMgr = 0x462c,
        LocalGUID = 0xE8,
        FirstObject = 0xCC,
        NextObject = 0x34
    }
    Classes Used (Simplified so you can see quickly whats happening)
    Code:
    public class WoWObject
    {
        public WoWObject(IntPtr BaseAddress)
        {
            this.BaseAddress = BaseAddress;
        }
    
        [Category("General"), Description("The objects base address pointer.")]
        public IntPtr BaseAddress { get; set; }
    
        [Category("Informations"), Description("Every object has an unique Guid. Use this to identify and access the object.")]
        public ulong Guid
        {
            get
            {
                return MemSharp.Read<ulong>(this.BaseAddress + 40, false);
            }
        }
    }
    
    public class WoWUnit : WoWObject
    {
        public WoWUnit(IntPtr BaseAddress)
            : base(BaseAddress)
        {
        }
    }
    
    public class WoWPlayerMe : WoWUnit
    {
        public WoWPlayerMe(IntPtr BaseAddress)
            : base(BaseAddress)
        {
        }
    }
    Main Program Extract
    Code:
    ulong WoWBaseAddr = (ulong)MemSharp.Modules.MainModule.BaseAddress;
    ulong ObjMgrBase  = MemSharp.Read<ulong>(new IntPtr((uint)WoWBaseAddr + (uint)Offsets.ObjMgr)      , false);
    ulong ObjMgr      = MemSharp.Read<ulong>(new IntPtr((uint)ObjMgrBase  + (uint)Offsets.CurMgr)      , false);  
    ulong PlayerGUID  = MemSharp.Read<ulong>(new IntPtr((uint)ObjMgr      + (uint)Offsets.LocalGUID)   , false);
    ulong CurObj      = MemSharp.Read<ulong>(new IntPtr((uint)ObjMgr      + (uint)Offsets.FirstObject) , false);
    
    LogActivity("ObjMgrBase : 0x" + ObjMgrBase.ToString("X"));
    LogActivity("ObjMgr     : 0x" + ObjMgr.ToString("X"));
    LogActivity("Player GUID: 0x" + PlayerGUID.ToString("X"));
    LogActivity("CurObj     : 0x" + CurObj.ToString("X"));
    
    WoWPlayerMe Me;
    
    while ((CurObj != 0) && ((CurObj & 1) == 0))  <-- This loop throws the error on first or 2nd loop
    {
        ulong num = MemSharp.Read<ulong>(new IntPtr((uint)CurObj + (uint)Offsets.NextObject), false);
        WoWObject currentObj = new WoWObject((IntPtr)CurObj);
    
        if (currentObj.Guid == PlayerGUID)
        {
            Me = new WoWPlayerMe((IntPtr)CurObj);
        }
        CurObj = num;
    }
    Outputs
    Code:
    Player Name: BobYesReallyBob
    ObjMgrBase : 0xDA3B1580AF86D38
    ObjMgr     : 0xD9D1E90327F33C0
    Player GUID: 0x9999999999999999 <-- This is correct but not showing it here
    CurObj     : 0x381280ED3C
    Arithmetic operation resulted in an overflow.  <-- The error I am encountering mentioned above
    Last edited by WiNiFiX; 09-17-2014 at 12:41 PM.

    Object Manager - Loop through objects
  2. #2
    Remus3's Avatar Hobby 3D Character Artist Ex-Super Mod CoreCoins Purchaser
    Reputation
    272
    Join Date
    Jan 2011
    Posts
    1,356
    Thanks G/R
    3/7
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im no expert- but did you set a limit to how much its supposed to sort through? 1-10,000 ? trying to find what im meaning.
    i see your post- so nvm ): --- wish you luck bud
    Last edited by Remus3; 09-17-2014 at 12:45 PM.


    Think before you post. You can only get smarter by playing a smarter opponent.

  3. #3
    WiNiFiX's Avatar Banned
    Reputation
    242
    Join Date
    Jun 2008
    Posts
    447
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Remus3 View Post
    im no expert- but did you set a limit to how much its supposed to sort through? 1-10,000 ? trying to find what im meaning.
    Nope, but I am in a very populated area and that fact that it fails on the 1st or 2nd loop shows me its not that, thats the issue.

  4. #4
    aeo's Avatar Contributor
    Reputation
    127
    Join Date
    Apr 2007
    Posts
    270
    Thanks G/R
    84/62
    Trade Feedback
    7 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This is the outdated and complicated way to traverse the object list. Look into EnumVisibleObjects/EnumVisiblePlayers. These functions will handle all the pointer issues that are giving you trouble. Look at TOM_RUS wow addin project( its on his github)

  5. #5
    WiNiFiX's Avatar Banned
    Reputation
    242
    Join Date
    Jun 2008
    Posts
    447
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by aeo View Post
    This is the outdated and complicated way to traverse the object list. Look into EnumVisibleObjects/EnumVisiblePlayers. These functions will handle all the pointer issues that are giving you trouble. Look at TOM_RUS wow addin project( its on his github)
    I shall have a look at it, I am not an expert at C++ but it looks like the file you are referring to is ObjectMgr.h

    I would however still like to know where I went wrong in my code above, because although it may be outdated way of doing it it will help me understand what I did wrong.

  6. #6
    WiNiFiX's Avatar Banned
    Reputation
    242
    Join Date
    Jun 2008
    Posts
    447
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I have looked at the code and googled like crazy, I have no idea how to begin converting that code to C#, and hints on what the C# equivalent of

    From: https://github.com/tomrus88/WowAddin...in/ObjectMgr.h
    Code:
    typedef uint64 (__cdecl *ClntObjMgrGetActivePlayerGuidPtr)();
    
    typedef CGObject_C* (__cdecl *ClntObjMgrObjectPtr)(uint64 objectGuid, TypeMask objectTypeMask, const char *file, int line);
    
    // return 0 to stop enumeration, 1 to continue
    typedef BOOL (__cdecl *VisibleObjectsEnumProc)(uint64 objectGuid, void *param);
    
    // returns 0 if enumeration stopped by callback, 1 otherwise (iterate through all objects)
    typedef BOOL (__cdecl *ClntObjMgrEnumVisibleObjectsPtr)(VisibleObjectsEnumProc proc, void *param);
    The rest of the methods I should manage.

  7. #7
    WiNiFiX's Avatar Banned
    Reputation
    242
    Join Date
    Jun 2008
    Posts
    447
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I have looked at the code and googled like crazy, I have no idea how to begin converting that code to C#, and hints on what the C# equivalent of

    typedef uint64 (__cdecl *ClntObjMgrGetActivePlayerGuidPtr)();

    typedef CGObject_C* (__cdecl *ClntObjMgrObjectPtr)(uint64 objectGuid, TypeMask objectTypeMask, const char *file, int line);

    // return 0 to stop enumeration, 1 to continue
    typedef BOOL (__cdecl *VisibleObjectsEnumProc)(uint64 objectGuid, void *param);

    // returns 0 if enumeration stopped by callback, 1 otherwise (iterate through all objects)
    typedef BOOL (__cdecl *ClntObjMgrEnumVisibleObjectsPtr)(VisibleObjectsEnumProc proc, void *param);

    I think it is similar to the below in a way where you define a struct layout for an object, in the below case for wow's chat window

    Code:
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct WowChatMsg
        {
            public UInt64 SenderGuid;  
                                    
            public UInt32 Unknown1;
            public UInt32 Unknown2;
            public UInt16 Unknown3;
            public UInt16 Unknown4;
    
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 49)] 
            public string senderName;
    
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 3000)]
            public string formattedMsg;
    
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 3000)]
            public string plaintextMsg;
    
            public UInt32 type;
            public UInt32 channelNr;
            public UInt32 time;        
        }

  8. #8
    namreeb's Avatar Legendary

    Reputation
    658
    Join Date
    Sep 2008
    Posts
    1,023
    Thanks G/R
    7/215
    Trade Feedback
    0 (0%)
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    It sounds like you may be trying to walk before you can crawl. You were given the name of the function(s) to look at for how to iterate over the object list, and I believe the location of those functions can be found on this forum.

  9. #9
    WiNiFiX's Avatar Banned
    Reputation
    242
    Join Date
    Jun 2008
    Posts
    447
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have had a more in-detail look over the solution of EnumVisibleObjects, but have come to realise that it uses injection, I am trying to keep 100% passive until I understand memory more as I am getting tired of creating new trial accounts to test on :P

    http://www.ownedcore.com/forums/worl...managment.html ([WoW][3.2.0] Better Object Managment)

    @ namreeb - if a person didn't push themselves then they would never achieve anything, all im doing is pushing my limits - I do believe I understand enough about objects in memory to grasp the basics, I was just hoping that someone could give me a nudge in the correct direction to solve my initial question.

  10. #10
    WiNiFiX's Avatar Banned
    Reputation
    242
    Join Date
    Jun 2008
    Posts
    447
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well managed to find my mistake, I was reading ObjMgr, CurObj as ulong instead of uint,
    I forgot that when reading from memory I needed to be precise on numeric sizes.

  11. #11
    Corthezz's Avatar Elite User Authenticator enabled
    Reputation
    386
    Join Date
    Nov 2011
    Posts
    325
    Thanks G/R
    183/98
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    --- snip ---
    Check my blog: https://zzuks.blogspot.com

  12. #12
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1511
    Join Date
    May 2008
    Posts
    2,432
    Thanks G/R
    81/333
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by WiNiFiX View Post
    @ namreeb - if a person didn't push themselves then they would never achieve anything, all im doing is pushing my limits - I do believe I understand enough about objects in memory to grasp the basics, I was just hoping that someone could give me a nudge in the correct direction to solve my initial question.
    He's right though. You were trying to access an internal function before you could even recognise that it was an internal function.

  13. #13
    namreeb's Avatar Legendary

    Reputation
    658
    Join Date
    Sep 2008
    Posts
    1,023
    Thanks G/R
    7/215
    Trade Feedback
    0 (0%)
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by WiNiFiX View Post
    @ namreeb - if a person didn't push themselves then they would never achieve anything, all im doing is pushing my limits - I do believe I understand enough about objects in memory to grasp the basics, I was just hoping that someone could give me a nudge in the correct direction to solve my initial question.
    If you got it working then great. I'm simply saying that the questions you're asking you could answer yourself if you had the knowledge that, frankly, you need to have to get into this area of programming. You're skipping some steps, in other words. The good will of this community is big but not big enough to carry you over the disadvantage you are placing on yourself by doing it this way. In this case, you could have looked at the EnumVisibleObjects function in IDA and seen how WoW itself iterates over objects, and then answered your own question(s).

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. [C++] Looping through object manager not working
    By halcynthis in forum WoW Memory Editing
    Replies: 6
    Last Post: 06-11-2015, 05:37 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. Object Manager
    By Shamun in forum WoW Memory Editing
    Replies: 11
    Last Post: 11-28-2008, 02:06 PM
  5. WoW Object Manager ?
    By discorly in forum WoW ME Questions and Requests
    Replies: 4
    Last Post: 07-28-2007, 06:34 PM
All times are GMT -5. The time now is 10:09 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