Detours 的使用
Detours 是一个用于在 ARM, ARM64, X86, X64 和 IA64 机器上拦截二进制函数的库。 Detours 最常用来拦截应用程序中的 win32 api 调用,比如添加调试工具。 拦截代码在运行时动态应用。
Detours 将目标函数的前几个指令替换为无条件跳转到用户提供的 detour 函数
它与 WriteProcessMemory 有所不同
区别:
WriteProcessMemory是 Windows API 中的一个函数,用于将数据写入到指定进程的内存空间中。通常情况下,这个函数被用于与进程间通信,比如注入 DLL、修改其他进程的内存内容等。这个函数能够在一定程度上用于修改其他进程的行为,因此在一些涉及软件修改的场景中被使用。- Detours 是 Microsoft Research 开发的一种库,用于在 Windows 平台上修改函数调用的行为。它允许开发者截获特定函数的调用,并将其重定向到自定义的函数中,从而实现对目标函数的修改、监视和扩展。Detours 在软件开发中被广泛用于实现各种目的,包括代码注入、API hooking、性能分析等。
结合使用:
- 在某些情况下,可以将 WriteProcessMemory 和 Detours 结合使用,以实现对其他进程的函数调用的修改和扩展。例如,可以使用 WriteProcessMemory 在目标进程中注入 DLL,然后使用 Detours 修改目标进程的某些函数调用,以实现一些特定的行为,比如游戏作弊、反作弊等。
- 通常情况下,Detours 会更适合用于修改目标进程内的函数调用,而不是直接修改其内存内容。因此,结合 WriteProcessMemory 和 Detours 使用时,可能会将 Detours 用于修改函数调用,而使用 WriteProcessMemory 用于注入所需的代码或 DLL。
项目上我们将其用于 hook 播放器声音,利用 UDP 将数据传回给我们的软件用于播放和传输
主要用到 DetourCreateProcessWithDllEx
功能:Create a new process and load a DLL into it. Chooses the appropriate 32-bit or 64-bit DLL based on the target process.
它可以根据目标进程自动加载 32-bit DLL 或者 64-bit DLL
方法:
To support both 32-bit and 64-bit applications on a single system, you must create two DLLs. One DLL must contain 32-bit code, the other DLL must contain 64-bit code. The DLLs must reside in the same directory and must have identical names except that the name of the 32-bit DLL should end with "32" and the name of the 64-bit DLL should end with "64". For example, matching DLLs would be named foo32.dll and foo64.dll.
You should use the DetourCreateProcessWithDllEx or DetourCreateProcessWithDlls API to start a process with your DLL. Furthermore, your DLLs must:
Export the DetourFinishHelperProcess API as export ordinal 1.
Call the DetourIsHelperProcess API in your DllMain function. Immediately return TRUE if DetourIsHelperProcess return TRUE.
Call the DetourCreateProcessWithDllEx or DetourCreateProcessWithDlls API instead of DetourCreateProcessWithDll to create new target processes.
文档参考:https://github.com/microsoft/detours/wiki/OverviewHelpers
demo 参考:https://github.com/microsoft/Detours/blob/main/samples/withdll/withdll.cpp
Detours 的使用的更多相关文章
- 使用detours实现劫持
第一步:下载detours3.0,安装detours 第二步:构建库文件,nmake编译 第三步:包含库文件和头文件 #include "detours.h" //载入头文件 #p ...
- Microsoft Detours 2.1简介
http://blog.163.com/qcb_163/blog/static/9545466420117851038971/ Microsoft Detours 2.1简介 2011-08-0817 ...
- Detours简介 (拦截x86机器上的任意的win32 API函数)
Detours 当然是用detours,微软明显高腾讯一筹,同上,至今没失败过.写这种HOOK一定要再写个测试程序,不要直接HOOK你的目的程序,例如QQ,因为这样不方面更灵活的测试.说明一下:Det ...
- 运用Detours库hook API(原理是改写函数的头5个字节)
一.Detours库的来历及下载: Detours库类似于WTL的来历,是由Galen Hunt and Doug Brubacher自己开发出来,于99年7月发表在一篇名为<Detours: ...
- Detours信息泄漏漏洞
v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VM ...
- Detours修改段属性漏洞
v:* { } o:* { } w:* { } .shape { }p.MsoNormal,li.MsoNormal,div.MsoNormal { margin: 0cm; margin-botto ...
- Detours HOOK 库 过滤LoadLibraryExW
Detours HOOK 库 Hook 过滤LoadLibraryExW 一丶简介 1.1 Detours库简介 Detours是微软提供的HOOK库.为我们Hook提供了方便.再也不用手撸 HOOK ...
- detours express版本的使用
原文最早发表于百度空间2012-03-21 一.编译lib 1)拷贝它的src文件夹和system.mak文件到VS的VCVARS32.BAT所在的目录下 2)在命令提示符中运行VCVARS32.BA ...
- 丢弃昂贵的Detours Professional 3.0,使用免费强大的EasyHook
我们要先看看微软官方的著名HOOK库: Detours Professional 3.0 售价:US$9,999.95 功能列表: Detours 3.0 includes the following ...
- Detours改动段属性漏洞
v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VM ...
随机推荐
- PG数据库的离线rpm包下载
PG数据库的离线rpm包下载 背景 周末时间研究数据库的版本. 发现PostgreSQL数据库的版本号已经变成了一年一个大版本. 兼容起来其实成本很高. 想着能够在能够上网的机器上面弄好多套数据库. ...
- Python学习之十五_不同类型数据库表内容比较
Python学习只十五_不同类型数据库表内容比较 前言 最近学习力总结了很多Python相关的内容 本次想继续学习一下不同数据库之间的数据比较. 这样理论上可以极大的缩减不同数据库测试成本. 感谢Py ...
- [转帖]如何监控Redis性能指标(译)
Redis给人的印象是简单.很快,但是不代表它不需要关注它的性能指标,此文简单地介绍了一部分Redis性能指标.翻译过程中加入了自己延伸的一些疑问信息,仍然还有一些东西没有完全弄明白.原文中Metri ...
- [转帖]Oracle数据库下PreparedStatementCache内存问题解决方案
https://github.com/alibaba/druid/wiki/Oracle%E6%95%B0%E6%8D%AE%E5%BA%93%E4%B8%8BPreparedStatementCac ...
- 银河麒麟在线升级新版本docker
银河麒麟在线升级新版本docker 卸载 学习来自: https://cloud.tencent.com/developer/article/1491742 yum remove docker \ d ...
- 【springboot整合druid】java.sql.SQLException: url not set
问题描述 未使用自动装配的机制,实现springboot整合druid时(就是使用druid的jar包,而不是druid-spring-boot-starter)报错 <dependency&g ...
- 【Spring】Bean装配类注解
默认注入类型 多个同类型Bean 注入失败 依赖 使用目标(@Target) @AutoWired 通过type 默认首先安装属性名称进行注入 结合@Qualifier注解(value属性)设置注入的 ...
- win10安装wget,从此可以更快的下载文件 and windows10 下 zip命令行参数详解
1.win10安装wget 1.1安装下载 GNU Wget 1.21.3 for Windows 依次如下: 2.将下载好的wget.exe放到 C:/windows/system32文件夹下 也可 ...
- 推荐系统[四]:精排-详解排序算法LTR (Learning to Rank)_ poitwise, pairwise, listwise相关评价指标,超详细知识指南。
0.前言召回排序流程策略算法简介 推荐可分为以下四个流程,分别是召回.粗排.精排以及重排: 召回是源头,在某种意义上决定着整个推荐的天花板: 粗排是初筛,一般不会上复杂模型: 精排是整个推荐环节的重中 ...
- 搭建私有仓库Registry(Docker Hub)
搭建私有仓库Registry(Docker Hub) 安装Docker 拉取仓库镜像:# docker pull registry 生成认证certificate mkdir ~/certs open ...