It is more correct to use lower device in stack for queries
during filter initialization. Lower device is in initialized
state and can process all kinds of requests, when current one is
not ready yet.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
This commit migrates from VS 2013 to VS 2015. Beside the auto conversion
which was performed by VS this commit includes the following fixes
which enabled the builld to work:
Win (7, 8, 8.1, 10):
* Set the KMDF Version Major to 1.
* Set the KMDF Version Minor to 11.
Win XP:
* Add _When_ define.
* Add empty implementation to guard functions which else would cause an
unresolved symbols.
* Add path to WinDDK's wdfinstaller.h in UsbDkHelper project.
* Add "GetDriverProjectAttributes" and "GetPackageFiles" targets to
UsbDkController, UsbDkHelper and UsbDkInstHelper project files.
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
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>
The driver may report non-USB device in list of devices
available for redirection (for example, this happens with
FTDI dual-port serial adapter PID 6010)
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
When attempting to redirect a device and the <device id> input string doesn't
match the actual <device id> string (case sensitive) the UsbDkController gets
stuck for two minutes and the error: "Redirect of USB device failed" is shown.
This is caused by case insensitive comparison between the input string and the
<device id> string in "CRegText::Match(PCWSTR String)" followed by case
sensitive comparison in "CStringBase::operator== (const UNICODE_STRING& Str)"
causing the "m_RedirectionCreated" event's timeout - two minutes - to expire.
This commit makes the error message show instantly eliminating the two
minutes delay.
<device id> string comparison should be case sensitive as defined
by user mode UsbDk API contract.
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
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>
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>
Sometimes UsbDk cannot query device descriptors for USB hubs,
in such cases it does not attach to theirs stack during parent bus
relations processing.
However, since UsbDk is registered as USB hub class filter,
WDF will call its AddDevice callback anyway.
In this case UsbDk should assume that it is dealing with a hub
and assign its usual hub strategy.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
m_Relations can be null therefore we should access it carefully.
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
On unplug of USB hub that contains a redirected
device, removal of redirection is started when redirected
device PDO is still present in UsbDk device lists.
In this case UsbDk will try to send reset IOCTL to this device
and system will return STATUS_NO_SUCH_DEVICE error code.
This commit changes behavior of redirection removal
logic in a way that it will not interrupt removal
process when such an error is returned by reset.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
There are two reasons for that:
1. There are devices that do not provide device description:
In this case, for normal devices, Windows gets description from INF file.
Since there is no INF file for UsbDk devices, Windows may fail
to initialize the device (depending on implementation of bus driver).
2. With this patch redirected devices show up in device manager as
"UsbDk device" which is better then "Unknown Device" or
"Mass Storage Device" etc.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This patch adds support for IRP post processing
on failure and in all cases.
New logic will be used by following commits to
implement device text patching.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This commit retires old device hider logic based
on wiping PDOs from BusRelations array.
Previous commits introduce new logic based on IDs
patching.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Wiping PDOs from BusRelations list has side effect
of absence of hotplug events from the OS.
This is not good for applications that want devices
appear hidden and start redirection process on plug
at the same time.
Following patches will retire old hiding logic.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
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>
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>
This reverts commit 32aadcb4fe.
Reverting commit because a regression was discovered on some devices.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>