diff --git a/scripts/verify/baselines/raw-buffer-read.json b/scripts/verify/baselines/raw-buffer-read.json index 0be587a8d0..2563cd0c6f 100644 --- a/scripts/verify/baselines/raw-buffer-read.json +++ b/scripts/verify/baselines/raw-buffer-read.json @@ -2,7 +2,7 @@ "src/domain/apple/machoLoadCommandReader.ts": 2, "src/domain/desktop/openPgpKeys.ts": 2, "src/domain/managed/managedMetadataInventoryRows.ts": 2, - "src/native/AppleDispatchMetadata.ts": 4, + "src/native/AppleDispatchMetadata.ts": 1, "src/native/AppleObjcDispatchFacets.ts": 1, "src/native/AppleSwiftDispatchFacets.ts": 1, "src/native/elf/ElfNoteParser.ts": 6, diff --git a/src/native/AppleDispatchMetadata.ts b/src/native/AppleDispatchMetadata.ts index fcc40eebb4..a0fda5513e 100644 --- a/src/native/AppleDispatchMetadata.ts +++ b/src/native/AppleDispatchMetadata.ts @@ -47,7 +47,10 @@ import { readBoundedFileBytes } from "../process/BoundedFileBytes.js"; import { EvidenceIntegrityError } from "../domain/evidenceErrors.js"; import { pushDispatchCoverage } from "./AppleDispatchCoverage.js"; import { parsePointerFixupsSteps } from "../domain/apple/appleMachoFixups.js"; -import { BinaryFormatFailure } from "../domain/binaryContainer.js"; +import { + BinaryFormatFailure, + BinaryReader, +} from "../domain/binaryContainer.js"; import { parseMachoLayout } from "../domain/apple/appleMachoSelection.js"; import { selectMachoSlice, @@ -102,6 +105,7 @@ export function* decodeAppleDispatchMetadataSteps( } const layout = parseMachoLayout(bytes, selected.value); const { segments, sections, offset } = layout; + const metadata = new BinaryReader(bytes, true, "macho"); const fixups = yield* parsePointerFixupsSteps( bytes, layout.fixups, @@ -116,9 +120,10 @@ export function* decodeAppleDispatchMetadataSteps( addressesComplete: objcClassImportAddressesComplete, maxRecords, }); - const u32 = (address: bigint) => bytes.readUInt32LE(offset(address, 4)); + const u32 = (address: bigint) => metadata.u32(offset(address, 4)); + const u64 = (address: bigint) => metadata.word(offset(address, 8), 64); const decodePointer = (address: bigint) => - fixups.decode(address, bytes.readBigUInt64LE(offset(address, 8))); + fixups.decode(address, u64(address)); /** In-image target of a raw or rebased pointer; a bind is not an address. */ const pointer = (address: bigint) => { const decodedPointer = decodePointer(address); @@ -212,7 +217,7 @@ export function* decodeAppleDispatchMetadataSteps( const readers = { u32, i32: (address: bigint) => bytes.readInt32LE(offset(address, 4)), - u64: (address: bigint) => bytes.readBigUInt64LE(offset(address, 8)), + u64, pointer, resolvePointer: decodePointer, bound,