views:

42

answers:

2

I'm writing a python script in Linux, and need to call some Windows functions available in Wine. Specifically, AllocateAndInitializeSid and LookupAccountSidW, to determine who is logged in to a remote Windows computer. These functions are part of advapi32.dll in Wine (edit: using the answers, I was able to call the function, but LookupAccountSidW only works on the local computer).

How can I access these functions, or a Wine dll in general? I've tried

>>> cdll.LoadLibrary("~/.wine/drive_c/windows/system32/advapi32.dll")

but it results in an error:

OSError: ~/.wine/drive_c/windows/system32/advapi32.dll: invalid ELF header

Is there another ctypes function that would work, or some wine interface I could use?

+2  A: 

Doesn't Wine provide *.so versions of the dlls? I seem to have /usr/lib32/wine/advapi32.dll.so, for example.

If you're on a 64-bit machine, keep in mind that you'll need a 32-bit version of Python to load 32-bit libraries.

adw
Thanks, this works! For me it was actually at `/usr/lib/wine/advapi32.dll.so`.
Justin
For the curious, I actually only got the call to work running python inside wine and using windll.LoadLibrary, since apparently the .so file uses the stdcall calling convention, which is not exposed in the linux version of ctypes (cdll).
Justin
+1  A: 

Understand that .DLL is the format used by Windows.

On linux, such libraries end with .SO

You can't use a library compiled for one platform on the other one. It's not compatible.

karlphillip