我们已经得到了它,我们用它来执行安全相关任务对我们是一个机库。我们写了一个互操作的库,这样我们可以从.NET中使用它。
We've got a native library which we use to perform security related tasks for us. We've written an interop library so that we can use it from .NET.
我们已经有了两个测试应用程序,第一个应用程序是用C ++(非托管),第二个是用C#。他们生成调用本机库完全相同的序列,但产生不同的结果。
We've got two test applications, the first application is written in C++ (unmanaged) and the second is written in C#. They generate the exact same sequence of calls to the native library, but produce different results.
我迷路了,找不到在.NET进口定义任何明显的错误。我已经简单化下来,这样我只能用一个非常简单的接口工作。我在寻找想法,为什么从.NET环境中调用本机库可能会影响结果。
I'm lost and can't find any apparent mistake in the .NET import definitions. I've already dumbed it down so that I only work with a very simple interface. I'm looking for ideas why calling a native library from a .NET environment might influence the result.
编辑: 我没有在库的深入了解,所以我不能提供太多的关于什么是天然code完成。我知道它确实维护(heatbeat)线程。库,它是用于标识在VM应用程序是否正在运行的另一部分,也表现出相同的行为。这不是必然的关系。
I do not have in depth knowledge of the library, so I can't provide much on what is done in the native code. I know it does maintain a (heatbeat) thread. Another part of the library, which is used to identify whether the application is running on a VM, also exhibits the same behavior. This isn't necessarily related.
我在C ++ / CLI写了另外一个测试应用程序,因为它是一个比较容易消耗本地库比从C#,它也给了相同的结果C#。
I wrote another test application in C++/CLI, since it is a little easier to consume the native library than from the C# and it is also giving the same result as the C#.
大胆猜测:你名帅功能以布尔
来一个函数以布尔
。这给了不同的结果,从本地code调用和管理code,因为布尔
不能被整理为布尔
Wild guess: You marshal a function taking bool
to a function taking bool
. This gives different results when calling from native code and managed code because bool
must not be marshalled to bool