Commit graph

619 commits

Author SHA1 Message Date
Dmitry Fleytman
c6c5078807 UsbDk: Fix roll-back of control device creation
If control device creation fails - memory
allocated for control device object gets leaked.

The issue is found by HCK fault injection test.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-16 13:49:59 +03:00
Dmitry Fleytman
00faeaa3bd UsbDk: Always delete old pipes information on reconfiguration
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-16 12:02:53 +03:00
Dmitry Fleytman
d76d90125c UsbDk: Introduce CObjHolder::reset() method
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-16 12:02:53 +03:00
Dmitry Fleytman
8245f6e483 UsbDk: Fix filter device cleanup on error
This patch fixes crash on cleanup after unsuccessfull
filter device creation.

Found by HCK fault injection test.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-16 12:02:36 +03:00
Pavel Gurvich
7bd5c64b65 UsbDk: Fix leak of CUsbDkFilterDevice objects
If driver fails filter device creation process
before WDF device created context memory allocated
must be freed explicitely.

Bug found by HCK fault injection test.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-16 08:48:24 +03:00
Dmitry Fleytman
0cdabff70d UsbDk: simplify CRegText and make it more robust
1. Replace pointer to CWdmMemoryBuffer with inplace object
2. Ensure proper error handling on memory allocation failures

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-11 10:48:19 +03:00
Pavel Gurvich
7bfc8c8fb4 UsbDk: drop unused CWdfMemoryBuffer class
This patch removes CWdfMemoryBuffer class
and merges CMemoryBuffer with CWdmMemoryBuffer

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-11 10:25:58 +03:00
Pavel Gurvich
eb9942e5dc UsbDk: drop unused DeviceAccess logic
This patch removes CWdfDeviceAccess class,
merges CDeviceAccess with CWdmDeviceAccess
and removes unused CWdmDeviceAccess code.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-11 10:25:06 +03:00
Dmitry Fleytman
d0094f66a0 UsbDkController: BZ#1138233 - "UsbDkController.exe -i" fails when not called from current directory
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-11 09:35:52 +03:00
Dmitry Fleytman
ccb28eb69e UsbDkController: Use uniform TCHAR type
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-11 09:35:51 +03:00
Dmitry Fleytman
5c885dc641 UsbDkController: Fix windows.h include
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-11 09:35:50 +03:00
Dmitry Fleytman
95ffc41ee8 UsbDkController: Mark internal functions static
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-11 09:35:49 +03:00
Dmitry Fleytman
5a94f3e505 UsbDkHelper/Controller: Beautify error messages
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-11 09:35:49 +03:00
Pavel Gurvich
c8e6ed4378 UsbDk. Add comment for EnumUsbDevicesByID()
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-11 09:33:13 +03:00
Pavel Gurvich
77d3665802 UsbDk: Fix number of bytes transferred for control transfers
Return number of bytes transferred without transfer header.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-10 11:44:15 +03:00
Dmitry Fleytman
00effeed26 usbdk: optimize urb.h includes
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-10 11:41:51 +03:00
Dmitry Fleytman
35cb09f07a UsbDk: BZ#1136908/BZ#1101593 Fix unsuccessfull driver installation pop-ups
This patch fixes 2 issues from Bugzilla:

1. BZ#1136908 - Windows XP launches "Found New Hardware" dialog
                when the device gets redirected after plugging
2. BZ#1101593 - Windows reports unsuccessful driver installation
                after USB redirection

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-09 18:10:48 +03:00
Dmitry Fleytman
f31d25fde7 UsbDk: Cache configuration descriptors on QDR
It is basically forbidden to send arbitrary requests to device
directly via PDO while device driver is present in device stack.
This may lead to unexpected behaviour because device may be
in many different states e.g. low power, processing other
requests etc.

In order to avoid sending descriptor requests to devices with
active functional driver we're caching all descriptors we need
on QDR post-processing while we're on top of device stack for
sure.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-09 18:10:47 +03:00
Dmitry Fleytman
fede63de4f UsbDk: Introduce CBufferSet class
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-09 18:10:46 +03:00
Dmitry Fleytman
536e35fda8 UsbDk: Make CObjHolder deleter template parameter
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-09 18:10:46 +03:00
Dmitry Fleytman
9efa94607e UsbDk: Make CObjHolder::operator= follow best practices
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-09 18:10:45 +03:00
Dmitry Fleytman
e04099b3d6 UsbDk: Add more traces on new child registration
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-09 18:10:44 +03:00
Pavel Gurvich
e435c25be5 UsbDk: BZ#1139434 Windows XP crashes after some time of a realtime USB traffic (webcam)
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-09-09 17:54:26 +03:00
Pavel Gurvich
df4ccac547 UsbDk: Fix output data length for transfer requests
WDF request completion information must always be
sizeof(USBDK_TRANSFER_REQUEST) because this is what
user mode passes to Read/Write syscalls.

The length of transfered data must be always returned via
USB_DK_TRANSFER_RESULT structure.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-20 17:28:54 +03:00
Pavel Gurvich
5db75d296e UsbDk: Fill DEVICE_CAPABILITIES as required for QueryCapabilities IRP
The problem revealed while testing with driver verifier.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-20 17:28:53 +03:00
Pavel Gurvich
413c56304c UsbDk: Remove unused IOCTL RemoveRedirect
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-20 17:28:52 +03:00
Pavel Gurvich
2757bfc506 UsbDkHelper: Remove unused RemoveRedirect method
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-20 17:28:52 +03:00
Pavel Gurvich
f36902947a Revert "UsbDk: Fix never completed IOCTLs issue"
This reverts commit eb1e6fc61d.

The fix is not needed. The problem observed was related to HW.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-20 17:28:51 +03:00
Pavel Gurvich
eb1e6fc61d UsbDk: Fix never completed IOCTLs issue
In some cases driver sends IOCTLS to the underlying devices.
It uses IoBuildDeviceIoControlRequest() function to allocate
IOCTL IRP.

This function allocates threaded IRP which has a number of
limitations for contexts it may be sent from.
In particular it must be sent from PASSIVE_LEVEL
and non-arbitrary thread context to complete successfully.

Since this is not always true for contexts driver sends IRPs from,
never completed IOCTLs were observed on load tests.

This patch fixes the problem by using IoAllocateIrp()
function to allocate IOCTL IRPs.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-17 09:30:53 +03:00
Pavel Gurvich
9c891832c2 UsbDk: Fix race conditions in device enumeration
During stop redirection process driver signals
redirection stopped event before adding corresponding
device back to childen list.

In case of unfortunate timing client code that
enumerates devices right after stoppng redirection
may not get device for which redirection was stopped
in devices list.

This patch fixes the issue by changing order of
corresponding operations.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-17 09:29:56 +03:00
Pavel Gurvich
47e5e036a1 UsbDk: Fix stop redirection failures
Move redirection stopped event signalling from DeviceAdd
callback to QDR post-processing callback.

DeviceAdd callback is not (usually) called for non-redirected devices.

Without this patch stop redirection process fails to
complete because corresponing event never set.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-17 09:01:52 +03:00
Dmitry Fleytman
d83afefae0 UsbDk: Add all build output to .gitignore
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-12 11:30:32 +03:00
Dmitry Fleytman
d9aa8f4621 Build: Add version information into binaries
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-12 11:29:47 +03:00
Pavel Gurvich
6956b7ba35 UsbDkController: Fix message text when reboot is required on install
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-11 13:25:36 +03:00
Pavel Gurvich
6c1f136844 UsbDkHelper: Fix processing of reboot needed case on install
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-11 13:23:51 +03:00
Dmitry Fleytman
a679fb0386 Build: Rename package project to avoid spaces in file names
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-05 17:55:44 +03:00
Dmitry Fleytman
d4e1080d4c UsbDk: Process isochronous transfers requests
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-04 18:31:55 +03:00
Dmitry Fleytman
3a9f570d2e UsbDk: Introduce infrastructure for isochronous transfers
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-04 17:53:52 +03:00
Dmitry Fleytman
ce6f4b645b UsbDk: Introduce class for isochronous URB
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-04 17:45:34 +03:00
Dmitry Fleytman
cda83bc49e UsbDk: Implement isochronous URB allocation for Widnows XP
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-04 16:10:51 +03:00
Dmitry Fleytman
f57d561fd3 UsbDk: Introduce USHORT_MAX definition
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-04 13:07:19 +03:00
Dmitry Fleytman
0ed3967d14 UsbDk: Make WDFMEMORY accessor class type-aware
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-03 15:23:52 +03:00
Pavel Gurvich
b42b6b2092 UsbDk: Add completion context parameter for CWdfRequest
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-03 15:22:36 +03:00
Dmitry Fleytman
816de3e6a2 Build: Make build tree structure more formalized
1. Put all build output under Install/Install_Debug folders
2. Make x86/x64 paths symmetrical

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-07-31 15:53:18 +03:00
Dmitry Fleytman
ed08ca71a2 Build: Introduce script for batch builds
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-07-31 15:53:17 +03:00
Pavel Gurvich
d0da1a29c8 UsbDk: Use Transfer type instead of Endpoint address.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-07-30 15:10:00 +03:00
Pavel Gurvich
3952264ae6 UsbDk: add TransferType enum to UsbDkData.h
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-07-30 15:09:51 +03:00
Dmitry Fleytman
ded5ad4245 UsbDk: Add README.md file with basic information
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-07-03 13:40:22 +03:00
Pavel Gurvich
1e4a50708d UsbDk: Split IoInCallerContextRW() function
This is a refactoring commit to make code more simple.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-07-03 13:04:32 +03:00
Pavel Gurvich
4f4a211556 UsbDk: Avoid deadlocks on device reconfiguration
Some transfers may be pended for a long time, especially
on input pipes. In order to avoid deadlocks cancel pending
transfers instead of waiting for completion.

Replace WdfIoQueueStopSynchronously() by WdfIoQueueDrain()

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-07-03 13:00:35 +03:00