-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_arch.py
More file actions
38 lines (29 loc) · 998 Bytes
/
python_arch.py
File metadata and controls
38 lines (29 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from binaryninja import Architecture, RegisterInfo, InstructionInfo
from .python_disasm import Disassembler
class PythonBytecodeArch(Architecture):
name = "python_bytecode"
max_instr_length = 2 #3.7+ only 2 bytes
regs = {
"sp":RegisterInfo("sp",2)
}
for x in range(1,99):
reg_name = f"global_{x}"
regs[reg_name] = RegisterInfo(reg_name,2)
stack_pointer = "sp"
def __init__(self):
super().__init__()
self.disassembler = Disassembler()
def get_instruction_info(self,data,addr):
# try:
(tokens,length,result) = self.disassembler.disassemble(data,addr)
return result
# except:
# pass
def get_instruction_text(self,data,addr):
# try:
(tokens,length,cond) = self.disassembler.disassemble(data,addr)
return tokens,length
# except:
# pass
def get_instruction_low_level_il(self,data,addr,il):
pass