Commit graph

47 commits

Author SHA1 Message Date
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
Dmitry Fleytman
d47bd4d237 UsbDkHelper: Do not print API errors to console
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2017-02-07 15:59:58 +02:00
Sameeh Jubran
1340ea01e2 UsbDkHelper: Add static modifier to printExceptionString function
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
2017-01-26 18:03:27 +02:00
Sameeh Jubran
b0660af0d1 UsbDKHelper: Add unpackHandle function
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>
2017-01-26 18:03:20 +02:00
Dmitry Fleytman
29814251f4 UsbDk: Introduce UsbDk_ResetPipe() user mode API
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-05-03 10:36:23 +03:00
Dmitry Fleytman
ec04c9a874 trivial: cleanup comments
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-03-25 17:38:00 +02:00
Dmitry Fleytman
456334a73f UsbDkHelper/Controller: Update persistent hide rules after modification
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-03-25 17:37:57 +02:00
Dmitry Fleytman
eb8c876fc9 UsbDkHelper: Add persistent hide rules interface
Signed-off-by: Kirill Moizik <kirill@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-03-25 17:37:52 +02:00
Dmitry Fleytman
e389fb7924 UsbDkHelper: Introduce hider API
Signed-off-by: Kirill Moizik <kirill@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2015-02-17 09:13:05 +02:00
Pavel Gurvich
6c1f136844 UsbDkHelper: Fix processing of reboot needed case on install
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-08-11 13:23:51 +03:00
Pavel Gurvich
99f3c0dbef UsbDkHelper: Open redirector handle in driver
This commit contains user mode adaptations for
driver interface changes introduced by previous commit.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-06-12 01:00:08 +03:00
Pavel Gurvich
310ef26669 UsbDkHelper: remove unnecessary call to RemoveRedirection
With new kernel mode code redirection stops automatically
when redirector handle is closed.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-31 19:21:04 +03:00
Pavel Gurvich
6239ffba38 UsbDkHelper: Introduce ResetDevice API
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-26 18:42:52 +03:00
Pavel Gurvich
02076801c4 UsbDkHelper: Add UsbDk_SetAltsetting API
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-26 18:41:17 +03:00
Pavel Gurvich
225d12c9d8 UsbDk: Drop Control Transfer IOCTL
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-26 18:41:13 +03:00
Pavel Gurvich
f0db6b4e62 UsbDkHelper: Add AbortPipe API
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-20 11:56:28 +03:00
Pavel Gurvich
99521baed4 UsbDkHelper: add UsbDk_ prefix to UsbDkHelper API functions
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-20 11:56:23 +03:00
Pavel Gurvich
f118d34ac5 UsbDkHelper: Cosmetics: rename ReleaseDeviceList ReleaseDevicesList
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-20 11:56:22 +03:00
Pavel Gurvich
a77d8161e4 UsbDk: Add license-related files and headers
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-20 11:56:20 +03:00
Dmitry Fleytman
43f4646cd9 UsbDkHelper: Fix warnings in release builds
This patch uses "potentially uninitialized variable used"
warnings in release builds.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:15 +03:00
Pavel Gurvich
1ca133b506 UsbDkHelper: Fix bug: second install leads to configuration corruption
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:15 +03:00
Pavel Gurvich
2127d90c4b UsbDkHelper: Support asynchronous calls
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:15 +03:00
Pavel Gurvich
cdff8c0bae UsbDkHelper: Add interface GetRedirectorSystemHandle()
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:15 +03:00
Dmitry Fleytman
d680b5b139 UsbDk: Fix ReadPipe/WritePipe number of bytes transferred propagation
Number of bytes transferred returned by ReadFile/WriteFile cannot
be larger then the size of buffer passed to the function.

Since buffer passed to ReadFile/WriteFile is our request
structure and number of bytes transferred to/from usb device
depends on buffer size passed via the request structure and not on
request structure size we have to return actual number of bytes
transferred via some field in request structure and not via system
facilities.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:15 +03:00
Dmitry Fleytman
008699089f UsbDkHelper: Fix read/write logic
Do not destroy redirector handle after each operation.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:15 +03:00
Dmitry Fleytman
5cdaf656f9 UsbDkHelper: Introduce ReadPipe/WritePipe API
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:15 +03:00
Dmitry Fleytman
9a12b44669 UsbDkHelper: Trivial: typos and cosmetics
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:14 +03:00
Dmitry Fleytman
9e09d8b764 UsbDk: Implement control transfer logic
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:14 +03:00
Dmitry Fleytman
c5ea213221 UsbDk: Fix start redirect error value
It is inconsistent to return nullptr as invalid handle.
The proper value for invalid handle is INVALID_HANDLE_VALUE.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:14 +03:00
Dmitry Fleytman
a37e2a4a0b UsbDk: Trivial: ULONG* -> PULONG in interfaces
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:14 +03:00
Dmitry Fleytman
59f80a0f90 UsbDk: Introduce API for configuration descriptors retrieval
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:14 +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
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
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
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
Pavel Gurvich
f4e565be17 UsbDkHelper: Make UsbDk interface files compilable with gcc
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:11 +03:00
Dmitry Fleytman
e2275bb0f2 UsbDkHelper: Redirections collection management
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:11 +03:00
Dmitry Fleytman
3d4b8eda14 UsbDkHelper: Isolate common code for some ioctls
All IOCTLs that perform operation on USB device
identified by USB_DK_DEVICE_ID are pretty similar,
common code may be isolated.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:11 +03:00
Dmitry Fleytman
c4e8d29e50 UsbDkHelper: make CDriverAccess::ResetDevice return void
Return value is not needed, function
throws exception in case of error

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:11 +03:00
Dmitry Fleytman
653ce6b4ad UsbDk: Drop ping IOCTL and children dump logic
Debugging code removed.

Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:11 +03:00
Pavel Gurvich
9352d2887c UsbDkHelper: Add ResetDevice functionality to Helper
Add ResetDevice functionality to Helper

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:11 +03:00
Pavel Gurvich
c0bf20d715 UsbDkHelper: add EnumerateDevice functionality to UsbDkHelper
Add flow of device enumeration to DriverAccess

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:10 +03:00
Pavel Gurvich
0f9d483c6f UsbDkHelper: Do full roll-back on install failure.
Run uninstall process if installation failed.

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:10 +03:00
Pavel Gurvich
3137e01236 UsbDkHelper: Print exception text to all sources
Print exception text to both OutputDebugString and console

Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:10 +03:00
Dmitry Fleytman
800676db2b UsbDkHandler: Exception handling beautification
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:10 +03:00
Dmitry Fleytman
244ade2a35 UsbDkHelper: Introduce UsbDkDriverAccess class and PING IOCTL
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:10 +03:00
Pavel Gurvich
7abe649fbf UsbDk: Add .dll and .exe with installer logic
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
2014-05-11 19:26:09 +03:00