2
votes

I am currently trying to port some code from a 32 bit windows XP computer to a 64 bit windows 10 computer. I need in my python code to import home developed C dlls as follow :

    from ctypes import *
    [...]
    self.inter_test_dll = windll.LoadLibrary("my.dll")

    self.w = QtWidgets.QWidget()
    self.wid = self.w.winId()
    self.wid.setsize(64)
    print(self.wid)
    self.inter_test_dll.dll_load_window(int(self.wid), 'test')
    self.inter_test_dll.dll_connect(2, self.callback)
    [...]

The program crashes as soon as the dll is loaded with a cryptic

    Windows Error 1114

Which means a dll crashed on initialization. I have tried my dll on my personal machine (64 bits Windows 7), no issue, it all works fine. I have tried that dll on the same 64 bits Windows 10 machine from within a C program, LoadLibrary("my.dll") also fails but LoadLibraryEx("my.dll",NULL, DONT_RESOLVE_DLL_REFERENCE ) does work.

When I run a dependency walker on my dll, it seems to miss some 2 to 4 depth level dll, but it weirdly doesn't seem to affect its working when called properly from within the C program.

So my question is, is there a way to instantiate my dll within Python without an in-depth check of its dependencies ? If not, is there a way to modify my windows behavior, in order to skip that check by default ?

Thanks a lot !

1
What do you want to do with the dll after loading it into python? Because it seems that it will be unusable in either way, unless you resolve the dependencies.macro_controller
Use gflags to enable loader snaps for python.exe, and run ctypes.WinDLL("my.dll") with a debugger attached. This will tell you which DLL's init routine is failing.Eryk Sun
@Train : What I am doing with it is unimportant (or at least it seems so to me), because when loaded in a C program, it works perfectly... The missing dlls are not level 1 dependencies and it seems to me that the fact they are missing, though affecting the behavior of level 1 dlls are not affecting their behavior in my particular case.y3t1
@ eryksun : Thing is I know which are failing (I check the dependencies with a dependency walker). And they are many ! Plus they all are in c:/system32/downlevel and I really don't what to mess up my windows completely as I am not sure to be competent enough...y3t1
Dependency walker is outdated and will show lots of 'missing' DLLs for API sets. Don't use it. You don't have missing DLLs. You've already gotten to the point that all DLLs in the graph are loaded, with all required symbol names updated in import tables. Now the loader is calling the DLL entry points for DLL_PROCESS_ATTACH, and one of them is failing. Unfortunately the loader no longer says which failed in a message box, and there's no event in the system log telling you which fails, so you have to use a debugger with loader snaps.Eryk Sun

1 Answers

1
votes

Thanks for the comments, I have resolved my issue.

WxWidgets has been updated 2 days ago. I have recompiled my dll with this new version and the bug is gone.

Sorry I couldn't find a more general approach to the problem.