Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

[C++/Xinput] Crash on script reload


ikt
 Share

Recommended Posts

Hello there, I've got a super specific crash but it's annoying as hell. Normal users won't ever come into contact with it, I think, but I'd rather be sure anyway.

 

I've put Xinput support into my mod to stop relying on the game's control readouts, which works awesome. However, the game just crashes if I reload it with the ScriptHookV.dev CTRL+R reload method. It's the game that crashes, not my .asi. If the game is stopped normally, it won't crash. It will neither crash if there's no Xbox controller plugged in. If it's re-plugged though, it will crash. I've tried this on a 617 build. Strangely, it won't crash on a 350 build with the same method. It will also not crash if I don't use any methods from the XboxController class even if there's a XboxController object.

 

I've tried a clean install, with just ScriptHookV, but it just crashes. My script and the ScriptHookV log both confirm that my mod exited succesfully. I've narrowed it down to xinput1_4.dll crashing from the Windows Event Log.

 

The up-to-date source code is here and the class that matters is this one:

XboxController.hpp

XboxController.cpp

 

The script.cpp might be a bit long, but just this should be equivalent for this purpose. It crashes with just this, regarding the XboxController thing.

#include "script.h"#include "XboxController.hpp" XboxController controller(1); void update() {    if (controller.IsConnected()) {      //bla    }}//bla

I thought it could've been a memory leak or something, but I wasn't using any dynamic objects anyway. If it was leaking memory, it would crash upon exit too, or at unplugging and reloading, right? I'm completely lost here.

 

Also, a crash report:

Faulting application name: GTA5.exe, version: 1.0.617.1, time stamp: 0x56a0f7f2Faulting module name: XINPUT1_4.dll_unloaded, version: 10.0.10586.0, time stamp: 0x5632d83fException code: 0xc0000005Fault offset: 0x0000000000001557Faulting process id: 0x8f4Faulting application start time: 0x01d170dccbbb6543Faulting application path: D:\Games\Steam\steamapps\common\Grand Theft Auto V\GTA5.exeFaulting module path: XINPUT1_4.dllReport Id: f0642610-32f0-4dfd-8c33-9aa565c1f4ccFaulting package full name:Faulting package-relative application ID:

I'm on Windows 10 (and I don't have machines running other versions) to check against.

Edited by ikt
Link to comment
Share on other sites

From what I know, the game relies on xinput1_3.dll - so maybe the DLLs somehow conflict?

Link to comment
Share on other sites

From what I know, the game relies on xinput1_3.dll - so maybe the DLLs somehow conflict?

 

Hmm, I tried putting an xinput1_3.dll in the game folder but the game still uses the xinput1_4.dll from Windows? I built my asi by just adding XInput.lib to the linker additional options. Shouldn't it crash on load if it conflicted?

 

Edit - Also tried to link against Xinput_9_1_0.lib but it didn't change anything. Curiously, application still crashes with XInput 1.4 being the culprit:

 

 

Faulting application name: GTA5.exe, version: 1.0.617.1, time stamp: 0x56a0f7f2Faulting module name: XInput1_4.dll_unloaded, version: 10.0.10586.0, time stamp: 0x5632d83fException code: 0xc0000005Fault offset: 0x0000000000001557Faulting process id: 0x1370Faulting application start time: 0x01d170eb44c64bf2Faulting application path: D:\Games\Steam\steamapps\common\Grand Theft Auto V\GTA5.exeFaulting module path: XInput1_4.dllReport Id: e287b702-e8e9-4c4f-a988-492ca87d4955Faulting package full name:Faulting package-relative application ID:

 

So I think it's definitely the game crashing, but now how do I get rid of this conflict?

Edited by ikt
Link to comment
Share on other sites

You probably should link against DirectX SDK.

Link to comment
Share on other sites

Okay, I'll try that. Thanks!

 

In any case, the Xinput.h I was using was from Windows and used xinput1_4.dll

 

Edit -

Linking it against the XInput.lib from DirectX SDK (2010) didn't work as it didn't have XInputGetState . Linking it against XInput9_1_0.lib make the game not even load. Apparently the Windows SDK is the one people should work with now?

 

Trying Windows 10 SDK now.

 

Edit -

Same sh*t happens.

Edited by ikt
Link to comment
Share on other sites

For .NET mods you can use SharpDx.XInput and everything will work fine.

 

Sadly, this is an .ASI mod and I don't feel like rewriting it for DotNet ;)

 

Also, the DirectX SDK did compile with linking against XInput1.3, but it still crashes in the same way. The event viewer still puts XInput 1.4 as the crashing module though? I'm pretty sure I'm linking the 1.3 one - got the DirectX SDK as highest priority include/library folders and VS opens the DirectX SDK headers.

Edited by ikt
Link to comment
Share on other sites

What really matters is the lib you're linking - you might have to include it as $(DXSDK_DIR)\lib\xinput.lib or so (not sure of the exact path).

Link to comment
Share on other sites

Op --

 

I am running into this same issue trying to compile my code against ScriptHookV. What did you do to differently to utilize the DirectX XInput vs Win10 XInput? Did you need to install the DirectX SDK and manually modify the pointer to use it, or are you doing something different, entirely?

 

Thanks for any insight -- reloading the whole game to validate compiled ASI is killing productivity :-/.

Link to comment
Share on other sites

Op --

 

I am running into this same issue trying to compile my code against ScriptHookV. What did you do to differently to utilize the DirectX XInput vs Win10 XInput? Did you need to install the DirectX SDK and manually modify the pointer to use it, or are you doing something different, entirely?

 

Thanks for any insight -- reloading the whole game to validate compiled ASI is killing productivity :-/.

 

You'll need to install it: DirectX SDK (June 2010). Then, in your Project Properties, go to Linker -> Input. In the Additional Dependencies page, just add this specific library:

 

"$(DXSDK_DIR)\Lib\x64\XInput.lib"

 

You'll need the quotes since VS doesn't like spaces in path names.

Link to comment
Share on other sites

You're a rockstar, ikt!

 

Thanks!

 

- Edit: that 100% solved my problem. If there were kudos on GTAF, I'd give you and Silent all of them. Thanks again!

Edited by thedeuceII
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.