| 68 | |
| 69 | @exceptions_handler(Exception) |
| 70 | def print_header(binary): |
| 71 | format_str = "{:<33} {:<30}" |
| 72 | format_hex = "{:<33} 0x{:<28x}" |
| 73 | format_dec = "{:<33} {:<30d}" |
| 74 | |
| 75 | print("== Header ==") |
| 76 | header = binary.header |
| 77 | flags_str = " - ".join([str(s).split(".")[-1] for s in header.flags_list]) |
| 78 | |
| 79 | print(format_str.format("Magic:", str(header.magic).split(".")[-1])) |
| 80 | print(format_str.format("CPU Type:", str(header.cpu_type).split(".")[-1])) |
| 81 | print(format_hex.format("CPU sub-type:", header.cpu_subtype)) |
| 82 | print(format_str.format("File Type:", str(header.file_type).split(".")[-1])) |
| 83 | print(format_str.format("Flags:", flags_str)) |
| 84 | print(format_dec.format("Number of commands:", header.nb_cmds)) |
| 85 | print(format_hex.format("Size of commands:", header.sizeof_cmds)) |
| 86 | print(format_hex.format("Reserved:", header.reserved)) |
| 87 | |
| 88 | @exceptions_handler(Exception) |
| 89 | def print_commands(binary): |