Can I just right click on a function and copy the dissasembly? I cant’ find it lol
Hi!
A short tip from our colleague:
You can try Alt + L to start the selection, click at the end of the function, then Ctrl + C to copy the disassembly.
You can also use the selection in the File → Produce file submenu.
PS: Have you seen our dedicated blog posts about selections?
Hope it helps!
Seriously? Are you kidding? I can’t right click on function → copy ?
Isn’t it less effort to write this functionality than to write another blog post explaining stuff that shouldn’t ever happen?
Hi @bukowa
A dedicated “copy function disassembly” action is a reasonable request. It’s a bit more involved than it might first appear because IDA would need to choose sensible defaults.
- What counts as “the function”? A function isn’t always one solid block of instructions. The compiler sometimes generates function chunks that are scattered far away in the file.
- What is “the disassembly”? Could be what IDA literally displays in the disassembly window (addresses, raw bytes, comments), or clean assembler source you could feed back into a compiler, or just the bare instructions.
Recommended approaches
- Select the lines you’re interested in and copy them, like @teresa_hexrays suggested.
- From the menu “Help → Extract function…”. Then, “File → Produce file → Create ASM file…”. This is the best way if your intention is to share the function with other users, as it keeps all the necessary context.
- Use a script. I’ll give you an example below (tested with IDA 9.4).
import ida_funcs, ida_bytes, ida_kernwin, idc
def func_disasm_lines(ea=None):
func_ea = ida_funcs.get_func_start(idc.here() if ea is None else ea)
if func_ea == idc.BADADDR:
return
fii = ida_funcs.function_item_iterator_t(func_ea)
prev_end = None
ok = fii.first()
while ok:
head = fii.current()
if prev_end is not None and head != prev_end:
ida_kernwin.msg(f"; ---- chunk break -> {head:#x} ----\n")
ida_kernwin.msg(f"{head:08X} {idc.GetDisasm(head)}\n")
prev_end = head + ida_bytes.get_item_size(head)
ok = fii.next_code()
A built-in “right-click → copy” command would have to make those choices automatically, which is why there isn’t a single obvious default today.
I’ll pass the usability suggestion along to the UI team.