Chinaunix首页 | 论坛 | 博客
  • 博客访问: 146856
  • 博文数量: 31
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 835
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-22 04:00
文章分类

全部博文(31)

文章存档

2011年(9)

2010年(8)

2009年(9)

2008年(5)

我的朋友
最近访客

分类: C/C++

2011-06-28 10:14:47

  1. /**
  2.  * Only available on 32-bit i686 machine
  3.  */

  4. #include <iostream>
  5. using namespace::std;
  6. int injection(int i)
  7. {
  8.   cout << "injection" << " " << i << endl;
  9.   return 0;
  10. }
  11. int main()
  12. {
  13.   int a;
  14.   // Save the proper return address of main().
  15.   unsigned int addr = *(&a + 2);
  16.   // Set return address of main to be first instruction of injection().
  17.   *(&a + 2) = (unsigned int)injection;
  18.   // Set return address of injection() to be that of main() so that
  19.   // main() will return properly.
  20.   *(&a + 3) = addr;
  21.   // Set the argument of injection().
  22.   *(&a + 4) = 99;
  23.   return 0;
  24. }
阅读(299) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~