1

I have created a script in Java and I have a structure type as a string name which I want to set at given global variable which I have the Address of.

However I can't seem to find a way to do this - like I can get the symbol or something but this doesn't allow me to change the type.

Any ideas?

3
  • 1
    This seems like a better fit for Stack Overflow because it doesn't contain any reverse engineering elements. Jul 13 at 18:04
  • 1
    @dingo_kinznerhook: as the OP pointed out here this is indeed RE-related, given the Ghidra complex. Java alone would be for StackOverflow, of course, but in the context of Ghidra and asking about how to interface with that to accomplish something is clearly a fit.
    – 0xC0000022L
    Jul 27 at 6:55
  • well you can open .data section where u will find all initialized data
    – user42008
    Sep 22 at 13:04

1 Answer 1

6

First get the DataType that you want, for example struct foo:

DataType dt = getDataTypes("foo")[0];

Or if it's just a pointer you'll have to get the pointer of that type.

You said you already have the address, you'll need to make sure it's an Address if not already:

Address addr = toAddr(0x12345678);

Then create the data:

Data data = createData(addr, dt);

It may already have something there if that fails, you can clear out that memory (there is another API for this if you need more control, this is the simple case):

clearListing(addr, addr.add(dt.getLength() - 1);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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