Hooks

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

Moderator: JeremyaFr

Re: Hooks

User avatar
Ace Antilles
Admiral (Moderator)
Posts: 7824
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: 3918
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: 7824
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: 3918
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: 3918
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: 3918
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: 2174
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: 3918
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: 3918
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: 2263
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: 3918
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: 3918
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: 3918
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: 266
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: 266
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: 3918
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.

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

Post by JeremyaFr » Sat Jan 29, 2022 11:20 am

UPDATE

Hello,
I've updated the hooks.

Changes are:
- Switch to Visual Studio 2022.
- Remove support for Windows XP. The minimal OS requirement is now Windows 7.

User avatar
Vince T
Fleet Admiral (Administrator)
Posts: 14045
Joined: Fri Apr 27, 2001 11:01 pm
Contact:

Post by Vince T » Sat Jan 29, 2022 4:50 pm

Fair enough :)
Your ship, Captain. I need a drink. - Vince Trageton
Vince T's X-Wing HQ - where the bad guys get their gear

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

Post by Ace Antilles » Sun Jan 30, 2022 8:05 pm

JeremyaFr wrote:
Sat Jan 29, 2022 11:20 am
UPDATE
Hello,
I've updated the hooks.
Hi @JeremyaFr I just added the new hooks and the game won't start.
Crashes after the launcher right away. No 3d screen nothing.
Complete standard XWAU update 5 install.

Screenshot 2022-01-30 200102.jpg

Anyone else had this issue?
You do not have the required permissions to view the files attached to this post.
Chief XWAU Team annoying nitpicker.
Ace Antilles - The X-Wing Outpost
Image

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

Post by JeremyaFr » Sun Jan 30, 2022 8:46 pm

Ace Antilles wrote:
Sun Jan 30, 2022 8:05 pm
Hi @JeremyaFr I just added the new hooks and the game won't start.
@Ace Antilles
Hello,
There was a bug in the main hook.
I've fixed it.
Please redownload the hooks.

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

Post by Ace Antilles » Sun Jan 30, 2022 8:59 pm

JeremyaFr wrote:
Sun Jan 30, 2022 8:46 pm
Ace Antilles wrote:
Sun Jan 30, 2022 8:05 pm
Hi @JeremyaFr I just added the new hooks and the game won't start.
@Ace Antilles
Hello,
There was a bug in the main hook.
I've fixed it.
Please redownload the hooks.
Thanks Jeremy. That seems to have fixed it :)
Chief XWAU Team annoying nitpicker.
Ace Antilles - The X-Wing Outpost
Image

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

Post by JeremyaFr » Sun Apr 03, 2022 1:27 pm

UPDATE

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

Now a crash dump will be generated next to XWingAlliance.exe when the game crashes.

Bman
Lieutenant Commander
Posts: 1167
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Sat Apr 09, 2022 7:46 am

Hi @JeremyaFr , I'm still getting crash to desktop issues with various *.dll hooks referenced as the faulting modules in the .dmp or in Windows Events Viewer. Sometimes the ntdll.dll system file too. I don't think this is related to DEP setting for XwingAllliance.exe or BlueMax's newest ddraw.dll and packaged files. Seems the hooks from XWAUPGv5 & TFTC v1.2 install are stable and work fine. I recently installed all of your newest 2022 hooks from you github webpage and the game .exe is currently crashing before launching, during mission review loading screen, and during inflight play, referencing different hooks at different times, i.e. hook_shield.dll, hook_mission_tie.dll, hook_pilot.dll etc. Did you recompile your dynamic link library files based on Microsoft's Visual Studio 2022 platform ? If so, do we need to install Microsoft .NET Framework version 4.8 or another version ? Or the Microsoft Visual C++ 2015 to 2022 Redestributable (x86) package ? I don't think DirectX11/12 API drivers are a related issue. Can you investigate when you have some free time? Do you need a sample crash report? Thanks.
W-I-P: TFTC, MC Viscount Cr., ISD-II Avenger, NL-1 Platform, Ton-Falk Esc. Cr., & Misc.

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

Post by JeremyaFr » Sat Apr 09, 2022 7:24 pm

I think that all these crashes are related to the memory usage of the game when more than 2 Gb are allocated.
Need to investigate.

Post Reply