MS Detours 2.1 - 未解决的外部问题
我正在使用 MS Detours 2.1 Library 和 VS 2010。我正在尝试绕行 PlaySoundW 函数。
我无法编译该代码,并且收到以下错误:
Error 2 error LNK1120: 1 unresolved externals (...)\detoursLearning.dll detoursLearning
Error 1 error LNK2001: unresolved externals符号 __imp__PlaySoundW@12 (...)\detoursLearning\main.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
I'm using MS Detours 2.1 Library and VS 2010. I'm trying to detour PlaySoundW function.
I can't compile that code and I'm getting these errors:
Error 2 error LNK1120: 1 unresolved externals (...)\detoursLearning.dll detoursLearning
Error 1 error LNK2001: unresolved external symbol __imp__PlaySoundW@12 (...)\detoursLearning\main.obj detoursLearning
My code:
#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;
}
One more thing, can you explain me this:
&(PVOID&)OrgPlaySoundW
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有链接到 winmm.lib。
http://msdn.microsoft.com/en-us /library/dd743680%28VS.85%29.aspx
马丁
You're not linking to winmm.lib.
http://msdn.microsoft.com/en-us/library/dd743680%28VS.85%29.aspx
Martyn