Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
cde1f2b
chore(ENG-2785): stop sending advanced_analysis
brettwold Nov 10, 2026
74f570a
feat(ENG-4410): align plugin design with Ghidra themes and RevEng.AI …
robertmarsal Nov 10, 2026
9a7b420
fix(ENG-4233): open portal links via OS launcher; right-click to open…
robertmarsal Nov 10, 2026
f5c36a9
Merge pull request #217 from RevEngAI/chore-ENG-2785
brettwold Nov 10, 2026
129d27d
fix(ENG-4402): sort and colour BigDecimal similarity and confidence c…
robertmarsal Nov 10, 2026
d98da38
fix(ENG-4412): show only status in check status dialog (#222)
robertmarsal Nov 10, 2026
81f7b7a
test: assert theme colours in similarity cell colour test
robertmarsal Nov 10, 2026
66076e1
feat(ENG-4404): open matched binary in portal from function matching …
robertmarsal Nov 10, 2026
01c30a8
feat(ENG-4399): auto-run single function matching with 5 results (#224)
robertmarsal Nov 10, 2026
9ef7143
feat(ENG-4401): prompt users to update the plugin (#225)
robertmarsal Nov 11, 2026
a34938f
feat(ENG-4405): always show user submitted debug symbols option (#226)
robertmarsal Nov 11, 2026
d0f1c98
fix(ENG-4375): handle unsized data types in decoder (#227)
robertmarsal Nov 11, 2026
a0859be
feat(ENG-4421): bump ai.reveng:sdk to 4.75.1-rc.1
vgoat21 Nov 11, 2026
6567b3b
ci: run tests on PRs into staging
vgoat21 Nov 11, 2026
554a2d5
Merge pull request #228 from RevEngAI/joshuavillaltaesp/eng-4421-ghid…
vgoat21 Nov 11, 2026
839ad1f
fix(ENG-4400): keep Ghidra responsive when the network is down
vgoat21 Nov 11, 2026
3d6ffdd
Merge pull request #231 from RevEngAI/joshuavillaltaesp/eng-4400-ghid…
vgoat21 Nov 11, 2026
3e4ba55
feat(ENG-4403): add platform, architecture and user filters to functi…
vgoat21 Nov 11, 2026
a03b9a4
Merge pull request #232 from RevEngAI/joshuavillaltaesp/eng-4403-ghid…
vgoat21 Nov 11, 2026
e528615
feat(ENG-4406): redesign function matching dialog and fix its progres…
vgoat21 Nov 11, 2026
347caea
test(ENG-4406): wait for the automatic match before pressing Match Fu…
vgoat21 Nov 11, 2026
9ff2be7
fix: guard against null pointer exceptions and related crashes (#230)
robertmarsal Nov 11, 2026
5690732
test(ENG-4406): check the dialog is idle on the EDT before pressing M…
vgoat21 Nov 11, 2026
f58df8a
Merge pull request #233 from RevEngAI/joshuavillaltaesp/eng-4406-ghid…
vgoat21 Nov 11, 2026
eec4a86
feat(ENG-4411): transfer name, signature or both from function matching
vgoat21 Nov 11, 2026
4d8839c
Merge pull request #234 from RevEngAI/joshuavillaltaesp/eng-4411-ghid…
vgoat21 Nov 11, 2026
b8cb86c
fix(ENG-4453): don't overwrite real signatures with the server placeh…
vgoat21 Nov 11, 2026
3af051b
Merge pull request #235 from RevEngAI/joshuavillaltaesp/eng-4453-ghid…
vgoat21 Nov 11, 2026
82c139b
ci: don't fail the build when publishing the test report flakes
vgoat21 Nov 11, 2026
3fb6e55
Merge pull request #237 from RevEngAI/ci/test-report-continue-on-erro…
vgoat21 Nov 11, 2026
1ee24c4
Give each TypedApiImplementation its own ApiClient
vgoat21 Nov 12, 2026
03937b4
Retry idempotent requests on 5xx/429 and give uploads their own client
vgoat21 Nov 12, 2026
c8430cb
Merge pull request #239 from RevEngAI/joshuavillaltaesp/eng-4479-ghid…
vgoat21 Nov 12, 2026
772d97f
Merge pull request #238 from RevEngAI/joshuavillaltaesp/eng-4454-ghid…
vgoat21 Nov 12, 2026
897ba7f
Key debounced local-edit pushes by program as well as address/type path
vgoat21 Nov 12, 2026
60311fd
Merge pull request #240 from RevEngAI/joshuavillaltaesp/eng-4466-ghid…
vgoat21 Nov 12, 2026
754cbd3
Suppress pushback per program and only around the sync's own writes
vgoat21 Nov 12, 2026
4dfaa7d
Merge pull request #242 from RevEngAI/joshuavillaltaesp/eng-4456-ghid…
vgoat21 Nov 12, 2026
d71198c
Batch local renames per program, skip local-variable edits, re-tag re…
vgoat21 Nov 12, 2026
3432059
Wait for in-flight event delivery before ending a server write
vgoat21 Nov 12, 2026
190e487
Merge pull request #243 from RevEngAI/joshuavillaltaesp/eng-4482-ghid…
vgoat21 Nov 12, 2026
0be7d63
Report failed local-edit pushes and send them on the next sync
vgoat21 Nov 12, 2026
c2a9121
Report a failing portal once and retry unpushed edits automatically
vgoat21 Nov 12, 2026
c9776ad
Stop retrying edits the portal will never take, and isolate them
vgoat21 Nov 12, 2026
5508ae9
Report the edits that go up once a refused API key works again
vgoat21 Nov 12, 2026
ce7f6bd
Merge pull request #244 from RevEngAI/joshuavillaltaesp/eng-4455-ghid…
vgoat21 Nov 12, 2026
76fee77
fix(ENG-4464): bound the auto-unstrip poller, make it stoppable and s…
vgoat21 Nov 12, 2026
94c6a18
fix(ENG-4459): undo a half-finished attach and offer a retry
vgoat21 Nov 12, 2026
cbe9c8f
fix(ENG-4457): rename on the portal only the matches applied locally
vgoat21 Nov 12, 2026
da32b90
fix(ENG-4457): leave the transferred renames to the reactive push
vgoat21 Nov 12, 2026
33be697
fix(ENG-4464): let Detach cancel a running auto-unstrip sync and stop…
vgoat21 Nov 12, 2026
b95cf77
fix(ENG-4459): roll back a failed load in one transaction
vgoat21 Nov 12, 2026
db38bb5
fix(ENG-4460): retry transient errors while polling analysis status (…
robertmarsal Nov 12, 2026
1c81194
Merge pull request #247 from RevEngAI/joshuavillaltaesp/eng-4457-ghid…
vgoat21 Nov 12, 2026
1f90ec5
Merge pull request #245 from RevEngAI/joshuavillaltaesp/eng-4464-ghid…
vgoat21 Nov 12, 2026
d43ff66
fix(ENG-4461): bound and back off every status polling loop
vgoat21 Nov 12, 2026
b672cad
fix(ENG-4461): point unfinished-wait messages at a recovery that works
vgoat21 Nov 12, 2026
1dc31bb
test(ENG-4461): drive StatusPoller timing tests with a fake clock
vgoat21 Nov 12, 2026
11a2482
Merge pull request #249 from RevEngAI/joshuavillaltaesp/eng-4461-ghid…
vgoat21 Nov 12, 2026
e97dc67
fix(ENG-4476): normalise api and portal hostnames (#250)
robertmarsal Nov 13, 2026
0eb2321
fix(ENG-4465): report server-side analysis errors with the log tail a…
vgoat21 Nov 13, 2026
c3b54d9
test(ENG-4465): wait for the work behind the error dialog instead of …
vgoat21 Nov 13, 2026
ff1a930
test(ENG-4465): wait for every stage before looking for the error dialog
vgoat21 Nov 13, 2026
dab671d
test(ENG-4465): poll for the error dialog instead of counting task ro…
vgoat21 Nov 13, 2026
dcfc57f
Merge remote-tracking branch 'origin/staging' into joshuavillaltaesp/…
vgoat21 Nov 13, 2026
e8ba54c
Merge pull request #251 from RevEngAI/joshuavillaltaesp/eng-4465-ghid…
vgoat21 Nov 13, 2026
a011140
Merge remote-tracking branch 'origin/staging' into joshuavillaltaesp/…
vgoat21 Nov 13, 2026
296d643
Merge pull request #246 from RevEngAI/joshuavillaltaesp/eng-4459-ghid…
vgoat21 Nov 13, 2026
2076233
fix(ENG-4478): show the server's error message on API failures (#252)
robertmarsal Nov 13, 2026
99bf1dd
test(ENG-4485): cover every SDK method and model the plugin uses
vgoat21 Nov 13, 2026
b4f3374
feat(ENG-4563): migrate upload and analysis creation to v3 (#253)
robertmarsal Nov 13, 2026
d8f5783
Merge remote-tracking branch 'origin/staging' into joshuavillaltaesp/…
vgoat21 Nov 13, 2026
03ec824
Merge pull request #254 from RevEngAI/joshuavillaltaesp/eng-4485-ghid…
vgoat21 Nov 13, 2026
ca846ff
fix(ENG-4475): treat an empty mangled_name as absent
vgoat21 Nov 13, 2026
727e2ce
Merge pull request #255 from RevEngAI/joshuavillaltaesp/eng-4475-ghid…
vgoat21 Nov 13, 2026
f1a303c
fix(ENG-4484): load analysis details off the EDT before opening Funct…
vgoat21 Nov 13, 2026
0ae602f
Merge pull request #257 from RevEngAI/joshuavillaltaesp/eng-4484-ghid…
vgoat21 Nov 13, 2026
cbafc04
test(ENG-4483): pin how a transferred signature reaches the portal
vgoat21 Nov 13, 2026
b2ac9f7
Merge pull request #258 from RevEngAI/joshuavillaltaesp/eng-4483-ghid…
vgoat21 Nov 13, 2026
460a428
feat(ENG-4587): add cross-platform installation script (#259)
robertmarsal Nov 13, 2026
044073a
fix(ENG-4588): stop staging CI flakes in dialog and sync tests
vgoat21 Nov 13, 2026
7cec5c9
fix(ENG-4590): stop the analysis wait on Detach and close, ignore sta…
vgoat21 Nov 13, 2026
2f1cc6e
fix(ENG-4589): never push a null data type id
vgoat21 Nov 13, 2026
760305c
fix(ENG-4588): give the matching-status wait its own deadline
vgoat21 Nov 13, 2026
b562984
fix(ENG-4590): drop a results load the program was detached from mid-…
vgoat21 Nov 13, 2026
97e7ef1
fix(ENG-4589): explain closure-limit holds and quieten their logging
vgoat21 Nov 13, 2026
f1890b1
fix(ENG-4590): use the TaskMonitor names Ghidra 12.2 still has
vgoat21 Nov 13, 2026
ae51e0d
Merge pull request #260 from RevEngAI/joshuavillaltaesp/eng-4588-ghid…
vgoat21 Nov 13, 2026
c416221
Merge pull request #261 from RevEngAI/joshuavillaltaesp/eng-4590-ghid…
vgoat21 Nov 13, 2026
1feb649
Merge remote-tracking branch 'origin/staging' into joshuavillaltaesp/…
vgoat21 Nov 13, 2026
d5191b9
fix(ENG-4590): drop the duplicate awaitDialog that breaks the test build
vgoat21 Nov 13, 2026
eb17532
fix(ENG-4590): drop the duplicate awaitDialog that breaks the test build
vgoat21 Nov 13, 2026
a6867d1
test(ENG-4590): dump thread stacks when awaitDialog times out
vgoat21 Nov 13, 2026
ad40ca3
fix(ENG-4590): fire analysis status events after the current delivery
vgoat21 Nov 14, 2026
6602935
test(ENG-4590): dump thread stacks when awaitDialog times out
vgoat21 Nov 13, 2026
d8d10b1
fix(ENG-4590): fire analysis status events after the current delivery
vgoat21 Nov 14, 2026
cf8420c
Merge pull request #262 from RevEngAI/joshuavillaltaesp/eng-4589-ghid…
vgoat21 Nov 16, 2026
7538f6b
Merge pull request #263 from RevEngAI/joshuavillaltaesp/eng-4590-fix-…
vgoat21 Nov 16, 2026
2b80eee
fix(ENG-4588): don't let a late status from a cancelled wait resume it
vgoat21 Nov 16, 2026
4b08a45
ci(ENG-4588): complete a test report check the reporter left in progress
vgoat21 Nov 16, 2026
03da3b9
Merge pull request #265 from RevEngAI/joshuavillaltaesp/eng-4588-comp…
vgoat21 Nov 16, 2026
8fc86bf
Merge pull request #264 from RevEngAI/joshuavillaltaesp/eng-4588-stal…
vgoat21 Nov 16, 2026
102c346
chore: bump SDK to 4.77.1 (#266)
robertmarsal Nov 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: build

on:
pull_request:
branches: [ "main" ]
branches: [ "main", "staging" ]

jobs:
build:
Expand Down Expand Up @@ -66,6 +66,7 @@ jobs:
run: $GHIDRA_INSTALL_DIR/support/sleigh $GHIDRA_INSTALL_DIR/Ghidra/Processors/x86/data/languages/x86-64.slaspec

- name: Run tests
id: tests
run: xvfb-run ./gradlew test

- name: Upload test results
Expand All @@ -76,9 +77,44 @@ jobs:
path: build/reports/tests/test/

- name: Publish test report
id: report
if: always()
# Updating the check run right after creating it intermittently 404s, which failed jobs whose
# tests had passed. Failing tests already fail "Run tests", so the report is display only.
continue-on-error: true
uses: dorny/test-reporter@d61b558e8df85cb60d09ca3e5b09653b4477cea7 # v1
with:
name: Tests (Ghidra ${{ matrix.ghidra }})
path: build/test-results/test/*.xml
reporter: java-junit

- name: Complete a test report left in progress
# When the reporter's update 404s, the check run it created stays "in progress" for good, so the PR never
# shows all checks finished. Complete it with the outcome of the tests. Display only, like the report.
if: always() && steps.report.outcome == 'failure'
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
CHECK_NAME: Tests (Ghidra ${{ matrix.ghidra }})
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
CONCLUSION: ${{ steps.tests.outcome == 'success' && 'success' || 'failure' }}
run: |
summary="The test reporter could not attach the results to this check (HTTP 404). See the Run tests step and the test-results artifact."
# The check run may not be visible to the API yet, which is what made the reporter's update fail
for attempt in 1 2 3 4 5; do
ids=$(gh api -X GET "repos/$GITHUB_REPOSITORY/commits/$HEAD_SHA/check-runs" \
-f check_name="$CHECK_NAME" -f filter=all \
--jq '.check_runs[] | select(.status != "completed") | .id') || ids=""
completed=true
for id in $ids; do
gh api -X PATCH "repos/$GITHUB_REPOSITORY/check-runs/$id" \
-f status=completed -f conclusion="$CONCLUSION" \
-f "output[title]=$CHECK_NAME" -f "output[summary]=$summary" >/dev/null || completed=false
done
if [ -n "$ids" ] && [ "$completed" = true ]; then
echo "Completed '$CHECK_NAME' ($ids) as $CONCLUSION"
exit 0
fi
sleep 5
done
echo "::warning::Could not find or complete an in-progress '$CHECK_NAME' check"
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ and use it for Binary Code Similarity to help you Reverse Engineer stripped bina

## Installation

### Install script

Close Ghidra, then run:

```sh
# Linux / macOS
curl -fsSL https://raw.githubusercontent.com/RevEngAI/plugin-ghidra/main/install.sh | bash
```

```powershell
# Windows (PowerShell)
irm https://raw.githubusercontent.com/RevEngAI/plugin-ghidra/main/install.ps1 | iex
```

The script finds your Ghidra installs (asking which one if several), downloads the matching release, installs it and enables the plugins in the CodeBrowser.
Set `GHIDRA_INSTALL_DIR` to target a specific install, or `REVENG_PLUGIN_VERSION` (e.g. `v1.1.2`) to pin a release.

### Manual installation

The builds for latest stable version of the RevEng.AI Ghidra plugin for common Ghidra versions can be downloaded from the [Releases](https://github.com/revengai/plugin-ghidra/releases/latest) page.

### Supported Ghidra versions
Expand Down
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ dependencies {
implementation group: 'com.fifesoft', name: 'rsyntaxtextarea', version: '3.5.2'
implementation 'org.commonmark:commonmark:0.24.0'
implementation 'org.commonmark:commonmark-ext-gfm-tables:0.24.0'
implementation('ai.reveng:sdk:4.75.0')
implementation('ai.reveng:sdk:4.77.1')
testImplementation('junit:junit:4.13.1')
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.8.2")
// Version comes from the junit-bom pulled in by junit-vintage-engine.
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
// Compile-time API for ForkTempDir; matches the runtime version above.
testCompileOnly('org.junit.platform:junit-platform-launcher:1.8.2')

// https://mvnrepository.com/artifact/org.jetbrains/annotations
implementation group: 'org.jetbrains', name: 'annotations', version: '26.0.2'
Expand Down Expand Up @@ -107,6 +109,10 @@ test {
useJUnitPlatform()
jvmArgs '--add-exports=java.desktop/sun.awt=ALL-UNNAMED'
systemProperty "ghidra.test.property.batch.mode", 'true'
// Parent of the per-fork Ghidra temp dirs created by ForkTempDir.
def forkTempRoot = layout.buildDirectory.dir('tmp/ghidra-test-forks').get().asFile
systemProperty 'reveng.test.fork.tmproot', forkTempRoot.path
doFirst { forkTempRoot.mkdirs() }

// Ghidra 12.1+ installs a serial filter factory during application initialization. The JVM
// only allows this if no ObjectInputStream has been constructed yet, but Gradle's test
Expand Down
38 changes: 38 additions & 0 deletions data/reveng.theme.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[Defaults]

color.bg.reveng.tag = rgba(14,169,104,.08)
color.border.reveng.tag = rgba(14,169,104,.35)
color.border.reveng.title = [color]laf.color.Separator.foreground

color.fg.reveng.similarity.critical = #b31d1d
color.fg.reveng.similarity.high = #ac3f09
color.fg.reveng.similarity.medium = #985a04
color.fg.reveng.similarity.low = #137236

color.bg.reveng.diff.deleted = rgba(201,55,55,.15)
color.bg.reveng.diff.inserted = rgba(14,169,104,.15)
color.bg.reveng.diff.changed = rgba(184,108,0,.15)
color.bg.reveng.diff.placeholder = rgba(7,9,13,.04)

icon.reveng.mark.16 = images/reveng_16.png
icon.reveng.mark.24 = images/reveng_24.png
icon.reveng.mark.large = images/icon.png

[Dark Defaults]

color.bg.reveng.tag = rgba(92,240,163,.06)
color.border.reveng.tag = rgba(92,240,163,.3)

color.fg.reveng.similarity.critical = #f26d6d
color.fg.reveng.similarity.high = #f08b3c
color.fg.reveng.similarity.medium = #f5c04a
color.fg.reveng.similarity.low = #47d17a

color.bg.reveng.diff.deleted = rgba(255,107,107,.15)
color.bg.reveng.diff.inserted = rgba(92,240,163,.15)
color.bg.reveng.diff.changed = rgba(255,180,84,.15)
color.bg.reveng.diff.placeholder = rgba(255,255,255,.03)

icon.reveng.mark.16 = images/reveng_16_dark.png
icon.reveng.mark.24 = images/reveng_24_dark.png
icon.reveng.mark.large = images/icon_dark.png
4 changes: 4 additions & 0 deletions ghidra_scripts/RevEngExamplePostScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
public class RevEngExamplePostScript extends GhidraScript {
@Override
protected void run() throws Exception {
if (currentProgram == null) {
printerr("No program open");
return;
}
// Services are not available in headless mode, so we have to instantiate it ourselves
var ghidraRevengService = new GhidraRevengService(ApiInfo.fromConfig(ReaiPluginPackage.DEFAULT_CONFIG_PATH));

Expand Down
134 changes: 134 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Installs the RevEng.AI Ghidra plugin and enables it in the CodeBrowser tool.
#
# irm https://raw.githubusercontent.com/RevEngAI/plugin-ghidra/main/install.ps1 | iex
#
# $env:GHIDRA_INSTALL_DIR target this Ghidra install instead of detecting one
# $env:REVENG_PLUGIN_VERSION release tag to install (default: latest)

& {
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Add-Type -AssemblyName System.IO.Compression, System.IO.Compression.FileSystem

$Repo = 'RevEngAI/plugin-ghidra'
$ExtName = 'plugin-ghidra'
$PluginPackage = 'RevEng.AI'
$SettingsRoot = Join-Path $env:APPDATA 'ghidra'

function Get-Prop($Ghidra, $Name) {
$line = Get-Content (Join-Path $Ghidra 'Ghidra\application.properties') |
Where-Object { $_ -like "$Name=*" } | Select-Object -First 1
$line.Substring($Name.Length + 1).Trim()
}

function Test-Ghidra($Dir) {
$Dir -and (Test-Path -LiteralPath (Join-Path $Dir 'Ghidra\application.properties'))
}

function Find-Installs {
$candidates = @()
$lastrun = Join-Path $SettingsRoot 'lastrun'
if (Test-Path $lastrun) { $candidates += (Get-Content $lastrun -Raw).Trim() }
$roots = @('C:\', $env:ProgramFiles, ${env:ProgramFiles(x86)}, 'C:\tools', $HOME,
"$HOME\Downloads", "$HOME\Desktop", "$HOME\scoop\apps\ghidra",
"$env:ProgramData\chocolatey\lib\ghidra\tools")
foreach ($root in $roots | Where-Object { $_ -and (Test-Path $_) }) {
foreach ($d in Get-ChildItem $root -Directory -ErrorAction SilentlyContinue) {
if ($d.Name -like 'ghidra*' -or $root -like '*ghidra*') {
$candidates += $d.FullName
$candidates += Get-ChildItem $d.FullName -Directory -Filter 'ghidra*' -ErrorAction SilentlyContinue |
ForEach-Object { $_.FullName }
}
}
}
$candidates | Where-Object { Test-Ghidra $_ } |
ForEach-Object { (Get-Item -LiteralPath $_).FullName.TrimEnd('\') } | Sort-Object -Unique
}

if ($env:GHIDRA_INSTALL_DIR) {
if (-not (Test-Ghidra $env:GHIDRA_INSTALL_DIR)) { throw "No Ghidra install at $env:GHIDRA_INSTALL_DIR" }
$ghidra = $env:GHIDRA_INSTALL_DIR
} else {
$installs = @(Find-Installs)
if ($installs.Count -eq 0) { throw 'No Ghidra install found; set $env:GHIDRA_INSTALL_DIR to its path' }
if ($installs.Count -eq 1) {
$ghidra = $installs[0]
} else {
Write-Host 'Ghidra installs found:'
for ($i = 0; $i -lt $installs.Count; $i++) {
Write-Host (" {0}) {1} {2}" -f ($i + 1), (Get-Prop $installs[$i] 'application.version'), $installs[$i])
}
$choice = Read-Host "Install into [1-$($installs.Count)]"
if ($choice -notmatch '^\d+$' -or [int]$choice -lt 1 -or [int]$choice -gt $installs.Count) { throw 'Invalid choice' }
$ghidra = $installs[[int]$choice - 1]
}
}

$version = Get-Prop $ghidra 'application.version'
$settings = Join-Path $SettingsRoot "ghidra_${version}_$(Get-Prop $ghidra 'application.release.name')"
Write-Host "Ghidra $version at $ghidra"

$running = Get-CimInstance Win32_Process -Filter "Name LIKE 'java%'" -ErrorAction SilentlyContinue |
Where-Object { $_.CommandLine -match 'ghidra\.GhidraRun' }
if ($running) { throw 'Ghidra is running; close it and rerun' }

$tmp = Join-Path ([IO.Path]::GetTempPath()) ([Guid]::NewGuid())
New-Item -ItemType Directory $tmp | Out-Null
try {
$asset = "ghidra_${version}_$ExtName.zip"
if ($env:REVENG_PLUGIN_VERSION) {
$url = "https://github.com/$Repo/releases/download/$env:REVENG_PLUGIN_VERSION/$asset"
} else {
$url = "https://github.com/$Repo/releases/latest/download/$asset"
}
$zip = Join-Path $tmp $asset
$unpacked = Join-Path $tmp 'x'
Write-Host "Downloading $url"
try {
Invoke-WebRequest $url -OutFile $zip -UseBasicParsing
} catch {
throw "No release build for Ghidra $version; see https://github.com/$Repo#building-your-own-plugin-for-custom-ghidra-forks-and-versions"
}

[IO.Compression.ZipFile]::ExtractToDirectory($zip, $unpacked)
if (-not (Test-Path (Join-Path (Join-Path $unpacked $ExtName) 'extension.properties'))) { throw 'Unexpected archive layout' }
$extensions = Join-Path $settings 'Extensions'
New-Item -ItemType Directory -Force $extensions | Out-Null
$target = Join-Path $extensions $ExtName
if (Test-Path $target) { Remove-Item -Recurse -Force $target }
Move-Item (Join-Path $unpacked $ExtName) $extensions
Write-Host "Installed to $target"

$tool = Join-Path (Join-Path $settings 'tools') '_code_browser.tcd'
if (-not (Test-Path $tool)) {
Write-Host 'CodeBrowser not configured yet; Ghidra will offer to enable the plugins when it opens.'
return
}

$jar = [IO.Compression.ZipFile]::OpenRead((Join-Path (Join-Path $target 'lib') "$ExtName.jar"))
try {
$plugins = $jar.Entries | ForEach-Object { $_.FullName } |
Where-Object { $_ -match '^ai/reveng/toolkit/ghidra/plugins/[^/$]*Plugin\.class$' } |
ForEach-Object { ($_ -replace '\.class$', '') -replace '/', '.' }
} finally { $jar.Dispose() }
if (-not $plugins) { throw "No plugins found in $ExtName.jar" }

Copy-Item $tool "$tool.bak" -Force
[xml]$xml = Get-Content $tool -Raw
$toolNode = $xml.TOOL_CONFIG.SelectSingleNode('TOOL')
foreach ($old in @($toolNode.SelectNodes("PACKAGE[@NAME='$PluginPackage']"))) { [void]$toolNode.RemoveChild($old) }
$package = $xml.CreateElement('PACKAGE')
$package.SetAttribute('NAME', $PluginPackage)
foreach ($plugin in $plugins) {
$include = $xml.CreateElement('INCLUDE')
$include.SetAttribute('CLASS', $plugin)
[void]$package.AppendChild($include)
}
[void]$toolNode.AppendChild($package)
$xml.Save($tool)
Write-Host "Enabled in CodeBrowser (backup: $tool.bak)"
} finally {
Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue
}
}
Loading
Loading