Skip to content

Instantly share code, notes, and snippets.

@HookedBehemoth
Created July 1, 2020 20:49
Show Gist options
  • Save HookedBehemoth/3c8710caff4ffb3a1fb0dbe0b409165c to your computer and use it in GitHub Desktop.
Save HookedBehemoth/3c8710caff4ffb3a1fb0dbe0b409165c to your computer and use it in GitHub Desktop.
import sys
import re
import nxo64
def main(pattern, filename):
f = nxo64.load_nxo(open(filename, 'rb'))
f.binfile.seek(0)
target_text = f.binfile.read(f.textsize)
rows = eval('[' + open(pattern).read() + ']')
with open(filename + '-sdk-syms', 'wb') as f:
for value, size, regex, name in rows:
positions = [m.start() for m in re.finditer(regex, target_text)]
if len(positions) == 1:
f.write('%s 0x%X\n' % (name, 0x7100000000 + positions[0]))
if __name__ == '__main__':
if len(sys.argv) < 2:
print 'usage: applypattern.py pattern.txt [nxo files...]'
print 'writes output to input filename + "-sdk-syms"'
for filename in sys.argv[2:]:
main(sys.argv[1], filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment