Pav*_*ath 6 python typecast-operator
我有一个类似的地址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)
Run Code Online (Sandbox Code Playgroud)
有了那个艺术地址:)
>>> cast(0x6041f0, c_int_p)
<__main__.LP_c_int object at 0x7f44d06ce050>
>>> cast(0x6041f0, c_int_p).contents
Segmentation fault
Run Code Online (Sandbox Code Playgroud)
请参阅:ctypes供参考
| 归档时间: |
|
| 查看次数: |
1016 次 |
| 最近记录: |