none
LoadLibrary -> GetProcAddress on 32bit DLL from 64bit exe

    Question

  • Hi

    Is it possible to load a function in a 32 bit dll dynamically from a 64bit exe. Using the LoadLibrary -> GetProcAddress method I always get an error with GetProcAddress.

    Thanks

    Ricky

     

    Thursday, September 16, 2010 12:37 PM

Answers

  • Not if you intend to call the function.  There is such a fundamental difference between the 32-bit and 64-bit way of doing things that it's simply not possible.

    Just about the only thing you might be able to do is call LoadLibraryEx() with flag LOAD_LIBRARY_AS_DATAFILE, but this still won't allow you to call GetProcAddress. 


    Answering policy: see profile.
    Thursday, September 16, 2010 2:07 PM
  • Ricky65 wrote:

    Thanks for the quick reply. Are there any workarounds?

    Write a 32-bit process that would load the library and call the function  on your behalf, talk to it via some interprocess communication  mechanism.

    Or, if you have source code to the library, recompile it as 64-bit.


    Igor Tandetnik

    Thursday, September 16, 2010 5:13 PM

All replies

  • Ricky65 wrote:

    Is it possible to load a function in a 32 bit dll dynamically from a  64bit exe.

    No. It's impossible to load a 32-bit DLL into 64-bit process, and vice  versa.

    Using the LoadLibrary -> GetProcAddress method I
    always get an error with GetProcAddress.

    Most likely because LoadLibrary fails already, and you are passing a  NULL handle to GetProcAddress.


    Igor Tandetnik

    Thursday, September 16, 2010 12:48 PM
  • Thanks for the quick reply. Are there any workarounds?

    Thursday, September 16, 2010 1:21 PM
  • Not if you intend to call the function.  There is such a fundamental difference between the 32-bit and 64-bit way of doing things that it's simply not possible.

    Just about the only thing you might be able to do is call LoadLibraryEx() with flag LOAD_LIBRARY_AS_DATAFILE, but this still won't allow you to call GetProcAddress. 


    Answering policy: see profile.
    Thursday, September 16, 2010 2:07 PM
  • Ricky65 wrote:

    Thanks for the quick reply. Are there any workarounds?

    Write a 32-bit process that would load the library and call the function  on your behalf, talk to it via some interprocess communication  mechanism.

    Or, if you have source code to the library, recompile it as 64-bit.


    Igor Tandetnik

    Thursday, September 16, 2010 5:13 PM
  • Ok, I thought there might have been something like a 32bit emulation function. Guess I'll have to write a 32-process instead.
    Friday, September 17, 2010 10:41 AM