利用detours劫持自己的系统函数

来源:互联网 发布:如何修改淘宝评价 编辑:程序博客网 时间:2024/06/03 12:42

//劫持自己

#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
#include<string.h>
#include "detours.h"
#pragma comment(lib,"detours.lib")
static int(*poldsystem)(const char * _Command) = system;
int newsystem(const char * _Command)
{
//禁止tasklist
char *p = strstr(_Command, "tasklist");
if (p == NULL)
{
poldsystem(_Command);


}
else
{


printf("%stasklist禁止执行", _Command);
return 0;
}
}
void Hook()
{
DetourRestoreAfterWith();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread);
DetourAttach((void**)&poldsystem,newsystem);
DetourTransactionCommit();
}




void main()


{
system("calc");
Hook();
system("calc");
system("tasklist");
getchar();


}
0 0
原创粉丝点击