Reminder: Internet Explorer 6 or below are NOT supported.





There are currently 50 users playing Freelancer on
38 servers. | April. 16, 2021 |
The Starport Forum Index
>
The Shipyard
>
Speciality Modding
>
Freelancer-related Programming
>
CObject* to IObjInspectImpl*?
Browsing this Thread:
1 Anonymous Users
CObject* to IObjInspectImpl*? |
||||
---|---|---|---|---|
Starport Admin
![]() ![]() Joined:
2009/2/21 21:42 Group:
Webmasters Registered Users
Posts:
3520
![]() |
So this has been bugging me for ages: we can easily pass from an IObjInspectImpl* to a CObject by the cobject() function, but there appears to be no straightforward manner of going the other way around.
Is there a function which can be used to find or create an IObjInspectImpl* from a CObject* or its id? The server has GetShipInspect, which uses the id, but that doesn't seem to exist on the client, or I haven't found it if it does. Thoughts?
Posted on: 2014/5/9 19:02
|
|||
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try." -Peggy Noonan |
||||
|
Re: CObject* to IObjInspectImpl*? |
||||
---|---|---|---|---|
Home away from home
![]() ![]() Joined:
2009/8/16 2:58 From Qld, Aus.
Group:
Registered Users FLServer Admins Trusted Speciality Developers Senior Members
Posts:
1985
![]() |
It looks like some equipment contains a pointer to the Inspect, so use EquipTraverser to find one that matches. Hope I've done this right, I was just tracing through the debugger:
Code: CObject* object;
Posted on: 2014/5/10 17:01
|
|||
|
Re: CObject* to IObjInspectImpl*? |
||||
---|---|---|---|---|
Starport Admin
![]() ![]() Joined:
2009/2/21 21:42 Group:
Webmasters Registered Users
Posts:
3520
![]() |
Huh, I wouldn't have thought to go that way around. I'll check if that works, thanks!
Posted on: 2014/5/10 23:07
|
|||
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try." -Peggy Noonan |
||||
|
Re: CObject* to IObjInspectImpl*? |
||||
---|---|---|---|---|
Starport Admin
![]() ![]() Joined:
2009/2/21 21:42 Group:
Webmasters Registered Users
Posts:
3520
![]() |
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.
Posted on: 2015/4/2 22:54
|
|||
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try." -Peggy Noonan |
||||
|
Re: CObject* to IObjInspectImpl*? |
||||
---|---|---|---|---|
Home away from home
![]() ![]() Joined:
2009/8/16 2:58 From Qld, Aus.
Group:
Registered Users FLServer Admins Trusted Speciality Developers Senior Members
Posts:
1985
![]() |
There still doesn't seem to be any way to get the inspector from the object. I think you'd have to hook
CBase::advise 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.
Posted on: 2015/4/3 9:20
|
|||
|
Re: CObject* to IObjInspectImpl*? |
||||
---|---|---|---|---|
Starport Admin
![]() ![]() Joined:
2009/2/21 21:42 Group:
Webmasters Registered Users
Posts:
3520
![]() |
You mean that the game builds the IObjInspectImpl when the CObject contained within is created?
Posted on: 2015/4/3 15:38
|
|||
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try." -Peggy Noonan |
||||
|
Re: CObject* to IObjInspectImpl*? |
||||
---|---|---|---|---|
Home away from home
![]() ![]() Joined:
2009/8/16 2:58 From Qld, Aus.
Group:
Registered Users FLServer Admins Trusted Speciality Developers Senior Members
Posts:
1985
![]() |
Looks that way. Turns out removing old ones is simple:
CBase::advise is called with a bool parameter - true for creation, false for destruction.
Posted on: 2015/4/4 14:06
|
|||
|
Re: CObject* to IObjInspectImpl*? |
||||
---|---|---|---|---|
Starport Admin
![]() ![]() Joined:
2009/2/21 21:42 Group:
Webmasters Registered Users
Posts:
3520
![]() |
Excellent then, thanks!
Posted on: 2015/4/4 15:21
|
|||
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try." -Peggy Noonan |
||||
|
Re: CObject* to IObjInspectImpl*? |
||||
---|---|---|---|---|
Starport Admin
![]() ![]() Joined:
2009/2/21 21:42 Group:
Webmasters Registered Users
Posts:
3520
![]() |
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.
Posted on: 2015/4/5 3:07
|
|||
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try." -Peggy Noonan |
||||
|
Re: CObject* to IObjInspectImpl*? |
||||
---|---|---|---|---|
Home away from home
![]() ![]() Joined:
2009/8/16 2:58 From Qld, Aus.
Group:
Registered Users FLServer Admins Trusted Speciality Developers Senior Members
Posts:
1985
![]() |
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).
Posted on: 2015/4/6 1:54
|
|||
|
Re: CObject* to IObjInspectImpl*? |
||||
---|---|---|---|---|
Starport Admin
![]() ![]() Joined:
2009/2/21 21:42 Group:
Webmasters Registered Users
Posts:
3520
![]() |
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.
Posted on: 2015/4/9 20:23
|
|||
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try." -Peggy Noonan |
||||
|
Re: CObject* to IObjInspectImpl*? |
||||
---|---|---|---|---|
Starport Admin
![]() ![]() Joined:
2009/2/21 21:42 Group:
Webmasters Registered Users
Posts:
3520
![]() |
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.
Posted on: 2016/1/10 18:58
|
|||
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try." -Peggy Noonan |
||||
|
Re: CObject* to IObjInspectImpl*? |
||||
---|---|---|---|---|
Starport Admin
![]() ![]() Joined:
2009/2/21 21:42 Group:
Webmasters Registered Users
Posts:
3520
![]() |
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.
Posted on: 2016/1/15 1:00
|
|||
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try." -Peggy Noonan |
||||
|