summaryrefslogtreecommitdiff
path: root/python/examples/arch_hook.py
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2022-01-27 22:43:28 -0500
committerKyleMiles <krm504@nyu.edu>2022-01-28 00:24:06 -0500
commit6812c973c9fa9b4ad642ab81856c05f87bd6fcc4 (patch)
treedace4156d03148bcaf02df138ab4e0d93e61bc6f /python/examples/arch_hook.py
parent519c9db22367f2659d1a54599fab47e6313be06e (diff)
Format All Files
Diffstat (limited to 'python/examples/arch_hook.py')
-rw-r--r--python/examples/arch_hook.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/python/examples/arch_hook.py b/python/examples/arch_hook.py
index 452bd2b6..a6e280cc 100644
--- a/python/examples/arch_hook.py
+++ b/python/examples/arch_hook.py
@@ -1,16 +1,17 @@
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)
+ 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'
- # 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
- return result, length
# Install the hook by constructing it with the desired architecture to hook, then registering it
X86ReturnHook(Architecture['x86']).register()
-