我正在尝试为 'Version.dll' 构建代理 DLL,但一直遇到与导出函数相关的错误。
00000000 characteristics
4A5BC9E3 time date stamp Tue Jul 14 05:27:23 2009
0.00 version
1 ordinal base
15 number of functions
15 number of names
ordinal hint RVA name
1 0 00001B14 GetFileVersionInfoA
2 1 00001E40 GetFileVersionInfoByHandle
3 2 0000193C GetFileVersionInfoExW
4 3 00001AB4 GetFileVersionInfoSizeA
5 4 000014E8 GetFileVersionInfoSizeExW
6 5 000015FC GetFileVersionInfoSizeW
7 6 00001614 GetFileVersionInfoW
8 7 00002820 VerFindFileA
9 8 00003F50 VerFindFileW
10 9 00002AF0 VerInstallFileA
11 A 000043F8 VerInstallFileW
12 B VerLanguageNameA (forwarded to KERNEL32.VerLanguageNameA)
13 C VerLanguageNameW (forwarded to KERNEL32.VerLanguageNameW)
14 D 00001B94 VerQueryValueA
15 E 000015E0 VerQueryValueW
我的代码看起来像这样:
extern "C"
{
BOOL WINAPI DllMain(HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls((HMODULE)hDllHandle);
// do stuff
}
return TRUE;
}
DWORD APIENTRY Wrapper_GetFileVersionInfoSizeExA(__in DWORD dwFlags, __in LPCSTR lpwstrFilename, __out LPDWORD lpdwHandle)
{
return ::GetFileVersionInfoSizeExA(dwFlags, lpwstrFilename, lpdwHandle);
}
// and so on for the rest
}
导出定义文件:
LIBRARY Version
EXPORTS
GetFileVersionInfoA=Wrapper_GetFileVersionInfoA
GetFileVersionInfoByHandle=Wrapper_GetFileVersionInfoByHandle
GetFileVersionInfoExW=Wrapper_GetFileVersionInfoExW
GetFileVersionInfoSizeA=Wrapper_GetFileVersionInfoSizeA
GetFileVersionInfoSizeExW=Wrapper_GetFileVersionInfoSizeExW
GetFileVersionInfoSizeW=Wrapper_GetFileVersionInfoSizeW
GetFileVersionInfoW=Wrapper_GetFileVersionInfoW
VerFindFileA=Wrapper_VerFindFileA
VerFindFileW=Wrapper_VerFindFileW
VerInstallFileA=Wrapper_VerInstallFileA
VerInstallFileW=Wrapper_VerInstallFileW
VerLanguageNameA=Wrapper_VerLanguageNameA
VerLanguageNameW=Wrapper_VerLanguageNameW
VerQueryValueA=Wrapper_VerQueryValueA
VerQueryValueW=Wrapper_VerQueryValueW
我使用不同的函数名称来防止包含Windows.h头文件时出现原型重定义错误。尝试构建以上代码会生成以下错误:
1>Main.obj : error LNK2001: unresolved external symbol _GetFileVersionInfoW@16
1>Main.obj : error LNK2001: unresolved external symbol _VerQueryValueA@16
1>Main.obj : error LNK2001: unresolved external symbol _GetFileVersionInfoSizeA@8
1>Main.obj : error LNK2001: unresolved external symbol _VerQueryValueW@16
1>Main.obj : error LNK2001: unresolved external symbol _GetFileVersionInfoSizeExW@12
1>Main.obj : error LNK2001: unresolved external symbol _VerInstallFileA@32
1>Main.obj : error LNK2001: unresolved external symbol _VerInstallFileW@32
1>Main.obj : error LNK2001: unresolved external symbol _GetFileVersionInfoA@16
1>Main.obj : error LNK2001: unresolved external symbol _GetFileVersionInfoExW@20
1>Main.obj : error LNK2001: unresolved external symbol _GetFileVersionInfoSizeW@8
1>Main.obj : error LNK2001: unresolved external symbol _VerFindFileW@32
1>Main.obj : error LNK2001: unresolved external symbol _GetFileVersionInfoSizeExA@12
1>Main.obj : error LNK2001: unresolved external symbol _GetFileVersionInfoExA@20
我承认这是我第一次尝试构建代理DLL,所以我可能会忽略一些显而易见的东西。谢谢。