Loading of Mingw Provided .sys files

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Wed Apr 8 05:15:03 CDT 2009

>>>>> "Alexander" == Alexander Morozov <amorozov at etersoft.ru> writes:

    >> trying to use the supplied or the mingw (cross) compiled libusb0.sys
    >> from sourceforge with the USB enabled tree from
    >> http://git.etersoft.ru/people/lav/packages/wine.git
    >> loading libusb0.sys fails:

    Alexander> Drivers built with WinDDK is not page-aligned and
    Alexander> (nt->OptionalHeader.SectionAlignment <= page_mask) is true
    Alexander> for them.  But libusb0.sys is page-aligned: $ winedump
    Alexander> libusb0.sys | grep section section align 0x1000 4096

    Alexander> See map_image() in dlls/ntdll/virtual.c:

    Alexander>     /* check for non page-aligned binary */

    Alexander>     if (nt->OptionalHeader.SectionAlignment <= page_mask) {
    Alexander> /* unaligned sections, this happens for native subsystem
    Alexander> binaries */ /* in that case Windows simply maps in the whole
    Alexander> file */ ...............  goto done; }

The libusb-win32 Makefile sets the -shared Linker option, This results in
the DLL attribute set:
(from i386-mingw32msvc-objdump -x)
Characteristics 0x230e
        line numbers stripped
        symbols stripped
        32 bit words
        debugging information removed

and DriverEntry being called as DllMain without the storage for the

Removing the -shared Linker option from the Makefile lets libusb0.sys at
least load. No time fort further tests yet.


Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------

More information about the wine-devel mailing list