如何找到第三方dll的调用约定?

发布于 2024-10-02 14:13:22 字数 125 浏览 3 评论 0原文

谁能解释一下如何在不获取和处理方法名称的情况下了解 dll 的调用约定?假设我们的应用程序正在加载第三方 dll,为了处理它,是否有任何有效的方法来了解 dll 的调用约定? (__stdcall、__cdecl、__fastcall)

Could any one explain me how to get to know the calling convention of a dll without getting and processing method names? Lets say our application is loading a third party dll and in order to handle it, is there any effective ways to get to know the calling convention of a dll? (__stdcall, __cdecl, __fastcall)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哀由 2024-10-09 14:13:22

如果符号以 _ 开头但没有 @,则它是 __cdecl。如果它以 _ 开头并具有 @,则为 __stdcall。如果它以 @ 开头并且有另一个 @,则它是 __fastcall

来源

If the symbol begins with a _ but has no @, then it's __cdecl. If it begins with _ and has a @ it's __stdcall. If it begins with @ and has another @, it's __fastcall.

source

夜吻♂芭芘 2024-10-09 14:13:22

在试图找出为什么我在链接第三方 dll 时遇到未解析的符号时,我偶然发现了一种(某种)编程解决方案。

我使用 Dbghelp.h 中的 UnDecorateSymbolName 针对 Windows API 编写了一个小程序来解码损坏方案:

#include "Windows.h"
#include "Dbghelp.h"
#include "tchar.h"

int _tmain(int argc, _TCHAR* argv[])
{
    CHAR out[512];
    UnDecorateSymbolName(
        // Mangled symbol
        "?OFFReader@IO@OpenMesh@@YGAAV_OFFReader_@12@XZ",
        out,
        // Length of symbol
        46,
        UNDNAME_32_BIT_DECODE);
}

肯定有更漂亮的方法可以做到这一点。我只是在调试器中运行它并查看 out.txt 的内容。

另外值得注意的是,与 Ignacio 的答案相反,DLL 中的 cdecl 方法的损坏名称与正在查找的 stdcall 方法之间的区别是 YAAAV代码>与<代码>YGAAV。

While trying to figure out why I was getting unresolved symbols when linking against a third-party dll I stumbled upon a (sort of) programmatic solution.

I wrote a small program against the Windows API using UnDecorateSymbolName from Dbghelp.hto decode the mangling scheme:

#include "Windows.h"
#include "Dbghelp.h"
#include "tchar.h"

int _tmain(int argc, _TCHAR* argv[])
{
    CHAR out[512];
    UnDecorateSymbolName(
        // Mangled symbol
        "?OFFReader@IO@OpenMesh@@YGAAV_OFFReader_@12@XZ",
        out,
        // Length of symbol
        46,
        UNDNAME_32_BIT_DECODE);
}

There are definitely prettier ways to do it. I just run it in a debugger and look at the contents of out.

Also worth noting, contrary to Ignacio's answer, the difference between the mangled names for the cdecl methods in the dll and the stdcall methods being looked for was YAAAV vs. YGAAV.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文