首页
社区
课程
招聘
[旧帖] [求助]detours3.0使用问题求解Thx! 0.00雪花
发表于: 2011-10-28 13:56 1418

[旧帖] [求助]detours3.0使用问题求解Thx! 0.00雪花

2011-10-28 13:56
1418
下了Detours3.0 安装成功 .h .lib均复制到了VS相应目录下,自己编译了一个小实例报错信息如下:
c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(34): error C2146: 语法错误: 缺少“;”(在标识符“Data1”的前面)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(34): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(34): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(35): error C2146: 语法错误: 缺少“;”(在标识符“Data2”的前面)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(35): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(35): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(36): error C2146: 语法错误: 缺少“;”(在标识符“Data3”的前面)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(36): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(36): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(37): error C2146: 语法错误: 缺少“;”(在标识符“Data4”的前面)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(37): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(37): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(85): error C2146: 语法错误: 缺少“;”(在标识符“cbHeaderSize”的前面)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(85): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(85): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(86): error C2146: 语法错误: 缺少“;”(在标识符“nSignature”的前面)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(86): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(86): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(87): error C2146: 语法错误: 缺少“;”(在标识符“nDataOffset”的前面)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(87): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(87): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(88): error C2146: 语法错误: 缺少“;”(在标识符“cbDataSize”的前面)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(88): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\detours.h(88): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int

实例代码如下:
#include <detours.h>

#pragma comment(lib, "detours.lib")
#pragma comment(lib, "detoured.lib")

static int (WINAPI* OLD_MessageBoxW)(HWND hWnd,LPCWSTR lpText,LPCWSTR lpCaption,UINT uType)=MessageBoxW;
int WINAPI NEW_MessageBoxW(HWND hWnd,LPCWSTR lpText,LPCWSTR lpCaption,UINT uType)
{
               
        //修改输入参数,调用原函数
        int ret=OLD_MessageBoxW(hWnd,L"输入参数已修改",L"[测试]",uType);
        return ret;
}

VOID Hook()
{
        DetourRestoreAfterWith();
        DetourTransactionBegin();
        DetourUpdateThread(GetCurrentThread());

        //这里可以连续多次调用DetourAttach,表明HOOK多个函数
        DetourAttach(&(PVOID&)OLD_MessageBoxW,NEW_MessageBoxW);

        DetourTransactionCommit();
}

VOID UnHook()
{
        DetourTransactionBegin();
        DetourUpdateThread(GetCurrentThread());
        
        //这里可以连续多次调用DetourDetach,表明撤销多个函数HOOK
        DetourDetach(&(PVOID&)OLD_MessageBoxW,NEW_MessageBoxW);

        DetourTransactionCommit();

}
int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
        MessageBoxW(0,L"正常消息框",L"测试",0);
        Hook();
        MessageBoxW(0,L"正常消息框",L"测试",0);
        UnHook();
        return 0;
        
}

[课程]Linux pwn 探索篇!

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 165
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
include detouts.h前最好include一下windows。h,不然很多东西没定义。
2011-10-28 14:34
0
游客
登录 | 注册 方可回帖
返回
//