Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find path #96

Open
rsagas opened this issue Feb 9, 2023 · 2 comments
Open

Cannot find path #96

rsagas opened this issue Feb 9, 2023 · 2 comments
Labels

Comments

@rsagas
Copy link

rsagas commented Feb 9, 2023

Hi all, I am very glad to have found this package. We have managed to install wine on our linux server, and trying to use it to load a windows dll, but the path just plainly does not work.

I have understood properly the paths, I have both a "Disc C" (the fake windows install) and a "Disc Z" (symlink to the home dir of the server) and managed to put the right path onto the cdll(path) call, but I keep getting the "FileNotFound" error, that the call gives when the file path is wrong or does not exist.

Is there any obvious thing to point out?

@s-m-e
Copy link
Member

s-m-e commented Feb 9, 2023

Glad the package is of use to you. FileNotFound indicates that something is off with the location of your DLL - it's not an issue related to loading it (e.g. a broken DLL or similar), which is good news from my perspective.

Consider the following experiments:

>>> from zugbruecke import ctypes
>>> import os
>>> os.getcwd()
'/home/ernst/Desktop/zugbruecke'
>>> ctypes.zb_path_unix_to_wine(os.getcwd())
'Z:\\home\\ernst\\Desktop\\zugbruecke'
>>> ctypes.cdll.LoadLibrary
<bound method LibraryLoader.LoadLibrary of <ctypes.LibraryLoader object at 0x7f781b157460>>
>>> dll_handle = ctypes.cdll.LoadLibrary('Z:\\full\\or\\relative\\path\\to.dll')

zugbruecke has a bunch of convenience functions prefixed with zb_. One of them is called zb_path_unix_to_wine, also see here, which does what it says. From experience, sometimes it is hard to get all the idiosyncrasies of path conversion from Unix to Windows/Wine right and this function is plainly asking Wine to do this job correctly for you. You can use it to check if you correctly converted your path. One noteworthy aspect of Windows/Wine paths is the double backslashes - in normal Python strings one needs to escape backslashes, hence the double backslashes.

Second, reading your question, I am not sure if you are familiar with LoadLibrary from ctypes. zugbruecke is essentially a drop-in-replacement for ctypes, so it does expose LoadLibrary for cdll and windll and accepts Windows/Wine paths, both relative and absolute.

@rsagas
Copy link
Author

rsagas commented Feb 9, 2023

Thanks a lot s-m-e, I was indeed looking at the code and observing those functions, but was not entirely clear to me to launch that little test.

What I did manage was to run the test on the msvrct DLL that comes along with windows and that worked perfectly, so I reached the same conclusion as you (it is about the path, not the package).

I will try that tomorrow, as well as another test I came up with (registering the dll via regserv32 so that I can call it without path). Will report my findings so we can hopefuly close this issue!

@s-m-e s-m-e added the question label Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants