From 60a417daffeb65219ebfb3940e2416258069ec9b Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Wed, 5 Feb 2020 20:52:04 +0300 Subject: first commit --- apple-efi-dump-verbs.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 apple-efi-dump-verbs.py (limited to 'apple-efi-dump-verbs.py') diff --git a/apple-efi-dump-verbs.py b/apple-efi-dump-verbs.py new file mode 100755 index 0000000..c79b7c4 --- /dev/null +++ b/apple-efi-dump-verbs.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +import argparse +import sys +import os +import struct + +def main(): + parser = argparse.ArgumentParser(description="Dump verbs from Apple EFI resource file") + parser.add_argument("file", nargs=1, help="Path to file") + parser.add_argument("--decode", action="store_true") + + args = parser.parse_args() + + file = args.file[0] + if not os.path.isfile(file): + return "%s does not exists or is not a file" % (file) + + with open(args.file[0], "rb") as f: + f.seek(16) + size = struct.unpack("i", f.read(4))[0] + + for i in range(int(size / 8)): + val = struct.unpack("i", f.read(4))[0] + print("0x{0:08X}".format(val), end="") + if (args.decode): + node_id = (val >> 20) & 0xffff + verb_id = (val >> 8) & 0xffff + payload = val & 0xffff + print(" (0x{0:02x} 0x{1:04x} 0x{2:02x})".format(node_id, verb_id, payload), end="") + print() + +if __name__ == "__main__": + result = main() + if result: + print("error: %s" % result) + sys.exit(1) -- cgit v1.2.3