Skip to content

feat(ghidra): support native PE DLLs on Windows - #1303

Merged
morluto merged 4 commits into
morluto:mainfrom
kvalls:codex/windows-ghidra-native-dlls
Oct 10, 2026
Merged

morluto merged 4 commits into
morluto:mainfrom
kvalls:codex/windows-ghidra-native-dlls

Conversation

@kvalls

@kvalls kvalls commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Windows Ghidra currently rejects native PE DLLs before import even when the matching Windows native controls are available. This extends the existing read-only provider to native x86 and x64 DLLs, preserving their shared-library identity.

Fixes #1290. Please review the implementation and Windows verification coverage.

Change and scope

  • Admit PE shared libraries alongside applications; retain managed-image, unsupported-architecture and non-executable refusals.
  • Record the observed PE role and managed flag in analysis profiles.
  • Generate original PE32/PE32+ DLL fixtures with two exported caller/callee functions, no imports and no entry routine. Existing EXE fixtures remain byte-identical to the base.
  • Extend the raw and packaged Windows verification lanes and guarded Windows workflow to both DLL architectures.
  • Run packaged verification in a child so the parent can remove the temporary installation after Windows releases the loaded REA addon. The initial package test exposed this cleanup failure after its analysis checks passed.
  • Update the owning Windows/provider documentation.

Contract and boundary impact

  • Semantic owner: Windows target admission in GhidraProvider.
  • CLI/MCP and tool catalog: existing operations and schemas; no new tool or permission switch.
  • Evidence/profile: PE profiles additionally commit to executable_role and managed, so PE profile IDs change. Non-PE profile parameters stay unchanged.
  • Authority and cleanup: static import of an immutable snapshot, read-only Windows capabilities, native handle admission, DACLs, authenticated transport and Job Object ownership retained. Target DLLs are not loaded or executed.
  • Package/setup: no dependency, version, installation or client-registration changes. Generated outputs remain ignored.

Validation performed

On Windows 11 x64, Node 24.18.0/npm 11.16.0, Ghidra 12.1.4 and JDK 25.0.4.1+1:

  • npm run build:cached, npm run check and npm run docs:check passed.
  • npm run test:focused -- src/ghidra/GhidraProvider.behavior.test.ts tests/conformance/providers/ghidra/realGhidraWindowsWorkflow.test.ts: 28 tests passed. The missing-native-control case ran with the ignored addon absent; it was restored for real-provider checks.
  • npm run verify:windows-native:artifact and npm run verify:windows-native passed, including protected DACLs, immutable snapshots, rejected junctions/streams/forged handles, cancellation and descendant cleanup.
  • node scripts/verify-real-ghidra-windows.mjs --dll and --x86 --dll: both passed all 25 read-only operations, the known return value and caller/callee relationship, digest linkage and cleanup.
  • npm run verify:ghidra:windows:package -- --dll and -- --x86 --dll: both passed against packed artifacts installed into isolated prefixes, including ordinary-user CLI/MCP, shared-library profile identity, unchanged source hashes, caller-directory collision preservation and empty runtime cleanup.

The matching addon was built locally from unchanged upstream C++ sources using MSVC 14.44 and Node-API 8. The canonical Linux/MinGW artifact build and protected upstream runner were not run locally. Static lint completed with existing warnings and zero errors. Full deterministic coverage is left to CI. Managed DLLs, other target architectures and Windows NativeAOT metadata recovery were not added or tested.

@morluto
morluto marked this pull request as ready for review October 10, 2026 05:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T05:53:51.955286Z ea1dbda New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@morluto
morluto merged commit a957f39 into morluto:main Oct 10, 2026
19 checks passed
@morluto

morluto commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Looks good, thank you Kvalls!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea1dbda1c7

ℹ️ 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".

Comment on lines +33 to +35
const [packageRootArgument, targetArgument, reportArgument] =
fixtureArguments.filter(
(argument) => argument !== "--x86" && argument !== "--dll",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep custom targets in the target slot after --x86

When callers use the pre-existing --x86 <target> [report] form, removing the flag before destructuring promotes <target> to packageRootArgument; prior to this commit argv[3] was resolved as the target while the current tree was packed. The verifier therefore tries to import dist below the executable (and can treat the report path as the target), so this custom-x86 verification no longer runs against the selected binary; preserve the positional meaning for a leading fixture flag or introduce unambiguous named options.

AGENTS.md reference: AGENTS.md:L11-L11

Useful? React with 👍 / 👎.

await writeFile(reportArgument, `${JSON.stringify(report)}\n`);
process.stdout.write(`${JSON.stringify(report)}\n`);
process.stderr.write(result.stderr);
process.exit(0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Flush packaged proof streams before exiting

When the Windows package lanes pipe this process through Tee-Object in .github/workflows/real-ghidra-windows.yml, stdout and stderr are pipe-backed and the explicit process.exit(0) may terminate before the two preceding writes flush. A run can therefore report success while its JSON proof or captured child diagnostics is truncated or missing; let the parent branch finish only after those writes complete rather than forcing exit.

AGENTS.md reference: AGENTS.md:L11-L11

Useful? React with 👍 / 👎.

darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
…ve-dlls

feat(ghidra): support native PE DLLs on Windows
@morluto morluto added enhancement New feature or request area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@morluto morluto added the provider: ghidra Analysis provider / engine: ghidra label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Support native x86/x64 PE DLLs in the Windows Ghidra provider

2 participants