Commit graph

71 commits

Author SHA1 Message Date
Yuri Benditovich
db6c11f48a driver: add log on filter file close
Currently we stop redirection when filter device file handle
closed. This might be incorrect if some application just opens
and closes the file. Log entry with process id will help
diagnosing such problems.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-02 21:47:41 +02:00
Dmitry Fleytman
6dd93fb7c5 RedirectorStrategy: Fix MakeAvailable() logic chaining
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2017-02-19 11:15:50 +02:00
Dmitry Fleytman
c80effc7dd UsbDk: Introduce hider strategy class
This class will be used by following patches to
implement hiding via patching device IDs.

See commit messages of corresponfing patches
for rationale.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2016-06-29 17:31:55 +03:00
Dmitry Fleytman
0a4f4811bc RedirectorStrategy: Add request counters to traces
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2016-02-10 12:03:39 +02:00
Dmitry Fleytman
3d0a2050b3 UsbTarget: Introduce TargetRequest class
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2016-02-10 11:02:14 +02:00
Dmitry Fleytman
603d98e602 FilterDevice: Use generic WDF request context
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2016-02-10 10:56:23 +02:00
Dmitry Fleytman
346554ff0c RedirectorStrategy: Use more specific type for request objects
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2016-02-10 10:56:21 +02:00
Dmitry Fleytman
44e3837eff RedirectorStrategy: Replace explicit type names with auto where possible
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2016-02-10 10:56:09 +02:00
Dmitry Fleytman
c573972ff1 RedirectorStrategy: Do not report STALL conditions on control pipe
STALL condition on control pipe cleared automatically
by underlying infrastructure. Do not report it to client
otherwise it may decide to clear it via ResetPipe and
reset of control pipe is not supported by WDF.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2016-01-14 11:30:59 +02:00
Dmitry Fleytman
3b1f461d5c Revert "RedirectorStrategy: Ensure there are no short buffers on read"
This reverts commit 32aadcb4fe.

Reverting commit because a regression was discovered on some devices.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-12-25 08:44:38 +02:00
Dmitry Fleytman
32aadcb4fe RedirectorStrategy: Ensure there are no short buffers on read
To avoid "BABBLE" conditions.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-12-24 11:25:31 +02:00
Dmitry Fleytman
3bca6777e7 RedirectorStrategy: Trivial: Make variable names follow the convention
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-12-24 10:35:33 +02:00
Dmitry Fleytman
785f05451f RedirectorStrategy: Extend transfer error traces
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-12-24 10:35:32 +02:00
Dmitry Fleytman
74cba9509d UsbDk: Make WdfRequest constructor explicit
To avoid implicit CWdfRequest objects construction
and requests completion.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-12-21 18:46:34 +02:00
Dmitry Fleytman
1a97440166 UsbDk: Propagate USBD errors to user mode clients
WARNING: This patch breaks compilation of client code
due to changes in interface structures.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-11-24 13:04:17 +02:00
Dmitry Fleytman
d5f12a4699 UsbDk: Eliminate camelCase notation from interface definitions
This is a cosmetic change that unifies naming convention
in UsbDk public API.

WARNING: This change breaks compilation of client code.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-11-24 13:04:17 +02:00
Dmitry Fleytman
2cac450d17 UsbDk: Drop uneeded dynamic memory allocations 2015-11-24 12:32:35 +02:00
Dmitry Fleytman
5df028f84c Redirector: Drop empty Delete() override
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-11-24 12:32:31 +02:00
Dmitry Fleytman
464fbef889 Redirector: Make some debug traces more clear
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-11-24 12:31:00 +02:00
Dmitry Fleytman
900b148f0a Redirector: allow zero length pipe Read/Write requests
This patch fixes issue reported at
https://github.com/daynix/UsbDk/issues/11

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-11-24 12:30:59 +02:00
Dmitry Fleytman
4a0354fdcd UsbDk: Perform ReadPipe/WritePipe via IOCTLs
This commit fixes issues with accessing USB devices on
some USB host controllers.

Before this fix UsbDk assumed IO type NEITHER for
ReadFile/WriteFile operations performed on captured
USB device. This assumption is not true in some cases
because UsbDk creates filter devices which use the
same IO type as device being filtered, i.e. IO type
is effectively defined by USB host controller driver.

While some host controllers work in NEITHER IO mode,
others use DIRECT IO instead. When capturing device
plugged into such a controller UsbDk failed to retrieve
ReadFile/WriteFile buffers because there are different API
used different IO types and UsbDk used the wrond one.

This patch changes UsbDk DLL/Driver interface to use IOCTL
for ReadPipe/WritePipe operations. Since IO type for IOCTL
requests is determined by IOCTL code and not by target device
settings UsbDk need not consider IO type used by the host
controller being filtered.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-10-28 09:11:41 +02:00
Dmitry Fleytman
a01f9214ac UsbDk: trivial: make function parameters const
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-10-28 09:11:40 +02:00
Dmitry Fleytman
07baa62166 UsbDk: Fix type in word Interrupt
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-07-19 12:02:54 +03:00
Dmitry Fleytman
29814251f4 UsbDk: Introduce UsbDk_ResetPipe() user mode API
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-05-03 10:36:23 +03:00
Dmitry Fleytman
ec04c9a874 trivial: cleanup comments
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-03-25 17:38:00 +02:00
Kirill Moizik
70c36f1320 UsbDk: Set Red Hat vendor ID for redirected devices
Signed-off-by: Kirill Moizik <kirill@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-02-17 09:13:09 +02: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
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
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
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
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
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
f6b5cb2056 UsbDk: Allow control transfers without data buffer
According to spec control transfer may have no data buffer.
Make driver process cases like this properly.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-07-03 08:54:37 +03:00
Pavel Gurvich
4a677d08fc UsbDk: Return proper status on CUsbDkRedirectorStrategy::IoInCallerContext failure
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-07-02 18:14:58 +03:00
Pavel Gurvich
72cf6b764d UsbDk: Do not create symlinks for redirector devices
Symlinks not needed anymore since we create redirector handles
in kernel.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-06-12 01:02:49 +03:00
Dmitry Fleytman
5c4d0af852 UsbDk: Open redirector handle in driver
This commit makes redirection creation atomic operation
from user mode client point of view.

This ensures redirection will be stopped automatically
in case of unexpected user mode client termination.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-06-12 00:57:33 +03:00
Pavel Gurvich
3abe48f93b UsbDk: Drop ReadTransferRequestSafe()
Use newly introduced generic utility
UsdDkReadUserBufferSafe() instead.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-06-12 00:22:54 +03:00
Dmitry Fleytman
d5d51dfd47 UsbDk: place all system includes into stdafx.h
This makes include policy more strict and ensures
all system includes properly wrapped with extern "C"

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-06-09 11:50:26 +03:00
Pavel Gurvich
093251727e UsbDk: Add OnClose callback to Strategies
OnClose is called when device symlink is fully closed by used mode.

For redirector strategy OnClose stops redirection.
For other strategies OnClose is currently no-op.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-31 19:17:12 +03:00
Pavel Gurvich
32e7243f99 UsbDk: Implement RESET_DEVICE IOCTL
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-26 18:42:51 +03:00
Pavel Gurvich
40154c5bab UsbDk: Implement IOCTL_USBDK_DEVICE_SET_ALTSETTING
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-26 18:41:16 +03:00
Pavel Gurvich
34dea22308 UsbDk: Separate transfer and configuration requests processing
Introduce separate queues for different types of requests:

1. Read/Write queue
2. Configuration (IOCTL) queue

This is needed to stop transfers during reconfiguration.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-26 18:41:14 +03:00
Pavel Gurvich
96ac1e3f9b UsbDk: Implement Control Transfer via R/W functions
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-26 17:59:23 +03:00
Pavel Gurvich
00da1f59fc UsbDk: make stop redirection synchronous
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-20 12:03:27 +03:00
Pavel Gurvich
55e7d683fe UsbDk: Add handling of AbortPipe IOCTL
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-20 11:56:27 +03:00
Pavel Gurvich
dfcbfb2d65 UsbDk: Make ControlTransfer asynchronous
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-20 11:56:26 +03:00
Pavel Gurvich
a77d8161e4 UsbDk: Add license-related files and headers
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-20 11:56:20 +03:00
Pavel Gurvich
223a2d8fe3 UsbDk: fix trace message
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:15 +03:00
Dmitry Fleytman
882b77a27d UsbDk: Make control transfer logic method of CWdfUsbTarget
This allows to drop internal object acessor of CWdfUsbTarget
and preserve better encapsulation.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:15 +03:00
Dmitry Fleytman
af30ad9b0a UsbDk: Move MAX_DEVICE_ID_LEN definition to Public.h
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:15 +03:00