Cannot load DLL with Python in 4.1 and above

My add-on relies on an external Python module that’s essentially a ctypes wrapper for a dll/so/dylib file. The add-on can import the module perfectly fine in 4.0, but in 4.1 and 4.2 it’s erroring out and not loading. Here’s what I’ve done so far to debug…

I’ve confirmed that I can successfully import the module in an external 3.11.7 Python session through the command line. I’ve also confirmed that paths to the folder containing the DLL and the Python module are available to Blender via os.environ['PATH'] and sys.path respectively.

I’ve debugged the DLL with the Windows dependency walker, and nothing is jumping out as an issue with the DLL.

The add-on works on Linux and macOS with 4.1 and 4.2, so it appears to be a Windows-only problem.

I’ve added breakpoints to the Python module function that loads the DLL and can confirm it’s looking in the right spot for the DLL. It will load it in a regular Python shell just fine, but will return an error in Blender.

When I try to directly load the DLL into Blender with ctypes.CDLL() and ctypes.windll.LoadLibrary(), both return a WinError [127] the specified procedure could not be found error.

I’m at a loss at this point. What could I possibly be missing? Losing functionality on Windows will effectively break the add-on for everyone but the few of us on Linux and Mac, so I’m really hoping to find a solution to this.

When you say “an external 3.11.7 python”, you mean blender’s python executable ran from a shell?

Does the dll have dependencies, if yes, are they before blender’s native in the path?

Can you provide the given dll?