我正在使用此代码进行挂钩,并且正在使用 MS Detours。我已将 Detours.cpp、Detours.h、Detours.lib 放入detours目录中,我将其临时创建到我的 VS(Visual Studio)代码所在的挂钩文件夹中。我使用VS设置将放置的detours目录包含为“Additional include directory”和“Additional Library directory”的目录。程序在这里
#include <Windows.h>
#include "detours.h"
#pragma comment(lib, "detours.lib")
typedef BOOL (__stdcall* tGetFileVersionInfoExW)(DWORD dwFlags, LPCWSTR lpwstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData);
tGetFileVersionInfoExW pGetFileVersionInfoExW;
BOOL WINAPI MyGetFileVersionInfoExW(DWORD dwFlags, LPCWSTR lpwstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData)
{
//Messagebox
MessageBox(NULL, "myGetFileVersionInfoExW Just Got Called","InsertDateTime", MB_OK);
return pGetFileVersionInfoExW(dwFlags, lpwstrFilename, dwHandle, dwLen, lpData); //Return the origional function
}
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call) //Decide what to do
{
case DLL_PROCESS_ATTACH: //On dll attach
{
pGetFileVersionInfoExW = (tGetFileVersionInfoExW)DetourFunction((PBYTE)0x0100A036, (PBYTE)MyGetFileVersionInfoExW);
}
break;
case DLL_THREAD_ATTACH: //On thread attach
break;
case DLL_THREAD_DETACH: //On thread detach
break;
case DLL_PROCESS_DETACH: //on process detach
{
DetourRemove((PBYTE)pGetFileVersionInfoExW, (PBYTE)MyGetFileVersionInfoExW);
}
break;
}
return true;
}
我仍然收到此错误-
IntelliSense: identifier "DetourRemove" is undefined
IntelliSense: identifier "DetourFunction" is undefined
如果我使用MS Detours的默认安装目录,程序仍然无法编译。我哪里错了?