|
| 1 | +# Development Guide |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +This is the repo for bincraft ghidra release. |
| 6 | +The organization of the code in this repo is roughly: |
| 7 | + |
| 8 | +- ghidra: submodule to the [forked ghidra](https://github.com/StarCrossPortal/ghidra). The branch `bincraft_ghidra` of the forked ghidra is where we put our forked version. The `master` branch of that repo is for tracking upstream changes, we should keep it follow the upstream. |
| 9 | +- ghidracraft: our plugin. Currently only examples. But in the future, if we decide to write a custom default plugin for ghidra, it should reside in this directory. |
| 10 | +- sleighcraft: one of the Ghidra-related tool in Rust. |
| 11 | +- bindings: bindings to Ghidra-related tools. Currently only `sleighcraft` |
| 12 | +- images: for README |
| 13 | + |
| 14 | +So, the structure follows as: |
| 15 | + |
| 16 | +- ghidra related tools reside in a new directory of its name (xxxCraft, maybe). When possible, write it in Rust and add bindings afterwards. |
| 17 | +- the binding to that tool should reside in the `bindings` directory |
| 18 | +- all custom default Ghidra plugin (extension) should be in the `ghidracraft` directory |
| 19 | +- custom changes to the Ghidra itself should be PRed to the [forked version of Ghidra here](https://github.com/StarCrossPortal/ghidra) |
| 20 | + |
| 21 | +## Procedure |
| 22 | + |
| 23 | +### SleighCraft |
| 24 | + |
| 25 | +As a self-contained tool (at least for now, in the future, it should relate to our forked version of ghidra), you can use normal Rust toolchain to develop it. |
| 26 | + |
| 27 | +The `Cargo.toml` at the root dir specifies the work spaces. |
| 28 | + |
| 29 | +If you know anything about Rust development, it should be similar to just other Rust projects. |
| 30 | + |
| 31 | +Bindings are alike, just a normal workspace within. |
| 32 | + |
| 33 | +The dev procedure follows normal github dev procedure. |
| 34 | + |
| 35 | +### GhidraCraft |
| 36 | + |
| 37 | +The plugin of Ghidra. Currently only examples inside. |
| 38 | + |
| 39 | +To dev it, you need a working Ghidra release, either built yourself or released version. |
| 40 | +(However, we prefer the self-built version.) |
| 41 | + |
| 42 | +Set the environment `GHIDRA_INSTALL_DIR` to the released ghidra directory, and do `gradle buildExtension`. |
| 43 | + |
| 44 | +A zip file within `dist` file is the extension you build. |
| 45 | + |
| 46 | +The debugging experience is not yet completed. Currently you might need to start ghidra with `ghidraDev` (within ghidra release, `support/`) and attach java debugger to it. |
| 47 | + |
| 48 | +The dev procedure follows normal github dev procedure. |
| 49 | + |
| 50 | +### Upstream Ghidra |
| 51 | + |
| 52 | +You should refer to [official ghidra dev doc](https://github.com/NationalSecurityAgency/ghidra/blob/master/DevGuide.md) to get a glance of how things should be doing. |
| 53 | + |
| 54 | +However, we don't use Eclipse that much. |
| 55 | + |
| 56 | +VSCode or IntelliJ IDEA is preferred. But to launch and debug it, you might need settings like: |
| 57 | + |
| 58 | +(This is mine, in VSCode `launch.json`) |
| 59 | + |
| 60 | +```json |
| 61 | + { |
| 62 | + "type": "java", |
| 63 | + "name": "Launch Ghidra", |
| 64 | + "request": "launch", |
| 65 | + "projectName": "Framework Utility", |
| 66 | + "mainClass": "ghidra.GhidraLauncher", |
| 67 | + "vmArgs": "-Djava.system.class.loader=ghidra.GhidraClassLoader -DbinaryPath=build/classes/java/main:build/resources/main/:bin/default/::src/main/resources/", |
| 68 | + "classPaths": ["${workspaceFolder}\\Ghidra\\Framework\\Utility\\build\\classes\\java\\main"], |
| 69 | + "args": "ghidra.GhidraRun" |
| 70 | + }, |
| 71 | +``` |
| 72 | + |
| 73 | +IDEA setting is almost the same, you should set it according to this one. |
| 74 | + |
| 75 | +And since this repo (bincraft) is just a shelter repo for our forked version of ghidra, the dev procedure can be a little bit different. |
| 76 | + |
| 77 | +Decide if you are developing a bincraft-only feature or upstream-compatible feature (or bug fix). |
| 78 | + |
| 79 | +- bincraft-only: feature (or bug fix). Fork [this repo](https://github.com/StarCrossPortal/ghidra). Be sure to develop your code based on `bincraft_ghidra` branch. |
| 80 | +- upstream-compatible: fork either original official [ghidra](https://github.com/StarCrossPortal/ghidra) or [our version](https://github.com/StarCrossPortal/ghidra) but be sure to based on `master` branch (which should always track upstream `master`). |
| 81 | + |
| 82 | +Now your dev is done. Also, based on your type of feature or fix, you have two choices. |
| 83 | + |
| 84 | +- bincraft-only: fire a pull request directly to [our repo](https://github.com/StarCrossPortal/ghidra), to `bincraft_ghidra` branch. |
| 85 | +- upstream-compatible: first, fire a pull request to [our repo](https://github.com/StarCrossPortal/ghidra) as well. Since we may merge it quicker than official. Then, fire a PR directly to the official repo, follow normal ghidra contribute procedure. |
0 commit comments