我正在尝试使用python绑定idaemu为一个独角兽引擎模拟一个函数调用。
int __cdecl sub_46F8B0(int a1, char *a2)
我想调用的函数是sprintf (a2, template, ... )
上的包装器。
在IDA 6.6中,我称之为:
from idaemu import *
a = Emu ( UC_ARCH_X86 , UC_MODE_32 )
print a.eFunc(0x0046F8B0, None, [0x4105C0, ?])
如何传递第二个参数?
最合理的是使用ctypes.create_string_buffer(%)
(因为返回类型为ctypes.c_char_Array_%
)。但是需要一个整数参数。
Python>s2=ctypes.create_string_buffer(50)
Python>print a.eFunc(0x454AB0, None, [0x4105C0, s2])
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:/Program Files (x86)/IDA 6.6/plugins\idaemu.py", line 371, in eFunc
self._emulate(func.startEA, retAddr, args)
File "C:/Program Files (x86)/IDA 6.6/plugins\idaemu.py", line 285, in _emulate
self._initStackAndArgs(uc, stopAddr, args)
File "C:/Program Files (x86)/IDA 6.6/plugins\idaemu.py", line 177, in _initStackAndArgs
uc.mem_write(sp, pack(self.pack_fmt, args[i]))
struct.error: cannot convert argument to integer
我对python和ctypes并不擅长。如何在这种情况下?