diff options
| author | Karl Froelich <[email protected]> | 2017-03-13 09:57:05 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-03-13 09:57:05 -0700 |
| commit | 6f54e0945a4deffb6d129a79374f8788769ab090 (patch) | |
| tree | 669246ed6a9ff6c9f0325d260e8bdad372f464dd | |
| parent | 1098c82e7d71d3f47157e0837cb939203f944939 (diff) | |
| parent | 5349d6e8684017a770b231aa60c21c3153bcc88a (diff) | |
Merge pull request #120 from ajbarb/update-osrfx2usb-customcapability
Setting custom capability on a device interface instance to access it…
| -rw-r--r-- | usb/kmdf_fx2/driver/Device.c | 40 | ||||
| -rw-r--r-- | usb/kmdf_fx2/driver/osrusbfx2.inx | bin | 5758 -> 7628 bytes | |||
| -rw-r--r-- | usb/kmdf_fx2/driver/osrusbfx2.vcxproj | 2 | ||||
| -rw-r--r-- | usb/umdf2_fx2/driver/Device.c | 31 | ||||
| -rw-r--r-- | usb/umdf2_fx2/driver/osrusbfx2um.inx | bin | 4388 -> 6348 bytes | |||
| -rw-r--r-- | usb/umdf2_fx2/driver/osrusbfx2um.vcxproj | 2 |
6 files changed, 69 insertions, 6 deletions
diff --git a/usb/kmdf_fx2/driver/Device.c b/usb/kmdf_fx2/driver/Device.c index 8516ef09..34aff070 100644 --- a/usb/kmdf_fx2/driver/Device.c +++ b/usb/kmdf_fx2/driver/Device.c @@ -76,7 +76,7 @@ Return Value: WDFQUEUE queue; GUID activity; UNICODE_STRING symbolicLinkName; - WDFSTRING symbolicLinkString; + WDFSTRING symbolicLinkString = NULL; DEVPROP_BOOLEAN isRestricted; UNREFERENCED_PARAMETER(Driver); @@ -363,13 +363,40 @@ Return Value: sizeof(isRestricted), &isRestricted ); - WdfObjectDelete(symbolicLinkString); - if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, - "IoSetDeviceInterfacePropertyData failed %!STATUS!\n", status); + "IoSetDeviceInterfacePropertyData failed to set restricted property %!STATUS!\n", status); + goto Error; + } +#if (NTDDI_VERSION >= NTDDI_WIN10_RS2) + + // + // Adding Custom Capability: + // + // Adds a custom capability to device interface instance that allows a Windows + // Store device app to access this interface using Windows.Devices.Custom namespace. + // This capability can be defined either in INF or here as shown below. In order + // to define it from the INF, uncomment the section "OsrUsb Interface installation" + // from the INF and remove the block of code below. + // + + static const wchar_t customCapabilities[] = L"microsoft.hsaTestCustomCapability_q536wpkpf5cy2\0"; + + status = g_pIoSetDeviceInterfacePropertyData(&symbolicLinkName, + &DEVPKEY_DeviceInterface_UnrestrictedAppCapabilities, + 0, + 0, + DEVPROP_TYPE_STRING_LIST, + sizeof(customCapabilities), + (PVOID)&customCapabilities); + + if (!NT_SUCCESS(status)) { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "IoSetDeviceInterfacePropertyData failed to set custom capability property %!STATUS!\n", status); goto Error; } + +#endif } TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<-- OsrFxEvtDeviceAdd\n"); @@ -378,6 +405,11 @@ Return Value: Error: + if(symbolicLinkString != NULL) + { + WdfObjectDelete(symbolicLinkString); + } + // // Log fail to add device to the event log // diff --git a/usb/kmdf_fx2/driver/osrusbfx2.inx b/usb/kmdf_fx2/driver/osrusbfx2.inx Binary files differindex d515de34..2e1bdcb6 100644 --- a/usb/kmdf_fx2/driver/osrusbfx2.inx +++ b/usb/kmdf_fx2/driver/osrusbfx2.inx diff --git a/usb/kmdf_fx2/driver/osrusbfx2.vcxproj b/usb/kmdf_fx2/driver/osrusbfx2.vcxproj index 2db1f7c1..08cde31a 100644 --- a/usb/kmdf_fx2/driver/osrusbfx2.vcxproj +++ b/usb/kmdf_fx2/driver/osrusbfx2.vcxproj @@ -229,7 +229,7 @@ <ResourceCompile Include="osrusbfx2.rc" /> </ItemGroup> <ItemGroup> - <Inf Exclude="@(Inf)" Include="*.inf" /> + <Inf Include="osrusbfx2.inx" /> <FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" /> </ItemGroup> <ItemGroup> diff --git a/usb/umdf2_fx2/driver/Device.c b/usb/umdf2_fx2/driver/Device.c index 0003dad7..8a6442a6 100644 --- a/usb/umdf2_fx2/driver/Device.c +++ b/usb/umdf2_fx2/driver/Device.c @@ -304,6 +304,37 @@ Return Value: goto Error; } +#if (NTDDI_VERSION >= NTDDI_WIN10_RS2) + // + // Adding Custom Capability: + // + // Adds a custom capability to device interface instance that allows a Windows + // Store device app to access this interface using Windows.Devices.Custom namespace. + // This capability can be defined either in INF or here as shown below. In order + // to define it from the INF, uncomment the section "OsrUsb Interface installation" + // from the INF and remove the block of code below. + // + + WDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData = { 0 }; + static const wchar_t customCapabilities[] = L"microsoft.hsaTestCustomCapability_q536wpkpf5cy2\0"; + + WDF_DEVICE_INTERFACE_PROPERTY_DATA_INIT(&PropertyData, + &GUID_DEVINTERFACE_OSRUSBFX2, + &DEVPKEY_DeviceInterface_UnrestrictedAppCapabilities); + + status = WdfDeviceAssignInterfaceProperty(device, + &PropertyData, + DEVPROP_TYPE_STRING_LIST, + sizeof(customCapabilities), + (PVOID)customCapabilities); + + if (!NT_SUCCESS(status)) { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfDeviceAssignInterfaceProperty failed %!STATUS!\n", status); + goto Error; + } +#endif + // // Create the lock that we use to serialize calls to ResetDevice(). As an // alternative to using a WDFWAITLOCK to serialize the calls, a sequential diff --git a/usb/umdf2_fx2/driver/osrusbfx2um.inx b/usb/umdf2_fx2/driver/osrusbfx2um.inx Binary files differindex 41879bce..9b2cce79 100644 --- a/usb/umdf2_fx2/driver/osrusbfx2um.inx +++ b/usb/umdf2_fx2/driver/osrusbfx2um.inx diff --git a/usb/umdf2_fx2/driver/osrusbfx2um.vcxproj b/usb/umdf2_fx2/driver/osrusbfx2um.vcxproj index 8e3127cd..72e39bc1 100644 --- a/usb/umdf2_fx2/driver/osrusbfx2um.vcxproj +++ b/usb/umdf2_fx2/driver/osrusbfx2um.vcxproj @@ -195,7 +195,7 @@ </Link> </ItemDefinitionGroup> <ItemGroup> - <Inf Exclude="@(Inf)" Include="*.inf" /> + <Inf Include="osrusbfx2um.inx" /> <FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" /> </ItemGroup> <ItemGroup> |
