locked
IoSetDevicePropertyData fails in Win8, but works fine in Win7 RRS feed

  • Question

  • I have a device driver for custom device (written using WDF APIs) running on Windows 7. I have installed the same driver in Windows Developer Preview (WDP) and worked fine. However, it seems that device interface needs to be defined as restricted to make driver work with Metro App in Win8.

    I have used the IoSetDevicePropertyData function call to make the device interface restricted. This call works successfully in Windows 7. However, when the same driver is installed in Win8, the API fails with error code 0xC000000D (STATUS_INVALID_PARAMETER).

    The API arguments does not seem to be invalid, as the same driver works fine in Win7. Is there any change in the API argument requirements in Win8?  Any help in resolving the issue is really appreciated.

    Thanks

    Thursday, January 26, 2012 4:05 PM

Answers

  •  

    The property is for device interfaces, not devices; so you actually want to make the device interface privileged and not the device itself:

    ...

            status = WdfDeviceCreateDeviceInterface(device,
                                                    <your GUID>,
                                                    NULL); // Reference String

            status = WdfStringCreate(NULL,
                                     WDF_NO_OBJECT_ATTRIBUTES,
                                     &symbolicLinkString);

            if (!NT_SUCCESS(status)) {
                goto Error;
            }

            status = WdfDeviceRetrieveDeviceInterfaceString(device,
                                                            <your device interface GUID>,
                                                            NULL,
                                                            symbolicLinkString);

            if (!NT_SUCCESS(status)) {
                goto Error;
            }

            WdfStringGetUnicodeString(symbolicLinkString, &symbolicLinkName);

            status = IoSetDeviceInterfacePropertyData(&symbolicLinkName,
                                                         &devPropKey,
                                                         0,
                                                         0,
                                                         DEVPROP_TYPE_BOOLEAN,
                                                         sizeof(privilegedAccess),
                                                         &privilegedAccess );

            WdfObjectDelete(symbolicLinkString);

            if (!NT_SUCCESS(status)) {
                goto Error;
            }

    ...

    Hope this helps; let us know if you run into any other issues.

    -paul

    • Marked as answer by U__K Monday, March 5, 2012 8:51 PM
    Thursday, January 26, 2012 11:25 PM
  • There's one more correction needed to deal with the STATUS_INVALID_PARAMETER error from the property API call.

    The data type for the DEVPROP_TYPE_BOOLEAN property type is not a TRUE/FALSE BOOLEAN.  It is DEVPROP_BOOLEAN and DEVPROP_TRUE/DEVPROP_FALSE are the only allowed values.

    DEVPROP_TYPE_BOOLEAN:
    http://msdn.microsoft.com/en-us/library/windows/hardware/ff543566.aspx

        typedef CHAR DEVPROP_BOOLEAN, *PDEVPROP_BOOLEAN;
        #define DEVPROP_TRUE  ((DEVPROP_BOOLEAN)-1)
        #define DEVPROP_FALSE ((DEVPROP_BOOLEAN) 0)

    In addition to the IoSetDeviceInterfacePropertyData change your code should also have:

        DEVPROP_BOOLEAN privilegedAccess = DEVPROP_TRUE;

    Hope this helps,
    Jim.

     


    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by U__K Monday, March 5, 2012 8:51 PM
    Friday, January 27, 2012 1:41 AM

All replies

  • post your code.
    d -- This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, January 26, 2012 5:10 PM
  • DEFINE_DEVPROPKEY(devPropKey, 0x026e516e, 0xb814, 0x414b, 0x83, 0xcd, 0x85, 0x6d, 0x6f, 0xef, 0x48, 0x22, 6);
    {
     BOOLEAN previledgedAccess = TRUE;
     PDEVICE_OBJECT pDevObject;
     NTSTATUS code;
    ....
     pDevObject = WdfDeviceWdmGetPhysicalDevice( Device );
     code = IoSetDevicePropertyData( pDevObject,
      &devPropKey,
      LOCALE_NEUTRAL, 0, DEVPROP_TYPE_BOOLEAN,
      sizeof(BOOLEAN), &previledgedAccess);
    ....
    }
    Thursday, January 26, 2012 6:58 PM
  •  

    The property is for device interfaces, not devices; so you actually want to make the device interface privileged and not the device itself:

    ...

            status = WdfDeviceCreateDeviceInterface(device,
                                                    <your GUID>,
                                                    NULL); // Reference String

            status = WdfStringCreate(NULL,
                                     WDF_NO_OBJECT_ATTRIBUTES,
                                     &symbolicLinkString);

            if (!NT_SUCCESS(status)) {
                goto Error;
            }

            status = WdfDeviceRetrieveDeviceInterfaceString(device,
                                                            <your device interface GUID>,
                                                            NULL,
                                                            symbolicLinkString);

            if (!NT_SUCCESS(status)) {
                goto Error;
            }

            WdfStringGetUnicodeString(symbolicLinkString, &symbolicLinkName);

            status = IoSetDeviceInterfacePropertyData(&symbolicLinkName,
                                                         &devPropKey,
                                                         0,
                                                         0,
                                                         DEVPROP_TYPE_BOOLEAN,
                                                         sizeof(privilegedAccess),
                                                         &privilegedAccess );

            WdfObjectDelete(symbolicLinkString);

            if (!NT_SUCCESS(status)) {
                goto Error;
            }

    ...

    Hope this helps; let us know if you run into any other issues.

    -paul

    • Marked as answer by U__K Monday, March 5, 2012 8:51 PM
    Thursday, January 26, 2012 11:25 PM
  • There's one more correction needed to deal with the STATUS_INVALID_PARAMETER error from the property API call.

    The data type for the DEVPROP_TYPE_BOOLEAN property type is not a TRUE/FALSE BOOLEAN.  It is DEVPROP_BOOLEAN and DEVPROP_TRUE/DEVPROP_FALSE are the only allowed values.

    DEVPROP_TYPE_BOOLEAN:
    http://msdn.microsoft.com/en-us/library/windows/hardware/ff543566.aspx

        typedef CHAR DEVPROP_BOOLEAN, *PDEVPROP_BOOLEAN;
        #define DEVPROP_TRUE  ((DEVPROP_BOOLEAN)-1)
        #define DEVPROP_FALSE ((DEVPROP_BOOLEAN) 0)

    In addition to the IoSetDeviceInterfacePropertyData change your code should also have:

        DEVPROP_BOOLEAN privilegedAccess = DEVPROP_TRUE;

    Hope this helps,
    Jim.

     


    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by U__K Monday, March 5, 2012 8:51 PM
    Friday, January 27, 2012 1:41 AM
  • Paul, Jim,

    Thanks you very much for your detailed reply. I have changed the code as per your suggestions and none of the API fails. But, is there any way to verify that device interface has been made marked as privileged (i.e. Is there any way to test that code worked apart from seeing the return values of the APIs?)

    Thanks 

    Friday, January 27, 2012 3:13 PM