[英]How to remove the underscore from DLL export
I want to replace a DLL for which I don't have the full source code (but the function declarations).我想替换一个我没有完整源代码(但有函数声明)的 DLL。 The application loads this DLL at runtime and calls
GetProcAddress
with (all) the function names.应用程序在运行时加载此 DLL 并使用(所有)函数名称调用
GetProcAddress
。 (so I have to name the functions exactly the same). (所以我必须完全相同地命名函数)。
I created a new DLL (in MS VC2013) and wrote the functions.我创建了一个新的 DLL(在 MS VC2013 中)并编写了函数。 But I have a problem exporting them correctly.
但是我在正确导出它们时遇到了问题。
In the original DLL they are defined with _stdcall
but their names don't start with an underscore.在原始 DLL 中,它们是用
_stdcall
定义的,但它们的名称不以下划线开头。
If I specify the name in the .def file like this testfunc@4=testfunc
everything behind the @ is removed.如果我在 .def 文件中指定名称,像这样
testfunc@4=testfunc
后面的@ 的所有内容都将被删除。
How can I specify in VS2013 that I want an DLL-export like testfunc@4
?如何在 VS2013 中指定我想要像
testfunc@4
这样的 DLL 导出?
The easiest way I think is by adding我认为最简单的方法是添加
// in cpp, but will probably work in header too
#pragma comment(linker, "/export:FunctionName@4=_FunctionName@4")
// in header
extern "C" __declspec(dllexport) void __stdcall FunctionName(int param);
in the source code of your DLL.在 DLL 的源代码中。
I got the idea from here .我从这里得到了这个想法。 They also explain how to do it with a DEF file.
他们还解释了如何使用 DEF 文件执行此操作。 A matter of taste I guess.
我猜是口味问题。 You will end up with two entries for the same function in the export table but the application should be able to get the correct proc address.
您将在导出表中得到两个相同函数的条目,但应用程序应该能够获得正确的 proc 地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.