Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling LoadLibrary on a 64-bit dll from a 32-bit process

I have a 32-bit exe that needs to dynamically load a 64-bit dll when it detects that the operating system is 64-bit. Is this possible through LoadLibrary? If not, is there another way to accomplish the same goal?

like image 629
Spilly Avatar asked Mar 17 '10 23:03

Spilly


People also ask

Can a 32-bit program call a 64 bit DLL?

On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL). Additionally, a 32-bit process cannot load a 64-bit DLL.

How do I run a 32-bit DLL on a 64 bit system?

The recommended solution is to recompile the DLL from the source code for a 32-bit target architecture. Alternatively, you can load the DLL in a 64-bit LabVIEW VI or EXE and communicate between 64-bit LabVIEW and 32-bit LabVIEW using Shared Variables or other networking technologies.

What is the difference between 32-bit and 64 bit DLL?

If the first DLL in the path is 32 bit and your app is 32 bit, then the DLL load will work. If the app is 64 bit, it will fail to load the DLL and the process will abort. If you want two DLLs to coexist on the system path, you need to give them unique file names.


2 Answers

As previously mentioned, 32-bit code cannot load 64-bit code in the same process. You'll have to load it into a different process (CreateProcess() ?) and use IPC to coordinate.

like image 196
Jaxidian Avatar answered Oct 28 '22 05:10

Jaxidian


You can't mix 64-bit and 32-bit code in the same process. You'll need a 32-bit version of the DLL.

like image 44
nobody Avatar answered Oct 28 '22 07:10

nobody