x86到x64的移植问题

x86到x64的移植问题

本文介绍了x86到x64的移植问题(调用导出的DLL函数)64到64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在将我的项目移植到x64.
作为一个x86项目,BCRMaster是一个dll,具有在.DEF文件中定义的导出函数.
他们像冠军一样工作.

现在,所有内容都已编译为x64,我无法在BCRMaster的函数中接收到损坏的"数据.我正在从x64应用程序中调用它们.

GetProcAddress成功.
LoadLibrary也成功.

函数的实际调用与dll函数的调用一样成功,但是当我发送两个整数0和1(简化测试)时,到达dll函数的是1和11.

该代码在x86版本中与预期的工作方式相同.

我发现其他功能正常运行,而这一功能和至少另一功能则无法正常工作.两者都是发送"伪造数据.

有什么问题吗?

预先感谢,

:罗恩



Hi,

I am porting my project to x64.
As a x86 project, BCRMaster is a dll with exported functions defined in a .DEF file
They work like a champ.

Now that everything is compiled to x64, I am having trouble with ''corrupted" data being received at BCRMaster''s functions. I am calling them from an x64 app.

GetProcAddress succeeds.
LoadLibrary also succeeds.

The actual call of the function succeed in as much as the dll function is indeed called but while I am sending two ints 0 and 1 (simplified for testing), what arrives at the dll function is 1 and 11.

The code is the same in the x86 version where it works as expected.

I have found that other functions are working correctly while this one and at least another are not. Both are "sending" bogus data.

What could be wrong?

Thanks in advance,

:Ron



typedef void (CALLBACK* LPFNDLLFUNC1)(int Unit,int Preset);

   HINSTANCE hDLL;               // Handle to DLL
   LPFNDLLFUNC1 lpfnDllFunc1;    // Function pointer
   DWORD dwParam1 = NULL;

   UINT uReturnVal;
   hDLL = LoadLibrary("BCRMaster");
   if (hDLL != NULL)
   {
    lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hDLL, "SetBcrPreset");

      if (!lpfnDllFunc1)
      {

         // handle the error
        FreeLibrary(hDLL);
          return;

      }else{
       lpfnDllFunc1(0,1); // call the dll function
      }
   }

推荐答案


extern "C" void CALLBACK SetBcrPreset(int Unit, int Preset) {
	//This function has the correct name exported to the DLL
	InternalSetBcrPreset(Unit, Preset);
}

void InternalSetBcrPreset(int Unit, int Preset) {
	//Your original code from SetBcrPreset
	//This function exists in C++, so you can do all your C++ stuff in here, such as the string class you had issues with
}


这篇关于x86到x64的移植问题(调用导出的DLL函数)64到64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 08:44