6

Either by pasting from a text file or typing it out into a dialog box, which is still much faster than using Ghidra's Structure editor.

2 Answers 2

3

Create a file foo.h somewhere

Add your struct to that file.

File -> parse c source -> parse to program -> dismiss

Data type manager:
Data->choose Data Type and navigate to the header and apply your struct

contents of dudu.h

typedef unsigned char   undefined;

typedef unsigned int    dword;
typedef struct head_of_png_dude head_of_pnge_dud, *Phead_of_png_dude;

struct head_of_png_dude {
    dword pnghead;
    dword pngtail;
    dword pngfeet;
    dword yakk;
    dword bukk;
    dword luck;
};

parsed c source Ghidra Data Type Manager showing our new types

The applied the data type:
Ghidra Listing panel showing our struct applied

2

Using "Parse C Source" seems to only work if all other structs referenced by the parsed structs are also defined in such header files in correct order.

If you want to parse a struct that depends on types that have been added from another source (like plugins/scripts, PDB, or manually added), you could use a script.

This script allows you to do that: https://github.com/Katharsas/ghidra-struct-importer

(Disclaimer: I am the author of that repo)

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.