【发布时间】:2012-10-28 08:53:51
【问题描述】:
我有一个为 IDA 编写的简单 python 脚本,但我不知道我做错了什么。
file = open("c:\\example.txt", "r")
for line in file:
if line == "":
pass
else:
addr = line.split(None,1)
if len(addr) < 2:
pass
else:
address = ''.join(addr[0])
if(idc.Jump(address)):
sea = ScreenEA()
else:
print "There is a problem with the destenation address"
counter = 0
for l in addr[1]:
PatchByte(sea+counter, ord(l))
counter += 1
file.close()
example.txt 文件中的拖线:
0x1001b3a4 Kernel32.DLL
0x1001b3c8 CreateToolhelp32Snapshot
我得到的错误信息是:
对我来说很明显错误是在if(idc.Jump(address)): 行,我试图用if(Jump(addr[0])): 调用它,但我得到了相同的错误消息。
我在官方文档中看到了Jump 函数,但似乎我将正确的参数传递给它。
可能是什么问题?
【问题讨论】:
-
你不要在肯定的结果上使用 pass - 这是浪费和不必要的,你否定条件。在这种情况下,if not line == "": 等价于 if line: - Python 中的非空 strib 等价于 True逻辑表达式(实际上更复杂,但现在就足够了)