Ghidra: Change CodeBrowser Tool to Remember Previous Cursor Postion(s)

Created on 31 Oct 2019  路  4Comments  路  Source: NationalSecurityAgency/ghidra

Describe the bug
Same as #505. When opening an existing Ghidra program, cursor starts at top and the decompiler window is empty. Ghidra won't ask to save the program if I close code browser after moving the cursor without changing anything. This is listed in the official bugfix list, but is still happening.

To Reproduce
Steps to reproduce the behavior:
Open a program of an active project, a PE executable for example.
Move the cursor to a random function by double clicking the function name of a call.
Change the name of current function
Save the program and exit code browser
Open the program again, and the cursor is at top of disassembly window (just before PE header section).

Expected behavior
The cursor should be at the last position of previous running.

Environment (please complete the following information):

  • OS: Windows 10 1903 18362.418
  • Java Version: 12.0.2
  • Ghidra Version: 9.1
GUI Enhancement

Most helpful comment

This should be considered a feature request, not a bug. For better or worse, this is how the tool is currently designed. Some observations:

  • The cursor location is not saved with the program data, but with the project settings.
  • The individual tools do not save the cursor (this is only saved by the overall project)
  • To have the cursor position saved, as mentioned above, you must trigger a save to the overall project.
  • To save the project, you can either close Ghidra via the Front End or by executing a project save manually via File -> Save Project from the Front End.
  • To save the Code Browser tool settings, use File -> Save Tool from the Code Browser
  • The save icon in the Code Browser pertains only to the program and not to tool settings (e.g., installed plugins, window positioning, etc)

The reasoning behind the way it works is that we cannot simply save the cursor position in the Code Browser tool, since it only saves program-agnostic settings. In other words, if you save a cursor position, it is relative to an address in a program. If you open a new program, then the cursor location will not make sense for the new program. On the other hand, saving the location to the project settings makes sense because the projects settings save not only the tool settings, but also the active program and any related information.

I think that it make sense to change how this works so that it behaves as you expected in this case.

All 4 comments

Oddly enough it seems that ghidra will restore the cursor if you don't close the code browser before closing ghidra. If you leave the code browser open, close and relaunch ghidra it will restore it. It will also automatically restore the code browser and python window too which I'm personally not fond of since you can't do anything while the python environment is loading.

Oddly enough it seems that ghidra will restore the cursor if you don't close the code browser before closing ghidra. If you leave the code browser open, close and relaunch ghidra it will restore it. It will also automatically restore the code browser and python window too which I'm personally not fond of since you can't do anything while the python environment is loading.

Wow it works . Thank you. I too think it's counterintuitive, and I wonder why aren't many people complaining about it here.

Oddly enough it seems that ghidra will restore the cursor if you don't close the code browser before closing ghidra. If you leave the code browser open, close and relaunch ghidra it will restore it. It will also automatically restore the code browser and python window too which I'm personally not fond of since you can't do anything while the python environment is loading.

Wow it works . Thank you. I too think it's counterintuitive, and I wonder why aren't many people complaining about it here.

Yes, but I think you may be correct in reporting this as a bug. It probably should restore the cursor position if you close and reopen the code browser.

This should be considered a feature request, not a bug. For better or worse, this is how the tool is currently designed. Some observations:

  • The cursor location is not saved with the program data, but with the project settings.
  • The individual tools do not save the cursor (this is only saved by the overall project)
  • To have the cursor position saved, as mentioned above, you must trigger a save to the overall project.
  • To save the project, you can either close Ghidra via the Front End or by executing a project save manually via File -> Save Project from the Front End.
  • To save the Code Browser tool settings, use File -> Save Tool from the Code Browser
  • The save icon in the Code Browser pertains only to the program and not to tool settings (e.g., installed plugins, window positioning, etc)

The reasoning behind the way it works is that we cannot simply save the cursor position in the Code Browser tool, since it only saves program-agnostic settings. In other words, if you save a cursor position, it is relative to an address in a program. If you open a new program, then the cursor location will not make sense for the new program. On the other hand, saving the location to the project settings makes sense because the projects settings save not only the tool settings, but also the active program and any related information.

I think that it make sense to change how this works so that it behaves as you expected in this case.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lab313ru picture lab313ru  路  3Comments

CalcProgrammer1 picture CalcProgrammer1  路  3Comments

huettenhain picture huettenhain  路  3Comments

tambry picture tambry  路  3Comments

gemini00 picture gemini00  路  3Comments