批量劫持
2015-08-15 16:50
288 查看
批量劫持
#include<stdio.h>#include<stdlib.h>
#include"detours.h"
#include<Windows.h>
#pragma comment(lib,"detours.lib")
static int num1(int a, int b)
{
return a + b;
}
static int num2(int a, int b)
{
return a - b;
}
static int num3(int a, int b)
{
return a*b;
}
static int num4(int a, int b)
{
return a / b;
}
int newnum1(int a, int b)
{
printf("\n%d+%d=%d",a,b,a+b);
return a + b;
}
int newnum2(int a, int b)
{
printf("\n%d-%d=%d", a, b, a -b);
return a -b;
}
int newnum3(int a, int b)
{
printf("\n%d*%d=%d", a, b, a *b);
return a * b;
}
int newnum4(int a, int b)
{
printf("\n%d/%d=%d", a, b, a/b);
return a / b;
}
static int(*pold[4])(int a, int b) = { num1, num2, num3, num4 };
int(*pnew[4])(int a, int b) = { newnum1, newnum2, newnum3, newnum4 };
void Hook()
{
DetourRestoreAfterWith();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread);
for (int i = 0; i < 4; i++)
{
DetourAttach((void**)&pold[i], &pnew[i]);
}
DetourTransactionCommit();
}
void UnHook()
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread);
for (int i = 0; i < 4; i++)
{
DetourDeAttach((void**)&pold[i], &pnew[i]);
}
DetourTransactionCommit();
}
int main()
{
for (int i = 0; i < 4; i++)
{
printf("\n%d",pold[i](10,2));
}
printf("\n%d", num1(10, 2));
printf("\n%d", num2(10, 2));
printf("\n%d", num3(10, 2));
printf("\n%d", num4(10, 2));
Hook();
printf("\n%d", num1(10,2));
printf("\n%d", num2(10, 2));
printf("\n%d", num3(10, 2));
printf("\n%d", num4(10, 2));
}
相关文章推荐
- 系统win7 mac
- ZUFE OJ 2288 God Wang I
- 周赛F题 POJ 1458(最长公共子序列)
- 相见欢
- IIS 7上部署PHP
- Apache 2 with Tomcat 6 How To Configure Tomcat to work with Apache
- Wormholes
- 一起学CC3200之HttpServer文件传输(中序)
- VS快捷键
- python3使用smtplib发电子邮件
- 搜索引擎深度抓取和广度抓取如何理解
- PHP中require和include路径问题总结
- Android基础入门教程——4.2.2 Service进阶
- 库依赖问题
- Java内存溢出和连接池死锁等各种混乱问题的解决
- hdu2814
- NYOJ 76 超级台阶
- 类模板使用和深入
- C++ bitset类的使用与简介
- ERP实施过程中的误区 你知道吗?