Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am running two 64 bit com dlls, BCRMaster.dll and BCRSlave.dll in a process of a larger 64 bit application. BCRSlave calls a function in BCRMaster called SlaveCheckin
where the instance of a Slave instance is logged along with it's DWORD pointer, DWORD ID and BOOL LiveOrDie which is to be 1 or 0 whether the slave is connecting or disconnecting.

If compiled to 32 bit and run in a 32 application this works flawlessly.
If compiled to 64 bit and run in a 64 bit version of the same app the wrong data is received at the master. I am using a .DEF file to do the exports.

It looks like the receiving DWORD is not wide enough. What should I be doning and is there a bitness independent solution?

Here is the slave calling code:

Collapse | Copy Code

C++
typedef void (CALLBACK* LPFNDLLFUNC1)(DWORD,CBCRSlave*,BOOL);
	
    HINSTANCE hDLL;               // Handle to DLL
    LPFNDLLFUNC1 lpfnDllFunc1;    // Function pointer
	
   // DWORD dwParam1 = 1;
   // UINT  uParam2 = 2, uReturnVal;
    hDLL = LoadLibrary("BCRMaster");
    if (hDLL != NULL)
    {
     lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hDLL, "SlaveCheckin");
	 
       if (!lpfnDllFunc1)
       {
          FreeLibrary(hDLL);    
          return -1;
       }
       else
       {
	 
		   CurThisPtr = this;
		   lpfnDllFunc1(m_dwSurfaceId,CurThisPtr,1); 
	   }
 
	}
 
		if ( FAILED( hr ))
			return hr;
	}
 
	return hr;
 }



---------------------------------------------------------------------------------

Here is the receiving Master function:

Collapse | Copy Code

C++
void CBCRMaster::SlaveCheckin(DWORD SurfaceID, DWORD ObjInstPtr,BOOL BornOrDead)



----------------------------------------------------------------------------------

The Slave sends:

SurfaceID = 0x00000boc
ObjIstPtr = 0x000000000a9f7930
BornOrDead = 1

The Master Receives:

SurfaceID = 0x0b0c7930
ObjInstPtr = 0x00000001
BornOrDead = 0x0012e438

:Thanks

Ron
Posted
Updated 17-Mar-12 15:58pm
v3

1 solution

Here's the bug (in the receiving Master function):

C++
void CBCRMaster::SlaveCheckin(DWORD SurfaceID, DWORD ObjInstPtr,BOOL BornOrDead)


It should be void *, or a pointer type, if it receives a pointer.
DWORD is always 32 bits.

Best wishes,

Pablo.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900