Commit graph

619 commits

Author SHA1 Message Date
Dmitry Fleytman
2dfbe1d12a UsbDk: Helper to copy CString to C array
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
1942df5521 UsbDk: Cleanup old strategy before new strategy assignment
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
bbf9fa0300 UsbDk: Delete base strategy on hub strategy cleanup
Forgotten call of base class Delete() added

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
ba73c6882f UsbDkHelper: Mark GetErrorCode() of exception classes const
This is useful when catching exception by const reference

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
43a16ffb13 UsbDk: Introduce timeout converter
Helper function to convert seconds to 100-nanoseconds
intervals introduced.

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
cf899ee707 UsbDk: Extend request interface with buffers lengthes
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
bd8a0581d5 UsbDkHelper: Generalize SendIoctlWithDeviceId()
Extend function interface for output buffer 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
46dc023f46 UsbDk: Introduce UsbDkGetWdmDeviceIdentity() helper
This helper function encapsulates device IDs query
and corresponding error handling.

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
904631bc97 UsbDk: Introduce CWdmSet::ModifyOne() method
Method for making operations on set element
specified by ID introduced.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
ec768841b5 UsbDk: Introduce UsbDkFillIDStruct helper
Just a helper function that fills USB_DK_DEVICE_ID structure
havind DeviceID and InstanceID strings provided.

Available for both user mode and kernel mode.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
56c00f7d4b UsbDk: Make base filter strategy reference control device by default
1. Hub filter strategy requires control device to register with it.
2. Redirector strategy will require control device to
send attachment notifications.
3. Null strategy does't require control device.

So it's 2:1 vote ratio to reference filter device by default
and make null strategy override this logic explicitely.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
b93b71ce45 UsbDk: Add port number to per-device data supplied on enumeration
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
ec0af1e178 UsbDk: Add API to query device address in CDeviceAccess
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
0a6379435b UsbDk: Add filter ID to per-device data supplied on enumeration
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
Dmitry Fleytman
0e0f2fde51 UsbDk: Introduce dynamic names for redirector symlinks
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
6683dc7e86 UsbDk: Create symlinks for hub filter devices
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
c44d475387 UsbDk: Introduce instance counter class
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
9c6ca754f6 UsbDk: Extend CString class
1. Introduce Append() operation
2. Intoduce Create() for strings with numeric postfix

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
2ca0b2a3ab UsbDk: Rename CStringComparator -> CStringBase
This class will contain additional logic besides compares,
the name needs to be adjusted.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
975bf63c3f UsbDk: Trivial: fix trace groups
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
0687192cb8 UsbDk: Drop uneeded members of redirector strategy
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
d9618e05e7 UsbDk: Move abstract filter strategy to a separate file
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
298c37e024 UsbDk: Rename DevFilterStrategy RedirectorStrategy
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
82c21ede3e UsbDk: Cosmetic changes in FilterDevice
Move strategy definition to a separate function

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
f067af15e2 UsbDk: Cosmetic changes in FilterDevice
Rename CreateFilterDevice -> InitializeFilterDevice

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
cab94efc44 UsbDk: Cosmetic changes in FilterDevice
Fix traces severity

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Pavel Gurvich
5b7747afe7 UsbDk: Cosmetic changes
1. Remove unnesesary UNREFERENCED_PARAMETER
2. Add TRACE in UsbDk/Driver.cpp

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
9d68c75522 UsbDk: Rename RedirectorDevice -> RedirectorStrategy
No real changes done in this commit.
A few files renamed only.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
9e37474e50 UsbDk: Implement PDO filering instead of replacement
This patch implements better scheme for USB device
IDs patching. Instead of replacing PDO on QDR completion
and processing all requests coming to the PDO explicitely
we attach filter device to the PDO and indicate is as-is
to PnP Manager.

WDF implements direct pass-through for all requests
coming to PDO implicitely and we only intercept requests
we really have to filter.

Though both schemes are not fully documented the later
one doesn't require explicit coding to preserve PnP state
machine correctness. It also requires much less code overall.

This patch passed basic verification (install, redirect, uninstall)
with driver verifier.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:13 +03:00
Dmitry Fleytman
a7cd673ab3 UsbDk: Fix invalid status returned for IOCTL IRPs
API doesn't fill IOSTATUS->STATUS field when IRP
processing finished synchronously. In this case IoCallDriver
returns proper status directly.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Dmitry Fleytman
94a5284e2c UsbDk: Fix verifier BSOD in CIrp
For some requests API requires iostatus->status
IRP field to be initialized with STATUS_NOT_SUPPORTED.

Driver verifier checks this and produces BSOD on violation.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Dmitry Fleytman
c98b49296a UsbDk: Introduce CRegText:MatchPrefix() method
MatchPrefix() checks whether given string is a prefix
of at least one string held by CRegText object

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Dmitry Fleytman
688a990c0b UsbDkHelper: Improve error printout
Print symlink name on open failure

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Dmitry Fleytman
2073325b0f UsbDkHelper: Fix PCH creation directives
RedirectorAccess.cpp and DriverFile.cpp should not
create precompiled headers.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Pavel Gurvich
97fdb05b36 UsbDkController: Update test application with new interface of UsbDkHelper
Update test application with new interface of UsbDkHelper

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Pavel Gurvich
9e800256d1 UsbDkHelper: Integrate new redirection functionality
Integrate redirection functionality in driver with UsbDkHelper.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Pavel Gurvich
78e7e610ef UsbDkHelper: Refactoring of UsbDkDriverAccess
Make UsbDkDriverAccess inherited from UsbDkDriverFile

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Pavel Gurvich
1503502858 RHHelper: Introduce UsbDkRedirectorAccess class
UsbDkRedirectorAccess is responsible for redirected device interfacing

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Pavel Gurvich
82a7c6d339 UsbDkHelper: Introduce UsbDkDriverFile class
UsbDkDriverFile is responsible for operations on driver symlinks

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +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
bd7c2fd950 UsbDk: Simplify QDR processing
QDR processing greatly simplified by using "Forward-Wait-Process"
scheme instead of "Forward-Completion-Workitem-Process".

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Dmitry Fleytman
fada79a253 UsbDk: Introduce CIrp::ForwardAndWait
A generic function for sending IRP synchronously

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Dmitry Fleytman
c4781f5a0a UsbDk: Fix filter device context leak
Fixed leak of filter device context memory
on non-filtered device traversal.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Dmitry Fleytman
51b02ec56c UsbDk: Fix children devices removal
Removal of control device requires passive level.

Children device list is locked and its enumeration
is performed on IRQL raised by lock which is a problem
for children removal case.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00
Dmitry Fleytman
fe447f627d UsbDk: CIrp: Set event for async. completions only
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:12 +03:00