CObject* to IObjInspectImpl*?
-
I’ll just resurrect this because I’ve stumbled on a function that may be what I was looking for.
There’s a function at offset 0x5392D0 in Freelancer.exe which seems to initialize an IObjInspectImpl object. Looking up where it’s called I find another function at offset 0x530620 which calls this function after calling new. Moreover, its first argument is stored at offset 0x10 in the resulting object, which I know is the offset of the CObject* pointer in IObjInspectImpl.
The only thing I’m not sure about is what the second argument is; it’s probably another pointer and it’s used in a later call, but I’m not sure why or if it’s even necessary.
-
There still doesn’t seem to be any way to get the inspector from the object. I think you’d have to hook [c]CBase::advise[/c] and create your own map - (ecx - 0x0C) is the inspector and [ecx+4] the object. Not sure how you’d go about removing old ones, though.
-
You mean that the game builds the IObjInspectImpl when the CObject contained within is created?
-
Excellent then, thanks!
-
Hmm… Just looked into CBase::advise and it looks like it’s a dummy function? IDA is giving me 0x62ED730, which is also referenced as a bunch of other functions.
I’ve tried to hook the export address table but it doesn’t seem like the function is being called, so I’m not sure if the function is actually used or if I’m just sucking at hooking it.
-
Sure, the function does nothing, but it still gets called. It’s too late to patch the export (you’d have to patch the file itself for that, or create FL suspended), so you need to patch the import. It’s used by both freelancer.exe & server.dll, and they both create an inspector for the same object (well, they did for one CSolar, so probably for many things; didn’t test if only one creates one). So depending on what it is you want it for, you may need one or the other (but they’re probably the same).
-
After some more work figuring out how to hook a class member function with IATs, it appears to be working.
The only oddity is that you can’t use CBase::advise with the player’s ship, the IObjInspectImpl* pointer is always null in my mapping. Thankfully GetPlayerShip() works for that particular scenario.
-
Resurrecting this because of a particular annoyance: it seems like CGuided objects don’t call CBase::advise, even though they do have IObjInspects since they can be targeted.
-
Kept having issues with it so I dug again and I finally found it: offset 0x5416c0 contains a function of the signature IObjRW* (uint id, uint zero). Call it with the id and zero in the second parameter to get the IObjRW (which can just be cast to IObjInspectImpl) or null if there’s nothing associated.