小弟不才,想请教高人,detours库到底怎么用? 我在网上找了几个教程,看了一下,但好像就有地方出错,把src文件nmake了,放了个简单的dll编译,提示
error C2065: 'DetourTransactionBegin' : undeclared identifier
D:\转移\dll\dll.cpp(19) : error C2065: 'DetourUpdateThread' : undeclared identifier
D:\转移\dll\dll.cpp(20) : error C2065: 'DetourAttach' : undeclared identifier
D:\转移\dll\dll.cpp(21) : error C2065: 'DetourTransactionCommit' : undeclared identifier
D:\转移\dll\dll.cpp(26) : error C2065: 'DetourDetach' : undeclared identifier
我老是怀疑自己detours没装上,换了vs2005,用2。1版本的(上面那么是1。5,在vc6下),提示还是一样。。。我在编译的时候把detours.lib 和detours.h都放到我的工程目录下了
#include <windows.h>
#include "detours.h"
static LONG dwSlept = 0;
static VOID (WINAPI * TrueSleep)(DWORD dwMilliseconds) = Sleep;
VOID WINAPI TimedSleep(DWORD dwMilliseconds)
{
DWORD dwBeg = GetTickCount();
TrueSleep(dwMilliseconds/10);//改成原来的1/10
DWORD dwEnd = GetTickCount();
InterlockedExchangeAdd(&dwSlept, dwEnd - dwBeg);
}
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID reserved)
{
if (dwReason == DLL_PROCESS_ATTACH) {
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)TrueSleep, TimedSleep);
DetourTransactionCommit();
}
else if (dwReason == DLL_PROCESS_DETACH) {
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&(PVOID&)TrueSleep, TimedSleep);
DetourTransactionCommit();
}
return TRUE;
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课