Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1697757
  • 博文数量: 177
  • 博客积分: 9416
  • 博客等级: 中将
  • 技术积分: 2513
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-06 16:08
文章分类

全部博文(177)

文章存档

2013年(4)

2012年(13)

2011年(9)

2010年(71)

2009年(12)

2008年(11)

2007年(32)

2006年(25)

分类: 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. }
阅读(1084) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~