Accessing 32-bit DLLs from 64-bit code

Accessing 32-bit DLLs from 64-bit code

Postby Antonio Linares » Sat Apr 28, 2018 6:39 am

Thanks to Lailton for googling for it :-)

https://blog.mattmags.com/2007/06/30/accessing-32-bit-dlls-from-64-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/library/aa365574.aspx?f=255&MSPPError=-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: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby Antonio Linares » Sat Apr 28, 2018 8:44 am

https://stackoverflow.com/questions/1128150/win32-api-to-enumerate-dll-export-functions

https://msdn.microsoft.com/en-us/library/windows/desktop/ms679318(v=vs.85).aspx

Code: Select all  Expand view
#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
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby Lailton » Tue May 22, 2018 11:58 pm

Hi Antonio,

Thanks for it!

I will to test :D
Regards,
Lailton Fernando Mariano
User avatar
Lailton
 
Posts: 153
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil


Return to Utilities / Utilidades

Who is online

Users browsing this forum: No registered users and 16 guests