-
EnumVisibleObjects - Is ClntObjMgrPtr no longer in use? What to do with the callback
My diffing isn't really working because it renames the wrong functions, so I'm trying to track down a few things manually. There are like 3 functions that are nearly the same, and I suspect that one of them is EnumVisibleObjects. My understanding is that EVO takes a callback as a parameter and calls it according to a filter. I'm not sure what to do with this callback to retrieve the entities.
This is what I'm guessing is EnumVisibleObjects (Retail)
Code:
__int64 __fastcall enumVisibleObj_140FAD5F0(unsigned int (__fastcall *callback)(__int64, __int64), __int64 filter)
{
__int64 objFilter; // rdi
unsigned int (__fastcall *fCallback)(__int64, __int64); // rsi
_QWORD *entity; // rbx
__int64 objProperty???; // rcx
objFilter = filter;
fCallback = callback;
entity = *(_QWORD **)(sCurMgr_1429DFEF0 + 0x120);
if ( entity == (_QWORD *)(sCurMgr_1429DFEF0 + 0x120) )
return 1i64;
while ( 1 )
{
objProperty??? = (__int64)(entity + 5); // is this the object guid?
entity = (_QWORD *)*entity;
if ( !fCallback(objProperty???, objFilter) )
break;
if ( entity == (_QWORD *)(sCurMgr_1429DFEF0 + 0x120) )
return 1i64;
}
return 0i64;
}
I'm not sure what I'm supposed to be doing in the callback function. Any hint in the right direction would be greatly appreciated. It seems in previous builds, the callback would call ClntObjMgrPtr to get a pointer to the entity, but I'm confused because the behavior seems a bit different now.
edit: I think I'm overcomplicating this. I setup a basic callback to show a messagebox for the objectProperty??? and it has like 100 valid things it shows. Not sure what I'm looking at though (entity + 5)
edit edit: I found a nice candidate for ClntObjMgrPtr but I need a plugin to decompile since it's a big function. I'm now trying to find 'ByGUID' functions to test stuff out.
Last edited by GlittPrizes; 06-29-2020 at 11:15 PM.
Reason: update
-
Member
a good description posted by "counted" (8.2.5.31960)
Note that your line
Code:
objProperty??? = (__int64)(entity + 5); // is this the object guid?
the "+5" is probably wrong. For some unknown reason, my decompiler gives me a wrong offset "-3", too. The assembly line is like this
and the offset should be -0x18.
-
Post Thanks / Like - 1 Thanks
GlittPrizes (1 members gave Thanks to SailorMars for this useful post)
-
Originally Posted by
SailorMars
a good description posted by "counted" (8.2.5.31960)
Note that your line
Code:
objProperty??? = (__int64)(entity + 5); // is this the object guid?
the "+5" is probably wrong. For some unknown reason, my decompiler gives me a wrong offset "-3", too. The assembly line is like this
and the offset should be -0x18.
That makes sense the + 5 was throwing me off. After looking through counted's post I'm getting a better grasp of the object manager. So the - 0x18 should be a pointer to the next object? This pointer gets sent to the callback where I can dereference it and cast it to the WoWObject struct. From there I can use the guid to call ByGUID functions. That is my plan I'm just away from the PC at the moment, so I'll try to put a test together later.
-
I'm only getting objects (0) and no other types. The WoWObject struct seems to be aligned by checking with offsetof.
Main.cpp
Code:
uint64_t EnumObjectsCallback(int64_t objectPtr, int64_t filter)
{
if (objectPtr)
{
auto* object = reinterpret_cast<WoWObject*>(objectPtr);
// switch object->Type
return 1;
}
return 0;
}
void EnumObjects()
{
GameMethods::EnumVisible(EnumObjectsCallback, 0);
}
WoWObject.h
Code:
enum TypeId
{
OBJECT = 0,
ITEM = 1,
CONTAINER = 2,
AZERITE_EMPOWERED_ITEM = 3,
AZERITE_ITEM = 4,
UNIT = 5,
PLAYER = 6,
ACTIVE_PLAYER = 7,
GAME_OBJECT = 8,
DYNAMIC_OBJECT = 9,
CORPSE = 10,
AREA_TRIGGER = 11,
SCENE_OBJECT = 12,
CONVERSATION = 13
};
struct Guid
{
unsigned long High;
unsigned long Low;
};
#pragma pack(1)
struct WoWObject
{
int64_t VTable; // 0x0
char Pad1[2]; //
TypeId Type; // 0x10
char Pad2[4]; //
int64_t NextObj; // 0x18
char Pad3[14]; //
Guid Guid; // 0x40
};
GameMethods.cpp
Code:
typedef uint64_t (__fastcall* EnumVisibleCb)(int64_t, int64_t);
int64_t GameMethods::EnumVisible(EnumVisibleCb callback, int64_t filter)
{
return reinterpret_cast<int64_t(__fastcall*)(EnumVisibleCb, int64_t)>(Offsets::Base + Offsets::EnumVisibleObjects)(callback, filter);
}
Last edited by GlittPrizes; 07-01-2020 at 02:33 AM.
Reason: most recent attempt
-
Contributor
Originally Posted by
SailorMars
a good description posted by "counted" (8.2.5.31960)
Note that your line
Code:
objProperty??? = (__int64)(entity + 5); // is this the object guid?
the "+5" is probably wrong. For some unknown reason, my decompiler gives me a wrong offset "-3", too. The assembly line is like this
and the offset should be -0x18.
In C when you increase a pointer it increases by num * size of pointer so
+5 becomes 5 * 0x8 in this case because wow is 64-bit
and -3 becomes -3 * 0x8 which is equal -0x18.
For clarity about "pointer size", a 32-bit program would multiply by 0x4 because the pointer sizes in a 32-bit program is... 32-bit so 0x4. Respectively 0x8 in 64-bit programs because, 64-bit integers.
If it is prefixed with a * (dereference) it instead increases the value that the pointer is pointing to which you seem to confuse it with.
-
Post Thanks / Like - 1 Thanks
GlittPrizes (1 members gave Thanks to ejt for this useful post)
-
I think I have it working after reading type at obj + 0x16 and making sure the Type enum is uint8_t. I say I think so because when testing on two different characters, it only found one ACTIVE_PLAYER each as well as a variety of other object types. I suppose I could confirm it through the active player guid, but I'm pretty sure I have it setup now which is awesome for me I never thought I'd see the day
edit: I was confusing 0x16 with +16, so it is still 0x10 and the GUID appears to also be 0x40 in latest patch.
Last edited by GlittPrizes; 07-06-2020 at 11:04 AM.
Reason: hex to decimal confusion
-
Member
There are 3 functions.
EnumVisibleObjects should be + 0x120 and +5(+0x40) callback OBJECT
EnumVisibleObjectsPtr should be + 0x120 and -3(-0x18) callback objectPTR
EnumVisibleUnitsPtr should be + 0x130 and -5(-0x40) callback unitPTR
-
Post Thanks / Like - 1 Thanks
GlittPrizes (1 members gave Thanks to 34D for this useful post)