Painter can now be selected when using the --painter
argument
This commit is contained in:
parent
49ff6506e6
commit
43584807b1
21
main.py
21
main.py
|
@ -10,10 +10,16 @@ from TikzPainter import TikzPainter
|
|||
from AsciiPainter import AsciiPainter
|
||||
import Junk
|
||||
|
||||
PAINTER_ID_TO_CLASS = {
|
||||
'ascii': AsciiPainter,
|
||||
'tikz': TikzPainter
|
||||
}
|
||||
|
||||
def parse_args ():
|
||||
parser = argparse.ArgumentParser(description="For fun x86-64 emulator and stack visualizer.")
|
||||
parser.add_argument('-i', '--input-file', default='-', help = '.S file to use as input', dest = 'input-file')
|
||||
parser.add_argument('-o', '--output-file', default='-', help = '.S file to use as output', dest = 'output-file')
|
||||
parser.add_argument('-i', '--input-file', default='-', help = 'File to use as input', dest = 'input-file')
|
||||
parser.add_argument('-o', '--output-file', default='-', help = 'File to use as output', dest = 'output-file')
|
||||
parser.add_argument('-p', '--painter', default='ascii', help = 'Drawer to use', dest = 'painter-name', choices=PAINTER_ID_TO_CLASS.keys())
|
||||
for register in REGISTERS:
|
||||
parser.add_argument('--'+register[1:], nargs = 1, type = int, default = None, dest = register, help = 'the initial value of the register')
|
||||
args = vars(parser.parse_args())
|
||||
|
@ -46,13 +52,16 @@ def parse_args ():
|
|||
else:
|
||||
output_file = open(args['output-file'], 'w')
|
||||
|
||||
##
|
||||
|
||||
return (program, registers_init, output_file)
|
||||
# Determine painter class
|
||||
painter_class = PAINTER_ID_TO_CLASS[args['painter-name']]
|
||||
|
||||
## Return
|
||||
return (program, registers_init, output_file, painter_class)
|
||||
|
||||
def main ():
|
||||
|
||||
(program, registers_init, output_file) = parse_args()
|
||||
(program, registers_init, output_file, painter_class) = parse_args()
|
||||
|
||||
# Determine registers to display
|
||||
registers_to_draw = ["%rip","%rbp","%rsp", ""]
|
||||
|
@ -65,8 +74,6 @@ def main ():
|
|||
emu.setRegs(**registers_init)
|
||||
emu.setStack(Junk.Junk("junk..."), Junk.Junk("calling eip"))
|
||||
|
||||
painter_class = TikzPainter # AsciiPainter
|
||||
|
||||
painter = painter_class(registers_to_draw)
|
||||
|
||||
# Iteratively draw states.
|
||||
|
|
Loading…
Reference in New Issue
Block a user