Windows: Refactoring to consolidate and simplify common code
authorChris Dickens <christopher.a.dickens@gmail.com>
Fri, 7 Feb 2020 23:47:55 +0000 (15:47 -0800)
committerChris Dickens <christopher.a.dickens@gmail.com>
Fri, 7 Feb 2020 23:47:55 +0000 (15:47 -0800)
commit9c28ad219b654011783a42ec888ca87dbda704a6
treeb789d577d5547c0d7b247d165fe52dc96f5014c8
parent67e6816264e35a1f22b43a78b4be7481652bc51a
Windows: Refactoring to consolidate and simplify common code

Both the UsbDk and WinUSB backends perform common steps when handling
transfers in order to interact with the poll abstraction, both during
submission and when processing transfer completion. With some
rearranging of shared structures, this can be yanked from the individual
backends and placed in the common area. This allows for several
functions to be removed outright from each backend.

The cancellation logic can also be simplified by attempting CancelIoEx()
at the highest level and delegating to the backend if there are
alternatives to try should CancelIoEx() fail.

After some analysis of how Windows processes asychronous (OVERLAPPED)
requests that the underlying driver completes synchronously, it is now
evident that such requests need not be handled in any special fashion.
Each function that called a driver function that was expected to
complete asynchronously had logic to handle the case of a synchronous
completion, so this has all been killed off. This significantly cleans
up these call sites as now they must only check for an error condition.

Finally, the initialization code for the WinUSB backend has been
reworked to load the WinUSB DLL independent of the libusbK DLL.
Previously when the libusbK DLL was present, all requests to devices
using WinUSB would first be sent through the libusbK DLL where
they would then be forwarded to the WinUSB DLL. This is slightly
inefficient but is also limiting when using Windows 8.1 or later because
support for isochronous transfers through WinUSB will be lost.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/poll_windows.c
libusb/os/poll_windows.h
libusb/os/windows_common.c
libusb/os/windows_common.h
libusb/os/windows_usbdk.c
libusb/os/windows_winusb.c
libusb/os/windows_winusb.h
libusb/version_nano.h