Windows dll replacement with Linux library
Dan Timis
timis at museresearch.com
Wed Dec 31 18:33:03 CST 2003
Sorry, I hit send by mistake. Here is the entire message.
Hi,
I wrote to the list a few weeks ago. I needed to support a USB device
without changing the Windows dll that I have to use. I was trying to
hack into wine to implement support for the USB device using
CreateFile() and DeviceIoControl(). That was not a clean solution.
The author of the Windows dll has agreed to support a mid level dll
that would implement functions like USBDeviceOpen(), USBDeviceClose(),
USBDeviceRead(), and USBDeviceWrite(). On Windows those would use
CreateFile() and DeviceIoControl(), while on Linux they would use
libusb calls.
I followed the example from the winelib user guide, chapter 5 "Using
Linux libraries as DLLs" As an example I will talk just about
USBDeviceOpen(). Here it is how it is declared together with a proxy
function:
HANDLE WINAPI USBDeviceOpen(const DWORD in_dwIndex);
HANDLE WINAPI USBDeviceOpenProxy(const DWORD in_dwIndex);
This function opens a specific device from a specific manufacturer. If
more than one device is connected, the index will specify which device
to open.
In the spec file I put:
101 stdcall USBDeviceOpen (long) USBDeviceOpenProxy
I used winemaker, configure, make, and make install. Now I have
"USBUtils.dll.so in /usr/lib/wine.
I wrote a small test program. It has a WinMain function and it calls
USBDeviceOpen. I used winemaker again and I am running the test
application this way:
# wine -- test.exe.so
If I call USBDeviceOpenProxy (or any other proxy function), the test
application links and runs correctly. I tested all functions and they
work as expected.
But, if I call USBDeviceOpen, the application does not link (undefined
USBDeviceOpen). If I use the C compiler (instead of C++) the
application links, but at runtime it does not find USBDeviceOpen.
I don't understand how Windows dlls and Linux libraries link and how
functions are called. What am I missing?
I would appreciate any help.
Dan Timis
Muse Research, Inc.
More information about the wine-devel
mailing list