Commit graph

66 commits

Author SHA1 Message Date
Yuri Benditovich
3d2e5a6272 driver: bring device to D0 before redirection
Device redirection often fails when the device is in D3/D2 when
we start redirecting it. Current commit brings the device to
D0 before sending 'cycle power' command to the device port if
the device is in low power mode at the moment of starting
redirection.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-27 19:49:45 +02:00
Yuri Benditovich
427b3f0106 driver: maintain owner process id field of CUsbDkRedirection
Set owner process id when device redirection successfully
established (i.e. filter device is open and respective user
mode handle created for the process).

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-02 21:47:41 +02:00
Yuri Benditovich
7c93e05e60 driver: add printout on redirection object deletion
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-02 21:47:41 +02:00
Yuri Benditovich
b08ff21f7b driver: add optional message to Dump() procedure
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-02 21:47:41 +02:00
Yuri Benditovich
08ad758943 Use also extended rules to decide whether device should be hidden
Extended rules processing uses bitmask OR between device type
determination bitmap and class/type bitmap provided in 'Class'
parameter of the extended rule.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2019-04-15 11:19:13 +03:00
Yuri Benditovich
916f797c89 Load extended rules in the driver
Load dynamic and persistent rules with type == 1
to extended rules sets.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2019-04-15 11:19:13 +03:00
Yuri Benditovich
68500dc8c3 Add ability to dump rules with configurable trace level
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2019-04-15 11:19:13 +03:00
Yuri Benditovich
ad8a8836ab hider: maintain additional extended hiding rules
Add set of dynamic and persistent rules for advanced
device hiding feature.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2019-04-15 11:19:13 +03:00
Yuri Benditovich
6da5b27ca6 Alloc: Make non-paged allocation from Nx pool on Win8 and later
This is requirement of DeviceGuard and HyperVisor Code
Integrity Readiness Test on Win10/Server2016.
We use Nx allocations for all the systems where Nx pool
is implemented, i.e. for Windows 8 and later.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2017-04-02 17:24:35 +03:00
Dmitry Fleytman
a4bf95a211 ControlDevice: Generate serial numbers for UsbDk devices
Windows recognizes USB devices by PID/VID/SN combination,
for each new USB device plugged in it generates a new
cached driver information entry in the registry.

When UsbDk hides or redirects a device it creates a virtual
device with UsbDk VID/PID and a generated serial number.

On one hand, this serial number should be unique because
there should be no multiple devices with the same PID/VID/SN
combination at any given moment of time. On the other hand,
UsbDk should re-use serial numbers of unplugged devices,
because we don't want Windows to cache one more driver
information entry each time we redirect of hide a device.

This patch introduces a simple but efficient mechanism
for serial number generation for virtual UsbDk devices.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2017-02-19 14:09:52 +02:00
Dmitry Fleytman
848bb79ac2 FilterDevice: Raise redirection removal event on device disconnection
This is useful for devices that change ID on reset.

Previous scheme of raising event on device
"reconnection" after port cycle does not work
for such devices because after reset
they look like another device for UsbDK.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2017-02-09 18:28:21 +02:00
Dmitry Fleytman
4f1bec2125 ControlDevice: Add method for device descriptor retrieval
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2016-01-28 14:57:47 +02:00
Dmitry Fleytman
14c1730d5a Control/Hider: Trivial: Simplify queues creation
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-12-24 10:35:34 +02:00
Dmitry Fleytman
e46947dd23 UsbDk: Make USB transfers execute at dispatch level
Change ExecutionLevel for redirector data queue
to WdfExecutionLevelDispatch.

There is no real reason to force USB transfers exection
on PASSIVE_LEVEL and DISPATCH_LEVEL execution is definitely
faster.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-12-24 10:35:34 +02:00
Dmitry Fleytman
2cac450d17 UsbDk: Drop uneeded dynamic memory allocations 2015-11-24 12:32:35 +02:00
Dmitry Fleytman
5a7034b0e8 Utils: Make List/Set classes support reference counting bjects
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-11-24 12:32:34 +02:00
Dmitry Fleytman
8fcd2fe092 ControlDevice: Never delete redirection object explicitely
Redirection object is a refcountong object and cannot
be leter with operator delete().

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-11-24 12:32:33 +02:00
Dmitry Fleytman
a3ee8f04c0 ControlDevice: Refactoring: Rename some private members
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-11-24 12:32:30 +02:00
Dmitry Fleytman
cbd15f5d55 ControlDevice: Do not process AddRedirect in IoInCallerContext
This commit moves processing of AddRedirect IOCTL from
IoInCallerContext callback of control device to normal
default queue DeviceIoControl callback.

This change eliminates posibility for parallel execution
of AddRedirect and other operations, particularly RemoveRedirect.

Initially AddRedirect was perfomed in IoInCallerContext callback
to open user mode handle to the device being redirected in context
of correct user mode process. This patch achieves the same goal
by storing caller's process handle in request context in
IoInCallerContext callback and duplicating handle to the original
calling process from queue's DeviceIoControl callback.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-11-24 12:20:23 +02:00
Dmitry Fleytman
065604373f ControlDevice: Make WDF allocate context area for control requests
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-11-16 15:37:13 +02:00
Dmitry Fleytman
e05ca16aaa ControlDevice: Split dynamic and persistent hide rules lists
Required to properly support removal of persistent hide rule

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-03-25 17:37:59 +02:00
Dmitry Fleytman
2baf64f1e5 UsbDk: Add IOCTL for rescanning registry configuration
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-03-25 17:37:56 +02:00
Dmitry Fleytman
73ba48bfee Hider: Introduce header file with registry layout
Signed-off-by: Kirill Moizik <kirill@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-03-23 13:24:07 +02:00
Dmitry Fleytman
9075137d0c CControlDevice: Introduce support for persistent hide rules
1. Read persistent rules from registry on driver load
2. Re-read persistent rules on hide rules list clear

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-03-22 15:32:07 +02:00
Dmitry Fleytman
1b169f4bb4 UsbDk: Store driver params registry key path for future use
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-03-10 19:10:20 +02:00
Dmitry Fleytman
27a04f8d55 HiderDevice: Introduce hider device creation and registration
Signed-off-by: Kirill Moizik <kirill@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-02-16 11:49:02 +02:00
Dmitry Fleytman
2f9f80cd74 ControlDevice: Introduce hide rules collection
Signed-off-by: Kirill Moizik <kirill@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-02-16 11:49:01 +02:00
Dmitry Fleytman
1c87a881e4 ControlDevice: Introduce hide rule class
Signed-off-by: Kirill Moizik <kirill@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-02-11 17:30:53 +02:00
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
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
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
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
Dmitry Fleytman
447de6ad71 build: add XP/2003 configurations
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-06-01 23:01:13 +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
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
Dmitry Fleytman
52be87ee4c UsbDk: Make CWdmList accessors safer
Accessor functions made private, corresponding
list class specialization declared as friend.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:15 +03:00
Dmitry Fleytman
c07cfbf0c1 UsbDk: Increase redirection wait timeout
10 seconds is not enough for real platforms,
120 seconds looks more reasonable timeout.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:15 +03:00
Dmitry Fleytman
375a5eb10d UsbDk: Avoid multiple redirections of the same device
For some USB devices system calls our AddDevice callback for FDO.
In addition we call the same callback for PDO of the devices we
want to redirect. In this case we will try to install our filter
two times into the same stack which is problematic.

This patch eliminates such a possibility.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:14 +03:00
Dmitry Fleytman
af4d7e21e7 UsbDk: Make CUsbDkRedirection compare operators const
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:14 +03:00
Dmitry Fleytman
59f80a0f90 UsbDk: Introduce API for configuration descriptors retrieval
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:14 +03:00
Dmitry Fleytman
c0098eefed UsbDk: Introduce GetPDOByDeviceID() helper
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
57025f34c1 UsbDk: make DoUSBDeviceOp() more generic
Make CUsbDkControlDeviceQueue::DoUSBDeviceOp() input buffer type
a template parameter.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
dc8c3a09a4 UsbDk: Make StartRedirect operation synchronous
1. Wait for reset and redirector creation completion on IOCTL handler
2. Return RedirectorID from driver to user mode caller
3. Open corresponding redirector device using RedirectorID returned

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
968a4bbd2c UsbDk: Introduce DoUSBDeviceOp() species with output buffers support
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
a8eb08b2ce UsbDk: Notify control device about redirection activities
This patch make redirectors notify control device
on creation and destruction. These notifications
are needed to make Add/Remove redirection operations
synchronous from user mode client's point of view.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
44aeb7b40e UsbDk: Extend CUsbDkRedirection with notifications
Add logic for redirector device created/deleted notifications
Add storage for assotiated redirector ID

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
8a0311f624 UsbDk: Make device enumeration return more generic structure
This patch makes device enumeration API return array of
device info structures instead of array of device IDs.

This change is needed to return per-device information
in addition to device ID.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Pavel Gurvich
cabdf800c4 UsbDk&UsbDkHelper&UsbDkController: Remove separate reset API
Reset should be part of start/stop redirection. No separate API needed

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Dmitry Fleytman
499019813b UsbDk: Fix control device cleanup
Delete control device object on CleanupContext callback

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Dmitry Fleytman
1dc45a2c3d UsbDk: Control device: redirection list access API
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:11 +03:00