Win32 DLL导入问题(DllMain) [英] Win32 DLL importing issues (DllMain)

查看:399
本文介绍了Win32 DLL导入问题(DllMain)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个本地DLL,是一个插件到不同的应用程序(一个我基本上是零控制)。一切工作很好,直到我链接一个额外的.lib文件(链接我的DLL到另一个名为 ABLSMABasCoreUtils.dll 的DLL)。此文件包含我想使用的父应用程序中的一些其他API。我甚至没有写任何代码使用任何导出的函数,但只是链接在这个新的DLL是导致问题。具体来说,当我尝试运行程序时,我得到以下错误:



应用程序无法正确初始化(0xc0000025)。单击确定以终止应用程序。



我相信我已经读的地方,这通常是由于DllMain函数返回FALSE。此外,下面的消息写到标准输出:



错误:试图组件初始化之前内存分配



我几乎100%确定这个错误信息来自应用程序,而不是某种类型的Windows错误。



查看这个更多(aka flailing around和翻转我知道的每个开关)我链接/ MAP打开,并在生成的.map文件中找到:

  0001:000af220 ?? 3 @ YAXPEAX @ Z 00000001800b0220˚FABQSMABasCoreUtils_import:ABQSMABasCoreUtils.dll 
0001:000af226 ?? 2 @ YAPEAX_K @ Z 00000001800b0226˚FABQSMABasCoreUtils_import:ABQSMABasCoreUtils.dll
0001:000af22c? ?_U @ YAPEAX_K @ Z 00000001800b022c˚FABQSMABasCoreUtils_import:ABQSMABasCoreUtils.dll
0001:000af232 ?? _ V□的YAXPEAX @ Z 00000001800b0232˚FABQSMABasCoreUtils_import:ABQSMABasCoreUtils.dll

如果我使用undname解密这些名称,他们给出以下(相同的顺序):

 code>无效__cdecl的operator delete(void *的__ptr64)
无效* __ptr64 __cdecl的operator new(无符号__int64)
无效* __ptr64 __cdecl的operator new [](无符号__int64)
无效__cdecl运算符delete [](void * __ptr64)

我不知道我怎么理解 ABQSMABasCoreUtils.dll 可在此.MAP文件或为什么我的DLL甚至试图加载ABQSMABasCoreUtils.dll如果我没有引用该DLL的任何代码中存在。任何人都可以帮助我把这些信息在一起,找出为什么这不工作?对于什么是值得我已经通过DUMPBIN父申请进口 ABQSMABasCoreUtils.dll ,所以它被加载不管证实。我也试过延迟加载这个DLL在我的DLL,但是没有改变的结果。



EDIT



我有双重检查,所有涉及的文件都是64位。

解决方案

问题。这与Abaqus的API,而不是对DLL的加载问题。



我想这是因为Abaqus的API覆盖new和delete功能(你似乎已经注意到)。如果您在初始化Abaqus API之前(例如通过调用 odb_initializeAPI(); )在您的程序中调用新的或删除 >

错误:在组件初始化之前尝试内存分配



错误消息,程序崩溃。



在我的程序中,在第一个 new odb_initializeAPI(); c $ c>解决了问题。


I have a native DLL that is a plug-in to a different application (one that I have essentially zero control of). Everything works just great until I link with an additional .lib file (links my DLL to another DLL named ABQSMABasCoreUtils.dll). This file contains some additional API from the parent application that I would like to utilize. I haven't even written any code to use any of the functions exported but just linking in this new DLL is causing problems. Specifically, I get the following error when I attempt to run the program:

The application failed to initialize properly (0xc0000025). Click on OK to terminate the application.

I believe I have read somewhere that this is typically due to a DllMain function returning FALSE. Also, the following message is written to the standard output:

ERROR: Memory allocation attempted before component initialization

I am almost 100% sure this error message is coming from the application and is not some type of Windows error.

Looking into this a little more (aka flailing around and flipping every switch I know of) I linked with /MAP turned on and found this in the resulting .map file:

 0001:000af220       ??3@YAXPEAX@Z              00000001800b0220 f   ABQSMABasCoreUtils_import:ABQSMABasCoreUtils.dll
 0001:000af226       ??2@YAPEAX_K@Z             00000001800b0226 f   ABQSMABasCoreUtils_import:ABQSMABasCoreUtils.dll
 0001:000af22c       ??_U@YAPEAX_K@Z            00000001800b022c f   ABQSMABasCoreUtils_import:ABQSMABasCoreUtils.dll
 0001:000af232       ??_V@YAXPEAX@Z             00000001800b0232 f   ABQSMABasCoreUtils_import:ABQSMABasCoreUtils.dll

If I undecorate those names using "undname" they give the following (same order):

void __cdecl operator delete(void * __ptr64)
void * __ptr64 __cdecl operator new(unsigned __int64)
void * __ptr64 __cdecl operator new[](unsigned __int64)
void __cdecl operator delete[](void * __ptr64)

I am not sure I understand how anything from ABQSMABasCoreUtils.dll can exist within this .map file or why my DLL is even attempting to load ABQSMABasCoreUtils.dll if I don't have any code that references this DLL. Can anyone help me put this information together and find out why this isn't working? For what it's worth I have confirmed via "dumpbin" that the parent application imports ABQSMABasCoreUtils.dll, so it is being loaded no matter what. I have also tried delay loading this DLL in my DLL but that did not change the results.

EDIT

I have double checked and all files involved are 64 bit.

解决方案

I just had exactly the same problem. This is an issue with the Abaqus API rather than with the loading of DLLS.

I think it is because the Abaqus API overrides the new and delete functions (as you seem to have noticed). If you call new or delete in your program before initializing the Abaqus API, such as by calling odb_initializeAPI(); then you get the

ERROR: Memory allocation attempted before component initialization

error message and the program crashes.

In my program, calling odb_initializeAPI(); before the first new resolved the problem.

这篇关于Win32 DLL导入问题(DllMain)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆