重命名 DLL 函数?

huangapple go评论73阅读模式
英文:

Renaming DLL functions?

问题

有没有办法让我为我的导出 DLL 函数命名?当我使用 DLL 导出查看器时,显示的函数名称是完整的声明。我想使用 JNA(JNI)来访问 DLL 内部的函数,而函数名称需要是函数名,而不是完整的声明。如果这是重复的,请指出来!

英文:

Is there a way for me to name my exported dll functions? When I use a dll export viewer the function names shown are the full declarations. I would like to use the JNA (JNI) to access functions inside the DLL, and the function names need to be a function name not a full declaration. If this is a duplicate please point it out!

答案1

得分: 2

可以实际上只使用__declspec(dllexport)语法来完成(也就是说,不需要.def文件),如果你将函数声明为extern "C"(或者在C文件中实现它而不是C++)。

extern "C"
{
  __declspec(dllexport) void __stdcall MyFunc(std::string &);
}

通常比导出带有别名的名字(因为你需要追踪找到被混淆的名字,以便为其分配一个别名)要简单得多。

英文:

It can actually be done with just the __declspec(dllexport) syntax (that is, without a .def file) if you declare the function as extern "C" (or implement it in a C file instead of C++).

extern "C"
{
  __declspec(dllexport) void __stdcall MyFunc(std::string &);
}

Generally much easier than exporting a mangled name with an alias (as you then need to track down the mangled name in order to assign an alias).

huangapple
  • 本文由 发表于 2020年8月29日 11:41:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/63643190.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定