[英] stack

查看:80
本文介绍了堆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好..


int fun()

{

/ *任何东西* /

}

int main(无效)

{

fun();

}

这个程序中的
,当控件转移到函数fun()时..

将返回地址推送到堆栈中..

是否可以访问此值.. ??

hello everyone..

int fun()
{
/* anything */
}
int main(void)
{
fun();
}

in this program, when the control is transferred to function fun()..
the return address is pushed to the stack..
Is it possible to access this value..??

推荐答案

jt写道:
jt wrote:

大家好..


int fun()

{

/ *任何东西* /

}

int main(无效)

{

fun();

}


在这个程序中,当控件转移到函数fun()..

返回地址被推送到堆栈..

是否可以访问此值.. ??
hello everyone..

int fun()
{
/* anything */
}
int main(void)
{
fun();
}

in this program, when the control is transferred to function fun()..
the return address is pushed to the stack..
Is it possible to access this value..??



当然是。大多数病毒都有。

但是我们不会告诉你如何。

-

jacob navia

jacob at jacob point remcomp point fr

logiciels / informatique
http://www.cs.virginia.edu/~lcc-win32


On Sun,2008年8月3日09:32:16 - 0700,jt写道:
On Sun, 03 Aug 2008 09:32:16 -0700, jt wrote:

大家好..


int fun()

{

/ *任何东西* /

}

int main(无效)

{

fun();

}

这个程序中的
,当控件转移到函数fun()时..

返回地址被推送到堆栈..
hello everyone..

int fun()
{
/* anything */
}
int main(void)
{
fun();
}

in this program, when the control is transferred to function fun().. the
return address is pushed to the stack..



(我会假装你只是写了保存了返回地址。)


不在我的系统上,如果它在你的系统上,请考虑使用更好的

编译器。编译器可能会看到乐趣没有

副作用并消除调用或内联乐趣。前者可能

如果你开玩笑实际上不会发生什么事情,但后者相当可能会b / b
。如果是,则没有返回地址,因此没有

位置保存返回地址。

(I''ll pretend you just wrote "the return address is saved" instead.)

Not on my system, and if it is on yours, consider getting a better
compiler. It''s possible for the compiler to either see that fun has no
side effects and eliminate the call, or to inline fun. The former probably
won''t happen if you make fun actually do something, but the latter quite
possibly will. If it is, there is no return address, so there is no
location holding the return address.


是否可以访问此地址值..??
Is it possible to access this value..??



如果值完全存在,则没有标准方法可以访问它。一些

实现有这个选项;检查文档。但是如果你发现它,你甚至可以用它来理解它吗?

If the value exists at all, there is no standard way to access it. Some
implementations have options for this; check the documentation. But even
if you find it, what could you sensibly do with it?


jt写道:
jt wrote:

大家好..


int fun()

{

/ *任何东西* / < br $>
}

int main(无效)

{

fun();

这个程序中的
,当控件转移到函数fun()时..

返回地址被推送到堆栈..
hello everyone..

int fun()
{
/* anything */
}
int main(void)
{
fun();
}

in this program, when the control is transferred to function fun()..
the return address is pushed to the stack..



这不一定是这样。编译器可以内联有趣,消除它

,存储返回地址。 IOW,

这是你实现的一个细节,它看起来可能会有不同的变化。

This needn''t be so. The compiler could inline fun, eliminate it
altogether, store the "return address" on a different stack etc. IOW,
this is a detail of your implementation and it can vary in seemingly
unpredictable ways.


是否可以访问此值.. ??
Is it possible to access this value..??



不是来自便携式C代码。您需要详细了解实现的调用

约定,并确保优化

内联对此函数无效。实际上,你需要学习实现的内部结构,并且需要学习系统中使用的汇编语言。


有些实现提供了方便的扩展用于此目的

(例如,gcc'的__builtin_return_address内在函数),在其他实现上你可能需要

必须使用内联汇编程序。

Not from portable C code. You''ll need to know in fair detail the calling
conventions for your implementation, and make sure that optimisations
like inlining are not in effect for this function. Practically
speaking, you''ll have to learn the internals of your implementation and
the assembly language that is used on your system.

Some implementations provide convenient extensions for this purpose
(example, gcc''s __builtin_return_address intrinsic), on others you may
have to resort inline assembler.


这篇关于堆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆