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
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;
};
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)