#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#include "detours.h"
#pragma comment(lib,"detours.lib")
//包含库文件
int (*poldsystem)(
const char * _Command) =
system;
int newsystem(
const char *
_Command)
{
printf("%s", _Command);
}
void hook()
{
DetourRestoreAfterWith();//恢复之前状态,避免反复拦截
DetourTransactionBegin();
//开始劫持
DetourUpdateThread(GetCurrentThread());
//刷新当前的线程
DetourAttach((
void **)&poldsystem, newsystem);
//劫持
DetourTransactionCommit();
//立即生效
}
void main()
{
system("notepad");
hook();
system("notepad");
system("pause");
}
转载于:https://www.cnblogs.com/xiaochi/p/5094893.html
相关资源:android XPosed Hook登陆劫持源代码