【发布时间】:2010-11-02 19:28:32
【问题描述】:
在 LabVIEW 中调用 DLL 时遇到访问冲突。我们将 DLL 称为“extcode.dll”。我没有它的代码,它来自外部制造商。
在 Windbg 中运行它,它停止并显示消息:
(724.1200): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
ntdll!RtlNewSecurityObjectWithMultipleInheritance+0x12a:
调用栈是:
ntdll!RtlNewSecurityObjectWithMultipleInheritance+0x12a
ntdll!MD5Final+0xedfc
ntdll!RtlFindClearBitsAndSet+0xdf4
ntdll!RtlFindClearBitsAndSet+0x3a8
ntdll!RtlFindClearBitsAndSet+0x4b9
ntdll!RtlCreateProcessParametersEx+0x829
ntdll!LdrLoadDll+0x9e
KERNELBASE!LoadLibraryExW+0x19c
KERNELBASE!LoadLibraryExA+0x51
LabVIEW!ChangeVINameWrapper+0x36f5
LabVIEW!ChangeVINameWrapper+0x3970
LabVIEW!ExtFuncDynLibWrapper+0x211
请注意,extcode.dll 的依赖项是在访问冲突之前加载的。
情况是随机的,但当它发生时,所有后续尝试都会导致它。
代码是一个简单的LabVIEW函数调用DLL中的函数,原型非常简单(int function(void)),所以它不会是调用参数的错误配置,也不是指针算法。我检查了调用约定和错误检查级别的所有组合。
在其他环境(.NET 和 C)中调用时,DLL 运行良好。
我发现RtlFindClearBitsAndSet与位数组操作有关
这让你想到了什么?您认为这是 extcode.dll、LabVIEW 还是 Windows 中的问题?
PS:我在 Windows 7 64 位上使用 LabVIEW 2010 64 位(而 extcode.dll 是 64 位)。我没能在 32 位系统上重现它。
11/18 编辑
我最终制作了一个包装 DLL 的独立 exe; LabVIEW通过管道与其通信。它运行良好,但我仍然不明白为什么将 DLL 加载到 LabVIEW 中会崩溃。
【问题讨论】:
标签: winapi dll labview loadlibrary