简体   繁体   English

在 64 位 Python 进程中加载 32 位和 64 位 dll

[英]Loading 32-bit and 64-bit dll's in the 64-bit Python process

I have a python script (on Windows) that is depending on different wrappers from the corresponding 32-bit dll and a 64-bit dll.我有一个 python 脚本(在 Windows 上),它取决于相应的 32 位 dll 和 64 位 dll 的不同包装器。 Is there a way, like a sand boxing mechanism, that can allow me to load both the 64-bit dll and a 32-bit dll from the same environment( 64 bit python process)?有没有办法,比如沙盒机制,可以让我从同一环境(64 位 Z23EEEB4347BDD26BDDZ6B7EE9A3B75 进程)加载 64 位 dll 和 32 位 dll

For further understanding, here is an example: lets say, I have a python script test.py.为了进一步理解,这里有一个例子:假设我有一个 python 脚本 test.py。 The test.py is calling fun1 and fun2. test.py 正在调用 fun1 和 fun2。 fun1 is defined in fun1_test.pyd(32-bit) and fun2 is defined in fun2_test.pyd(64-bit). fun1 在 fun1_test.pyd(32-bit) 中定义,而 fun2 在 fun2_test.pyd(64-bit) 中定义。

Here is what I tried: Since the 64-bit environment can ideally run the 32-bit dll's, I tried executing the python script with the 64-bit python process.这是我尝试过的:由于 64 位环境可以理想地运行 32 位 dll,我尝试使用 64 位 python 进程执行 python 脚本。 But I am noticing the following error: " WindowsError: [Error 193] %1 is not a valid Win32 application "但我注意到以下错误:“WindowsError: [Error 193] %1 is not a valid Win32 application”

When I ran the dependency walker, it gives references to the CPU(x86 vs x64) mismatch dll's.当我运行依赖walker时,它提供了对CPU(x86 vs x64)不匹配dll的引用。

Is there a cleaner way to achieve this?有没有更清洁的方法来实现这一目标?

I don't think it is possible to import a 32bit dll from a 64bit process.我认为不可能从 64 位进程导入 32 位 dll 。 The pointers will be different sizes.指针大小不同。

It would be easiest to find a 64bit version and use that.最容易找到 64 位版本并使用它。

This is not python specific, but this questions explains the issue: Convert 32 bit dll to 64 bit dll这不是 python 特定的,但这个问题解释了这个问题: Convert 32 bit dll to 64 bit dll

Here is an article were the author decompiled a 32bit program and rewrote it for 64 bit: http://www.developingthefuture.net/disassembling-decompiling-and-modifying-executables/ That isn't a python dll though. Here is an article were the author decompiled a 32bit program and rewrote it for 64 bit: http://www.developingthefuture.net/disassembling-decompiling-and-modifying-executables/ That isn't a python dll though.

(I also flagged this a duplicate, just wanted to offer some advise too. Let me know if this is improper.) (我也将此标记为重复项,也只是想提供一些建议。如果这不正确,请告诉我。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM