r57zone / DualShock4-emulator

DualShock4 emulation for Xbox controllers or keyboard and mouse / Эмуляция DualShock4 для Xbox контроллеров или клавиатуры и мыши
https://youtu.be/17hY1zTqoYQ
The Unlicense
189 stars 30 forks source link

Still crashing seconds after startup #39

Closed e-t-l closed 2 years ago

e-t-l commented 2 years ago

Probably related to #3 and/or #17, possibly #22.

The Problem

When I open DS4Emulator or DS4Emulator64.exe, it crashes after a couple seconds. This has persisted through every version since at least 1.7.3. I have all the dependencies installed already. My machine is 64-bit Windows 11 Home, although this behavior also occurred when I was still on Windows 10 Home.

When it runs in a normal CMD window, the window closes automatically on crash. On Windows Terminal, however, the window stays open so I can see that it say: Process exited with code 3221225477

It generated a dump file and a windows error reporting file, but for some reason WinDBG is not starting on my computer, so I'm attaching them instead (zipped because github doesn't support .dmp or .wer attachments. Hopefully they will be helpful. [AppCrash_DS4Emulator64.zip]

The Workaround

A workaround that sometimes works to prevent DS4Emulator from crashing is, immediately after starting the emulator, pressing Alt+F9 to view stick input values, waiting a few seconds, then pressing Alt+F9 again to hide values. For some reason, the emulator usually will not crash during or after this (until the next restart, that is).

r57zone commented 2 years ago

Unfortunately, I don't know why this happens, I can only suggest reinstalling the Vigem driver, installing all the libraries, trying the regular version and the x64 version.

e-t-l commented 2 years ago

So the exit code and dump logs didn't help? :/

r57zone commented 2 years ago

Unfortunately nope

e-t-l commented 2 years ago

So my workaround is now not working consistently, which is weird. Just today it started crashing even while in Alt+F9 mode. I tried searching "[process exited with code 3221225477]" and it looks like a not-uncommon problem, but I don't know enough about the backend of DS4Emulator to know which fix is appropriate. Does this github thread help you at all?

e-t-l commented 2 years ago

And from this thread:

Try converting that number to hex. It is 0xC0000005. This is the Intel classic memory exception error. Try googling "C0000005".

Of course this doesn't actually help to locate the reason why it's occurring except to say that some process has made access to memory it does not (as far as GDTs say) "own".

I suppose it could be hinting at insufficient RAM in your PC?

So it might be something about memory access. I don't know if there's anything unorthodox with the way this emulator accesses stuff in memory. In the meantime, I'm going to see if there's a firewall or AV or something on my PC I can disable to make this issue stop...

In the thread I linked, the problem had to do with internet access. My instance of the emulator shouldn't use internet (I set [Motion] Activate=0) but is it possible the emulator is still trying to access a network connection even though it doesn't use it? Is there a way to make an offline version of this emulator that has all networking features stripped out?

r57zone commented 2 years ago

Motion - Activate = 0 completely disables network functions (support for external Android gyroscope). https://github.com/r57zone/DualShock4-emulator/releases/tag/1.7.2 It seems this is the last version without a gyroscope, but that version also crashes for some users. I don’t know the reason.

e-t-l commented 2 years ago

Interesting. I did some testing with it, and these are my findings so far:

Bottom line is that there might be two separate issues here. First, there's something about my AV that I have to figure out. Second, there's something about using xbox controller input that is causing an error. (I'm specifically using Xbox One controllers connnected via USB, if you're interested).

r57zone commented 2 years ago

Probably Kaspersky is blocking dynamic loading of dll libraries (I load dynamically XInput.dll), probably it will be possible to try to convert it to static loading.

r57zone commented 2 years ago

I made a test version with a static library, could you check it out? DS4Emulator.1.7.5.XInput.Static.Portable.zip

e-t-l commented 2 years ago

I tried it and it appears to work!

r57zone commented 2 years ago

The only problem is that there is no way to track the Guide button (Xbox) in the static api. I'll probably have to support 2 versions at the same time now.

r57zone commented 2 years ago

@e-t-l thanks for reporting the bug and testing!

e-t-l commented 2 years ago

there is no way to track the Guide button (Xbox)

You mean the static version can't detect presses on the round Xbox button? Back+RB from #29 still works to trigger the PS button, so it doesn't seem like that big of a deal if the Xbox button's functionality gets deprecated... Or is there some other purpose the Xbox button was going to serve?

r57zone commented 2 years ago

Back + RB works, but the Guide button on the Xbox controller itself is no longer tracked as a PS button. It will be necessary to think more on this topic.

r57zone commented 2 years ago

Last static release DS4Emulator.1.7.5.Static.Portable.zip

e-t-l commented 1 year ago

@r57zone Is there a patch I could apply when building from source in VS so that I can continue to use up-to-date versions of DS4em with static libs?

r57zone commented 1 year ago

It's hard for me to maintain two versions, static and dynamic load xinput, the problem with static is that it seems that we can't capture the Xbox button there.

I think this problem can be solved by sending the file to the antivirus company, with a link to the source code, maybe they will fix it, add the program to the exceptions or disable the antivirus (they are still useless, real new viruses bypass them, and they mark new programs as viruses without understanding, what they do, but if sign the program with a paid certificate for $5,000, then the virus turns into a good program).

e-t-l commented 1 year ago

Sorry I think my original question was poorly worded. I am not worried about the antivirus issue. I do not want to make you do extra work by maintaining two versions, however the static version does work better for me.

I am capable of compiling DS4em myself in Visual Studio, but I would like to compile a version with static libs. Is there a patch, diff, or instructions you could provide for the building the static version? Then I could compile "DS4Emulator.2.0.1.Static.Portable.exe" and static versions of all future releases by myself, and you would not have to do any work of maintaining two versions.

r57zone commented 1 year ago

Unfortunately there is no such patch, I just changed the Xbox controller state reading functions, here is an example of using XInput statics XInput.zip