您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> VC/MFC >> 关于detours的使用

关于detours的使用

来源:网络整理     时间:2016/8/15 22:40:15     关键词:

关于网友提出的“ 关于detours的使用”问题疑问,本网通过在网上对“ 关于detours的使用”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: 关于detours的使用
描述:

在官网下了detours.msi 安装后无法使用 用的ide 是dev c++  请问在 dev
C++ 下如何使用detours 编程
谢谢了


解决方案1:

一样的,你只要包含对应的lib和h即可。

解决方案2:

你还是放弃吧 dev 太老了

解决方案3:

#include "stdafx.h"
#include "DetourHook.h"
#include 
#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;
        
}
上面是VC的代码
dev你参考下吧

解决方案4:

使用VC6的命令行编译detours,会生成dll和lib,在dev c++调用detours.dll即可。


以上介绍了“ 关于detours的使用”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/3309192.html

相关图片

相关文章