aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.com>2020-02-05 20:52:04 +0300
committerEvgeny Zinoviev <me@ch1p.com>2020-02-05 20:52:04 +0300
commit60a417daffeb65219ebfb3940e2416258069ec9b (patch)
tree1026fc56d5b42e9bd730da5e0fb3f343e9d81f73
first commit
-rw-r--r--README.md1
-rwxr-xr-xapple-efi-dump-verbs.py36
2 files changed, 37 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..387e0f8
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+# apple-efi-dump-verbs
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)