我正在使用此代码进行 Hook ,并且我正在使用 MS Detours。我已将 Detours.cpp、Detours.h、Detours.lib 放入 detours 目录中,我临时将其创建到我的 VS (Visual Studio) 代码所在的 Hook 文件夹中。我使用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默认的安装目录走弯路的话,程序还是编译不通过。我哪里错了?
最佳答案
旧版本是 DetourFunction
和 DetourRemove
,现在的名称更改为 DetourAttach
和 DetourDetach
(Detours ver . 2.0 或更高版本)。
关于visual-c++ - DetourFunction 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14014310/