Merge pull request #55 from tylerni7/master

Fixed bug with argument printing
This commit is contained in:
George Hotz 2014-11-28 16:37:21 -08:00
commit c45db2cb58

View File

@ -300,15 +300,6 @@ def get_last_instr(dmap,clnum):
return None
return ret
# recall, the calling convention types from static2/model
'''
X86_CDECL stack
X86_FASTCALL ecx, edx, stack
X86_BFASTCALL eax, edx, ecx, stack
X64_WIN rcx, rdx, r8, r9, stack
X64_SYSV rdi, rsi, rdx, rcx, r8, r9, stack
ARM_STD r0, r1, r2, r3, stack
'''
def guess_calling_conv(program,readregs,readstack):
if not (readregs or readstack):
return ('UNKNOWN',0) #we can't guess the ABI with 0 information
@ -408,10 +399,13 @@ def display_call_args(instr,trace,clnum):
for i in xrange(min(nargs,len(args))):
ret += [ghex(regs[program.tregs[0].index(args[i])])]
if i+1 < nargs:
if len(args) > 0:
i += 1
if i < nargs:
stack_reg = ["ESP","RSP","SP"][["i386","x86-64","arm"].index(program.static['arch'])]
esp = regs[program.tregs[0].index(stack_reg)]
for j in xrange(i+1,nargs):
for j in xrange(i,nargs):
ret += [ghex(struct.unpack("<Q" if program.tregs[1] == 8 else "<I", \
trace.fetch_raw_memory(clnum, esp+program.tregs[1], program.tregs[1]))[0])]
esp += program.tregs[1]