Files
idapython-src/tools/split_hexrays_templates.py
T
2019-06-26 14:37:39 +02:00

31 lines
750 B
Python

from argparse import ArgumentParser
p = ArgumentParser()
p.add_argument("-i", "--input", required=True)
p.add_argument("--out-templates", required=True)
p.add_argument("--out-body", required=True)
args = p.parse_args()
templates = []
body = []
with open(args.input) as fin:
lines = fin.readlines()
in_template=False
for line in lines:
if not in_template:
if line.startswith("template <"):
in_template=True
else:
body.append(line)
if in_template:
templates.append(line)
if line.startswith("};"):
in_template = False
with open(args.out_templates, "wt") as fout:
fout.write("".join(templates))
with open(args.out_body, "wt") as fout:
fout.write("".join(body))