SilentPatchNFS90s icon indicating copy to clipboard operation
SilentPatchNFS90s copied to clipboard

Question About: Fixed a startup crash due to DirectInput controller enumeration being broken

Open elishacloud opened this issue 1 year ago • 14 comments

I have had an issue open in dinputto8 for a while regarding an issue with NFS: Porsche Unleashed crashing when certain controllers are used.

I troubleshot the issue down to a failing call to the CreateEffect function. The game cannot handle the fail and tries to access the nullptr after the call fails.

But I don't have the controller to test with so I am not quite sure why it fails. If you have any ideas that could help here that would be great.

elishacloud avatar Nov 06 '23 23:11 elishacloud

Sounds like #1 could be related - however it doesn't break on my wheel. It probably has to do with the game assuming specific FFB capabilities that the wheel might not have, but I am not sure how to test it more - maybe you could dump the input parameters and the result - who knows, perhaps the error here is not DIERR_INVALIDPARAM but something else.

CookiePLMonster avatar Nov 07 '23 09:11 CookiePLMonster

Sounds like #1 could be related

Yes, that is the same issue.

however it doesn't break on my wheel.

Ok, that is good to know at least. So it is not all wheels, just that one.

perhaps the error here is not DIERR_INVALIDPARAM but something else.

I just checked the logs and it is returning error code 0x80070057.

maybe you could dump the input parameters and the result

I did that and everything looked good, as far I as I can tell.

Here is the function call:

11420 16:27:50.551 m_IDirectInputDeviceX::CreateEffect (06D0CB60) Failed! GUID_Spring { dwSize: 52, dwFlags: 0x22, dwDuration: 4294967295, dwSamplePeriod: 2000, dwGain: 10000, dwTriggerButton: 4294967295, dwTriggerRepeatInterval: 50, cAxes: 2, rgdwAxes: 0019FC58, rglDirection: 0069CD38, lpEnvelope: 00000000, cbTypeSpecificParams: 48, lpvTypeSpecificParams: 0069CCF4, 6B14E57F} null hr: -2147024809

I am also seeing these calls fail:

10204 23:20:56.695 m_IDirectInputDeviceX::CreateEffect (0B119838) Failed! GUID_ConstantForce { dwSize: 52, dwFlags: 0x22, dwDuration: 4294967295, dwSamplePeriod: 2000, dwGain: 5000, dwTriggerButton: 4294967295, dwTriggerRepeatInterval: 0, cAxes: 2, rgdwAxes: 0019FC88, rglDirection: 0069CB88, lpEnvelope: 00000000, cbTypeSpecificParams: 4, lpvTypeSpecificParams: 0069CB44 ,00000000} null hr: -2147024809
10204 23:20:56.701 m_IDirectInputDeviceX::CreateEffect (0B119838) Failed! GUID_Square { dwSize: 52, dwFlags: 0x22, dwDuration: 4294967295, dwSamplePeriod: 2000, dwGain: 5000, dwTriggerButton: 4294967295, dwTriggerRepeatInterval: 0, cAxes: 2, rgdwAxes: 0019FC78, rglDirection: 0069CC18, lpEnvelope: 00000000, cbTypeSpecificParams: 16, lpvTypeSpecificParams: 0069CBD4 ,00000000} null hr: -2147024809

I don't see anything wrong with these calls, so I am not sure what parameter is wrong.

elishacloud avatar Nov 07 '23 23:11 elishacloud

BTW: here is the raw data with all functions logging: dinput_log.zip

For this update I created an IDirectInputEffect class and returned a pointer to that class even if the CreateEffect failed so that the game would play without crashing. Then I tried to add the effect by calling IDirectInputEffect::SetParameters().

3724 18:22:42.350 m_IDirectInputDeviceX::CreateEffect (090AC490) Trying! GUID_ConstantForce null
3724 18:22:42.350 DIEFFECT { dwSize:,52, dwFlags:,0x22, dwDuration:,4294967295, dwSamplePeriod:,2000, dwGain:,9900, dwTriggerButton:,4294967295, dwTriggerRepeatInterval:,0, cAxes:,2, rgdwAxes:,0019FC88, rglDirection:,0069CB88, lpEnvelope:,00000000, cbTypeSpecificParams:,4, lpvTypeSpecificParams:,0069CB44, ,0, }
3724 18:22:42.350 DIEFFECT rgdwAxes 0: 0
3724 18:22:42.350 DIEFFECT rgdwAxes 1: 4
3724 18:22:42.350 DIEFFECT rglDirection 0: 0
3724 18:22:42.350 DIEFFECT rglDirection 1: 0
3724 18:22:42.350 DIEFFECT lpvTypeSpecificParams { lMagnitude: 10000 }
3724 18:22:42.350 DIEFFECT { dwSize:,56, dwFlags:,0x22, dwDuration:,4294967295, dwSamplePeriod:,2000, dwGain:,9900, dwTriggerButton:,4294967295, dwTriggerRepeatInterval:,0, cAxes:,2, rgdwAxes:,0019FC88, rglDirection:,0069CB88, lpEnvelope:,00000000, cbTypeSpecificParams:,4, lpvTypeSpecificParams:,0069CB44, dwStartDelay:,4294967295, }
3724 18:22:42.351 DIEFFECT rgdwAxes 0: 0
3724 18:22:42.351 DIEFFECT rgdwAxes 1: 4
3724 18:22:42.351 DIEFFECT rglDirection 0: 0
3724 18:22:42.351 DIEFFECT rglDirection 1: 0
3724 18:22:42.351 DIEFFECT lpvTypeSpecificParams { lMagnitude: 10000 }
3724 18:22:42.351 m_IDirectInputDeviceX::CreateEffect (090AC490) Failed! hr: DIERR_INVALIDPARAM Retrying!
3724 18:22:42.351 m_IDirectInputDeviceX::CreateEffect (090AC490) SetParameters Failed! 359 hr: DIERR_INVALIDPARAM
3724 18:22:42.351 Creating interface m_IDirectInputEffect::m_IDirectInputEffect (0B510EA8)
3724 18:22:42.351 m_IDirectInputEffect::Unload (0B510EA8)

elishacloud avatar Nov 08 '23 00:11 elishacloud

Yes, that is the same issue.

This issue states

No other DirectInput wrappers. Running Windows 10.

which makes me think it's just a game bug - maybe these wheels just don't support the type of Force Feedback the game expects - although it would be strange not to support the constant force...

I have no further ideas atm, but I'll let you know if I manage to reproduce it or gather any more info.

CookiePLMonster avatar Nov 08 '23 16:11 CookiePLMonster

which makes me think it's just a game bug - maybe these wheels just don't support the type of Force Feedback the game expects

That is what I thought also, but it works without dinputto8. So I guess something is changing between the v1 CreateEffect() call and the v8 CreateEffect() call. Or some other function needs to be setup first that is not quite setup for v8, but still works with v1.

Anyways, thanks for looking. If you think of anything let me know.

elishacloud avatar Nov 08 '23 17:11 elishacloud

Anyways, thanks for looking. If you think of anything let me know.

Next time I have my wheel setup, I will try Porsche with dinputto8 - I use dinput.dll as an ASI loader for the patch, but I can just move to use dinput8.dll instead and both wrappers will co-exist.

CookiePLMonster avatar Nov 08 '23 17:11 CookiePLMonster

Thanks!

elishacloud avatar Nov 08 '23 17:11 elishacloud

Anyways, thanks for looking. If you think of anything let me know.

Next time I have my wheel setup, I will try Porsche with dinputto8 - I use dinput.dll as an ASI loader for the patch, but I can just move to use dinput8.dll instead and both wrappers will co-exist.

This would allow for Xidi to be used too. I'd really appreciate that. Thanks!

Goblan avatar Nov 10 '23 00:11 Goblan

This would allow for Xidi to be used too. I'd really appreciate that. Thanks!

You can already do that since UAL is generic - just rename dinput.dll to dinput8.dll and it will work fine. Of course you then need another dinput wrapper that'd load dinput8 so UAL works.

CookiePLMonster avatar Nov 10 '23 10:11 CookiePLMonster

This would allow for Xidi to be used too. I'd really appreciate that. Thanks!

You can already do that since UAL is generic - just rename dinput.dll to dinput8.dll and it will work fine. Of course you then need another dinput wrapper that'd load dinput8 so UAL works.

I'm not sure I understand... What dinput.dll file should I rename to dinput8.dll, yours or Xidi's?

Goblan avatar Nov 11 '23 10:11 Goblan

I am not sure if Xidi can load another DLL - if it can use another DLL as a proxy, you should have Xidi as dinput.dll and then rename mine to whatever you set the Xidi's proxy to.

CookiePLMonster avatar Nov 11 '23 10:11 CookiePLMonster

Xidi brings a dinput.dll file and a dinput8.dll file, to use one or the other depending on the game. I've contacted the creator to see if a solution can be found.

Goblan avatar Nov 11 '23 11:11 Goblan

Latest version of UAL allows to load original(or not original) dll by renaming it to <ualname>Hooked.dll. vorbisFile.dll -> vorbisHooked.dll for example. It was previously reserved for specific names, now works for all.

ThirteenAG avatar Nov 15 '23 05:11 ThirteenAG

Sounds great. I guess that sorts it out once and for all. Thanks so much!

Goblan avatar Nov 23 '23 22:11 Goblan