江西响应式网站制作,网站成功案例,wordpress焦点图插件,沧州制作网站在上一节 c语言-----劫持原理01 已经叙述了劫持原理#xff0c;下边正式进入劫持实战1. 需要实现的功能在c语言中system(notepad) 可以打开一个记事本system(mspaint) 可以打开画图工具所以这次我们需要把 可以打开一个记事本 这个功能更改为 在控制…在上一节 c语言-----劫持原理01 已经叙述了劫持原理下边正式进入劫持实战1. 需要实现的功能在c语言中system(notepad) 可以打开一个记事本system(mspaint) 可以打开画图工具所以这次我们需要把 可以打开一个记事本 这个功能更改为 在控制台打印 notepad可以打开画图工具 这个功能更改为 在控制台打印 mspaint 即实现监控的日志功能2. 需要的工具vs2017Detours3. 劫持原理实现(1) 查看system()函数定义_DCRTIMP int __cdecl system(_In_opt_z_ char const* _Command);去掉一些不需要的符号int system( char const* _Command );(2) 获取原system()的地址int (*plodsystem)(char const* _Command) system;(3) 劫持后system()函数int newsystem(char const* _Command){printf(你执行的是%s, _Command);}(4) 劫持函数void hook(){DetourRestoreAfterWith(); //恢复之前的状态DetourTransactionBegin(); //开始劫持DetourUpdateThread(GetCurrentThread());//更新当前线程DetourAttach((void **)plodsystem, newsystem);//劫持DetourTransactionCommit(); //提交}(5) 修改vs配置 Debug - Release(6) 完整源代码#include#include#include#include detours.h#pragma comment(lib,detours.lib)int (*plodsystem)(char const* _Command) system;int newsystem(char const* _Command){printf(你执行的是%s, _Command);}void hook(){DetourRestoreAfterWith();DetourTransactionBegin();DetourUpdateThread(GetCurrentThread());DetourAttach((void **)plodsystem, newsystem);DetourTransactionCommit();}int main(){system(notepad);hook();system(notepad);return 0;}3. 解释说明system()函数是一个int类型的函数 int system( char const*_Command );所以需要一个一级函数指针plodsystem获取plodsystem的地址 plodsystem需要一个二级指针