Is it possible to load a 64-bit dll into a 32-bit process ?
Generally speaking, I know it can not happen.
Yet, maybe there are some exceptions ?
- Why would there be exceptions? What would those exceptions possibly be? What conditions would create them? On what architecture?Cody Gray– Cody Gray ♦2012-01-09 11:18:34 +00:00Commented Jan 9, 2012 at 11:18
4 Answers
No, and neither a 64-bit process can load a 32-bit DLL.
If you're on a 64 bit OS, you can load the DLL in a 64-bit process and have it communicate with your 32-bit process through IPC.
If you're on a 32 bit OS, you're out of luck.
Comments
In .NET, it is possible to load a 64-bit DLL into a 32-bit process for reflection only. For details please check "Analyze 64-bit DLL from within T4 template in Visual Studio (32-bit) using Reflection".
I know that this is a special case, but I thought I'd add it anyway because it might help others looking for a similar solution as me.
Comments
Yes, you can load 64 code in 32 bit module. example: vmprotect metatrader4 above software mixed x86 and x64 in one process. I found metatrade4 for win7 has a function it exeucte a instruction like : jmp 0x33:0x175328 segment selector 33 is a 64bit segment. after execution this instruction, cpu will switch to 64bit mode from 32bit mode.
if you use windbg to trace some windows api on windows x64 OS, you will find similar code. for example: NtQueryInformationProcess
Comments
But new computer bought today at least have 4G ram. We cannot prevent using 64-bit OS to avoid problem. We must face 64-bit positively! Server 2008 R2 only have 64-bit. Issues around EXE AnyCPU / x86, 32-bit COM / C++ dll must be handled. Ideally compile both 32 and 64 bit COM / C++ dll.