Accessing 32-bit DLLs from 64-bit code

Post Reply
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Accessing 32-bit DLLs from 64-bit code

Post by Antonio Linares »

Thanks to Lailton for googling for it :-)

https://blog.mattmags.com/2007/06/30/ac ... -bit-code/

Basically the technique is to use IPC (Interprocess communication) between a 64 bits app and a 32 bits app:
The following IPC mechanisms are supported by Windows:

Clipboard
COM
Data Copy
DDE
File Mapping
Mailslots
Pipes
RPC
Windows Sockets
https://msdn.microsoft.com/en-us/librar ... 2147217396

From all of them, the WM_COPYDATA seems the simplest way to go :-)

SendMessage( hWndToReceiveTheMessage, WM_COPYDATA, hWndSender, pPointerToACOPYDATASTRUCT structure ) --> value returned from hWndToReceiveTheMessage
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Accessing 32-bit DLLs from 64-bit code

Post by Antonio Linares »

https://stackoverflow.com/questions/112 ... -functions

https://msdn.microsoft.com/en-us/librar ... s.85).aspx

Code: Select all

#include <windows.h>
#include <stdio.h>
#include <dbghelp.h>

BOOL CALLBACK EnumSymProc( 
    PSYMBOL_INFO pSymInfo,   
    ULONG SymbolSize,      
    PVOID UserContext)
{
    UNREFERENCED_PARAMETER(UserContext);
    
    printf("%08X %4u %s\n", 
           pSymInfo->Address, SymbolSize, pSymInfo->Name);
    return TRUE;
}

void main()
{
    HANDLE hProcess = GetCurrentProcess();
    DWORD64 BaseOfDll;
    char *Mask = "*";
    BOOL status;

    status = SymInitialize(hProcess, NULL, FALSE);
    if (status == FALSE)
    {
        return;
    }
    
    BaseOfDll = SymLoadModuleEx(hProcess,
                                NULL,
                                "foo.dll",
                                NULL,
                                0,
                                0,
                                NULL,
                                0);
                                
    if (BaseOfDll == 0)
    {
        SymCleanup(hProcess);
        return;
    }                                
        
    if (SymEnumSymbols(hProcess,     // Process handle from SymInitialize.
                        BaseOfDll,   // Base address of module.
                        Mask,        // Name of symbols to match.
                        EnumSymProc, // Symbol handler procedure.
                        NULL))       // User context.
    {
        // SymEnumSymbols succeeded
    }
    else
    {
        // SymEnumSymbols failed
        printf("SymEnumSymbols failed: %d\n", GetLastError());
    }
    
    SymCleanup(hProcess);
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Lailton
Posts: 99
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil
Contact:

Re: Accessing 32-bit DLLs from 64-bit code

Post by Lailton »

Hi Antonio,

Thanks for it!

I will to test :D
Regards,
Lailton Fernando Mariano
https://www.harbour.ninja
Post Reply