0

It may seems to be an unusual question at first but let me explain what I try to do.

I've developed a program which is able to hook into a 3rd party program called PS4 Remote Play. The PS4 Remote Play program only allows you to use a real Dualshock gamepad for controlling your games. So my program is hooking into low level APIs from Windows (kernel32.dll, hid.dll) to bypass this limitation. What my hooks are doing is whenever CreateFileW is called for an HID device my program returns a custom dummy pointer and the corresponding hooked hid.dll methods which are called afterwards are acting like this dummy pointer is a Dualshock gamepad.

So far so good. But recently I got some reports from users of my program that the "emulated" Dualshock is not working and the inputs send to this virtual Duashock are not processed. It took me some time to figure out why. Whenever a user is using a laptop or a PC without an HID device connected, the PS4 Remote Play program never calls the CreateFileW, at least not for creating an HID handle.

I don't want to install a dummy driver with my application for just making Windows think an HID device is connected. Instead I try to hook into the functions of setupapi.dll and only make the PS4 Remote Play program think a random dummy HID device is connected so that it calls the CreateFileW method. I'm already hooked into

  • SetupDiGetClassDevs
  • SetupDiEnumDeviceInfo
  • SetupDiGetDeviceInterfaceDetail

But I have no experience with this API so I have a few questions.

Does the device information set returned by SetupDiGetClassDevs always contain a device information element for HID devices even when no HID device is connected? If not, how can I add a fake device information for HID devices or how can I create a fake device information set in C# and return that instead? Or is this not needed at all, as I can just hook into the other two methods and do something there.

Any advice or hint how I could solve this issue would be great. It is not necessary that Windows think an HID device is connected only the 3rd Party program should act like there is one connected to the PC.

grill2010
  • 574
  • 6
  • 23
  • I think the solution with dummy driver is much better. Now you do some type of "hack". I guess in WDK exist example/dummy HID driver which can easily be modified and compiled. The only problem can be driver signature for easy installation. – i486 Dec 15 '18 at 21:52
  • Thank you for your answer, as I said I would prefer to not install any additional driver as it doesn't bring any benefit for the user. Anyway, I finally achieved it by hooking into the the SetupDiEnumDeviceInterfaces and SetupDiGetDeviceInterfaceDetailW method. It took me some time to understand the workflow of the setupapi but it works now on all of my test PCs. The official PS4 RemotePlay program always thinks now that an HID device is connected. I will share my solution soon. – grill2010 Dec 16 '18 at 19:55

0 Answers0