Skip to content

Commit

Permalink
Fixed argument reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosgprado committed Feb 8, 2022
1 parent 50e646c commit 67e0810
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions FIDL/decompiler_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# <carlos.garcia@fireeye.com>
# ===========================================================================

__version__ = '1.2'
__version__ = '1.3'

from idc import *
from idaapi import *
Expand Down Expand Up @@ -738,17 +738,16 @@ def get_function_vars(c=None, ea=0, only_args=False, only_locals=False):
# I need to re-order the list of arguments.
# No idea why, but IDA does not spit the arguments in order.
# It keeps however a list of how the indexes are messed up in ``c.cf.argidx``
ordered_vars = [None] * len(cf.lvars)

for i, v in enumerate(cf.lvars):
if v.is_arg_var:
# Need to fix order
idx = cf.argidx[i]
else:
# Local vars seem to be fine
idx = i
# Only arguments
arg_vars = [x for x in c.cf.lvars if x.is_arg_var and x.name]

# Lvars are in the correct order, args are messed up
ordered_vars = list(c.cf.lvars)

ordered_vars[idx] = v
# Second pass reordering "argument elements"
for i, j in enumerate(c.cf.argidx):
ordered_vars[i] = arg_vars[j]

if only_args:
return OrderedDict({idx: my_var_t(v) for idx, v in enumerate(ordered_vars)
Expand Down

0 comments on commit 67e0810

Please sign in to comment.