diff options
author | Evgeny Zinoviev <me@ch1p.com> | 2020-02-05 20:52:04 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.com> | 2020-02-05 20:52:04 +0300 |
commit | 60a417daffeb65219ebfb3940e2416258069ec9b (patch) | |
tree | 1026fc56d5b42e9bd730da5e0fb3f343e9d81f73 /apple-efi-dump-verbs.py |
first commit
Diffstat (limited to 'apple-efi-dump-verbs.py')
-rwxr-xr-x | apple-efi-dump-verbs.py | 36 |
1 files changed, 36 insertions, 0 deletions
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) |