How to detect open windows menu

User Tag List

Results 1 to 10 of 10
  1. #1
    Diablo3Bot's Avatar Corporal
    Reputation
    3
    Join Date
    Jul 2012
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to detect open windows

    How do I tell if the vendor and inventory windows are open? My bots been working great but in the newest release (1.0.5) there are a couple of errors with the vendor and stash where the inventory screen won't close when the character walks away. I have noticed this while playing. and last night it must have happened at some point cause my bot was wearing different gear and lost or sold some of my good gear. Reviewing the log there was one point where things looked funny, and I think he went into the field with the inventory screen open. And while clicking tossed or threw out gear.

    Another error I've noticed is when you click on the vendor the vendor screen doesn't open and you have to click again. This is not a big problem but If I can detect when the windows are open I can fix these problems.

    How to detect open windows
  2. #2
    DarthTon's Avatar Contributor
    Reputation
    171
    Join Date
    Apr 2010
    Posts
    108
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check UI element visibility?

  3. #3
    Diablo3Bot's Avatar Corporal
    Reputation
    3
    Join Date
    Jul 2012
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I haven't messed around with the UI stuff yet. After reading pages here etc I tried to figure it out. I have something wrong and not sure what. Here is my code:

    Code:
    private const uint ofs_ObjectManger = 0x0186FA3C;
    private const uint ofs_UIElements_Base = 0x93C;
    private const uint ofs_UIElements = 0x8;
    private const uint ofs_UIElements_cnt = 0x40;
                        
    itrObjectManagerA = m_memoryReader.Readuint(ofs_ObjectManger);
    UIElements_ofsA = m_memoryReader.Readuint(itrObjectManagerA + ofs_UIElements_Base);
    UIElements_ofsB = m_memoryReader.Readuint(UIElements_ofsA);
    UIElements = m_memoryReader.Readuint(UIElements_ofsB + ofs_UIElements);
    UIElements_Count = m_memoryReader.Readuint(UIElements_ofsB + ofs_UIElements_cnt);
    
    UIElementNames = new string[UIElements_Count];
    vis = new int[UIElements_Count];
    curUIOffset = UIElements;
    for (int i = 0; i < UIElements_Count; i++)
    {
                    vis[i] = m_memoryReader.ReadInt(curUIOffset + 0x28);
                    UIElementNames[i] = m_memoryReader.ReadCString(curUIOffset + 0xAE0);
                    curUIOffset += 0xE9C;
    }
    The count is always 0x7FF each time I start the game. The reading loop never finishes it crashes before getting to the end of the loop.

    The text that it reads looks like random data half the time, but the other half it has different text that I've seen in game, sometimes what looks like a complete string other times it seems to be a complete string (I'm taking this as I must be close).

    The vis (visible) value I though would be a true or false, but seems to be a 0x00000000, or some weird value like 0x4023C5CE.

    I got the UI structure from this thread "http://www.ownedcore.com/forums/diablo-3/diablo-3-bots-programs/diablo-3-memory-editing/382344-1-0-5-ui-text-changes.html"

    I'm also not sure what I'm looking for. I was hoping I would find the UI element for the title strings on the windows (such as INVENTORY, WEAPONS, REPAIR, etc) and then see if that UI is visible. When visible, window was open.

    Any idea where I'm going wrong?

  4. #4
    DarthTon's Avatar Contributor
    Reputation
    171
    Join Date
    Apr 2010
    Posts
    108
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    private const uint ofs_UIElements_cnt = 0x10;
    And iterating:
    Code:
    struct Pair
    {
    	Pair *next;
    	UIReference key;
    	UIComponent* value;
    };
    
    struct UIReference
    {
    	ULONGLONG hash;		// 0x000
    	char name[0x200];	// 0x008
    };
    
    struct UIComponent
    {
    ......
    DWORD visible;	    // 0x028
    ......
    char* text_ptr;	    // 0xAE0
    .....
    }
    
    for(DWORD i = 0; i < comp_map.table_size; i++)
    {
    	UIComponentMap::Pair pair;
    
    	if(CProcess::Instance().Core.Read(CProcess::Instance().Core.Read<DWORD>((DWORD)comp_map.table +  i*sizeof(UIComponentMap::Pair*)), sizeof(pair), &pair) != ERROR_SUCCESS)
    		continue;
    
    	//Read linked list nodes
    	for(; pair.value;)
    	{
    		UIComponent element;
    
    		CProcess::Instance().Core.Read((DWORD)pair.value, sizeof(element), &element); 
    
    		if(CProcess::Instance().Core.Read((DWORD)pair.next, sizeof(pair), &pair)  != ERROR_SUCCESS)
    			break;
    	}
    	}

  5. #5
    Diablo3Bot's Avatar Corporal
    Reputation
    3
    Join Date
    Jul 2012
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DarthTon thanks for the help I am still having a few problems. I fixed the count offset, and now I am able to iterate the list with crashing.

    After looking over your code and mine I noticed that the line:
    Code:
    UIElementNames[i] = m_memoryReader.ReadCString(curUIOffset + 0xAE0);
    was reading the pointer to the string as a string, and should be changed to:
    Code:
    UIElementNames[i] = m_memoryReader.ReadCString(m_memoryReader.Readuint(curUIOffset + 0xAE0));
    But this still doesn't fix my problem, actually makes it worse since some of the values returned are 0x00000000;

    Part of the problem is that I don't really know what I'm looking for or at. Without all of your code I can't tell if the UIComponents are linked lists (which is how you appear to be storing them) or if they are just stacked in order in memory (which is what I assume). Also what should the text look like? I see some references when looking at the memory to what appear to be the component type (radio button, text box, etc).

    I also looked at the visible variable. After opening the inventory screen none of the values changed? any idea what I'm doing wrong there?

    Thanks for the help!

  6. #6
    DarthTon's Avatar Contributor
    Reputation
    171
    Join Date
    Apr 2010
    Posts
    108
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But this still doesn't fix my problem, actually makes it worse since some of the values returned are 0x00000000
    Not all UI element have text. The one you are looking for is "Root.NormalLayer.inventory_dialog_mainPage" - inventory window (btw it also has 0 text pointer).
    For UI parsing info you can look into my code here http://www.ownedcore.com/forums/diab...framework.html ([C++] My D3 OOP framework)

  7. #7
    Diablo3Bot's Avatar Corporal
    Reputation
    3
    Join Date
    Jul 2012
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DathTon thank for all the help. I ran the same code I ran yesterday and now it doesn't work. It seems to find the first 2 elements then there is what appears to be some sort of character table. And then more elements and character tables??????, and the character tables are not the same size as the elements??????

    My Visual C++ skills are not up to your level (I'm writing this in C# if you weren't able to tell from the code). I checked out your code and need a little help figuring out what's going on.

    This struct:
    Code:
    struct Pair
    {
    	Pair *next;
    	UIReference key;
    	UIComponent* value;
    };
    along with this line:
    Code:
    if(CProcess::Instance().Core.Read(CProcess::Instance().Core.Read<DWORD>((DWORD)comp_map.table +  i*sizeof(UIComponentMap::Pair*)), sizeof(pair), &pair) != ERROR_SUCCESS)
    if I am reading it what it does correctly, This says that all of the UIElements are stored in a linked list and this is a table containing the linked list. And the above line reads in the entire table. The Linked list is a single direction list, so to find an element we always need to search starting from the beginning.

    Then the code iterates through the loop and this line:
    Code:
    CProcess::Instance().Core.Read((DWORD)pair.value, sizeof(element), &element);
    uses the the pointer stored in value, to read and store the UIElement struct, which should contain the info I need?

    Am I correct in my thinking of how this works?

  8. #8
    Diablo3Bot's Avatar Corporal
    Reputation
    3
    Join Date
    Jul 2012
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright I got a little further. I was able to go through the loop and read in something but it doesn't match the UIelements structure from what I can tell. I am able to consistently find the chunk of memory with the name "Root.NormalLayer.inventory_dialog_mainPage". When I view it in memory it looks like this:

    How to detect open windows-capture-jpg

    So now that I can find this what am I missing that I need to find the UIElement so I can see if this is visible or not?

    Thanks again.
    Last edited by Diablo3Bot; 10-31-2012 at 03:58 PM.

  9. #9
    Evozer's Avatar Contributor
    Reputation
    150
    Join Date
    Jan 2011
    Posts
    214
    Thanks G/R
    1/15
    Trade Feedback
    9 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to do it the easy way, find or dump a list of all UIElements with their name and hashcode. Then you can retrieve an UIElement using its hashcode like this:

    Code:
    private int AddressFromHash(long hash)
            {
                int uiman = mem.ReadInt(DiabloIII.ObjectManager, 0x93C, 0);
    
                long v1 = (hash >> 32) ^ hash;
                int v2 = (int)(mem.ReadInt(uiman + 8) + 4 * (mem.ReadInt(uiman + 0x40) & v1));
    
                do
                {
                    long h = mem.ReadLong(v2 + 8);
                    if (h == hash)
                    {
                        return mem.ReadInt(v2 + 0x210);
                    }
                    v2 = mem.ReadInt(v2);
                } while (v2 != 0);
                return 0;
            }
    Most of this is just copied from a function from D3 reassembled in IDA. Much faster than iterating the entire list.

    Then add 0x28 to the address you get, if it's 1 it is visible.

  10. #10
    Diablo3Bot's Avatar Corporal
    Reputation
    3
    Join Date
    Jul 2012
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Evozer the code worked great.

    1 Question though, are the memory locations for the UIElements static once Diablo 3 starts or can their location change every time I start a game? I noticed that each time I restart diablo 3 the inventory UIElement is in a different spot, but it seems to stay in the same location in memory until I restart diablo 3. Currently I am looking for the element each time I start a game.

Similar Threads

  1. How blizzard detects AHK
    By wikiwika in forum Overwatch Exploits|Hacks
    Replies: 20
    Last Post: 08-23-2016, 08:02 PM
  2. [Questition]How do i open a frame
    By sve3nn in forum WoW UI, Macros and Talent Specs
    Replies: 8
    Last Post: 09-13-2008, 02:40 PM
  3. [OB] How to make Open Bot Run very Smoothly
    By Stephen Colbert in forum World of Warcraft Bots and Programs
    Replies: 11
    Last Post: 04-06-2008, 09:18 AM
  4. How to Detect Invisable Walls
    By idusy-org in forum World of Warcraft Exploration
    Replies: 3
    Last Post: 12-26-2006, 01:06 PM
  5. How to turn off window mode
    By insaneomato in forum World of Warcraft General
    Replies: 1
    Last Post: 05-31-2006, 11:18 PM
All times are GMT -5. The time now is 04:14 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search