Advertisement
Guest User

GhidraScript 2 Program Colorization Example

a guest
Oct 15th, 2019
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1.  
  2. //TODO write a description for this script
  3. //@author
  4. //@category _NEW_
  5. //@keybinding
  6. //@menupath
  7. //@toolbar
  8.  
  9. import java.awt.Color;
  10.  
  11. import ghidra.app.plugin.core.colorizer.ColorizingService;
  12. import ghidra.app.script.GhidraScript;
  13. import ghidra.app.services.ProgramManager;
  14. import ghidra.program.model.address.Address;
  15. import ghidra.program.model.listing.Program;
  16.  
  17. public class ColorTest extends GhidraScript {
  18.  
  19.     public void run() throws Exception {
  20.         Program program1 = getState().getCurrentProgram();
  21.         Program program2 = askProgram("Please select program 2");
  22.  
  23.         ProgramManager programManager = getState().getTool().getService(ProgramManager.class);
  24.         ColorizingService service = getState().getTool().getService(ColorizingService.class);
  25.  
  26.         int id = program2.startTransaction("colorizing");
  27.         try {
  28.             programManager.setCurrentProgram(program1);
  29.             Address address1 = program1.getMinAddress();
  30.             service.setBackgroundColor(address1, address1, Color.RED);
  31.  
  32.             programManager.setCurrentProgram(program2);
  33.             Address address2 = program2.getMinAddress();
  34.             service.setBackgroundColor(address2, address2, Color.ORANGE);
  35.         } finally {
  36.             program2.endTransaction(id, true);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement