堆栈函数返回地址的修改 堆栈溢出

这里的代码只是将返回地址改为跳过对x的赋值,如果想进一步的修改,可以将你想要跳转的函数的地址赋给这个堆栈单元

//下面是版本信息。

//C:/>gcc -v
//Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
//Configured with: /gcc/gcc-3.4.4/gcc-3.4.4-1/configure --verbose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libex
//ecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,java,objc --enable-nls --without-include
//d-gettext --enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter --di
//sable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchroniza
//tion --enable-libstdcxx-debug : (reconfigured)
//Thread model: posix
//gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
//
//C:/>gdb -v
//GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special)
//Copyright 2004 Free Software Foundation, Inc.
//GDB is free software, covered by the GNU General Public License, and you are
//welcome to change it and/or distribute copies of it under certain conditions.
//Type "show copying" to see the conditions.
//There is absolutely no warranty for GDB.  Type "show warranty" for details.
//This GDB was configured as "i686-pc-cygwin".
//
//C:/>uname
//CYGWIN_NT-5.1
//
//C:/>uname -a
//CYGWIN_NT-5.1 徐盎 1.5.18(0.132/4/2) 2005-07-02 20:30 i686 unknown unknown Cygwin

void function(void)
{
 char buffer[5];
 int* ret;
 printf("%08x/n",buffer);
 ret=buffer+28;//指向function函数的返回地址
 (*ret)+=7;//跳过指令x=1;
}

void main()
{
 int x;
 x=0;
 function();
 x=1;
 printf("%08x/n",&x);
 printf("%d/n",x);
 return;
}
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值