Mangle dll exported names with DEF file

蹲街弑〆低调 提交于 2020-01-04 05:27:18

问题


I'm trying to create a proxy dll and ran into this issue. Suppose I have following files:

a.cpp:

extern "C" int __declspec(dllexport) func(int x) {return x;}

a.def:

EXPORTS
func
??4Test@@QAEAAU0@ABU0@@Z = func

Then I run:

cl /c c.cpp
link /RELEASE /DLL /DEF:c.def /OUT:c.dll c.obj

Output of dumpbin /exports c.dll shows that following symbols are exported: func ??4Test

Where is the rest of the "Test" exported name? And is there any way to get it back?


回答1:


One idea which came to my mind: export the symbols using a different placeholder character than "@" (e.g. "^") and then lateron rewrite the export table by treating the DLL as a PE file and rewriting the export table entries on disk.




回答2:


Give this a shot instead, without using a DEF file:

extern "C" __declspec(dllexport) int __cdecl func(int x) {return x;}

Now it shouldn't mangle the function name at all.



来源:https://stackoverflow.com/questions/13589435/mangle-dll-exported-names-with-def-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!