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.

hippietrail
  • 515
  • 4
  • 17

2 Answers2

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

hippietrail
  • 515
  • 4
  • 17
blabb
  • 16,376
  • 1
  • 15
  • 30
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)

Katharsas
  • 121
  • 3