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>
Currently, in some cases, attempting to start the driver can fail
and cause Usb devices to become non functional. An example of such
case is attemteting to install an unsigned version of UsbDk on Windows
where the driver signature enforcement is enabled. The reason why this
happens is not making sure the driver can start on the system prior to
attaching it to all of the devices.
This patch solves this issue by checking that the driver can start on the
system prior to step 2 in the list below.
UsbDk's installation process:
1) Create and register UsbDk's service
2) Add UsbDk to the registry
3) Reset all Usb host conrollers on the system
4) PNP manager attaches and starts the driver for each Usb device's stack
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Include getting traces using logman and converting binary traces
to text using installed TMF file.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Existing batch file records binary trace using TraceView that
shall be copied from WDK, which is not always installed on end
user machine. Added batch file allows recording without additional
tools, using built-in logman application.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Single TMF file contains all the data required for converting
binary trace to text for all the operating systems.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.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>
https://technet.microsoft.com/en-us/library/security/3033929
required on Windows 7, otherwise UsbDk driver's signature is not
recognized properly and OS fails to load driver.
Signed-off-by: Yuri Benditovich <yuri.benditovich@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>
unpackHandle checks if the provided HANDLE is null or has an
INVALID_HANDLE_VALUE and casts it to the suitable data type.
This check can prevent the UsbDkHelper from crashing becuase of api misuse.
Signed-off-by: Sameeh Jubran <sameeh@daynix.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>