question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How To Update this.currentAddress During Script Execution

See original GitHub issue

I have an instruction address trace and I’d like to visualize it with Ghidra. I’m able to update the address via this.currentAddress = this.currentAddress.getAddress(address); (which feels like the improper way to update the cursor location), but when I update the address multiple times within a script the cursor is only ever updated to the final address at the end of the script execution. This makes it where I’m unable to watch the instruction trace at all.

Here is my script.

public class TraceGoTo extends GhidraScript {

	@Override
	public void run() throws Exception {
		String addresses[] = new String[] {"0x10a094", "0x10a098", "0x10a09c"};
		
		System.out.println("TraceGoTo!");
		for (String address : addresses) {
			setAddress(address);
			TimeUnit.SECONDS.sleep(1);
		}
		
	}
	
	public void setAddress(String address) throws AddressFormatException
	{
		System.out.println("Setting address to " + address);
		this.currentAddress = this.currentAddress.getAddress(address);	
	}
}
  1. What is the proper way to set this.currentAddress?
  2. How can I get ghidra to render the updated address during the script execution (change the current cursor location)
  3. Better yet, how could I make a dialogue of sorts, where I could just click a button for “Next Address” and then update this.currentAddress? This would actually suit my needs and seems like the ideal approach anyways.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
dev747368commented, Jul 11, 2022

re: addresses, use toAddr(String) or toAddr(long)

re: dialog. I haven’t played with the table convenience methods much, but using a dialog with a table does sound like a more user-friendly way to go.

0reactions
dev747368commented, Jul 11, 2022

Creating TableModels for tables is just one of the those things you have to get comfortable with when you venture outside the easy, predefined helper methods published in GhidraScript / FlatProgramAPI.

You have the full might and power of java and the internal classes defined in Ghidra to create anything you want. It just takes a bit of work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Script: Customer Address Update - AudienceView
The script will update the address with this ID for the customer. If the Address ID value is not provided by the source...
Read more >
How can I update the current script before running it?
Yes, you can update the script you're running, then execute it again. (Just make sure to exit the first script after updating.) ...
Read more >
How do I change data using a script to update a user field.
Here you go. Please run this from background script. Try this on your dev instance first. var gr = new GlideRecord('sys_user');.
Read more >
Run custom actions during a feature update | Microsoft Learn
Custom actions folder structure ; %windir%\System32\update\runonce, Scripts in this folder will only run in one upgrade and won't be migrated for ...
Read more >
Verified script execution for private locations
To change your passphrase or disable verified script execution, follow the same basic process to go to your minion's IP address and update...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found