mcuee / libusb-win32

libusb-win32 project official github repo
179 stars 49 forks source link

Allocation / OS check optimization, Mingw updates #36

Closed tormodvolden closed 1 year ago

tormodvolden commented 1 year ago

The first commit was originally motivated by plans for other functions needing run-time OS version checks, but I have dropped those. It makes sense anyway.

The remaining commits are safe clean-ups and MinGW-only changes. The GUID macro changes were compile-tested on WDK by mcuee along with the rest.

The extra IRP debug printing can be omitted, but these events are relatively rare so it should not spam the debug log too much.

mcuee commented 1 year ago

@dontech

Please review the changes when you are available. Thanks.

Take note we do not officially support MinGW for the driver building. Still please review the changes to see if the changes are good to have or not.

dontech commented 1 year ago

I think it looks great! :-) Thanks for the patches Tormod!

One question: What does the optimization do? Does it improve speed or anything else?

tormodvolden commented 1 year ago

I guess no noticeable difference. But before, on every memory allocation the OS version was retrieved through a library function and the pool type determined. Now this is done only once when the driver is loaded, and the pool type is accessed through a simple variable.

dontech commented 1 year ago

Hi @mcuee

Take note we do not officially support MinGW for the driver building. Still please review the changes to see if the changes are good to have or not.

No, but building using other compilers (and testing) is always great as it reveals bugs and problems from a new angle.

Super work @tormodvolden

Thanks,

/pedro

dontech commented 1 year ago

New snapshots: https://sourceforge.net/projects/libusb-win32/files/libusb-win32-snapshots/20230920/

tormodvolden commented 1 year ago

No, but building using other compilers (and testing) is always great as it reveals bugs and problems from a new angle.

Indeed, GCC discovers a lot of things, mostly formal issues that might not influence the execution but sometimes they may. I reran compilation with GCC 12 now and there are many new warnings to look at.

Super work @tormodvolden

Thanks!

tormodvolden commented 1 year ago

Note that the current binaries built with GCC (MinGW on latest Debian) don't load in Windows 10 ({Driver Entry Point Not Found} The %hs device driver could not locate the entry point %hs in driver %hs.)

However it should be possible (as demonstrated by projects like https://github.com/utoni/mingw-w64-dpp) so I hope to figure it out one day.