none
Access HID vendor collection from within metro app

    Question

  • Hi All,

     

       Though I did some progress, I am still stuck with trying to access HID vendor collection from within a metro app

    (see this thead, btw Eric thanks for your answer I did not reply..).

     

        I managed to install a stub HID filter driver on that vendor collection. In driver's INF file, HID interface class is declared as privileged :

     

     

    ;--- Win 8 Privileged Interface ------
    
    [HIDFiltInst.NT.Interfaces]
    AddInterface={4D1E55B2-F16F-11CF-88CB-001111000030},,Hid_Interface
    
    [Hid_Interface]
    AddProperty=Hid_Interface_AddProperty
    
    [Hid_Interface_AddProperty]
    {026e516e-b814-414b-83cd-856d6fef4822},6,0x11,,1 ; Privileged Interface

     


    ..and it  works : my winrt component is able to successfully issue HID Class Driver IOCTLs, and HID Class drivers replies.

    (Of course I also created a device metadata package and added <DeviceCapability Name="4D1E55B2-F16F-11CF-88CB-001111000030" /> in package.appxmanifest).

     

       Yet, this solution is not satisfactory, because :

    1. I need to find a reliable way to read input reports without loosing any of them : from here, I see that issuing IOCTL_HID_GET_INPUT_REPORT is not advised, since we may loose reports, whereas with ReadFile not.

      Question them : is there a plan in the future to add ReadFile and WriteFile to your IDeviceIoControl interface?

    2.  Once I get preparsed data with IOCTL_HID_GET_COLLECTION_DESCRIPTOR , my C++ winrt component cannot call any of the HidP_.. HidClass support rountines (e.g. HidP_GetButtonCaps), since <hidpi.h> is locked by a #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)..

      Yet, I think that I can write a C# winrt component which will DLLImport("hid.dll") and overcome the issue..

      Question 2 : that seems more a hack (what about ARM support..) than something recommended.. What do you think? 

     

       The other option I'm thinking of is to create a(n UMDF) filter driver which would do the ReadFile, WriteFile and CreateFile itself, hence exposing its own

    functions to my winrt component. Are there ways to send requests to lower HID Class driver without "escaping" to Win32?

     

       I need your expert's advice, please..

    Many thanks in advance, (and this time I will not forget to thank you for the great job you're doing!) 

    Julien

     



    • Edited by jracle Thursday, January 12, 2012 3:58 PM
    Thursday, January 12, 2012 8:46 AM

Answers

  • Hi Mike,

    Some things to check from Julien's instructions above:

    1.  Does your metadata package correctly trigger off the hardware id for the device node you are filtering?

    2.  Did you use the INF method Julien specified above?  You can also take a code snippet from the OSR Fx2 UMDF driver to register your device interface GUID as "restricted."  Does that code succeed?

    3.  Did you deploy the metadata to the test machine where you are running the metro application?  On the "Finish" tab, there is a check box to "Copy packages to your system's local metadata store."

    Janet

    Tuesday, February 21, 2012 4:48 PM

All replies

  • Hi Jracle,

    I encountered a problem that my metro style app can't issue IOCTL to my filter driver. Even I follow the rules that add privileged interface to inf, device metata and package.appxmanifest, I still got the E_AccessDenied from ICreateDeviceAccessAsync->GetResult. Does any thing I missed to do?

    I'm excited knowing you can issue IOCTLs to filter driver from your metro style app. I'll be very appreciated if you can provide some settings of Device Metadata or some recommends I need to be noticed.

    Thank you.

    Mike


    • Edited by Mike_Wu Tuesday, January 17, 2012 11:47 AM
    Tuesday, January 17, 2012 8:32 AM
  • Hi Mike,

     

      sure, glad to help you!

     

    1. So, you'll need to build a metadata package so that your device (device container more precisely) will be associated with one companion app and one or more privileged app. A good example is the one you find for the sample usb device OSR FX2.

      You can grab it there after you install the DDK : C:\Program Files (x86)\Windows Kits\8.0\src\usb\osrusbfx2\devicemetadatapackage\en-us.

      2 tabs are crucial : Associations and Applications.

      Open the package with "Devices and Printers Metadata Authoring Wizard" (available in Driver menu in VS11).

      Here are screen dumps :





      If you don't have this well in place, your app won't be authorized to access your driver.
    2. In your driver's INF file, you need to tell the OS that your driver's device interface class GUID is "privileged".

      There seem to be a flaw in online documentation. I ordered MoFX2 board from OSR and got it to work correctly with the INF taken from the code sample.
      I paste here the interesting section:

      [OsrUsb_Install.NT.Interfaces]

      AddInterface={573E8C73-0CB4-4471-A1BF-FAB26C31D384},,OsrUsb_Interface ; replace this GUID with targeted driver's interface class GUID

      [OsrUsb_Interface]

      AddProperty=OsrUsb_Interface_AddProperty

      [OsrUsb_Interface_AddProperty]

      {026e516e-b814-414b-83cd-856d6fef4822},6,0x11,,1 ; Privileged Interface

      --> on my side I have a filter driver which acts on top of an existing interface (HID), which already exists.
      I got I working with below code :

      AddInterface={4D1E55B2-F16F-11CF-88CB-001111000030},,Hid_Interface    ; in bold is HID device interface class GUID

      [Hid_Interface]
      AddProperty=Hid_Interface_AddProperty

      [Hid_Interface_AddProperty]
      {026e516e-b814-414b-83cd-856d6fef4822},6,0x11,,1 ; Privileged Interface

    3. Then... in your application's package.appxmanifest (in raw XML view...), you need to declare target interface GUID's capability, like for instance :

      <Capabilities>
        <DeviceCapability Name="573E8C73-0CB4-4471-A1BF-FAB26C31D384"/>
      </Capabilities>
      
    4. There you go.. now you can ONLY access your driver with IDeviceIOControl interface..

    Please tell me if it works :)

    Regards,

    Julien

     

    Tuesday, January 17, 2012 12:53 PM
  • Hi Julien,

    Thanks for your reply. This helps me a lot but I still got AccessDenied from my Metro style app.

    The difference to your sample is I used custom Device Interface both in Device Metadata and my WDM filter driver. Maybe there is something wrong in my driver when I register a custom Device Interface.

    One question is that does the GUID of Privileged Interface(your [Hid_Interface_AddProperty]section in inf) be used in other places (metadata, package.appxmanifest)? I don't know what the mechanism about the Privileged Interface between driver, Device Metadata and Metro style app. Even I can't find this Privileged Interface GUID in registry after driver installed.

    Another question is that do you specify HID HardwareID in your Device Metadata? Because you mentioned your sample is a HID filter driver, I think your driver isn't associate with specific hardwareID.

    I'm trying this again but change driver to a keyboard class filter driver. I hope it can work.... I'll be glad to tell you if I get it done.

    Regards,

    Mike



    • Edited by Mike_Wu Friday, January 20, 2012 7:55 AM
    Thursday, January 19, 2012 8:37 AM
  • message regarding non-public build deleted

    This forum is for discussion of the public Windows 8 Developer Preview only. If you have a newer build please address all questions throgh the channel from which you received it.


    Friday, February 17, 2012 10:25 AM
  • Hi Mike,

    Some things to check from Julien's instructions above:

    1.  Does your metadata package correctly trigger off the hardware id for the device node you are filtering?

    2.  Did you use the INF method Julien specified above?  You can also take a code snippet from the OSR Fx2 UMDF driver to register your device interface GUID as "restricted."  Does that code succeed?

    3.  Did you deploy the metadata to the test machine where you are running the metro application?  On the "Finish" tab, there is a check box to "Copy packages to your system's local metadata store."

    Janet

    Tuesday, February 21, 2012 4:48 PM