(address, instructions=1, emulate=False, show_prev_insns=True)
return insns
Disasms instructions near given `address`. Passing `emulate` makes use of
    unicorn engine to emulate instructions to predict branches that will be taken.
    `show_prev_insns` makes this show previously cached instructions
    (this is mostly used by context's disasm display, so user see what was previously)
Disasms instructions near given `address`. Passing `emulate` makes use of
    unicorn engine to emulate instructions to predict branches that will be taken.
    `show_prev_insns` makes this show previously cached instructions
    (this is mostly used by context's disasm display, so user see what was previously)
Disasms instructions near given address . Passing emulate makes use of unicorn engine to emulate instructions to predict branches that will be taken . show_prev_insns makes this show previously cached instructions ( this is mostly used by context s disasm display so user see what was previously )
def near(address, instructions=1, emulate=False, show_prev_insns=True):
    """
    Disasms instructions near given `address`. Passing `emulate` makes use of
    unicorn engine to emulate instructions to predict branches that will be taken.
    `show_prev_insns` makes this show previously cached instructions
    (this is mostly used by context's disasm display, so user see what was previously)
    """

    current = one(address)

    pc = pwndbg.regs.pc

    if current is None or not pwndbg.memory.peek(address):
        return []

    insns = []

    # Try to go backward by seeing which instructions we've returned
    # before, which were followed by this one.
    if show_prev_insns:
        cached = backward_cache[current.address]
        insn   = one(cached) if cached else None
        while insn is not None and len(insns) < instructions:
            insns.append(insn)
            cached = backward_cache[insn.address]
            insn = one(cached) if cached else None
        insns.reverse()

    insns.append(current)

    # Some architecture aren't emulated yet
    if not pwndbg.emu or pwndbg.arch.current not in pwndbg.emu.emulator.arch_to_UC:
        emulate = False

    # Emulate forward if we are at the current instruction.
    emu = None

    # If we hit the current instruction, we can do emulation going forward from there.
    if address == pc and emulate:
        emu = pwndbg.emu.emulator.Emulator()
        # skip current line
        emu.single_step()

    # Now find all of the instructions moving forward.
    #
    # At this point, we've already added everything *BEFORE* the requested address,
    # and the instruction at 'address'.
    insn = current
    total_instructions = 1 + (2*instructions)

    while insn and len(insns) < total_instructions:
        target = insn.target

        # Disable emulation if necessary
        if emulate and set(insn.groups) & DO_NOT_EMULATE:
            emulate = False
            emu = None

        # If we initialized the emulator and emulation is still enabled, we can use it
        # to figure out the next instruction.
        if emu:
            target_candidate, size_candidate = emu.single_step()

            if None not in (target_candidate, size_candidate):
                target = target_candidate

        # Continue disassembling at the *next* instruction unless we have emulated
        # the path of execution.
        elif target != pc:
            target = insn.address + insn.size

        insn = one(target)
        if insn:
            insns.append(insn)

    # Remove repeated instructions at the end of disassembly.
    # Always ensure we display the current and *next* instruction,
    # but any repeats after that are removed.
    #
    # This helps with infinite loops and RET sleds.
    while insns and len(insns) > 2 and insns[-3].address == insns[-2].address == insns[-1].address:
        del insns[-1]

    return insns
def near ( address , instructions = 1 , emulate = False , show_prev_insns = True ) : current = one ( address ) pc = pwndbg . regs . pc if current is None or not pwndbg . memory . peek ( address ) : return [ ] insns = [ ] # Try to go backward by seeing which instructions we've returned # before, which were followed by this one. if show_prev_insns : cached = backward_cache [ current . address ] insn = one ( cached ) if cached else None while insn is not None and len ( insns ) < instructions : insns . append ( insn ) cached = backward_cache [ insn . address ] insn = one ( cached ) if cached else None insns . reverse ( ) insns . append ( current ) # Some architecture aren't emulated yet if not pwndbg . emu or pwndbg . arch . current not in pwndbg . emu . emulator . arch_to_UC : emulate = False # Emulate forward if we are at the current instruction. emu = None # If we hit the current instruction, we can do emulation going forward from there. if address == pc and emulate : emu = pwndbg . emu . emulator . Emulator ( ) # skip current line emu . single_step ( ) # Now find all of the instructions moving forward. # # At this point, we've already added everything *BEFORE* the requested address, # and the instruction at 'address'. insn = current total_instructions = 1 + ( 2 * instructions ) while insn and len ( insns ) < total_instructions : target = insn . target # Disable emulation if necessary if emulate and set ( insn . groups ) & DO_NOT_EMULATE : emulate = False emu = None # If we initialized the emulator and emulation is still enabled, we can use it # to figure out the next instruction. if emu : target_candidate , size_candidate = emu . single_step ( ) if None not in ( target_candidate , size_candidate ) : target = target_candidate # Continue disassembling at the *next* instruction unless we have emulated # the path of execution. elif target != pc : target = insn . address + insn . size insn = one ( target ) if insn : insns . append ( insn ) # Remove repeated instructions at the end of disassembly. # Always ensure we display the current and *next* instruction, # but any repeats after that are removed. # # This helps with infinite loops and RET sleds. while insns and len ( insns ) > 2 and insns [ - 3 ] . address == insns [ - 2 ] . address == insns [ - 1 ] . address : del insns [ - 1 ] return insns