CS:APP
renzhenmac
全部博文(24)
2009年(24)
迷惑的风
wzzushx
HughNian
gaopengt
fox1955
Tjie_S
aku1
enenshiw
hanzhenl
分类: C/C++
2009-08-07 18:04:48
// #include using namespace std; int thefunction() // 返回本函数自己的地址, 用caller把它写入上一个桢的返回地址 { // cout << "deadbeef" << endl; // 随便干点啥吧 return (int)thefunction; } void caller() { int a[8]; int *ptr; ptr = &a[7]; if (*ptr == 0) // 为了跳过像 (subl $16 %esp) 这类因编译器优化而向桢中加的空字节 ptr++; ptr += 1; int x = thefunction(); // 写入上一桢返回地址 *ptr = x; }
上一篇:程序的对齐
下一篇:初学gdb
登录 注册