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(native): count Swift vtable coverage in slot units
morlutof789fd1fd8c6
diff --git a/docs/native-investigation.md b/docs/native-investigation.mdindex 64417b7ed..22cd35468 100644--- a/docs/native-investigation.md+++ b/docs/native-investigation.md@@ -425,6 +425,8 @@ complete observation.vtable descriptors. Records include exact virtual addresses/file offsets andartifact evidence. Vtable indexes are metadata word offsets; witness indexesstart after the conformance header. Names unavailable in metadata remain null.+ The `swift_class_vtable_descriptors` coverage counters count examined vtable+ slots and successfully decoded slots, rather than type-section entries.Pointers are decoded through the image's fixups:- `LC_DYLD_CHAINED_FIXUPS` rebases and binds, including the authenticatedarm64e formats;diff --git a/src/native/AppleDispatchMetadata.test.ts b/src/native/AppleDispatchMetadata.test.tsindex 5bff9c138..6a46b9bac 100644--- a/src/native/AppleDispatchMetadata.test.ts+++ b/src/native/AppleDispatchMetadata.test.ts@@ -906,7 +906,12 @@ describe("malformed Apple dispatch metadata", () => {const coverage = result.coverage.find(({ facet }) => facet === "swift_class_vtable_descriptors",);- expect(coverage).toMatchObject({ status: "partial", examined: 3 });+ expect(coverage).toMatchObject({+ status: "partial",+ examined: 2,+ decoded: 2,+ reason: expect.stringContaining("class name is empty"),+ });});it("rejects malformed command and section boundaries", () => {diff --git a/src/native/AppleSwiftVtables.test.ts b/src/native/AppleSwiftVtables.test.tsindex fe79b955e..5873de933 100644--- a/src/native/AppleSwiftVtables.test.ts+++ b/src/native/AppleSwiftVtables.test.ts@@ -8,13 +8,13 @@ import type { DispatchRecordBudget } from "./AppleSwiftDispatchFacets.js";import { issue } from "./AppleDispatchDecodeFacts.js";describe("Swift vtable coverage facts: unresolved Swift dispatch slots", () => {- it("returns a located issue for an emitted unresolved async slot", () => {+ it("counts examined slots and reports an unresolved async slot", () => {const result = objcSwiftMetadataSchema.parse({ db_save_result: null });const values = new Map<bigint, number>([[0x200n, 0x80000010], // class descriptor with a vtable[0x22cn, 0], // table offset- [0x230n, 1], // slot count- [0x21cn, 1], // descriptor positive words+ [0x230n, 2], // slot count+ [0x21cn, 2], // descriptor positive words[0x234n, 0x40], // async method flag]);const facts = decodeSwiftClassVtables({@@ -41,14 +41,17 @@ describe("Swift vtable coverage facts: unresolved Swift dispatch slots", () => {artifact_sha256: "a".repeat(64),},],- executable: () => false,+ executable: (address) => address === 0x400n,admit: () => true,},});expect(result.swift_dispatch_slots[0]?.decode.status).toBe("partial");+ expect(result.swift_dispatch_slots[1]?.decode.status).toBe("decoded");expect(facts).toMatchObject({facet: "swift_class_vtable_descriptors",+ examined: 2,+ decoded: 1,exhaustive: false,issues: [{ code: "vtable_implementation_unresolved", location: "0x234" }],});@@ -88,6 +91,8 @@ describe("Swift vtable coverage facts: unresolved Swift dispatch slots", () => {),).toMatchObject({status: "partial",+ examined: 2,+ decoded: 1,reason: expect.stringContaining("0x234"),});});diff --git a/src/native/AppleSwiftVtables.ts b/src/native/AppleSwiftVtables.tsindex 9a9c74308..a680957ac 100644--- a/src/native/AppleSwiftVtables.ts+++ b/src/native/AppleSwiftVtables.ts@@ -25,6 +25,8 @@ export const decodeSwiftClassVtables = (input: {const { readers: read, result } = input;const failures: string[] = [];const issues = [] as ReturnType<typeof issue>[];+ // Coverage counts vtable slots, matching `decoded`; descriptor entries are+ // a discovery input and are not slot records.let examined = 0;let decoded = 0;for (const field of input.entries) {@@ -40,7 +42,6 @@ export const decodeSwiftClassVtables = (input: {);break;}- examined++;try {const descriptor = read.relative(field);const flags = read.u32(descriptor);@@ -84,6 +85,7 @@ export const decodeSwiftClassVtables = (input: {);break;}+ examined++;const methodFlags = read.u32(entry);// Async slots reference async descriptors; coroutine and future kinds need separate decoders.const synchronous =