Created
February 14, 2022 10:19
-
-
Save xire-/b6dab392f682d19bb2bc655f345ce459 to your computer and use it in GitHub Desktop.
Minimal architecture plugin to reproduce bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from binaryninja import IntrinsicInfo | |
from binaryninja.types import Type | |
from binaryninja.log import log_info, log_error | |
from binaryninja.architecture import Architecture | |
from binaryninja.function import RegisterInfo, InstructionInfo, InstructionTextToken | |
from binaryninja.enums import InstructionTextTokenType, BranchType, LowLevelILFlagCondition | |
class TESTARCH(Architecture): | |
name = 'Test intrinsics' | |
address_size = 2 # bytes | |
default_int_size = 1 # bytes | |
instr_alignment = 2 | |
max_instr_length = 4 # bytes??? | |
regs = { | |
'R0': RegisterInfo('R0', size=2), | |
'R1': RegisterInfo('R1', size=2), | |
'R2': RegisterInfo('R2', size=2), | |
'R3': RegisterInfo('R3', size=2), | |
'R4': RegisterInfo('R4', size=2), | |
'R5': RegisterInfo('R5', size=2), | |
'R6': RegisterInfo('R6', size=2), | |
'R7': RegisterInfo('R7', size=2), | |
} | |
stack_pointer = "R7" | |
intrinsics = { | |
'test_intr': IntrinsicInfo([Type.int(2)], []), | |
} | |
def get_instruction_info(self, data, addr): | |
instr_len = 2 | |
instr_info = InstructionInfo() | |
instr_info.length = instr_len | |
return instr_info | |
def get_instruction_text(self, data, addr): | |
instr_len = 2 | |
instr_display = [InstructionTextToken(InstructionTextTokenType.InstructionToken, 'TEST')] | |
return instr_display, instr_len | |
def get_instruction_low_level_il(self, data, addr, il): | |
instr_len = 2 | |
il.append(il.intrinsic([il.reg(2, 'R0')], 'test_intr', [])) | |
return instr_len | |
TESTARCH.register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment