|
|
|
|
@ -148,15 +148,16 @@ def get_regs(*regs):
|
|
|
|
|
pwndbg.config.Parameter('emulate', True, '''
|
|
|
|
|
Unicorn emulation of code near the current instruction
|
|
|
|
|
''')
|
|
|
|
|
code_lines = pwndbg.config.Parameter('context-code-lines', 10, 'number of additional lines to print in the code context')
|
|
|
|
|
|
|
|
|
|
def context_code():
|
|
|
|
|
banner = [pwndbg.ui.banner("code")]
|
|
|
|
|
emulate = bool(pwndbg.config.emulate)
|
|
|
|
|
result = pwndbg.commands.nearpc.nearpc(to_string=True, emulate=emulate)
|
|
|
|
|
result = pwndbg.commands.nearpc.nearpc(to_string=True, emulate=emulate, lines=code_lines // 2)
|
|
|
|
|
|
|
|
|
|
# If we didn't disassemble backward, try to make sure
|
|
|
|
|
# that the amount of screen space taken is roughly constant.
|
|
|
|
|
while len(result) < 11:
|
|
|
|
|
while len(result) < code_lines + 1:
|
|
|
|
|
result.append('')
|
|
|
|
|
|
|
|
|
|
return banner + result
|
|
|
|
|
@ -212,10 +213,12 @@ def context_source():
|
|
|
|
|
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
stack_lines = pwndbg.config.Parameter('context-stack-lines', 8, 'number of lines to print in the stack context')
|
|
|
|
|
|
|
|
|
|
def context_stack():
|
|
|
|
|
result = []
|
|
|
|
|
result.append(pwndbg.ui.banner("stack"))
|
|
|
|
|
telescope = pwndbg.commands.telescope.telescope(pwndbg.regs.sp, to_string=True)
|
|
|
|
|
telescope = pwndbg.commands.telescope.telescope(pwndbg.regs.sp, to_string=True, count=stack_lines)
|
|
|
|
|
if telescope:
|
|
|
|
|
result.extend(telescope)
|
|
|
|
|
return result
|
|
|
|
|
|