函数的地址是否在每次运行时更改 [英] Does the address of a function change per runtime

查看:145
本文介绍了函数的地址是否在每次运行时更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用c ++编写东西,我想从文件中读取文本,该文件指示我在程序中声明的字符串和函数之间的相关性.例如,该文件可能显示为:

I'm writing something in c++ where I want to read text from a file that indicates correlations between Strings and Functions I have declared in my program. For example the file could read:

sin:sin
PI:getPi
+:add

我希望代码采用此方法,并创建一个哈希表或String和Function Pointer数据结构的向量.不幸的是,我意识到代码将无法在运行时找到函数的名称,因此我希望能够将这些函数的地址放入文件中.但是,如果每次程序运行或编译时函数的地址都不同,则该系统将无法正常工作.对这些问题中的任何一个问题的启发或替代解决方案都将是很好的.

I wanted the code to take this and create a hash table or vector of String and Function Pointer data structures. Unfortunately, I realize that code would not be able to find the name of functions at run-time, so I want to be able to put the addresses of these functions in the file. But this system would, of course, not work if the addresses of the functions were different every time the program ran or compiled. Enlightenment, or alternative solution to any of these problems would be great.

推荐答案

也许吗?

您的系统是否使用ASLR?

Is your system using ASLR?

地址空间布局随机化,一种现代系统用来防止利用漏洞执行私有或特权功能来执行ROP攻击的技术.

Adress Space Layout Randomization, its a technique used by modern systems to prevent exploits from executing private or privledged function from executing ROP attacks.

基本上,它使函数在内存中的位置随机化.如果您知道基本映像的位置,则这是可以克服的,因为所有内容仍是相对的.您会经常看到诸如0xDEADBEEF + 13之类的符号.

Basically it randomizes the location of functions in memory. This is defeatable if you know the location of the base image, because everything is still relative. You'll often see notation like 0xDEADBEEF+13.

有关更多信息,请参见 ASLR .

See ASLR for more info.

这篇关于函数的地址是否在每次运行时更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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