OpenSWE1R / openswe1r

An Open-Source port of the 1999 Game "Star Wars Episode 1: Racer"
https://openswe1r.github.io/
GNU General Public License v2.0
312 stars 26 forks source link

GOG - HID Device Write Access Error #164

Closed SeraEris closed 5 years ago

SeraEris commented 6 years ago

I'm sure you guys have a ton on your plate but maybe you can lend the GOG guys a hand with your back-end knowledge to help identify a nasty issue for a lot of players these days. There's an issue stemming from dinput enumerating the HID devices if one of them isn't supported(?) properly. The reverse stack-trace using window's Global Flags points it to this line.

Toggling each HID device until you disable the one that allows you to boot is the only way I've found to identify the incompatible device.

However once this is done the game runs fine, I've sort of reached my limits on this and sent GOG what I had; but maybe you guys already fixed this by using your own code?

JayFoxRox commented 6 years ago

Thanks for the bug report!

Unfortunately we have barely any DirectInput code disassembled or re-implemented :( There is some research about the games input subsystem, but it's probably incomplete. I'm also interested in why this happens, because I read that plugging in a specific model of headset will also break the game (which sounds super-weird to me). The game only uses Win32 (for mouse and very little keyboard during menus) and DirectInput APIs (for actual input) directly, so I can't fathom where the trouble comes from. It's also possible that Microsofts version of DirectInput has some bug which is being hit: the crash is in dinput.dll, not in the game. You'd expect DirectInput to sanitize the API inputs, so what's left is errors on the device backend (too many, weird unicode names, ...).

It would still be great if you could provide a more complete stacktrace, so we can see the function in SWEP1RCR.exe that was calling that code (we can only see dinput.dll in the screenshot - which is not part of the game). Also, if the GOG.com version ships with its own dinput.dll (possible!) or overloads these functions elsewhere (possible!) then it's probably a bug in their code instead.

The best idea I have, is that there' just too many devices of one kind, so SWE1R passes a bad buffer. That's the same issue the game has when the display has too many supported resolutions. But even then it should have been crashing in SWEP1RCR.exe probably.

I'm currently busy on other projects so OpenSWE1R is currently not getting active development by me. I still plan to return to this in the future and will certainly look at it again.

Also fun fact: I applied as Reverse Engineer at GOG (started writing my application just days before SWE1R was released by them - a crazy coincidence), but I never got a response to my application. They were also somewhat unresponsive on their forum and support.

SeraEris commented 6 years ago

Hey man, sorry to hear it's just you working on this; but here's a dump file of the issue being triggered, I'm just debugging with native symbols.

SWEP1RCR.exe.14032.dmp.zip

I'm using the windows app "Global Flags (x86)" for this to get the expanded backtrace.

gflags_2018-07-19_22-20-39

JayFoxRox commented 5 years ago

Closing this because it's not an issue with OpenSWE1R. If you care enough, create a new issue in swe1r-re and link this one. The RE project is the proper space to discuss issues / bugs / logic in the original game.