x64 dll调用问题-以为我可以修复它,但不能这么快....... [英] x64 dll calling issue - thought I could fix it but not so fast.......
问题描述
在一个较大的64位应用程序的过程中,我正在运行两个64位com dll,即BCRMaster.dll和BCRSlave.dll. BCRSlave在BCRMaster中调用一个称为SlaveCheckin的函数
从属实例的实例连同其DWORD指针,DWORD ID和BOOL LiveOrDie一起记录,无论从属是连接还是断开连接,该实例都将是1或0.
如果编译为32位并在32位应用程序中运行,则可以正常工作.
如果编译为64位并在同一应用程序的64位版本中运行,则主服务器接收到错误的数据.我正在使用.DEF文件进行导出.
接收DWORD似乎不够宽.我应该做些什么,并且有一个独立的解决方案吗?
这是从属调用代码:
收合|复制代码
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
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
void CBCRMaster::SlaveCheckin(DWORD SurfaceID, DWORD ObjInstPtr,BOOL BornOrDead)
-------------------------------------------------- --------------------------------
从属发送:
SurfaceID = 0x00000boc
ObjIstPtr = 0x000000000a9f7930
BornOrDead = 1
主人收到:
SurfaceID = 0x0b0c7930
ObjInstPtr = 0x00000001
BornOrDead = 0x0012e438
:谢谢
Ron
----------------------------------------------------------------------------------
The Slave sends:
SurfaceID = 0x00000boc
ObjIstPtr = 0x000000000a9f7930
BornOrDead = 1
The Master Receives:
SurfaceID = 0x0b0c7930
ObjInstPtr = 0x00000001
BornOrDead = 0x0012e438
:Thanks
Ron
推荐答案
以下是错误(在接收方Master函数中):
Here''s the bug (in the receiving Master function):
void CBCRMaster::SlaveCheckin(DWORD SurfaceID, DWORD ObjInstPtr,BOOL BornOrDead)
如果它接收到指针,则应为void *
或指针类型.
DWORD始终为32位.
最好的祝福,
巴勃罗.
It should be void *
, or a pointer type, if it receives a pointer.
DWORD is always 32 bits.
Best wishes,
Pablo.
这篇关于x64 dll调用问题-以为我可以修复它,但不能这么快.......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!