While searching solution for my question I found related issue in GitHub repository of project: NationalSecurityAgency/ghidra#issue-19.
According to many comments, community around ghidra are waiting for this functionality allowing patching binaries.
In this comment: NationalSecurityAgency/ghidra/issue-19#issuecomment-560485351 @schlafwandler offers own ...
The solution that I found that suffices for my current issue of debugging the EXT4 parser is is the following Ghidra Script, saved as ImportFS.java:
For starters you could start by geting rid of most of the casts then start carving out the stack and heap structs where possible, then try to change the name of variables where possible to more type oriented ones, this will show most of the "duplicate" variables.
Then start following the main flow following labels and maybe change their name to ...
This is a helper function used by PPC EABI conforming compilers for reducing code size. From ctrsavres.asm:
/* Routines for saving integer registers, called by the compiler. */
/* Called with r11 pointing to the stack header word of the caller of the */
/* function, just beyond the end of the integer save area. */
Because it is called by the compiler, it ...
Regarding unaff_ and in_ prefixes (source):
in or unaff : this typically indicates that a register is read
before it is written (and it does not contain a parameter
passed to the function)
So, if you encounter them in decompilator, it means that their values are used before they are initialised in the function (they contain the values assigned earlier, in ...
In order to run a script in Ghidra you can run the following:
analyzeHeadless <project_location> <project_name> -import <path/to/file> -scriptPath <path/to/scripts> -preScript <preScript_name> <preScript_params> -postScript <postScript_name> <postScript_params>
analyzeHeadless is the Ghidra GUI-less executable ...
I came up with this after I read the post but couldn't find a way to make it neat and clean
just recording the thought process as pawel created an answer that is nice
>>> inst = currentProgram.listing.getCodeUnitAt(currentAddress)
>>> print (inst,inst.getReferencesFrom())
(CALL qword ptr [0x1c0007050], ->NTOSKRNL.EXE::EtwRegister)
So, the answer was provided in the OP's ticket #1994, just transferring it here for the future seekers:
from ghidra.program.model.listing import CodeUnitFormat, CodeUnitFormatOptions
codeUnitFormat = CodeUnitFormat(CodeUnitFormatOptions(CodeUnitFormatOptions.ShowBlockName.ALWAYS,CodeUnitFormatOptions.ShowNamespace.ALWAYS,"",True,True,True,True,True,...
Indeed, it seems to be incorrect. The syntax [R0],#1 is called post-indexed: first the store (or load) is performed, and then the base address is incremented (or decremented) by the value specified. So the assignment and increment should be swapped.
As for 00 BF, it is the opcode for the NOP instruction, probably inserted to align next function on a 4-byte ...
By default, there is a setting in Code Browser that allows Ghidra to eliminate unreachable code, you would have to change the setting by editing the options for Code Browser. This can be done by going to Edit -> Tools Options. This would bring you to a page as seen in the screenshot below
Under the Analysis options in the Decompiler folder, there is a ...