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>
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>
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>
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>
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>
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>
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>
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>
Integrate redirection functionality in driver with UsbDkHelper.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
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>
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>
Print exception text to both OutputDebugString and console
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>