Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
6e487369
Commit
6e487369
authored
Mar 18, 2010
by
Damjan Jovanovic
Committed by
Alexandre Julliard
Mar 19, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
usbd.sys: Add USB descriptor parsing functions.
parent
a72b363e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
5 deletions
+86
-5
usbd.c
dlls/usbd.sys/usbd.c
+77
-0
usbd.sys.spec
dlls/usbd.sys/usbd.sys.spec
+5
-5
usbdlib.h
include/ddk/usbdlib.h
+4
-0
No files found.
dlls/usbd.sys/usbd.c
View file @
6e487369
...
...
@@ -27,10 +27,87 @@
#include "winbase.h"
#include "winternl.h"
#include "ddk/wdm.h"
#include "ddk/usb.h"
#include "ddk/usbdlib.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
usbd
);
PUSB_INTERFACE_DESCRIPTOR
WINAPI
USBD_ParseConfigurationDescriptorEx
(
PUSB_CONFIGURATION_DESCRIPTOR
ConfigurationDescriptor
,
PVOID
StartPosition
,
LONG
InterfaceNumber
,
LONG
AlternateSetting
,
LONG
InterfaceClass
,
LONG
InterfaceSubClass
,
LONG
InterfaceProtocol
)
{
/* http://blogs.msdn.com/usbcoreblog/archive/2009/12/12/
* what-is-the-right-way-to-validate-and-parse-configuration-descriptors.aspx
*/
PUSB_INTERFACE_DESCRIPTOR
interface
;
TRACE
(
"(%p, %p, %d, %d, %d, %d, %d)
\n
"
,
ConfigurationDescriptor
,
StartPosition
,
InterfaceNumber
,
AlternateSetting
,
InterfaceClass
,
InterfaceSubClass
,
InterfaceProtocol
);
interface
=
(
PUSB_INTERFACE_DESCRIPTOR
)
USBD_ParseDescriptors
(
ConfigurationDescriptor
,
ConfigurationDescriptor
->
wTotalLength
,
StartPosition
,
USB_INTERFACE_DESCRIPTOR_TYPE
);
while
(
interface
!=
NULL
)
{
if
((
InterfaceNumber
==
-
1
||
interface
->
bInterfaceNumber
==
InterfaceNumber
)
&&
(
AlternateSetting
==
-
1
||
interface
->
bAlternateSetting
==
AlternateSetting
)
&&
(
InterfaceClass
==
-
1
||
interface
->
bInterfaceClass
==
InterfaceClass
)
&&
(
InterfaceSubClass
==
-
1
||
interface
->
bInterfaceSubClass
==
InterfaceSubClass
)
&&
(
InterfaceProtocol
==
-
1
||
interface
->
bInterfaceProtocol
==
InterfaceProtocol
))
{
return
interface
;
}
interface
=
(
PUSB_INTERFACE_DESCRIPTOR
)
USBD_ParseDescriptors
(
ConfigurationDescriptor
,
ConfigurationDescriptor
->
wTotalLength
,
interface
+
1
,
USB_INTERFACE_DESCRIPTOR_TYPE
);
}
return
NULL
;
}
PUSB_COMMON_DESCRIPTOR
WINAPI
USBD_ParseDescriptors
(
PVOID
DescriptorBuffer
,
ULONG
TotalLength
,
PVOID
StartPosition
,
LONG
DescriptorType
)
{
PUSB_COMMON_DESCRIPTOR
common
;
TRACE
(
"(%p, %u, %p, %d)
\n
"
,
DescriptorBuffer
,
TotalLength
,
StartPosition
,
DescriptorType
);
for
(
common
=
(
PUSB_COMMON_DESCRIPTOR
)
DescriptorBuffer
;
((
char
*
)
common
)
+
sizeof
(
USB_COMMON_DESCRIPTOR
)
<=
((
char
*
)
DescriptorBuffer
)
+
TotalLength
;
common
=
(
PUSB_COMMON_DESCRIPTOR
)(((
char
*
)
common
)
+
common
->
bLength
))
{
if
(
StartPosition
<=
(
PVOID
)
common
&&
common
->
bDescriptorType
==
DescriptorType
)
return
common
;
}
return
NULL
;
}
ULONG
WINAPI
USBD_GetInterfaceLength
(
PUSB_INTERFACE_DESCRIPTOR
InterfaceDescriptor
,
PUCHAR
BufferEnd
)
{
PUSB_COMMON_DESCRIPTOR
common
;
ULONG
total
=
InterfaceDescriptor
->
bLength
;
TRACE
(
"(%p, %p)
\n
"
,
InterfaceDescriptor
,
BufferEnd
);
for
(
common
=
(
PUSB_COMMON_DESCRIPTOR
)(
InterfaceDescriptor
+
1
);
(((
PUCHAR
)
common
)
+
sizeof
(
USB_COMMON_DESCRIPTOR
))
<=
BufferEnd
&&
common
->
bDescriptorType
!=
USB_INTERFACE_DESCRIPTOR_TYPE
;
common
=
(
PUSB_COMMON_DESCRIPTOR
)(((
char
*
)
common
)
+
common
->
bLength
))
{
total
+=
common
->
bLength
;
}
return
total
;
}
NTSTATUS
WINAPI
DriverEntry
(
DRIVER_OBJECT
*
driver
,
UNICODE_STRING
*
path
)
{
TRACE
(
"(%p, %s)
\n
"
,
driver
,
debugstr_w
(
path
->
Buffer
)
);
...
...
dlls/usbd.sys/usbd.sys.spec
View file @
6e487369
@ stub USBD_CreateConfigurationRequestEx
@ st
ub USBD_ParseConfigurationDescriptorEx
@ st
ub USBD_ParseDescriptors
@ st
dcall USBD_ParseConfigurationDescriptorEx(ptr ptr long long long long long)
@ st
dcall USBD_ParseDescriptors(ptr long ptr long)
@ stub USBD_AllocateDeviceName
@ stub USBD_CalculateUsbBandwidth
@ stub USBD_CompleteRequest
...
...
@@ -14,15 +14,15 @@
@ stub USBD_FreeDeviceMutex
@ stub USBD_FreeDeviceName
@ stub USBD_GetDeviceInformation
@ st
ub USBD_GetInterfaceLength
@ st
dcall USBD_GetInterfaceLength(ptr ptr)
@ stub USBD_GetPdoRegistryParameter
@ stub USBD_GetSuspendPowerState
@ stub USBD_GetUSBDIVersion
@ stub USBD_InitializeDevice
@ stub USBD_MakePdoName
@ stub USBD_ParseConfigurationDescriptor
@ st
ub _USBD_ParseConfigurationDescriptorEx@28
@ st
ub _USBD_ParseDescriptors@16
@ st
dcall _USBD_ParseConfigurationDescriptorEx@28(ptr ptr long long long long long) USBD_ParseConfigurationDescriptorEx
@ st
dcall _USBD_ParseDescriptors@16(ptr long ptr long) USBD_ParseDescriptors
@ stub USBD_QueryBusTime
@ stub USBD_RegisterHcDeviceCapabilities
@ stub USBD_RegisterHcFilter
...
...
include/ddk/usbdlib.h
View file @
6e487369
...
...
@@ -25,4 +25,8 @@ typedef struct _USBD_INTERFACE_LIST_ENTRY {
}
USBD_INTERFACE_LIST_ENTRY
;
typedef
struct
_USBD_INTERFACE_LIST_ENTRY
*
PUSBD_INTERFACE_LIST_ENTRY
;
PUSB_INTERFACE_DESCRIPTOR
WINAPI
USBD_ParseConfigurationDescriptorEx
(
PUSB_CONFIGURATION_DESCRIPTOR
,
PVOID
,
LONG
,
LONG
,
LONG
,
LONG
,
LONG
);
ULONG
WINAPI
USBD_GetInterfaceLength
(
PUSB_INTERFACE_DESCRIPTOR
,
PUCHAR
);
PUSB_COMMON_DESCRIPTOR
WINAPI
USBD_ParseDescriptors
(
PVOID
,
ULONG
,
PVOID
,
LONG
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment