如何在python中将地址取消引用为整数?
发布时间:2020-12-20 13:50:25 所属栏目:Python 来源:网络整理
导读:参见英文答案 How to dereference a memory location from python ctypes?????????????????????????????????????1个 我有一个像0x6041f0的地址.我知道有一个整数坐在那里.在C中,我只需要完成*(int *)0x6041f0来获取该地址处的整数值. 如何在Python中实现相同
参见英文答案 >
How to dereference a memory location from python ctypes?????????????????????????????????????1个
我有一个像0x6041f0的地址.我知道有一个整数坐在那里.在C中,我只需要完成*(int *)0x6041f0来获取该地址处的整数值. 如何在Python中实现相同的功能? PS:我正在编写一个使用gdb模块的Python脚本.正在调试的实际程序是在C中.因此需要大量的低级操作. 解决方法
像这样的东西:
$python Python 2.7.9 (default,Mar 19 2015,22:32:11) [GCC 4.8.4] on linux2 Type "help","copyright","credits" or "license" for more information. >>> from ctypes import * >>> c_int_p = POINTER(c_int) >>> x = c_int(4) >>> cast(addressof(x),c_int_p).contents c_int(4) 随着那个artbitrary地址:) >>> cast(0x6041f0,c_int_p) <__main__.LP_c_int object at 0x7f44d06ce050> >>> cast(0x6041f0,c_int_p).contents Segmentation fault 见:ctypes供参考 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- python – Django REST框架:如何用空字符串替换null?
- Python实现返回数组中第i小元素的方法示例
- python-seaborn scatterplot datetime xaxis太宽
- python – 根据布尔向量选择numpy中的列
- day02 python基础
- 在python中的pandas中的DataFrame的dropna中的thresh
- python – 在文本浏览器中使用Django的https站点抛出CSRF验
- python – 将3d场景加载到Silverlight中
- 在Python中处理字符串之isdigit()方法的使用
- 浅谈django model的get和filter方法的区别(必看篇)
推荐文章
站长推荐
热点阅读