summaryrefslogtreecommitdiff
path: root/python/examples/arch_hook.py
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2018-04-04 14:11:55 -0400
committerPeter LaFosse <peter@vector35.com>2018-04-04 14:11:55 -0400
commitd990d5ebf56eb0f1a7d96e98577cb9ace9dac19d (patch)
tree752649d87db23f95a59384f5325b94b734e1c27b /python/examples/arch_hook.py
parent1eb3683b3a1ee0d263267b1e84957fadea7fadaa (diff)
parentfa716fe2da53a4f136380b1f60197bd197b2793a (diff)
Merging with dev
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()
+