Repository navigation
feat(ghidra): admit bounded ARM/ARM64 PE targets on Windows P0 - #2631
WestLabsAI wants to merge 9 commits into
Conversation
Extend inspectWindowsP0TargetSupport to accept arm and arm64 PE applications and DLLs alongside x86/x86-64, mirroring the existing macOS ARM64 and Linux AArch64 Ghidra lanes. Ghidra's PE loader selects the language from the machine field (ARMNT -> ARM:LE:32:v8 Thumb, ARM64/ARM64EC -> AARCH64:LE:64:v8A), so no manual raw-binary language mapping is needed for PE targets. Update the capability description, the Windows P0 admission test, and docs/windows-ghidra-p0.md. Real-provider acceptance via source-built ARM64 PE fixtures and `npm run verify:ghidra` remains pending (MIPS precedent morluto#718); this change gates admission only. Refs morluto#2186 Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Extend create-ghidra-windows-fixture.mjs to emit ARM64 (machine 0xAA64) PE32+ EXE and DLL with hand-assembled AArch64 code: an entry-point-free DLL exporting fixture_caller (returns callee()+1 = 43) and fixture_return42 (returns 42), and an EXE whose entry calls the callee. No compiler, target loading or execution. Add --arm64 to verify-real-ghidra-windows.mjs (language AARCH64:LE:64:, shared caller/callee return-value readback; the x86/x64 compact-reference battery is skipped for ARM64), and to the Windows P0 fixture-admission test and docs. Verified locally with Ghidra 12.1.4 headless: both fixtures import as AARCH64:LE:64:v8A at image base 0x140000000; fixture_return42 decompiles to "return 0x2a;" and fixture_caller to "fixture_return42() + 1". The REA Windows P0 real-provider lane (npm run verify:ghidra:windows -- --arm64) still needs a host with the P0 native isolation addon. Refs morluto#2186 Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Added source-built ARM64 PE fixtures (EXE + DLL) per the scope review on #2186.
Verified locally with Ghidra 12.1.4 headless (both fixtures import as Still pending: the REA Windows P0 real-provider lane ( |
|
@greptileai review |
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: add1719f15
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da3e2e8fc3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| /** Target architectures admitted by the Windows P0 native PE boundary. */ | ||
| export const WINDOWS_P0_NATIVE_PE_ARCHITECTURES: readonly string[] = | ||
| Object.freeze(["x86", "x86_64", "arm", "arm64"]); |
There was a problem hiding this comment.
Keep pending ARM targets outside the admitted set
On a Windows x64 installation, adding arm and arm64 here makes inspectWindowsP0TargetSupport report them as supported even though docs/windows-ghidra-p0.md:124-126 says real Windows verification is still pending. I checked .github/workflows/real-ghidra-windows.yml:59-90; it runs only x64/x86 targets and their package variants, and the repository has no ARM fixture at all, so these production paths become selectable before either architecture has the required real-provider proof. Leave both values fail-closed until those lanes pass.
AGENTS.md reference: AGENTS.md:L7-L7
Useful? React with 👍 / 👎.
|
Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open. Source changes are on da3e2e8. The handcrafted ARM64 caller now saves/restores X29/X30 around BL using an aligned 16-byte stack frame. The callee moved to RVA 0x1020; branch displacement, export RVA and verifier selectors were updated together, and the separate reference control moved past the callee. The return/control layout was inspected from source; actual Windows Ghidra execution remains unverified. Source inspection and git diff checks completed. Tests, typecheck/lint, generated-schema checks and real-provider lanes were not run for this final revision at the user's explicit request. Source changes are on da3e2e8. Removed ARM64EC from the ARM64-machine claim. Documentation now states that machine 0xAA64 is the ARM64 lane and that ARM64EC 0xA641 is distinct and not admitted; no unsupported-machine capability was enabled. Source inspection and git diff checks completed. Tests, typecheck/lint, generated-schema checks and real-provider lanes were not run for this final revision at the user's explicit request. Source changes are on da3e2e8. Windows P0 target architectures now have one exported capability owner, consumed by admission and the verifier receipt. The receipt reports that exact supported_target_architectures list and a native-PE role limitation, removing the stale x86-only contradiction for an ARM64 target. Source inspection and git diff checks completed. Tests, typecheck/lint, generated-schema checks and real-provider lanes were not run for this final revision at the user's explicit request. Source changes are on da3e2e8. Removed the ARM64EC alias claim and documented its distinct, unadmitted machine identity (0xA641 versus ARM64 0xAA64). The bounded provider continues to use the parsed architecture rather than silently accepting an ARM64EC image. Source inspection and git diff checks completed. Tests, typecheck/lint, generated-schema checks and real-provider lanes were not run for this final revision at the user's explicit request. Source changes are on da3e2e8. Corrected the guide to use npm run verify:ghidra:windows -- --arm64 (plus --dll) and label these fixtures handcrafted rather than compiler-produced. The host remains the existing controlled Windows x64 boundary. Actual ARM/ARM64 Windows Ghidra verification and compiler-produced coverage have not run; keeping this verification hold open before integration. Source inspection and git diff checks completed. Tests, typecheck/lint, generated-schema checks and real-provider lanes were not run for this final revision at the user's explicit request. Source changes are on da3e2e8. Updated installation, native, managed, MIPS, testing and provider support consumers together with the Windows guide. They distinguish the ARM/ARM64 PE admission list, handcrafted verifier modes, unsupported ARM64EC, and pending real Windows/compiler-produced verification. No guide claims those pending runs completed. Source inspection and git diff checks completed. Tests, typecheck/lint, generated-schema checks and real-provider lanes were not run for this final revision at the user's explicit request. |
|
Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open. The documentation now uses npm run verify:ghidra:windows -- --arm64 (with --dll where appropriate) and correctly labels the PE fixtures handcrafted. The stale behavior-test verification note is corrected in the final follow-up too. Source inspection confirms the command maps to the Windows verifier and the fixture generator; no tests or provider workloads were run at the user's explicit request. This documentation finding is handled. Actual Windows ARM/ARM64 proof and the separate admission/integration hold remain unresolved. |
|
Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open. Changes are on 2eeac79. This is an unresolved admission/integration proof requirement. The contribution branch still contains the bounded ARM/ARM64 admission prototype; existing x64/x86 Windows verification does not prove these target architectures. No maintainer approval or real Windows ARM/ARM64 result is available, so this thread remains open and must block integration. Source validation: Inspected the admitted architecture set, verification commands and pending-proof documentation. No tests or provider workloads were run, and no PR was merged. A maintainer scope decision and required ARM/ARM64 verification remain necessary. Tests, checks, builds, lint/typechecks, provider workloads and CI reruns were not run at the user's explicit request. Targeted formatting used the pinned Node toolchain with two formatter threads. Changes are on 2eeac79. The source verifier's --arm64 flag was incorrectly advertised for the packaged verifier, which does not implement it. Documentation now explicitly limits the package lane to --x86 and --dll and states that --arm64 is unavailable there. Source validation: Inspected the packaged argument parser and target assertions. This corrects the advertised contract without claiming an unimplemented or unexecuted packaged ARM lane; the separate admission/proof hold remains open. Tests, checks, builds, lint/typechecks, provider workloads and CI reruns were not run at the user's explicit request. Targeted formatting used the pinned Node toolchain with two formatter threads. Changes are on 2eeac79. The behavior-test note named the Linux/macOS verifier and mislabeled handcrafted PE bytes as source-built. It now names npm run verify:ghidra:windows -- --arm64 and explicitly leaves compiler-produced coverage pending. Source validation: Inspected the Windows fixture generator and verifier command mapping. No Windows/provider execution was performed; this documentation finding is handled separately from the integration hold. Tests, checks, builds, lint/typechecks, provider workloads and CI reruns were not run at the user's explicit request. Targeted formatting used the pinned Node toolchain with two formatter threads. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd71b1ffe0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| /** Target architectures admitted by the Windows P0 native PE boundary. */ | ||
| export const WINDOWS_P0_NATIVE_PE_ARCHITECTURES: readonly string[] = | ||
| Object.freeze(["x86", "x86_64", "arm", "arm64"]); |
There was a problem hiding this comment.
Keep unverified ARM targets out of the admitted set
On an otherwise available Windows x64 installation, any native ARM/ARM64 PE application or DLL now receives supported, allowing provider selection even though the changed guide explicitly says real Windows verification remains pending (docs/windows-ghidra-p0.md:132-134), the checked .github/workflows/real-ghidra-windows.yml:79-110 still runs only the default/x86 modes, and docs/ghidra-provider.md:197-200 says the package CLI/MCP lane does not implement ARM64; 32-bit ARM has no fixture or verifier mode at all. Fresh evidence after the earlier review is this final tree's explicit pending-verification text plus the still-unchanged x86/x64 workflow, so leave arm/arm64 out of the production set until the matching real public/provider lanes pass.
AGENTS.md reference: AGENTS.md:L7-L7
Useful? React with 👍 / 👎.
| diagnostics, | ||
| }; | ||
| if (target.architecture !== "x86" && target.architecture !== "x86_64") | ||
| if (!WINDOWS_P0_NATIVE_PE_ARCHITECTURES.includes(target.architecture)) |
There was a problem hiding this comment.
Preserve the PE machine before admitting ARM
For a native PE whose COFF machine is 0x01c0 (ARM) or 0x01c2 (THUMB), decodePeMachine maps it to the same arm family as ARMNT (src/domain/peMachine.ts:14-21) and BinaryTarget discards the machine, so this new architecture-only check admits those legacy variants too. The changed boundary identifies only IMAGE_FILE_MACHINE_ARMNT and its ARM:LE:32:v8 import (docs/windows-ghidra-p0.md:126-128), while the other machine values have no fixture or provider proof; carry the parsed PE machine into target support and restrict admission to the proven variant.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
|
Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open. Changes are on 2eeac79. This is an unresolved admission/integration proof requirement. The contribution branch still contains the bounded ARM/ARM64 admission prototype; existing x64/x86 Windows verification does not prove these target architectures. No maintainer approval or real Windows ARM/ARM64 result is available, so this thread remains open and must block integration. Source validation: Inspected the admitted architecture set, verification commands and pending-proof documentation. No tests or provider workloads were run, and no PR was merged. A maintainer scope decision and required ARM/ARM64 verification remain necessary. Tests, checks, builds, lint/typechecks, provider workloads and CI reruns were not run at the user's explicit request. Targeted formatting used the pinned Node toolchain with two formatter threads. |
Resolve conflicts:
- docs/ghidra-provider.md: keep the ARM64 verify-lane description, adopt
main's updated 26-read-only-operation count.
- GhidraProvider.behavior.test.ts: adopt main's installationHost("win32")
helper call, keep arm64 in the fixture-admission loop, and drop the now
unsatisfiable architecture_unsupported assertion in the native-failure
diagnostics test (every PE header architecture -- x86, x86_64, arm, arm64
-- is admitted on Windows P0).
Verified after merge: check:fast (typecheck + lint) and
GhidraProvider.behavior.test.ts (67/67) pass; ARM64 fixtures re-checked with
Ghidra 12.1.4 (fixture_return42 -> 42, fixture_caller -> 43, callee at RVA
0x1020, AARCH64:LE:64:v8A).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
TL;DR: The Windows gate now admits ARM64 as the PR says, and the ARM64 files it ships read back right in Ghidra on Linux. I could not run the Windows check this PR waits on. Head conflicts with main, and three Codex threads are still open. I tested head ffea1d8 as pushed against main 70cd4cb. Applying the PR diff to main fails in two files. They are the fixture script and the Windows verifier. Results
The "Windows gate" rows ask the provider about each parsed file. The provider has a fake Windows host description. This does not run Ghidra on Windows. The two failures in the second row say ARM64 was expected to be supported and was not. The two src files at the merge base match main's copies. The Ghidra rows use the Linux path. It already accepts ARM64 on main, and main gives the same caller result. So these rows check the fixture bytes, not the new gate. The caller saves x29 and x30, calls the helper, adds 1, and restores both. So the first review's return bug is fixed. I also built an ARM64 DLL and EXE with clang. Head admits both and main rejects both. Open Codex thread, confirmed: I patched the machine field of the PR's x86 fixture to 0x01c0, 0x01c2 and 0x01c4. These are header-only stubs with no ARM code. Head admits all three. The docs name only one ARM machine type. ARM64EC (0xa641) fails to parse on both main and head. Not run
Thanks, WestLabs, for the ARM64 fixtures and the clear scope notes. Another test job ran on this box. Load average (busy tasks over 1 minute, on 24 threads) was about 3. Ghidra readbackGhidra imported the PR's DLL as AARCH64:LE:64:v8A at base 0x140000000. The caller disassembles to stp x29, x30; bl 0x140001020; add w0, w0, #1; ldp x29, x30; ret. I built the second pair with clang 22.1.8 (Apache-2.0 WITH LLVM-exception OR NCSA). Ghidra reads them as AARCH64:LE:64:v8A at base 0x180000000. The compiler folded the call, so the caller returns 43 directly. Test setupCommandsThe gate check is a short script. It builds a provider with a fake win32 host. It parses each file and prints the gate answer. It ran against the built dist of main and of head. Each run sat under systemd-run --user --scope -p MemoryMax=6G. 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Ran the Windows check this PR is waiting on, Host: Windows 11 Pro x64 (build 26300), not a Windows on Arm device. Node 24.18.0, head
Both reports show Not run: 32-bit ARM PE with real code (so nothing new on the open Codex thread about the 0x01c0, 0x01c2 and 0x01c4 stubs), ARM64EC, head merged onto main, a Windows on Arm device, Node 22. Fixtures and commands
Edit: the baseline row first named main |
|
Closing — this is superseded by #3965 ("feat(ghidra): admit ARM PE targets on Windows"), which is merged and builds on this PR. #2186 is fixed there. The merged implementation refines what was proposed here (COFF-machine guard requiring ARMNT Thanks @N0zoM1z0 for carrying it to completion, and @pablodiazjorge and @CassieFox23 for the real Windows-x64 and Linux verification of the ARM64 fixtures. |
What
Extend the Windows Ghidra P0 admission boundary to accept native ARM and
ARM64 PE applications and DLLs, alongside the existing x86 / x86-64 lane.
Addresses #2186 and the scope review there.
Why
inspectWindowsP0TargetSupportcurrently rejects every non-x86 target, while thegeneral (non-Windows) provider already treats
arm/arm64as first-classarchitectures (
SUPPORTED_ARCHITECTURES). The refusal is a P0 policy gate, not anengine limitation — Ghidra analyses ARM PE/firmware fine on Windows with the
P0-documented toolchain (Ghidra 12.1.4 + JDK 21).
Scope (bounded)
P0 constraint is unchanged: PE-only, application/shared-library role,
native/non-managed, NTFS path admission, read-only operation set, no DB mutation.
(
ARMNT→ARM:LE:32:v8Thumb;ARM64/ARM64EC→AARCH64:LE:64:v8A), so noraw-binary language mapping is needed here.
Out of scope: raw/headerless ARM (incl. Cortex-M / Thumb-only firmware) — a
separate raw-binary-on-Windows follow-up (
docs/raw-binary.md).Changes
src/ghidra/GhidraProvider.ts— admitarm/arm64ininspectWindowsP0TargetSupportsrc/ghidra/GhidraProviderCapabilities.ts— capability descriptionsrc/ghidra/GhidraProvider.behavior.test.ts— Windows P0 admission test updateddocs/windows-ghidra-p0.md— supported boundary, language mapping, verification noteVerification
npm run check:fast(typecheck + lint): passGhidraProvider.behavior.test.ts: 49/49 passStill pending (per the #718 MIPS precedent): source-built ARM64 PE fixtures
(EXE + DLL) with verified function entry + decompiler readback, confirmed on a
Windows-on-Arm host via
npm run verify:ghidra. This PR gates admission only;it should not merge before that real-provider verification lands. Opening as a
draft for that reason.
🤖 Generated with Claude Code