在x86体系结构中运行DLLimports时Unity3D崩溃

时间:2017-06-27 10:30:57

标签: c# c++ unity3d 32bit-64bit dllimport

我一直在研究一个统一包装器,它将启用一些用C / C ++编写的DLL。包装器和DLL在64位体系结构上完美地工作,但是当尝试编译32位体系结构时它失败了。 C#包装器看起来像这样:

public class somePlugin : IDisposable
{
public IntPtr __this  = IntPtr.Zero;

public somePlugin()
{
    __this = CreateTheOject();
}

public bool initialize(ref uint area, ref uint volume)
{
    return CPP_init(__this, ref area, ref volume);
}

//C imports
[DllImport("interface100")]
private static extern IntPtr CreateTheObject();

//C++ imports

[DllImport("interface100", EntryPoint = "?init@Interface@@QAE_NPEA0@Z", CallingConvention = CallingConvention.ThisCall)]
private static extern bool CPP_init(IntPtr _this, ref uint area, ref uint volume);

};

C函数CreateTheOject()返回没有问题。但是当调用C ++函数CPP_init时,Unity会完全崩溃。崩溃来自DLL本身。它的标题如下所示:

bool objectInterface::init(unsigned int* area, unsigned int* volume);

调试问题我发现DLL接收区域的实际值代替了卷。卷的值丢失,Unity可能由于分段错误而崩溃。

有没有人对问题可能有什么想法?

0 个答案:

没有答案
相关问题