Commit graph

656 commits

Author SHA1 Message Date
Yan Vugenfirer
af46b7ee33 Fix appveyor badge in Readme
Signed-off-by: Yan Vugenfirer <yan@daynix.com>
2020-10-05 15:14:09 +03:00
Yuri Benditovich
84752c3003 build: fix build of Debug_NoSign
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-02-27 17:34:04 +02:00
Yuri Benditovich
3b80562684 build: remove binary DLL from the repository
Collect all the 'before-build' actions in single batch file.
Download the DLL required for AppVeyor during the build.
Remove the DLL from the repository.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-27 20:00:38 +02:00
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
c565bd513e driver: add procedure for getting power data by PDO
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-27 19:49:45 +02:00
Yuri Benditovich
c736f5d8be driver: fix driver verifier assertion in FileCreate callback
Previous commit 4de57a9ff causes driver verifier assertion with
latest Windows builds. Note that this assertion is not in latest
WDF sources on GitHub. The verifier does not allow to forward
the MJ_CREATE requestto local IO target using "send-and-forget".
It requires the request to set completion callback.
There is an option to remove the file create callback at all, but
we prefer to have printout on file open for better diagnostics.
So we add completion callback for forwarded request and complete
the request in it.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-27 19:49:45 +02:00
Yuri Benditovich
617f89695e build: adjust appveyor script
Discard wdf folder renaming, it is not needed.
Discard WiX renaming, we use WIX environment variable.
Populate proper VS2015 build DLL.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-26 13:01:08 +02:00
Yuri Benditovich
7ed2a59030 build: fix build of TMF files
tracepdb utility does not work as expected, it overrides
TMF file with each processed PDB file. Build each TMF
file separately and concatenate all the TMF files to one.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-02 21:47:41 +02:00
Yuri Benditovich
669d8cbddd installer: Use WIX environment variable
Use %WIX% instead of absolute path

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-02 21:47:41 +02:00
Yuri Benditovich
4de57a9ff6 driver: pass current process id in file close flow
https://github.com/daynix/UsbDk/issues/81
OnClose -> RemoveRedirect -> NotifyRedirectorRemovalStarted
NotifyRedirectorRemovalStarted passes process id to ModifyOne
in order to avoid stopping redirection if another not related
process just opens the filter device and then closes it.
Example (before this commit):
Start VM and use remote-viewer to it.
Separate application 'App' registers notification on USB
device interface arrival. When new device comes, the application
opens a file using symbolic link name and closes it.
Redirect USB device to VM.
The UsbDk forces device to be reenumerated.
Open-close operation from the 'App' unexpectedly discards
device redirection.
After this commit: because the 'App' process is not an owner
of the redirection, OnClose will not cause removal of the
redirection.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-02 21:47:41 +02:00
Yuri Benditovich
14dd054ae3 driver: extend ModifyOne template
Add optional process id parameter to the template
arguments. If process id is provided, the entry will be
additionally checked for match of owner process id saved in
the redirection object and caller process id.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-02 21:47:41 +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
db6c11f48a driver: add log on filter file close
Currently we stop redirection when filter device file handle
closed. This might be incorrect if some application just opens
and closes the file. Log entry with process id will help
diagnosing such problems.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-02 21:47:41 +02:00
Yuri Benditovich
26a3619666 driver: add file open callback for tracing
Add callback when filter device receives file open request.
Propagate open operation down the stack and log it.
ETW log will contain process id of open request.
It is possible that more than one process opens the device.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2020-01-02 21:47:41 +02:00
Yuri Benditovich
65f7251d2c driver: prevent access to already deleted object
https://github.com/daynix/UsbDk/issues/81
If during redirection the redirection object is deleted
we may try accessing the deleted object in the loop of
attempts to create the redirection handle.
To avoid this we reference the redirection object until
the redirection request completely satisfied or failed.

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
b7acf791dc Hider API: add ability to delete all persistent rules
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>
2019-04-15 11:19:13 +03:00
Yuri Benditovich
a07a062167 Add documention for extended Hider feature
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2019-04-15 11:19:13 +03: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
29b556b0ea hider: calculate device type bitmask for each child device
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>
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
4ebf0da3e9 implement UsbDkController operations for extended rules
Extending UsbDkController commands by adding 'Type' parameter.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2019-04-15 11:19:13 +03:00
Yuri Benditovich
12f71a300b implement read/write/compare operations for extended rules
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>
2019-04-15 11:19:13 +03:00
Yuri Benditovich
fe0a2ca005 extend Hider API by adding extended hide rules
Added:
UsbDk_AddExtendedHideRule
UsbDk_AddExtendedPersistentHideRule
UsbDk_DeleteExtendedPersistentHideRule
All existing APIs continue working as before.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2019-04-15 11:19:13 +03:00
Yuri Benditovich
3652e2a34d Preparation for extended rules for device hide
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>
2019-04-15 11:19:13 +03:00
Yuri Benditovich
7ad99b074c MSI installer: add ability to suppress message boxes
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>
2019-04-15 11:02:48 +03:00
Yuri Benditovich
4c33964158 InstallHelper: optionally suppress message boxes
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>
2019-04-15 11:02:48 +03:00
Yuri Benditovich
46c80bad84 Populate initial packet length in ISOCH OUT URB
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>
2019-01-29 11:10:55 +02:00
Yuri Benditovich
9ebf772799 Updated MAINTAINERS file
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2019-01-27 11:57:49 +02:00
Yuri Benditovich
4473e41ab3 Update project files for build with higher WDK installed
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>
2019-01-27 11:57:49 +02:00
Yuri Benditovich
4d1ecea50d Report superspeed properly on Win7
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>
2018-10-17 15:52:34 +03:00
Yuri Benditovich
960f44ed2c Prevent USB operation with non-USB devices
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>
2018-10-10 11:31:56 +03:00
Yuri Benditovich
19667102ee Revert commit f2dae22029
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>
2018-10-10 11:31:56 +03:00
golden
f2dae22029 Delete unused local variable
Closes #56
2018-04-11 13:46:36 +03:00
Yuri Benditovich
2910063697 Use lower device for queries during initialization
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>
2017-07-12 16:58:03 +03:00
Dmitry Fleytman
db09883b27 ci: Integrate with AppVeyor
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
2017-06-07 12:58:53 +03:00
Sameeh Jubran
5dda7555c5 Installer: Abort installation if the driver fails to start
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>
2017-05-29 16:45:38 +03:00
Sameeh Jubran
e7b4fd2391 ServiceManager: Add Start and Stop methods
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2017-05-29 16:45:32 +03:00
Yuri Benditovich
2214163c4e Documentation: Update tracing documentation
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>
2017-05-29 10:28:06 +03:00
Yuri Benditovich
b41c88dd48 tools: Add BAT file for recording of binary trace
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>
2017-05-29 10:27:24 +03:00
Yuri Benditovich
330368c38b build: Include TMF file to installation package
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>
2017-05-29 10:27:19 +03:00
Yuri Benditovich
860d2c2d11 build: Build TMF files after building all binaries
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2017-05-29 10:27:07 +03:00
Sameeh Jubran
6065c56ce9 Documentation: Add Uninstallation.txt
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
2017-05-25 12:12:09 +03:00
Dmitry Fleytman
446daeca3e Build: Introduce debug configurations without test signing
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
2017-04-06 13:24:06 +03:00
Sameeh Jubran
7abd2b9071 Documentation: Update for VS 2015 and Windows 10
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2017-04-03 15:06:48 +03:00
Sameeh Jubran
ae2d76c152 Build: Add Windows 10 to MSI
According to msdn [1]:
"When you install an .msi installation package on Windows 10 or Windows
Server 2016, the VersionNT value is 603." which is the same value for
Windows 8.1.
In order to differentiate between Windows 8.1 and Windows 10 the trick in
[2] was used.

[1] https://support.microsoft.com/en-us/help/3202260/versionnt-value-for-windows-10-and-windows-server-2016
[2] http://stackoverflow.com/questions/31932646/versionnt-msi-property-on-windows-10

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2017-04-03 15:06:48 +03:00
Sameeh Jubran
0cf33ff14c Build: Delete unnecessary build configurations
This commit deletes "Release" and "Debug" build configuration which
weren't used.

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2017-04-03 15:06:47 +03:00