mirror of https://github.com/pwndbg/pwndbg.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
720 B
Python
27 lines
720 B
Python
from capstone import CS_GRP_JUMP
|
|
|
|
import pwndbg.arch
|
|
import pwndbg.disasm.x86
|
|
|
|
|
|
def is_jump_taken(instruction):
|
|
"""
|
|
Attempt to determine if a conditional instruction is executed.
|
|
Only valid for the current instruction.
|
|
|
|
Returns:
|
|
Returns True IFF the current instruction is a conditional
|
|
*or* jump instruction, and it is taken.
|
|
|
|
Returns False in all other cases.
|
|
"""
|
|
if CS_GRP_JUMP not in instruction.groups:
|
|
return False
|
|
if pwndbg.regs.pc != instruction.address:
|
|
return False
|
|
|
|
return {
|
|
'i386': pwndbg.disasm.x86.is_jump_taken,
|
|
'x86-64': pwndbg.disasm.x86.is_jump_taken,
|
|
}.get(pwndbg.arch.current, lambda *a: False)(instruction)
|