0
我正在使用MS Detours 2.1庫和VS 2010.我試圖繞過PlaySoundW函數。MS Detours 2.1 - 無法解析的外部
我不能編譯代碼和我得到這些錯誤:
Error 2 error LNK1120: 1 unresolved externals (...)\detoursLearning.dll detoursLearning
Error 1 error LNK2001: unresolved external symbol [email protected] (...)\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
這工作,THX。還有一件事: 你能解釋一下嗎: &(PVOID&)OrgPlaySoundW – Hooch 2011-06-05 17:58:16