IDA API 中的 ea_t 数据类型

逆向工程 艾达 idapro插件
2021-07-09 11:37:34

在IDAPython中,ea_t数据类型是什么?它在set_debug_name()函数中的使用如下:

bool set_debug_name(ea, name)

如果我有一个 64 位地址,它可以用ea_t数据类型表示吗?

例如,在这个 Python 脚本中:

line = "ffffffff81000000 T startup_64"
addr = int(line[:16],16)
name = line[19:]
idaapi.set_debug_name(addr,name)

我在执行 IDA Python 脚本时收到此错误:

TypeError: Expected an ea_t type

来自 IDA Pro:

Python> from idaapi import *
Python> line="ffffffff81000000 T startup_64"
Python> addr=int(line[:16],16)
Python> name=line[19:]
Python> print "addr: %x" %(addr)
addr: ffffffff81000000
Python> print name
startup_64
Python> set_debug_name(addr,name)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "X\IDA Pro\IDA61\python\idaapi.py", line 23612, in set_debug_name
    return _idaapi.set_debug_name(*args)
TypeError: Expected an ea_t type

idaapi.py32 位和 64 位 IDA Pro 版本文件是否不同?

我使用的是 32 位版本的 IDAPro。

1个回答

来自 pro.h:

#ifdef __EA64__
  typedef uint64 ea_t;      // effective address

是的,在 python 中也可以表示 64 位地址

32 位和 64 位文件相同(它们只有 1 个文件)

以下非常基本的脚本在使用 64 位 IDA 的 notepad.exe 上对我来说很好用;

Python>from idaapi import *
Python>ea = 0x0000000100003590L
Python>hex(get_byte(ea))
0x48

-编辑-

更新以显示您的脚本在 32 位 IDA 中工作:

Python>print sys.version
2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]
Python>line="ffffffff81000000 T startup_64"
Python>addr=int(line[:16],16)
Python>type(addr)
<type 'long'>
Python>set_debug_name(addr,"bla")
True
Python>name=line[19:]
Python>set_debug_name(addr,name)
True

您是否尝试使用 Google 代码中的“较新”版本更新您的 idapython?http://code.google.com/p/idapython/