I wrote some Python scripts to help me disassemble one given file (only one), and I'd like to share some variables between differents scripts (or between 2 different executions of the same script).

Is there a way to do that with Ghidra, better than save shared variables in a temp file ?

  • May I know why this question was downvoted ? Jun 14, 2021 at 9:40
  • I don't think that you can save things outside of your script's context. You either have to recalculate the variable's content that you want to share in your 2nd script, or to save them in a temp file (which is a bit ugly to be honest)
    – Guillaume
    Jun 14, 2021 at 9:45
  • Thanks for the answer. Unfortunately, the first option is not really convenient here, so I'll go with a temp file. Jun 14, 2021 at 9:47
  • I suggest that you use python pickle objects to save your data. You can serialize the variables that you want to save with pickle.dump() and deserialize them from the 2nd script with pickle.load()
    – Guillaume
    Jun 14, 2021 at 9:50

1 Answer 1


if I understand the question correctly, then analyzeHeadless documentation will help you.

Headless Scripts: Passing Values Between Scripts If you are running multiple scripts in headless operation and would like to store a value in one script that is accessible by another script, use the HeadlessScript methods below. They facilitate the storage and retrieval of key-value pairs to/from a data structure that is available to any script of type HeadlessScript:

storeHeadlessValue(String key, Object value);
Object myObject = getStoredHeadlessValue(String key);
boolean containsKey = headlessStorageContainsKey(String key);

Also see:


  • I read the documentation, and unfortunately it's unlikely it applies in my precise situation. So I went with JSON (I could have chosen Pickle) and for now, it works. Jun 17, 2021 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.