Help with m_GroundItemInstanceMap

05/09/2021 23:46 ozuromo#1
Hello guys, I'm trying to iterate over all items on the ground and to do that i tried something like this:

Code:
typedef std::map<DWORD, DWORD*> _GroundItem;
_GroundItem GroundItem = *(_GroundItem*)(Start of the map);

_GroundItem::iterator it = GroundItem.begin()
DWORD itemVid = it->first;
But that did not work. Someone can help? I'm almost 100% sure that the adress is right...
05/10/2021 10:35 Aeryas#2
You have to iterate over the map, something like:

for ( auto itor = groundItems.begin(); itor != groundItems.end(); itor++) {
DWORD itemID = itor->first;
bla bla bla;
}

If you have a struct for the items, use that as well to retrieve valid data. It all depends how you retrieved your map pointer.

Sorry for the messy coding style, I'm writing from the phone.
05/10/2021 11:19 _asm#3
assuming you have a C++17 compiler
Code:
for (auto const& [vnum, item] : _GroundItem) {
    // do your shit here
}
05/10/2021 17:07 MrCrisp#4
Regarding the address of the std::map: It's almost always at Instance+0x4 bytes. Instance+0x8 will get you the current size of the map, as far as I can remember.
05/11/2021 04:23 ozuromo#5
Quote:
Originally Posted by MrCrisp View Post
Regarding the address of the std::map: It's almost always at Instance+0x4 bytes. Instance+0x8 will get you the current size of the map, as far as I can remember.
Yeah I have this exact address but when I try to iterate how __asm said my game just crashes... I'm in this for some time now haha ;'(
05/11/2021 12:41 MrCrisp#6
If you only add 0x4 bytes, you are accessing the vtable. Dereference the pointer and add another 0x4 bytes. Then dereference again and you should get the map pointer.
05/11/2021 23:36 ozuromo#7
Quote:
Originally Posted by MrCrisp View Post
If you only add 0x4 bytes, you are accessing the vtable. Dereference the pointer and add another 0x4 bytes. Then dereference again and you should get the map pointer.
If you only add 0x4 bytes, you are accessing the vtable:
Code:
itemInstance + 0x4
Dereference the pointer and add another 0x4 bytes:
Code:
*(DWORD*)(itemInstance + 0x4) + 0x4
Then dereference again and you should get the map pointer:
Code:
mapType* mapPointer = (mapType*)(*(DWORD*)(*(DWORD*)(itemInstance + 0x4) + 0x4));
That just crashes my game... Just to clarify I have other functions and they work just fine, this map is the only thing that I can't get to work.