Skip to content

Commit

Permalink
add strings ref table
Browse files Browse the repository at this point in the history
  • Loading branch information
clearbluejar committed Jan 4, 2024
1 parent e24ef3f commit e08dea2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ghidriff/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,25 @@ def gen_table_from_dict(self, headers: list, items: dict):

return table

def gen_strings_ref_table(self, str_data) -> str:

table_list = []
table_list.extend(['String', 'Ref Count', 'Ref Func'])
column_len = len(table_list)

count = 1
for item in str_data:

name = item['name']
ref_count = item['refcount']
calling = ','.join(item['calling'])
table_list.extend([name,ref_count,calling])
count += 1

diff_table = Table().create_table(columns=column_len, rows=count, text=table_list, text_align='center')

return diff_table

def gen_strings_diff(self, deleted_strings: dict, added_strings: dict):

added = [f'{item["name"]}\n' for item in added_strings]
Expand Down Expand Up @@ -644,6 +663,12 @@ def gen_diff_md(

md.new_header(3, 'Strings Diff', add_table_of_contents='n')
md.new_paragraph(self.gen_strings_diff(pdiff['strings']['deleted'], pdiff['strings']['added']))
md.new_header(3, 'String References', add_table_of_contents='n')
md.new_header(4, 'Old', add_table_of_contents='n')
md.new_paragraph(self.gen_strings_ref_table(pdiff['strings']['deleted']))
md.new_header(4, 'New', add_table_of_contents='n')
md.new_paragraph(self.gen_strings_ref_table(pdiff['strings']['added']))

else:
md.new_paragraph('*No string differences found*\n')

Expand Down

0 comments on commit e08dea2

Please sign in to comment.