53

Is there a way to load a 32-bit DLL library (something with the same usage as LoadLibrary) I would like to use that function along with GetProcAddress.

I looked at WOW, but it does not seem to offer the functionality. The functionality should exist, since tools like DependencyWalker are able to read the symbols of a 32-bit DLL even though its 64-bit.

phuclv
  • 37,963
  • 15
  • 156
  • 475
adk
  • 4,479
  • 9
  • 36
  • 38
  • This is answered here: http://stackoverflow.com/questions/128445/calling-32bit-code-from-64bit-process . John Knoeller's answer below is also correct. – John B. Lambe Feb 09 '16 at 09:15
  • @John B. Lambe The title of this post is clearer than the one you linked for those who're searching the exe-call-dll thing. – ebk Feb 14 '18 at 05:42

3 Answers3

64

You can only load a 32bit DLL into a 64 bit process when you are loading the dll as a datafile. You can't execute the code. (http://support.microsoft.com/kb/282423)

Microsoft recommends that you use interprocess COM to use 32 bit code with a 64 bit application. Here's an article explaining the process.

hacker1024
  • 3,186
  • 1
  • 11
  • 31
John Knoeller
  • 33,512
  • 4
  • 61
  • 92
  • 2
    Updated link for the article: http://blog.mattmags.com/2007/06/30/accessing-32-bit-dlls-from-64-bit-code/ See also http://stackoverflow.com/questions/128445/calling-32bit-code-from-64bit-process – Ed Greaves Mar 20 '13 at 19:17
8

If all you're wanting to do is get resources from it, you can load as a datafile:

LoadLibraryEx(exeName, NULL, LOAD_LIBRARY_AS_DATAFILE);

Then call FindResource as normal.

Dave F
  • 973
  • 9
  • 19
  • LOAD_LIBRARY_AS_DATAFILE is Const LOAD_LIBRARY_AS_DATAFILE = $00000002; and free also the handle: FreeLibrary(LibHandle64); – Max Kleiner Jun 17 '20 at 07:39
4

There's a difference between reading a 32 bit executable and executing code within a 32 bit executable. I don't believe that windows offers any functionality to do that.

The only way you're likely to be able to do that is to create a 32 bit process that loads the dll and then do interprocess communication to pass the results between the two processes.

Colin Newell
  • 3,073
  • 1
  • 22
  • 36