none
[UWP]How to use HSA in UWP to access a mouse class device RRS feed

  • Question

  • Hi 

    We need HSA to access a touchpad device which apply a KMDF filter driver in the mouse class.

    I meet the access-deny error in below API

    FromIdAsync(Id, DeviceAccessMode::ReadWrite, DeviceSharingMode::Shared)

    We already use company's SCCD but still fail.

    It's ok to pass the API in FX2 device. That make me wonder if it's the limitation for mouse class device?

    Please kindly share some advice with me, 

    Really appreciate it


    Wednesday, June 20, 2018 11:39 AM

Answers

  • Custom device access opens device interfaces, it can't open control devices ("\\\\.\\mydevice" in your case). You can't add a new interface to your filter device and open it because mouclass will block you.  You need to

    1. enumerate a raw PDO instead of a control device, register GUID_DEVINTERFACE_OSRFX2 on this raw PDO, give this raw PDO a unqiue hardware ID, something like <guid1>\RawPDO, where guid1 is generated with uuidgen.exe
    2. create a new INF and don't use the mouse class. Use the HID or system class (in the [Version] section)
    3. in this new INF, match against <guid1>\RawPDO and move from the old INF all of the sections (XxxxIinterfaces, XxxAddInterface, Xxxx.AddProps ) related to marking the interface with the custom cap 

    the moufiltr and kbdfiltr both show how to enumerate a raw PDO


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, June 27, 2018 6:29 PM

All replies

  • Hi,

    I'll help you to move the thread to Windows Driver Froum, you could get more professional support there.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 21, 2018 7:40 AM
  • Are you trying to open a filter driver? I would assume you are trying to open a (raw?) pdo creates by your filter. Does the open work in a normal win32 app? What interface/ winrt object are you opening with FromIdAsync? Post the inf which adds the custom cap to the interface.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, June 21, 2018 11:58 AM
  • Hi Doron Holan,

    KT Liao  is my colleague.

    Thank you very much for your help and answer.

    ------------------------------------------------------------------------------------

    1.Are you trying to open a filter driver?

    Yes! Our driver is filter driver.

    2.I would assume you are trying to open a (raw?) pdo creates by your filter.

    It’s mouse filter driver and attach on mouse hid(mouhid.sys) node.

    3.Does the open work in a normal win32 app?

    Yes! Win32 app opens symbolic name be exported by driver.

    4.What interface/ winrt object are you opening with FromIdAsync?

    We use CustomCapability sample, so it should be Windows::device::Custom device class’s FromIdAsync,

    Because We must be use SendIOControlAsync api communicate with filter driver.

    We also use CustomHIDDeviceAccess sample from git,

    but the Windows::device::humaninterfacedevice class’s api has no SendIOControlAsync function.

    5.Post the inf which adds the custom cap to the interface.

    Yes! We have added custom capability section in package.appxmanifest file.

    ---

    So, the Windows::device::Custom device class’s FromIdAsync can open mouse filter driver and use SendIOControlAsync?

    If the above is not possible, are there other ways?



    Friday, June 22, 2018 3:03 AM
  • Post the inf, not appx manifest, that adds the custom cap to the device interface. Please post the win32 code that finds the symbolic link name and opens a handle. Does your filter attach above mouhid and below mouclass?

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Friday, June 22, 2018 12:41 PM
  • Thank you again for your attention!

    ---------------------------------------------------------------------------

    Post the inf, not appx manifest, that adds the custom cap to the device interface.

    èWe check inf file and it already was added custom capability!

    Please post the win32 code that finds the symbolic link name and opens a handle.

    èDoes your mean that we porting Win32 code to UWP program? Or could package Win32 to .dll be used by UWP?

    Does your filter attach above mouhid and below mouclass?

    èYes! Completely correct!!

    Monday, June 25, 2018 2:49 AM
  • 1) Post your INF. like I said, it is easy to get this wrong.

    2) Post the win32 code that works outside of UWP.  What I mean is the code that runs in a win32 process (not in UWP) that successfully opens the filter driver. I am not suggesting putting it into a DLL and running it in a UWP.  Are you opening a fixed device name (\\.\MyDevice) or a custom device interface GUID (using setupapi to enumerate the instance)?

    3) does your filter create a raw PDO or a control device? 


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, June 26, 2018 6:09 AM
  • Thank you again for your attention!

    -------------------------------------------------------------------------------

    I post partial content of inf and win32 as below:

    1)Post your INF.

    [Version]
    Signature="$Windows NT$"
    Provider=%VenderName%
    ClassGUID={4D36E96F-E325-11CE-BFC1-08002BE10318}
    Class=Mouse
    CatalogFile=mydevice.cat
    DriverVer=06/2/2018, 5.2.10.1

    ..........

    [HID_device.NT.Interfaces] AddInterface = "{%GUID_DEVINTERFACE_OSRFX2%}",, OsrFx2AddInterface [OsrFx2AddInterface] AddProperty = OsrFx2AddInterface.AddProps [OsrFx2AddInterface.AddProps] {%DEVPKEY_DeviceInterface_UnrestrictedAppCapabilities%}, 8, 0x2012,, %CustomCapability%

    [Strings]

    GUID_DEVINTERFACE_OSRFX2 = "0535CF14-ABA0-45A4-8317-E9176E7A4F70"
    DEVPKEY_DeviceInterface_UnrestrictedAppCapabilities = "026e516e-b814-414b-83cd-856d6fef4822"



    2)Post the win32 code that works outside of UWP.....

    	g_mydevice = ::CreateFile(_T("\\\\.\\mydevice"),
    				      GENERIC_READ | 
                                          GENERIC_WRITE,
    				      0,
    				      NULL,
    				      OPEN_EXISTING,
    				      0,
    				      NULL);


    3)does your filter create a raw PDO or a control device? 

    Our filter Driver create a control device.(WdfControlDeviceInitAllocate)

    Wednesday, June 27, 2018 11:37 AM
  • Custom device access opens device interfaces, it can't open control devices ("\\\\.\\mydevice" in your case). You can't add a new interface to your filter device and open it because mouclass will block you.  You need to

    1. enumerate a raw PDO instead of a control device, register GUID_DEVINTERFACE_OSRFX2 on this raw PDO, give this raw PDO a unqiue hardware ID, something like <guid1>\RawPDO, where guid1 is generated with uuidgen.exe
    2. create a new INF and don't use the mouse class. Use the HID or system class (in the [Version] section)
    3. in this new INF, match against <guid1>\RawPDO and move from the old INF all of the sections (XxxxIinterfaces, XxxAddInterface, Xxxx.AddProps ) related to marking the interface with the custom cap 

    the moufiltr and kbdfiltr both show how to enumerate a raw PDO


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, June 27, 2018 6:29 PM
  • Really appreciate Doron's hint
    Monday, July 2, 2018 2:03 AM