The MASM Forum

64 bit assembler => 64 bit assembler. Conceptual Issues => Topic started by: caraveiro on July 05, 2015, 03:48:09 AM

Title: x64 Dll Wrapper for a X32 Dll
Post by: caraveiro on July 05, 2015, 03:48:09 AM
Hi there!

I need to call a legacy 32bit Dll from Excel x64. As Excel x64 does NOT support calling x32 Dlls I think that the only solution is to build a wrapper.

I found this article useful:

http://blog.mattmags.com/2007/06/30/accessing-32-bit-dlls-from-64-bit-code/ (http://blog.mattmags.com/2007/06/30/accessing-32-bit-dlls-from-64-bit-code/)

QuoteThe solution: a surrogate process

This issue can be solved by loading the dependency DLL into a separate 32-bit process space. The main module, running as a 64-bit process, can then access the dependency DLL across the process boundary using IPC (http://msdn2.microsoft.com/en-us/library/aa365574.aspx (http://msdn2.microsoft.com/en-us/library/aa365574.aspx)).


How do I do a surrogate process in asm?

Any clues?
Title: Re: x64 Dll Wrapper for a X32 Dll
Post by: BogdanOntanu on July 05, 2015, 07:06:39 AM
Nothing special about it. Just a simple x32 process that loads the x32 bits DLL.

It will have to wait on an IPC mechanism (for example via network sockets) for a message from the x64 application and it will send back the results of the x32 DLL function call.

It is kind of a lot of work.

IMHO it is much better to rewrite the x32 DLL into an x64 DLL.

Title: Re: x64 Dll Wrapper for a X32 Dll
Post by: jj2007 on July 08, 2015, 07:42:42 AM
Probably (=haven't tested that), you can use CreateProcess, ShellExecute or similar to launch the 32-bit process, and e.g. SendMessage hWnd, WM_COPYDATA or similar to exchange data.
Title: Re: x64 Dll Wrapper for a X32 Dll
Post by: caraveiro on July 10, 2015, 12:38:14 PM
Thank you guys.

I'll stay with Excel32 for a long time.

:icon_eek: