1

I know that the program I am decompiling uses openSSL.
I'd like to add the types from the include folder of the project to the data types.
To do that, I use File => Parse C Source.
I then select the include folder from the openSSL project

For every parse configuration I get

Encountered "<EOF>" at line 0 column 0
Was expecting one of:
"#line"...
<LINEALT>...
";"...

And if I try to import a subset of the .h files I get the following error because some types are not defined directly in the file.

C parser: Encountered errors during parsing

Is there a way to import all the types from the source of a project ?

2

The C parser of Ghidra has various issues, e.g. it has a less extensive list of sane preprocessor variables and it just completely chokes on GCC attributes. I personally tried some approaches to make this work better, e.g. using the clang/gcc preprocessor to dump one giant header file, but they are still highly experimental and probably require a lot of tinkering, so I would overall just declare the C Parser as an nonviable approach for your problem.

The best way that I have heard of so far is to compile the library with full debug symbols in the version and target you need, then import that into Ghidra. Ghidra should then parse all the PDB/DWARF type information, create all the relevant types and apply the function signatures. Then you can link the library file to the binary you want to analyze in the first place, and propagate that information to it. I don't know a tutorial for that right now, but Ghidra has good support for such projects that involve multiple binaries. If you encounter any issues with that, those are most likely worth a separate dedicated question, because this is then the same process as propagating type information from a library that you had to reverse engineer too.

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.