Loading of Mingw Provided .sys files
Uwe Bonnes
bon at elektron.ikp.physik.tu-darmstadt.de
Tue Apr 7 12:22:06 CDT 2009
Hello,
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:
trace:winedevice:ServiceMain starting service L"libusb0"
trace:winedevice:load_driver loading driver L"c:\\windows\\system32\\drivers\\libusb0.sys"
trace:winedevice:load_driver_module name L"c:\\windows\\system32\\drivers\\libusb0.sys" module (nil)
trace:winedevice:ServiceMain driver L"libusb0" failed to load
trace:winedevice:ServiceMain service L"libusb0" stopped
Using some other USB driver instead of libusb0.sys at least loads:
trace:winedevice:load_driver loading driver L"c:\\windows\\system32\\drivers\\ezusb.sys"
trace:winedevice:load_driver_module name L"c:\\windows\\system32\\drivers\\ezusb.sys" module 0x81340000
trace:winedevice:load_driver_module L"c:\\windows\\system32\\drivers\\ezusb.sys": relocating from 0x10000 to 0x81340000
trace:winedevice:load_driver_module name L"NTOSKRNL.EXE" module 0x84b70000
trace:winedevice:load_driver_module name L"HAL.DLL" module 0x84590000
trace:winedevice:load_driver_module name L"USBD.SYS" module 0x84580000
trace:winedevice:init_driver
trace:winedevice:init_driver init done for L"libusb0" obj 0x84c0a560
The failure happens in program/winedevices/devices.c:
static HMODULE load_driver_module( const WCHAR *name )
{
IMAGE_NT_HEADERS *nt;
const IMAGE_IMPORT_DESCRIPTOR *imports;
size_t page_size = getpagesize();
int i, delta;
ULONG size;
--> HMODULE module = LoadLibraryW( name );
if (!module) return NULL;
LoadLibraryW loads the file and then calls the DriverEntry of libusb0:
NTSTATUS DDKAPI DriverEntry(DRIVER_OBJECT *driver_object,
UNICODE_STRING *registry_path)
{
int i;
DEBUG_MESSAGE("DriverEntry(): loading driver");
/* initialize global variables */
debug_level = LIBUSB_DEBUG_MSG;
/* initialize the driver object's dispatch table */
for(i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
{
driver_object->MajorFunction[i] = dispatch;
}
driver_object->DriverExtension->AddDevice = add_device;
driver_object->DriverUnload = unload;
return STATUS_SUCCESS;
}
While loading, the protection is set to
0014:trace:virtual:VIRTUAL_DumpView 0x68640000 - 0x68640fff c-r--
and driver_object is in the 0x68640000 pages and so writing to
driver_object->MajorFunction[i] through an exception and the function fails.
I guess libusb0.sys works on WIN32, so here our loader does something wrong
or perhaps is not bug-to-bug compatible.
Any fixes?
Thanks
--
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