NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
51.32k stars 5.85k forks source link

Commit Functions/Params undoes custom storage #6318

Closed stgaine closed 7 months ago

stgaine commented 7 months ago

Describe the bug Commit Functions/Params undoes custom storage

To Reproduce Steps to reproduce the behavior:

  1. Import a File - I chose ntoskrnl.exe, but you can use whatever.
  2. Open in Code Viewer and allow auto-analysis to complete.
  3. Choose some function that has a return value - I chose BgkSetCursor at random.
  4. For the sake of example, change the return register from whatever it is (EAX in this example) to something else by following the steps: Right click on function in decompiler -> Edit Function Signature -> Check "Use Custom Storage" -> Double click on the return register to bring up the Storage Address Editor -> Double click the storage register (EAX in this example) -> Change to something else, lets use "EBX" -> Press OK.
  5. Verify that it took by re-checking the function signature.
ChangeReturnRegister
  1. Right click on the function and choose "Commit Params/Return". Then re-open the function signature. It will have reverted to what it was during auto-analysis. AfterCommitParamsReturn

Expected behavior The fact that a command that just says "Commmit" actually changes and then commits, is quite confusing. It should probably not change things before doing the commit. In the worst case, it should just do nothing in the case that no commit/params return actually needs to happen if the signature was modified.

Environment (please complete the following information):

ghidra1 commented 7 months ago

After trying it I can confirm the behavior is unexpected and I will look into it in more detail.

ghidra1 commented 7 months ago

It would appear that commit may always revert the return to its default state. I have a fix in the works. Thanks for reporting it.