DetourFunction未定义

时间:2012-12-23 20:06:59

标签: visual-c++ visual-studio-2012

我正在使用此代码进行挂钩,而我正在使用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的默认安装目录,程序仍然无法编译。我哪里错了?

1 个答案:

答案 0 :(得分:0)

旧版本为DetourFunctionDetourRemove,现在名称已更改为DetourAttachDetourDetach(Detours版本2.0或更高版本)。