0

I have a 32-bit application and I have a problem with it on Windows 7 x64. I'm loading a DLL. LoadLibraryW succeeds and the subsequent call to GetProcAddress fails with the error code 127 ("procedure not found" or something like that).

The funny part is that I know for a fact the function is exported by the DLL. I made no typos in the GetProcAddress call. I can see the function with Depends.exe and DllExp.exe. The exact same application binary successfully loads the function from the exact same DLL on Windows 10 x64, but not on Windows 7 x64.

Some more details: the library is dbghelp.dll and the "missing" function is MiniDumpWriteDump.

And the fun bit: dbghelp.dll provides API for inspecting the modules loaded into the process and for enumerating functions exported by those modules. So, first I took the HMODULE for this problematic dbghelp.dll and ran

auto ptrSymInitialize = (decltype(&SymInitialize))GetProcAddress(hDbgHelpDll, "SymInitialize");

It worked, this function did load! Then I loaded SymEnumSymbols, written the enumerator callback and finally ran the following to enumerate all the functions in this very `dbghelp.dll":

ptrSymEnum(GetCurrentProcess(), 0, "dbghelp*!*", &Enumerator, nullptr);

And what do you know, MiniDumpWriteDump is, in fact, listed there. Go figure.

Thoughts?

4

2 回答 2

2

我可以看到你的意图是使用MiniDumpWriteDump. 我们还在我们的产品中制作小型转储,我是支持这一点的人。

我建议不要使用dbghelp.dll随操作系统提供的。首先,它们往往已经过时并且不支持您想要拥有的最新小型转储功能。其次,它们已被证明是相当不可靠的。我相信他们只是缺少太多的错误修正。

我发现效果很好的是从Debugging Tools for Windows包(当前是 Windows SDK 的一部分)中获取 dbghelp.dll 并将其与我们的产品一起提供。这样,我可以确定 minidumps 将具有所有最新功能,并且它可以在所有操作系统上可靠地运行。现在已经8年了,操作系统从WinXP到Win10,我没有任何问题。

我不确定我用哪个版本的SDK来提取当前使用的dbghelp.dll,可能是Win7 SDK。从那以后,我根本没有理由更新。但是,我们Debugging Tools for Windows在 Win7 上使用 Win10 SDK 的包没有任何问题,所以我想你也可以使用 Win10 版本。

于 2017-02-25T16:27:22.307 回答
1

这正是我一直在做的,我没有带dbgcore.dll

这只是一个糟糕的主意。Microsoft 不努力使操作系统中包含的 DLL 向后兼容。他们不必这样做。在他们的实现中,只有接口需要兼容。他们确实利用新功能或设计更改来改进实施。

就像您在这里看到的那样, MinWin 项目的副作用。没有合理的猜测在哪里结束,如果它现在恰好在 Win7 机器上工作,那么你很幸运。也许您在没有 SP1 的 Win7 机器上不会那么幸运,也许在全新安装时缺少一些 minwin 胶水 DLL,也许 minidump 本身受到某种负面影响。无法预测。

所以永远不要这样做。Afaik 你根本不应该这样做,Win7 机器已经有 dbghelp.dll 可用。不是 100% 肯定,它已经太久了,Win7 正在迅速变成新的 XP。如果您认为有必要,请始终使用可再发行版本。包含在 SDK 的 Windows 调试工具中。将其复制到与需要它的 EXE 相同的文件夹中,这样您就不会弄乱机器。

于 2017-02-25T12:20:49.427 回答