MS Detours 2.1-未解决的外部问题
MS Detours 2.1 - Unresolved externals
我使用的是MS Detours 2.1 Library和VS 2010。我试图绕过PlaySoundW功能。
我无法编译该代码,并且出现以下错误:
Error 2 error LNK1120: 1 unresolved externals (...)detoursLearning.dll detoursLearning
Error 1 error LNK2001: unresolved external symbol __imp__PlaySoundW@12 (...)detoursLearningmain.obj detoursLearning
我的代码:
#include <Windows.h>
#include <tchar.h>
#include <detours.h>
namespace Hooks
{
BOOL(__stdcall *OrgPlaySoundW)(LPCTSTR pszSound, HMODULE hmod, DWORD fdwSound) = &PlaySoundW;
BOOL HookPlaySoundW(LPCTSTR pszSound, HMODULE hmod, DWORD fdwSound)
{
Beep(1000, 250);
return TRUE;
}
void DetourPlaySoundW(BOOL disable)
{
if(!disable)
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)OrgPlaySoundW, HookPlaySoundW);
DetourTransactionCommit();
} else
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&(PVOID&)OrgPlaySoundW, HookPlaySoundW);
DetourTransactionCommit();
}
}
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
Hooks::DetourPlaySoundW(FALSE);
break;
case DLL_PROCESS_DETACH:
Hooks::DetourPlaySoundW(TRUE);
break;
}
return TRUE;
}
还有一件事,你能解释一下吗:
&(PVOID&)OrgPlaySoundW
您没有链接到winmm.lib.
http://msdn.microsoft.com/en-us/library/dd743680%28VS.85%29.aspx
Martyn
相关文章:
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- 节俭并发:未解决的外部问题
- 未解决的外部链接问题
- 在 C++ 中使用 C 代码与外部"C"的问题
- 编译示例 Cinder 项目时存在大量未解决的外部问题
- 为使用boost的预开发库构建c++包装器时未解决的外部问题
- 伊利希特中未解决的外部问题
- 在Visual Studio 2013中尝试使用C++连接到mysql时未解决的外部问题
- 格鲁问题,未解决的外部问题
- 编译多源文件时未解决的外部问题
- 为什么我的程序总是得到未解决的外部问题
- TinyXml未解决的外部问题
- 使用qt模板时无法解决外部问题
- C++ 外部问题 - 未定义的引用
- c++:无法解决的外部问题让我抓狂
- MS Detours 2.1-未解决的外部问题
- 使用boost::asio(visual studio12,x64)解决的外部问题
- libcURL在7.36重建后未解决的外部问题
- 未解决的外部问题c++
- LNK 2019未解决的外部问题