Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes when closing host before RemotePlay #3

Open
grill2010 opened this issue Jan 5, 2018 · 12 comments
Open

Fix crashes when closing host before RemotePlay #3

grill2010 opened this issue Jan 5, 2018 · 12 comments

Comments

@grill2010
Copy link

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.

@komefai
Copy link
Owner

komefai commented Jan 5, 2018

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!

@grill2010
Copy link
Author

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?

@komefai
Copy link
Owner

komefai commented Jan 5, 2018

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?

@grill2010
Copy link
Author

grill2010 commented Jan 5, 2018

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

@komefai
Copy link
Owner

komefai commented Jan 5, 2018

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.

@grill2010
Copy link
Author

grill2010 commented Jan 5, 2018

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
Copy link
Author

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.

@komefai
Copy link
Owner

komefai commented Jan 6, 2018

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.

@hapile299
Copy link

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

@Tustin
Copy link

Tustin commented Oct 6, 2018

@hapile299
Pressing X one time:

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

Holding X for 5 seconds

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

@hapile299
Copy link

@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?

@wu452148993
Copy link

Hello, has this problem been solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants