Ghidra for Haiku

In an effort to learn more about Haiku and Ghidra, I’ve created a Haiku port. It’s now usable, so I’ve uploaded my code to Github and provided a binary release.

Ghidra is an open-source software reverse engineering framework written in Java. The project needed tweaks to make the build environment and project aware of Haiku, and to edit the C-based decompiler to compile on Haiku.

Dependency: OpenJDK 11.

Known issue: It can’t analyze Haiku ELF files, since it seems to think they’re iOS apps, and this makes Ghidra crash and burn. But I was able to test it out with OSX, Linux, and Windows executables to ensure it works. There are probably other bugs in there too, let me know if you find any.

8 Likes

I have updated Ghidra based on the development of version 9.1, and it’s available as a Haiku package. Link: https://github.com/rjzak/ghidra/releases/tag/9.1_DEV_A1.

Two questions:

  1. How do I add a screenshot to be shown when looking at the package with HaikuDepot?
  2. How is the integration with Java and Haiku? I’m thinking of writing a launcher which would appear in the applications menu, and how the Ghidra name and logo in the application list, instead of just “java”. I’ve done some Java programming with C++, but not much, and I’m not sure how well OpenJDK & Java work together.

Some outstanding issues:

  1. Data/config resides under the Unix/Linux default of $HOME/.ghdira, instead of /boot/home/config/settings/ghidra
  2. The package doesn’t inform the package manager of the apps data files, nor now to handle them when updating.
  3. Nothing has been done for handling installing a new version, I’d want data files to be kept, and multiple versions of Ghidra would not be allowed at the same time (doesn’t make sense to me)
  4. Make a launcher so the user doesn’t need the Terminal to start the program, make the Java program feel more native.
3 Likes

maybe you can read Building packages with haikuporter this to make recipe so your package will be available to all haiku users

Yup, I’ve read it and it’s on the to-do list.

I still have yet to learn about HaikuPorter, but in the meantime, Ghidra 10.1.1 is available for Haiku. Both native packages and a Zip are available. Luckily, this version also cleans up some code, which makes way for more operating system - arch support, so it wouldn’t be too hard to add RISC-V support once the support is in place.

2 Likes

The Screenshot is part of haikudepot Web,

https://depot.haiku-os.org

Wow… I don’t think I’ve ever seen that before.

Take a look at yab (yet another basic)

https://yab.besly.de

Or write a little c program to do that

https://besly.de/index.php/en/development/c-c/run-a-shell-script-or-command-with-c

I did start writing a C program GitHub - rjzak/ghidra at ghidra_haiku_launcher, and it compiles but doesn’t run (seems to not find the ghidra launcher function). Part of the issue is that Ghidra is (mostly) Java, and getting JNI to work is painful. Another option is a plain program which just launches the Java code and returns, but that feels cheap.

As for the screenshot appearing in HaikuDepot, how does that website have anything to do with adding the screenshot? It seems that, at best, a logged-in user can rate applications.

in your program you try to execute the .jar. Have you already tried to do this by anticipating java?

java -jar /path/to/file.jar (java: i does not know the java name in shell)

I could imagine that it could be because haiku does not know that .jar is a java program. at least you should test that to exclude it.

Not everyone can add icons, screenshots, translations at the HaikuDepot Server website. You need certain permissions. A small number of people have those and usually we manage to add those things to the new and updated packages in short time.

People can save me the work of installing and capturing informative screenshots by PMing me a few shots (and the (HVIF) icon). :slight_smile:

2 Likes

The correct invocation is “java -jar /here/is/your/jarfile.jar”

1 Like

An example of launcher:

:laughing: I was going to ask this myself when Speed_Dreams appeared in Haiku Depot. But then, magically, after a couple of days, Screenshots appeared! Thanks to @humdinger (or whoever posted the Screenies!)

I like how this example shows how to set an icon for the shell script, very cool.

Unfortunately, Ghidra is a bit of a monster, with various directories and subdirectories of .java files all over, and the occasional native binary. It already has a shell script launcher, but I wanted something nicer.