Skip to content

Commit

Permalink
refactor: improve implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzYeho authored Aug 18, 2024
1 parent cfdceb6 commit 7a58008
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion fa/commands/verify_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_parser():


def run(segments, args, addresses, interpreter=None, **kwargs):
hex_str = binascii.hexlify(args.hex_str)
hex_str = binascii.hexlify(args.hex_str.encode()).decode()
hex_str += '00' if args.null_terminated else ''

setattr(args, 'hex_str', hex_str)
Expand Down
5 changes: 3 additions & 2 deletions fa/fa_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import idc
import idaapi
import ida_auto
import ida_bytes
import ida_enum
import ida_struct

Expand Down Expand Up @@ -40,10 +41,10 @@ def add_value(self, name, value):
def update_idb(self):
id = ida_enum.get_enum(self._name)
if idc.BADADDR == id:
id = ida_enum.add_enum(idc.BADADDR, self._name, idaapi.decflag())
id = ida_enum.add_enum(idc.BADADDR, self._name, ida_bytes.dec_flag())

keys = self._values.keys()
keys.sort()
sorted(keys)

for k in keys:
ida_enum.add_enum_member(id, self._values[k], k)
Expand Down
7 changes: 4 additions & 3 deletions fa/fainterp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import shlex
import sys
import os
import re

import hjson

Expand Down Expand Up @@ -397,10 +398,10 @@ def _get_labeled_instructions(self, instructions):
labels[args.name] = pc
continue

for k, v in alias_items:
for alias, replacement in alias_items:
# handle aliases
if line.startswith(k):
line = line.replace(k, v)
pattern = r'^\b' + re.escape(alias) + r'\b'
line = re.sub(pattern, replacement, line)

processed_instructions.append(line)
pc += 1
Expand Down

0 comments on commit 7a58008

Please sign in to comment.