Skip to content

Commit

Permalink
add todo for get instr bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
DennyDai committed Mar 7, 2024
1 parent 73b5e52 commit 97d92a8
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/patcherex2/components/archinfo/aarch64.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Aarch64Info:
jmp_size = 4
alignment = 4
is_variable_length_isa = False
instr_size = 4
call_asm = "bl {dst}"
pc_reg_names = ["pc", "ip"]
save_context_asm = """
Expand Down
1 change: 1 addition & 0 deletions src/patcherex2/components/archinfo/amd64.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Amd64Info:
jmp_size = 6
alignment = 4
is_variable_length_isa = True
instr_size = -1 # variable length
call_asm = "call {dst}"
pc_reg_names = ["rip"]
save_context_asm = """
Expand Down
1 change: 1 addition & 0 deletions src/patcherex2/components/archinfo/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class ArmInfo:
jmp_size = 4
alignment = 4
is_variable_length_isa = False
instr_size = 4 # TODO: thumb 2
call_asm = "bl {dst}"
pc_reg_names = ["pc", "r15", "ip"]
save_context_asm = """
Expand Down
1 change: 1 addition & 0 deletions src/patcherex2/components/archinfo/mips.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class MipsInfo:
jmp_size = 8
alignment = 4
is_variable_length_isa = False
instr_size = 4
call_asm = "jal {dst}"
pc_reg_names = ["pc"]
save_context_asm = """
Expand Down
1 change: 1 addition & 0 deletions src/patcherex2/components/archinfo/mips64.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Mips64Info:
jmp_size = 8
alignment = 4
is_variable_length_isa = False
instr_size = 4
call_asm = "jal {dst}"
pc_reg_names = ["pc"]
save_context_asm = """
Expand Down
1 change: 1 addition & 0 deletions src/patcherex2/components/archinfo/ppc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class PpcInfo:
jmp_size = 4
alignment = 4
is_variable_length_isa = False
instr_size = 4
call_asm = "bl {dst}"
pc_reg_names = []
save_context_asm = """
Expand Down
1 change: 1 addition & 0 deletions src/patcherex2/components/archinfo/ppc64.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Ppc64Info:
jmp_size = 4
alignment = 4
is_variable_length_isa = False
instr_size = 4
call_asm = "bl {dst}"
pc_reg_names = []
save_context_asm = """
Expand Down
1 change: 1 addition & 0 deletions src/patcherex2/components/archinfo/ppc_vle.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class PpcVleInfo:
jmp_size = 4
alignment = 4
is_variable_length_isa = True
instr_size = -1 # variable length
call_asm = "bl {dst}"
pc_reg_names = []
save_context_asm = "" # TODO
Expand Down
1 change: 1 addition & 0 deletions src/patcherex2/components/archinfo/sparc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class SparcInfo:
jmp_size = 8
alignment = 4
is_variable_length_isa = False
instr_size = 4
call_asm = "call {dst}"
pc_reg_names = ["pc"]
save_context_asm = "" # TODO
Expand Down
1 change: 1 addition & 0 deletions src/patcherex2/components/archinfo/x86.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class X86Info:
jmp_size = 5
alignment = 4
is_variable_length_isa = True
instr_size = -1 # variable length
call_asm = "call {dst}"
pc_reg_names = ["eip"]
save_context_asm = """
Expand Down
2 changes: 2 additions & 0 deletions src/patcherex2/components/binary_analyzers/angr.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def get_basic_block(self, addr: int) -> Dict[str, Union[int, List[int]]]:
def get_instr_bytes_at(self, addr: int, num_instr=1) -> angr.Block:
addr += 1 if self.is_thumb(addr) else 0
addr = self.denormalize_addr(addr)
# TODO: Special handling for delay slot, when there is a call instr with delay slot
# angr will return both instrs, even when num_instr is 1
return self.p.factory.block(addr, num_inst=num_instr).bytes

def get_unused_funcs(self) -> List[Dict[str, int]]:
Expand Down

0 comments on commit 97d92a8

Please sign in to comment.