1

I have a python script (on Windows) that is depending on different wrappers from the corresponding 32-bit dll and a 64-bit 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)?

For further understanding, here is an example: lets say, I have a python script test.py. The test.py is calling fun1 and fun2. fun1 is defined in fun1_test.pyd(32-bit) and fun2 is defined in 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. But I am noticing the following error: " 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.

Is there a cleaner way to achieve this?

PYN
  • 39
  • 5
  • Possible duplicate of [Convert 32 bit dll to 64 bit dll](https://stackoverflow.com/questions/944962/convert-32-bit-dll-to-64-bit-dll) – shanecandoit Oct 18 '19 at 19:38

1 Answers1

0

I don't think it is possible to import a 32bit dll from a 64bit process. The pointers will be different sizes.

It would be easiest to find a 64bit version and use that.

This is not python specific, but this questions explains the issue: 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.

(I also flagged this a duplicate, just wanted to offer some advise too. Let me know if this is improper.)

shanecandoit
  • 581
  • 1
  • 3
  • 11
  • Thanks for the quick response. What I have is a vendor specific library and there is no 64-bit version of it. I am running the python script from a console and I wish there was a provision similar to "Any CPU". – PYN Oct 18 '19 at 19:58
  • You may have to have a 64bit python and a 32bit python talk to each other. I wish there was a better solution. Ask your vendor for a discount for your trouble. Good luck. – shanecandoit Oct 18 '19 at 20:02