From b0807663210ba6780c5350fa25130e8bcf14e5a9 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Tue, 27 Jun 2023 15:59:44 -0700 Subject: [PATCH] generate progress SVGs --- .github/workflows/build.yml | 6 ++- tools/reccmp/isle.png | Bin 0 -> 5448 bytes tools/reccmp/lego1.png | Bin 0 -> 5615 bytes tools/reccmp/reccmp.py | 60 ++++++++++++++++++++++++++++- tools/reccmp/template.svg | 74 ++++++++++++++++++++++++++++++++++++ 5 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 tools/reccmp/isle.png create mode 100755 tools/reccmp/lego1.png create mode 100644 tools/reccmp/template.svg diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index afa88865..295d88f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,8 +61,8 @@ jobs: C:\msys64\usr\bin\wget.exe https://legoisland.org/download/LEGO1.DLL pip install capstone pip install colorama - python3 tools/reccmp/reccmp.py -H ISLEPROGRESS.HTML ISLE.EXE Release/ISLE.EXE Release/ISLE.PDB . - python3 tools/reccmp/reccmp.py -H LEGO1PROGRESS.HTML LEGO1.DLL Release/LEGO1.DLL Release/LEGO1.PDB . + python3 tools/reccmp/reccmp.py -S ISLEPROGRESS.SVG --svg-icon tools/reccmp/isle.png -H ISLEPROGRESS.HTML ISLE.EXE Release/ISLE.EXE Release/ISLE.PDB . + python3 tools/reccmp/reccmp.py -S LEGO1PROGRESS.SVG -T 1929 --svg-icon tools/reccmp/lego1.png -H LEGO1PROGRESS.HTML LEGO1.DLL Release/LEGO1.DLL Release/LEGO1.PDB . - name: Upload Artifact uses: actions/upload-artifact@master @@ -72,3 +72,5 @@ jobs: Release ISLEPROGRESS.HTML LEGO1PROGRESS.HTML + ISLEPROGRESS.SVG + LEGO1PROGRESS.SVG diff --git a/tools/reccmp/isle.png b/tools/reccmp/isle.png new file mode 100644 index 0000000000000000000000000000000000000000..cfa26a234f1eeb4d65808b0097e809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JrJUl%; zy}Z1hKY#A+?d{{^^Wwz|I2`Wl>+9#|=kMp;^z`(M zjEv08%vY~oWo2b$XJ@~D{rb(DH*ep*&B@8h&CSir%gfKtFDNJ|EG#T4Dk?56E-5J~ zEiEl8D=RNAuc)Y~tgNi6s(SbCU3GOe0)eQhsd@kYeQj-RU0q#$eSJeiLt|s(hYuf` znwpxMn_F61T3cJ&+S=ON+dDcsIy*bNy1Kf%yL)PH={5U>7J~1&dIXO8sH8njwJu@>iJ3Bi!H#a{&zp${dxVZS~)2F4S zrRC-2m6es%)z!7Nwe|J&jg5`X&CRW?t?ljYot>S}pFi*J?(XgF?eFh@`SRuK*RKZ$ z2Zx7;M@L7;$H(8keLFchIXyl7{{8!pA3x5{&d$%zFD@=FFE6j_oIBdc_`33uT(#A8 z0O|E98vsBvRFai}y3c%`m%;U?#h2D9cG!QhN|Pl-X92Qte^C~_)B&of-beVR;(AeA zu}j^;mj;kf{?0@U2X4KGBaq^ahU+M_COWZbuQ$+tYO=YN?-TzM#+WxTYXXC}@E0mn zl%8t-r288){^W=m73=uEi(%Bi3&ej=ODBC-AdPVi!LNbc9Q+HgH&~%(0sqnbozzUu z!%%*nZ-Z^NRR;Pukbi3O2XQ(X!u9rVH-nLWE)O^H*4+8gUF8KUYAhrBG=7HscPiq) zE+sC;F;Dcn``^B)5Y}I6?UyM38>){pfVn@R^l!gitK7auLh}aJ-wR0nNtQPT*Jl#n zc>4?C;~W4A25V6^0{(MDvDpqgm+#EB+I`kFd;bsN&)e^> jkufR7GXBgvx+RGW7`y5!@OdyV1J{p|oVsi&*v#)=@KL|* literal 0 HcmV?d00001 diff --git a/tools/reccmp/lego1.png b/tools/reccmp/lego1.png new file mode 100755 index 0000000000000000000000000000000000000000..f76a54da16876d4bbb51cbff06e8a9c93df60aa6 GIT binary patch literal 5615 zcmbtY1z42Z*8T>N?i3KEyHh%b?ii${8A2pPDZ!yrkS-~e4iRLKlm1pu$9 zOg$(>Z-ZPCF?S%R77j~PbI~Qk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/tools/reccmp/reccmp.py +++ b/tools/reccmp/reccmp.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import argparse +import base64 from capstone import * import difflib import struct @@ -15,9 +16,12 @@ parser.add_argument('recompiled', metavar='recompiled-binary', help='The recompiled binary') parser.add_argument('pdb', metavar='recompiled-pdb', help='The PDB of the recompiled binary') parser.add_argument('decomp_dir', metavar='decomp-dir', help='The decompiled source tree') +parser.add_argument('--total', '-T', metavar='total-func-count', help='Total number of expected functions (improves total accuracy statistic)') parser.add_argument('--verbose', '-v', metavar='offset', help='Print assembly diff for specific function (original file\'s offset)') parser.add_argument('--html', '-H', metavar='output-file', help='Generate searchable HTML summary of status and diffs') parser.add_argument('--no-color', '-n', action='store_true', help='Do not color the output') +parser.add_argument('--svg', '-S', metavar='output-svg', help='Generate SVG graphic of progress') +parser.add_argument('--svg-icon', metavar='svg-icon', help='Icon to use in SVG (PNG)') args = parser.parse_args() @@ -50,6 +54,8 @@ if not os.path.isdir(source): parser.error('Source directory does not exist') +svg = args.svg + # Declare a class that can automatically convert virtual executable addresses # to file addresses class Bin: @@ -365,7 +371,8 @@ def parse_asm(file, addr, size): # If html, record the diffs to an HTML file if html: - htmlinsert.append('{address: "%s", name: "%s", matching: %s, diff: "%s"}' % (hex(addr), recinfo.name, str(ratio), '\\n'.join(udiff).replace('"', '\\"').replace('\n', '\\n'))) + escaped = '\\n'.join(udiff).replace('"', '\\"').replace('\n', '\\n').replace('<', '<').replace('>', '>') + htmlinsert.append('{address: "%s", name: "%s", matching: %s, diff: "%s"}' % (hex(addr), recinfo.name, str(ratio), escape)) except UnicodeDecodeError: break @@ -389,6 +396,49 @@ def gen_html(html, data): htmlfile.write(templatedata) htmlfile.close() +def gen_svg(svg, name, icon, implemented_funcs, total_funcs, raw_accuracy): + templatefile = open(get_file_in_script_dir('template.svg'), 'r') + if not templatefile: + print('Failed to find SVG template file, can\'t generate SVG summary') + return + + templatedata = templatefile.read() + templatefile.close() + + # Replace icon + if args.svg_icon: + iconfile = open(args.svg_icon, 'rb') + templatedata = templatedata.replace('{icon}', base64.b64encode(iconfile.read()).decode('utf-8'), 1) + iconfile.close() + + # Replace name + templatedata = templatedata.replace('{name}', name, 1) + + # Replace implemented statistic + templatedata = templatedata.replace('{implemented}', '%.2f%% (%i/%i)' % (implemented_funcs / total_funcs * 100, implemented_funcs, total_funcs), 1) + + # Replace accuracy statistic + templatedata = templatedata.replace('{accuracy}', '%.2f%%' % (raw_accuracy / implemented_funcs * 100), 1) + + # Generate progress bar width + total_statistic = raw_accuracy / total_funcs + percenttemplate = '{progbar' + percentstart = templatedata.index(percenttemplate) + percentend = templatedata.index('}', percentstart) + progwidth = float(templatedata[percentstart + len(percenttemplate) + 1:percentend]) * total_statistic + templatedata = templatedata[0:percentstart] + str(progwidth) + templatedata[percentend + 1:] + + # Replace percentage statistic + templatedata = templatedata.replace('{percent}', '%.2f%%' % (total_statistic * 100), 1) + + svgfile = open(svg, 'w') + if not svgfile: + print('Failed to write to SVG file %s' % svg) + return + + svgfile.write(templatedata) + svgfile.close() + if html: gen_html(html, htmlinsert) @@ -396,5 +446,13 @@ def gen_html(html, data): if not found_verbose_target: print('Failed to find the function with address %s' % hex(verbose)) else: + implemented_funcs = function_count + + if args.total: + function_count = int(args.total) + if function_count > 0: print('\nTotal accuracy %.2f%% across %i functions' % (total_accuracy / function_count * 100, function_count)) + + if svg: + gen_svg(svg, os.path.basename(original), args.svg_icon, implemented_funcs, function_count, total_accuracy) diff --git a/tools/reccmp/template.svg b/tools/reccmp/template.svg new file mode 100644 index 00000000..cb37b94c --- /dev/null +++ b/tools/reccmp/template.svg @@ -0,0 +1,74 @@ + + + +{name}{percent}Implemented: {implemented}Accuracy: {accuracy}