PS4RemotePlayInterceptor icon indicating copy to clipboard operation
PS4RemotePlayInterceptor copied to clipboard

Fix crashes when closing host before RemotePlay

Open grill2010 opened this issue 6 years ago • 12 comments

Hi,

I'm currently try to fix the problem that the RemotePlay program crashes when you exit the Intercepting program. I read that you solved the problem but I checked and it seems that the RemotePlay program is not crashing anymore but the hooks get not disposed correctly. This leads to the effect that you can't hook into the running RemotePlay application again until you restart it which is far from ideal. Nevertheless, the problem is the _dummyHandle which gets passed to the RemotePlay process I guess. Because when you look at the RemotePlay program, it still believes that a Dualshock gamepad is connected. The _dummyHandle is just a virtual Hid device which does not really exists but I guess we should somehow make the RemotePlay process believe that it is disconnected now. I found now solution so far and I don't now if it is possible anyway.

grill2010 avatar Jan 05 '18 16:01 grill2010

Hi, I'm testing the latest commit of PS4Macro right now (which uses the latest version of the interceptor) and I don't have the problems you mentioned. I tested both with and without controllers and on both InjectionMode (auto and compatibility).

The only known problem I can think of is this error message from EasyHook: "STATUS_INTERNAL_ERROR: Unknown error in injected C++ completion routine. (Code: 15)"

This error has been in the interceptor since the first version, but as far as I know, this error occurs when you're executing the injection from different paths (or exe file) on the same instance of RemotePlay (which is why restarting it fixes the problem). The issue on EasyHook's bountysource has just been resolved recently but it doesn't seems to help much, I'll have to look more into it.

Not sure if this is the error you saw or not, but if you can note the error message and send it to me that would be great. Thanks!

komefai avatar Jan 05 '18 20:01 komefai

Okay strange, I do not use the PS4Macro I just use the newest PS4RemotePlayInterceptor. My application is slightly different then yours but I never got the

"STATUS_INTERNAL_ERROR: Unknown error in injected C++ completion routine. (Code: 15)"

If you just download the PS4RemotePlayInterceptor and run the PS4RemotePlayInterceptorConsole app and you close it after you successfully injected the controller emulation part what happens on your PC?

grill2010 avatar Jan 05 '18 20:01 grill2010

That is strange indeed. I tried running the console demo app. Tried both closing it by pressing any key and force closing it. When I tried to inject again (and again) it still works correctly.

What are your results from running the console app?

komefai avatar Jan 05 '18 20:01 komefai

Things I did.

  1. I downloaded the PS4RemotePlayInterceptor project.

  2. I started the PS4 RemotePlayApp.

  3. I started the PS4RemotePlayInterceptorConsole application

  4. I closed the PS4RemotePlayInterceptorConsole by just hitting enter in the command line window

Results are:

  1. PS4 RemotePlay app still thinks that a Dualshock gamepad is connected (it is logical to me or how should it get removed?)

  2. I close the PS4 RemotePlay app but I can't open it again because it still runs in the background. I think this is because of the Hooks are not disposed correctly somehow.

I did not modify your Source code. In my application I can successfully dispose the hook but as soon as this happens the PS4 RemotePlay program crashes and I guess it is because of the _dummyHandle gets destroyed. I've made a video which you can watch at

https://vimeo.com/249860887

grill2010 avatar Jan 05 '18 21:01 grill2010

Thanks a lot for the video. However, I tried to to replicate your results but I could not make PS4 RemotePlay a zombie process like it did in your video. As you said, it might be possible that remote play thinks that the handle is still active and waiting for the I/O close. Perhaps there are native function calls to something like CloseHandle that needs to be intercept.

I'll try to find a way to trigger this problem (maybe on other machines). Please let me know if you have any updates on this issue.

PS. I fixed the crashing issue by surrounding every hook with try/catch block. This might fix the crashes in your application.

komefai avatar Jan 05 '18 21:01 komefai

No problem, I will try to use another PC to reproduce the issue but as I can reproduce the problem on my laptop every time it might also occur on other PCs as well.

Yes, you are right, I was already playing around with the CloseHandle function and I have already intercepted it. But so far I could not made any progress. By the way the the program API Monitor v2 helps me a lot to figure out what is going on under the hood of the PS4RemotePlay program.

Let me know what are your results on other machines.

PS. I fixed the crashing issue by surrounding every hook with try/catch block. This might fix the crashes in your application.

Yes, I saw this but unfortunately it it did not have any effect.

grill2010 avatar Jan 05 '18 22:01 grill2010

I tried it now on two other PCs. On the first I had the same results, zombie process and the PS4 Remote Play program still believed that a Dualshock gamepad was plugged in. On the second PC everything worked as expected as soon as I closed the interceptor program the PS4 Remote Play program disconnected the virtual Dualshock gamepad and continued working as normal. I will test on some more machines the next days but it seems the results are dependent on the PC where the interceptor program gets executed. Btw. the PCs where I tested the interceptor program have Windows 10 installed.

grill2010 avatar Jan 06 '18 17:01 grill2010

Thanks again for the results! Right now I don't have access to other PCs (except for my macbook). I'll let you know the results when I have a chance to test it. Hopefully it will trigger the zombie process so that I can inspect it in details.

komefai avatar Jan 06 '18 23:01 komefai

Hi, can i get example code for press X button 1 time, and hold X button for 5s?

hapile299 avatar Oct 06 '18 13:10 hapile299

@hapile299 Pressing X one time:

Press(new DualShockState() { Cross = true });

Holding X for 5 seconds

Press(new DualShockState() { Cross = true }, 5000);

Tustin avatar Oct 06 '18 17:10 Tustin

@Tustin thanks, that help alot :) btw, there is anyway to detect an error message " 4 user already login" or " remoteplay lost connect" and press them?

hapile299 avatar Jan 10 '19 05:01 hapile299

Hello, has this problem been solved?

wu452148993 avatar May 30 '22 14:05 wu452148993