如何强制 VC++名称修改 C++Builder?

发布于 2024-11-02 04:00:12 字数 429 浏览 6 评论 0原文

是否可以从 C++Builder DLL 中导出具有特定名称的函数?
我正在尝试构建一个 C++Builder DLL 来替换现有的 VC++ DLL。问题是使用 DLL 的应用程序期望其中一个函数具有特定的损坏名称。

也就是说,它期望调用该函数:

"?_FUNCTIONNAME_@@YAHPAU_PARAM1_@@PAU_PARAM2_@@@Z"

当然,我可以使用损坏的名称从 DLL 导出函数,但 CodeGear 坚持使用自己的名称损坏方案。

是否可以强制 C++Builder:

  1. 为函数使用特定的损坏名称?

  2. 对特定函数使用 VC++ 名称修饰?

请注意,我只想更改特定函数的重整,而不是 DLL 中的所有函数。

Is it possible to export a function from a C++Builder DLL with a specific mangled name?
I am trying to build a C++Builder DLL to replace an existing VC++ DLL. The problem is that the application that uses the DLL expects one of the functions to have a specific mangled name.

That is, it expects the function to be called:

"?_FUNCTIONNAME_@@YAHPAU_PARAM1_@@PAU_PARAM2_@@@Z"

Of course I can export function from my DLL with a mangled name but CodeGear insists on using its own name mangling scheme.

Is it possible to force C++Builder to:

  1. Use a specific mangled name for a function?

    or

  2. Use VC++ name mangling for a specific function?

Note that I only want to change the mangling for a specific function, not all the functions in the DLL.

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

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

发布评论

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

评论(2

桃气十足 2024-11-09 04:00:12

名称修改只是 ABI 的众多方面之一。事实上,它会更容易标准化。编译器在使用不同的 ABI 时会故意使用不同的名称修饰,以防止链接不兼容的对象。

对于给定函数,您可以尝试的一件事是将其标记为 extern "C",然后它将使用 C 的调用约定和相同的修饰(通常根本没有修饰或只是一个初始的 _)。显然这不会解决其他问题(异常处理、vtbls的精确内容、哪些寄存器用于传递参数、标准库的精确定义……)

Name mangling is just one of many aspects of the ABI. And it fact it would be the more easy to standardize. Compilers are using purposefully different name manglings when they are using different ABI in order to prevent linking incompatible objects.

One thing you may try for a given function is to mark it extern "C", then it will use the calling convention of C and the same mangling (commonly no mangling at all or just an initial _). Obviously that won't take care of other issues (handling of exceptions, precise content of vtbls, which registers are used for passing parameters, the precise definition of the standard library, ...)

凶凌 2024-11-09 04:00:12

使用 .def 文件为导出的函数指定您自己的命名。

Use a .def file to specify your own naming for the exported function.

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