Hooks

A Forum dedicated to the Suggestion, Creation and Editing of XWA Dynamic Link Library Files

Moderator: JeremyaFr

Post Reply

Re: Hooks

User avatar
Ace Antilles
Admiral (Moderator)
Posts: 6379
Joined: Sat Jan 22, 2000 12:01 am
Contact:

Post by Ace Antilles » Wed Sep 02, 2020 2:49 pm

JeremyaFr wrote:
Wed Sep 02, 2020 2:33 pm
Hello,
To replace the A-Wing with a R41, you can try to replace this in HangarObjects and Objects:

Code: Select all

;HangarObjects
FlightModels\AWing.opt = FlightModels\R41.opt

Code: Select all

;Objects
FlightModels\AWing.opt = FlightModels\R41.opt
FlightModels\AWingCockpit.opt = FlightModels\R41.opt
FlightModels\AWingExterior.opt = FlightModels\R41.opt
It didn't work. Did it work for you?
As said before it looks like something happens as the display image changes size, kinda like an LOD change, but it still didn't show the right opt.
You can change a Non Flyable ship like a Medium Transport into a R41. But I can't turn any Flyable fighter into another flyable fighter, R41 as an example.
Chief XWAU Team annoying nitpicker.
Ace Antilles - The X-Wing Outpost
Image

User avatar
JeremyaFr
XWAU Member
Posts: 3205
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Wed Sep 02, 2020 3:18 pm

I tested in B4M2.

So 1b4m2b.ini looks like that:

Code: Select all

;1b4m2b.ini

[Resdata]
Resdata\Planet2.dat

[HangarObjects]
FlightModels\AWing.opt = FlightModels\R41.opt

[Objects]
FlightModels\AWing.opt = FlightModels\R41.opt
FlightModels\AWingCockpit.opt = FlightModels\R41.opt
FlightModels\AWingExterior.opt = FlightModels\R41.opt

User avatar
Ace Antilles
Admiral (Moderator)
Posts: 6379
Joined: Sat Jan 22, 2000 12:01 am
Contact:

Post by Ace Antilles » Wed Sep 02, 2020 8:16 pm

That way did work but it changed things in the Hangar too which wasn't what I really wanted though.
It let me do the necessary experimenting I needed to check anyway.
Thanks for your help.
Chief XWAU Team annoying nitpicker.
Ace Antilles - The X-Wing Outpost
Image

User avatar
JeremyaFr
XWAU Member
Posts: 3205
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Thu Sep 03, 2020 2:54 pm

UPDATE

Hello,
I've updated XwaHooksSetup.

I've added support for tools exe in the hooks zip packages.
For now, no hook has a config tool inside the zip. So it is not needed to redownload the hooks.

User avatar
JeremyaFr
XWAU Member
Posts: 3205
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Fri Sep 11, 2020 11:39 am

UPDATE

Hello,
I've updated the mission objects hook.

Now you can overwrite the cockpit pov settings when an opt is replaced via the hook.

Suppose that the new craft is "FlightModels\[Model].opt".
To define the cockpit POV, set CockpitPovX, CockpitPovY and CockpitPovZ in a file named "FlightModels\[Model]CockpitPov.txt" or create a section named "[CockpitPov]" in "FlightModels\[Model].ini".

User avatar
JeremyaFr
XWAU Member
Posts: 3205
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sat Oct 10, 2020 2:43 pm

UPDATE

Hello,
I've updated the mission objects hook.

Now turrets settings are replaced when a craft is replaced.

User avatar
Driftwood
Admiral (Moderator)
Posts: 2157
Joined: Wed Oct 22, 2003 11:01 pm
Contact:

Post by Driftwood » Sat Oct 10, 2020 3:03 pm

Similar to cockpit POV changes?

User avatar
JeremyaFr
XWAU Member
Posts: 3205
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sat Oct 10, 2020 3:11 pm

Driftwood wrote:
Sat Oct 10, 2020 3:03 pm
Similar to cockpit POV changes?
Yes

User avatar
JeremyaFr
XWAU Member
Posts: 3205
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Wed Oct 21, 2020 1:55 pm

UPDATE

Hello,
I've updated the mission objects hook.

I've fixed a crash with the turrets.

baggy101
Cadet 2nd Class
Posts: 72
Joined: Mon Feb 02, 2015 9:32 am

Post by baggy101 » Thu Nov 26, 2020 10:34 pm

Can the mission objects hook be used to define a flightgroup opt rather than a flight model?

Tony Knightcrawler
Commander
Posts: 2255
Joined: Sat Nov 29, 2003 12:01 am
Contact:

Post by Tony Knightcrawler » Sat Nov 28, 2020 10:28 pm

Would it be possible to insert a ship-selection screen after the mission briefing? It could be the same selection screen that is used in the Skirmish Editor, but only some of the ships are shown and all options are locked except for what ship you are flying in? The Modified Strike Cruiser model (and the Shipyard, come to think of it) got me thinking that it'd be really cool to import the Balance of Power campaign into XWA. If we could get this ship selection and also get multiplayer campaigns, that'd be really cool. Maybe multiplayer campaigns could work by creating a duplicate clickable multiplayer area in the Simulation Room, where the host selects a battle and it sets everyone to mission 1, then it forces players into the concourse briefing room for that mission, wait for them to select ships, launch the mission when they have all selected, then load the next mission briefing if they succeeded or the same mission if they failed, etc.. Of course I know this'd be ridiculously hard, but I just thought maybe I should put that down here.

User avatar
JeremyaFr
XWAU Member
Posts: 3205
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sat Jan 30, 2021 4:04 pm

UPDATE

Hello,
I've updated the d3dinfos textures hook.

Now the illumination is not rendered for disabled crafts.

User avatar
JeremyaFr
XWAU Member
Posts: 3205
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Tue Feb 02, 2021 8:02 pm

UPDATE

Hello,
I've updated all the hooks.

Now the cfg files are read before the ini files.

User avatar
JeremyaFr
XWAU Member
Posts: 3205
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sat Mar 06, 2021 3:20 pm

UPDATE

Hello,
I've updated the main hook (dinput.dll).

Now the EFLAGS register is preserved when a hook function is called.
The EFLAGS register contains flags about the result of instructions like zero, carry, or overflow. One usage of the flags is a conditional jump instruction.

User avatar
m0rgg
XWAU Member
Posts: 100
Joined: Wed Apr 01, 2020 10:33 pm

Post by m0rgg » Tue Nov 02, 2021 12:54 am

Hello @JeremyaFr and all of the other hooking gurus,

I'm trying to understand how hooks work to be able to modify CockpitLook hook to improve VR head tracking and reduce jitter.

I see in hooks.h the values for where the hook should be inserted:

Code: Select all

static const HookFunction g_hookFunctions[] =
{
	{ 0x4F9A66, CockpitLookHook },

};

static const HookPatchItem g_patch[] =
{
	//////////////////// Hook Patches ////////////////////

	// Entry
	{ 0xF8E61, "66399369A08B00", "E8BAF00A009090" },
};
If I'm not mistaken the g_patch item tells Hook_Main to replace the instruction at 0xF8E61 (exe offset, that needs to be added to the default base address and it's in fact the same offset in the g_hookFunctions)

Code: Select all

cmp     PlayerDataTable.Camera.ExternalCamera[ebx], dx
with this:

Code: Select all

call    near ptr unk_5A8B20
I assume 0x5A8B20 is the address where the hook function will reside. How do you choose the address? Is it arbitrary and the main hook makes sure the right code from the DLL is loaded there? In that case, is there a list of addresses already occupied by existing hooks?
Also, will the hook function eventually call the cmp instruction replaced? Or is it lost?

If I want to hook a new function, how should I choose a valid address to patch? Can I target the "align 10h" immediately before the function? I'm looking specifically at 0x4EE817 (just before PlayerCameraUpdate).

Thanks in advance!

User avatar
m0rgg
XWAU Member
Posts: 100
Joined: Wed Apr 01, 2020 10:33 pm

Post by m0rgg » Tue Nov 02, 2021 1:11 am

m0rgg wrote:
Tue Nov 02, 2021 12:54 am
I assume 0x5A8B20 is the address where the hook function will reside. How do you choose the address? Is it arbitrary and the main hook makes sure the right code from the DLL is loaded there? In that case, is there a list of addresses already occupied by existing hooks?
OK, answering myself after realizing that the same address is used in most (all?) of the hooks, I assume the hook main will put some kind of "dispatcher" function there that will call the appropriate hook depending on the calling address. Is that correct?

User avatar
JeremyaFr
XWAU Member
Posts: 3205
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sat Nov 27, 2021 2:15 pm

m0rgg wrote:
Tue Nov 02, 2021 1:11 am
I assume the hook main will put some kind of "dispatcher" function there that will call the appropriate hook depending on the calling address. Is that correct?
That's right. The main hook (dinput.dll or hooks_main.dll) calls the right hook based on the calling address.

Post Reply