如何找到第三方dll的调用约定?
谁能解释一下如何在不获取和处理方法名称的情况下了解 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果符号以
_
开头但没有@
,则它是__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
在试图找出为什么我在链接第三方 dll 时遇到未解析的符号时,我偶然发现了一种(某种)编程解决方案。
我使用
Dbghelp.h
中的UnDecorateSymbolName
针对 Windows API 编写了一个小程序来解码损坏方案:肯定有更漂亮的方法可以做到这一点。我只是在调试器中运行它并查看 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
fromDbghelp.h
to decode the mangling scheme: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 thestdcall
methods being looked for wasYAAAV
vs.YGAAV
.