Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
fix(dotnet): inspect native boundaries of non-managed and malformed PEs
Kaoru0822d98dcfa8c2e4
diff --git a/src/dotnet/ManagedNativeBoundaryInspector.test.ts b/src/dotnet/ManagedNativeBoundaryInspector.test.tsindex a33c803bf..978110590 100644--- a/src/dotnet/ManagedNativeBoundaryInspector.test.ts+++ b/src/dotnet/ManagedNativeBoundaryInspector.test.ts@@ -101,4 +101,32 @@ describe("managed native boundaries", () => {expect.objectContaining({ code: "invalid-metadata-root" }),]);});++ it("reports unavailable boundaries for native and malformed PE files", () => {+ const nativeBytes = buildNativePeFixture();+ const native = inspectManagedNativeBoundariesBytes(+ nativeBytes,+ managedPeFixtureTarget(nativeBytes),+ );+ expect(native).toMatchObject({+ metadata: { status: "absent" },+ pinvoke_imports: [],+ coverage: { state: "unavailable", issues: [] },+ });++ const malformedBytes = buildManagedPeFixture({+ corruptMetadataSignature: true,+ });+ const malformed = inspectManagedNativeBoundariesBytes(+ malformedBytes,+ managedPeFixtureTarget(malformedBytes),+ );+ expect(malformed).toMatchObject({+ metadata: { status: "malformed" },+ coverage: {+ state: "unavailable",+ issues: [expect.objectContaining({ code: "invalid-metadata-root" })],+ },+ });+ });});diff --git a/src/dotnet/ManagedNativeBoundaryInspector.ts b/src/dotnet/ManagedNativeBoundaryInspector.tsindex 9fd96790b..e3f82c7cb 100644--- a/src/dotnet/ManagedNativeBoundaryInspector.ts+++ b/src/dotnet/ManagedNativeBoundaryInspector.ts@@ -29,10 +29,11 @@ import {type Inventory = ReturnType<typeof readManagedMetadataInventory>;+/** Report a PE whose CLI data is absent or cannot be admitted. */const emptyInspection = (target: BinaryTarget,bytes: Buffer,- classification: "not-managed" | "malformed" | "not-available" | "managed",+ classification: "not-managed" | "malformed",issues: readonly ManagedParseIssue[] = [],): ManagedNativeBoundaryInspection =>managedNativeBoundaryInspectionSchema.parse({@@ -44,10 +45,7 @@ const emptyInspection = (},module: null,metadata: {- status:- classification === "malformed" || classification === "not-available"- ? "malformed"- : "absent",+ status: classification === "malformed" ? "malformed" : "absent",version: null,table_row_counts: {},},@@ -75,7 +73,7 @@ const emptyInspection = (ready_to_run: false,mixed_mode_or_native_header: false,},- coverage: { state: classification, issues },+ coverage: { state: "unavailable", issues },limitations: ["No CLI data was admitted; native boundary declarations are unavailable.","Static inspection does not load or execute target code, so native export resolution is not performed.",