The application that uses Hider API does not have an ability
to query which persistent rules exist. So in order to use
UsbDk_DeletePersistentHideRule the application shall guess
which rule it needs to delete. Current commit adds ability to
delete all existing the persistent rules. This API requires
administrative privileges as all APIs related to persistent
hide rules.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
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>
Device type bitmask is calculated for device class and classes
of all its interfaces by narrowing set of device classes to set
of device types.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
This commit adds implementation of registry operation for
extended rules in user-mode. Kernel driver still recognizes
all the entries as default ones (it ignores the Type value).
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Added:
UsbDk_AddExtendedHideRule
UsbDk_AddExtendedPersistentHideRule
UsbDk_DeleteExtendedPersistentHideRule
All existing APIs continue working as before.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Extend structure USB_DK_HIDE_RULE by adding 'Type'
member derived from backward-compatible structure
USB_DK_HIDE_RULE_PUBLIC. Public API procedures of UsbDkHelper
receive USB_DK_HIDE_RULE_PUBLIC describing hiding rules.
Internally UsbDk works with extended structure.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Added option MSGBOX=n to MSI package that forces the
installer to run without pop-up message boxes in case
of failure or request to reboot.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Add optional command-line parameter to suppress message
box in case the installation requires reboot or aborted.
This supports use case when the UsbDk is installed along
with other product and restart is required regardless
installation status of UsbDk. When installation helper
runs with -in or -iN, the message boxes are suppressed.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
https://github.com/daynix/UsbDk/issues/66
According to interface definition, the UsbDk shall return
actual length on transfer completion. For isoch OUT transfers
the controller does not return it on respective URB field on
Win10 and the updated WDK documentation states this field is
not used for ISOCH OUT transfers. Current commit populates
the initial packet length in the URB, making the result
consistent on both Win7 and Win10.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
When higher WDK than 14393 is installed on the machine, the modified
files related to build of drivers and driver-related applications may
produce errors on build using VS2015. Fixed project files solve this.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Win7 with USB 3.0 stack might not report superspeed
the same way as Win8 does. Use bcdUSB field of device
descriptor for that (USB 3.0 device connected to USB 2.x
port usually falls to USB 2 compatible configuration).
Getting the speed from HUB driver via IOCTL is more
complicated.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
This commit aims to address
https://bugzilla.redhat.com/show_bug.cgi?id=1575043
The driver definitely may try accessing USB device where
it is not USB and sending 'Submit URB' IOCTL down the stack
may cause unpredictable result. Current commit change
the order of checks when the device is enumerated by its
parent device: first ensure this is USB device, then try
to get USB-specific information.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
This reverts previous commit that actually has removed the check
that the driver is accessible. Prior to removal this at least should
be investigated in corner cases which are also to be defined
(like UsbDk uninstall when it has active redirected device).
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
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>