I'm using Ghidra to reverse engineer an EXE file and save its assembly line code only. Does Ghidra have any function or scripts which exports the assembly line code? I don't want to manually copy the code from the Listing window.
1 Answer
Not sure if you ask about one line or the whole program.
One assembly line can be obtain for example by such script:
addr = toAddr(<address>)
print(currentProgram.getListing().getInstructionAt(addr))
if we are talking about the whole program
for instr in currentProgram.getListing().getInstructions(True):
print(instr)
but I guess the last one can take a while. More information can be found in the docs about Listing object.
-
Thank you so much, this is exactly what I wanted. The program has to be analyzed for this to work, I wrote a script which analyzes the program and then extracts the assembly code, but the issue is that the first time i run the script, it can't detect the current Listing window and gets a NoneType error (even though the script was analyzed), but if I run the script again after it has been analyzed once, then the assembly code is displayed. Is there a way where the script extracts the assembly code the first time the script has been run? Jun 11, 2020 at 12:34
-
-