usbd.sys: Add partial USBD_ValidateConfigurationDescriptor implementation (try 2)

André Hentschel nerv at dawncrow.de
Tue Aug 28 13:52:56 CDT 2012


I forgot WINAPI, thx Marcus
---
 dlls/usbd.sys/usbd.c        |   23 +++++++++++++++++++++++
 dlls/usbd.sys/usbd.sys.spec |    2 ++
 include/ddk/usbdlib.h       |    1 +
 3 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/dlls/usbd.sys/usbd.c b/dlls/usbd.sys/usbd.c
index 80fd02e..57aba3a 100644
--- a/dlls/usbd.sys/usbd.c
+++ b/dlls/usbd.sys/usbd.c
@@ -218,6 +218,29 @@ PUSB_COMMON_DESCRIPTOR WINAPI USBD_ParseDescriptors(
     return NULL;
 }
 
+USBD_STATUS WINAPI USBD_ValidateConfigurationDescriptor(
+        PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
+        ULONG BufferLength,
+        USHORT Level,
+        PUCHAR *Offset,
+        ULONG Tag )
+{
+    /* http://blogs.msdn.com/usbcoreblog/archive/2009/12/12/
+     *        what-is-the-right-way-to-validate-and-parse-configuration-descriptors.aspx
+     */
+    FIXME( "(%p, %u, %u, %p, %u) partial stub!", ConfigurationDescriptor, BufferLength, Level, Offset, Tag );
+
+    if (Offset) *Offset = 0;
+
+    if (!ConfigurationDescriptor ||
+        BufferLength < sizeof(USB_CONFIGURATION_DESCRIPTOR) ||
+        ConfigurationDescriptor->bLength < sizeof(USB_CONFIGURATION_DESCRIPTOR) ||
+        ConfigurationDescriptor->wTotalLength < ConfigurationDescriptor->bNumInterfaces * sizeof(USB_CONFIGURATION_DESCRIPTOR)
+       ) return USBD_STATUS_ERROR;
+
+    return USBD_STATUS_SUCCESS;
+}
+
 ULONG WINAPI USBD_GetInterfaceLength(
         PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor,
         PUCHAR BufferEnd )
diff --git a/dlls/usbd.sys/usbd.sys.spec b/dlls/usbd.sys/usbd.sys.spec
index 1cb507e..15cf352 100644
--- a/dlls/usbd.sys/usbd.sys.spec
+++ b/dlls/usbd.sys/usbd.sys.spec
@@ -16,6 +16,7 @@
 @ stub USBD_GetDeviceInformation
 @ stdcall USBD_GetInterfaceLength(ptr ptr)
 @ stub USBD_GetPdoRegistryParameter
+@ stub USBD_GetRegistryKeyValue
 @ stub USBD_GetSuspendPowerState
 @ stdcall USBD_GetUSBDIVersion(ptr)
 @ stub USBD_InitializeDevice
@@ -30,4 +31,5 @@
 @ stub USBD_RemoveDevice
 @ stub USBD_RestoreDevice
 @ stub USBD_SetSuspendPowerState
+@ stdcall USBD_ValidateConfigurationDescriptor(ptr long long ptr long)
 @ stub USBD_WaitDeviceMutex
diff --git a/include/ddk/usbdlib.h b/include/ddk/usbdlib.h
index 0003816..1980a93 100644
--- a/include/ddk/usbdlib.h
+++ b/include/ddk/usbdlib.h
@@ -31,5 +31,6 @@ ULONG WINAPI USBD_GetInterfaceLength(PUSB_INTERFACE_DESCRIPTOR,PUCHAR);
 VOID WINAPI USBD_GetUSBDIVersion(PUSBD_VERSION_INFORMATION);
 PUSB_COMMON_DESCRIPTOR WINAPI USBD_ParseDescriptors(PVOID,ULONG,PVOID,LONG);
 PUSB_INTERFACE_DESCRIPTOR WINAPI USBD_ParseConfigurationDescriptorEx(PUSB_CONFIGURATION_DESCRIPTOR,PVOID,LONG,LONG,LONG,LONG,LONG);
+USBD_STATUS USBD_ValidateConfigurationDescriptor(PUSB_CONFIGURATION_DESCRIPTOR,ULONG,USHORT,PUCHAR*,ULONG);
 
 #endif
-- 
1.7.4.1


-- 

Best Regards, André Hentschel


More information about the wine-patches mailing list