summaryrefslogtreecommitdiff
path: root/python/examples/arch_hook.py
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2018-07-05 18:28:59 -0400
committerRyan Snyder <ryan@vector35.com>2018-07-10 18:11:10 -0400
commit975249d22e10360ed2c4c0bcea151c39d9446b0a (patch)
tree93c2abb7b184bd64565ae1f116728141bfa051c2 /python/examples/arch_hook.py
parentfd42578dce78f4c5a530177426e6a2ea11fc95ed (diff)
Rebased so commit history is correct now
Diffstat (limited to 'python/examples/arch_hook.py')
-rw-r--r--python/examples/arch_hook.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/python/examples/arch_hook.py b/python/examples/arch_hook.py
new file mode 100644
index 00000000..452bd2b6
--- /dev/null
+++ b/python/examples/arch_hook.py
@@ -0,0 +1,16 @@
+from binaryninja.architecture import Architecture, ArchitectureHook
+
+class X86ReturnHook(ArchitectureHook):
+ def get_instruction_text(self, data, addr):
+ # Call the original implementation's method by calling the superclass
+ result, length = super(X86ReturnHook, self).get_instruction_text(data, addr)
+
+ # Patch the name of the 'retn' instruction to 'ret'
+ if len(result) > 0 and result[0].text == 'retn':
+ result[0].text = 'ret'
+
+ return result, length
+
+# Install the hook by constructing it with the desired architecture to hook, then registering it
+X86ReturnHook(Architecture['x86']).register()
+