mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 21:23:45 +00:00
* fix(managed): preserve duplicate GUID stream ambiguity * fix(managed): preserve ambiguous metadata stream declarations (#12226) Use one stream declaration owner for heap and table diagnostics. Keep user strings and row-layout uncertainty separate from independent PE/CLI observations. * test(managed): separate heap entries from cache behavior * fix(managed): preserve duplicate blob heap ambiguity (#12258) Resolve #Blob in the shared stream layout. Preserve nil references and independent facts without emitting unsupported keys, signatures or hashes.
66 lines
2.5 KiB
TypeScript
66 lines
2.5 KiB
TypeScript
import { buildManagedNestedTypeFixture } from "../../src/dotnet/ManagedPe.fixture.js";
|
|
import { readManagedPeLayout } from "../../src/domain/managed/managedPeReader.js";
|
|
import {
|
|
metadataRowOffset,
|
|
readManagedMetadataLayout,
|
|
} from "../../src/domain/managed/managedMetadataLayout.js";
|
|
import {
|
|
metadataRowCursor,
|
|
readMetadataBlob,
|
|
} from "../../src/domain/managed/managedMetadataHeaps.js";
|
|
import { readMethodDefinitionRow } from "../../src/dotnet/ManagedMethodDefinitionRows.js";
|
|
|
|
/** Two nested Inner declarations, one with its own Fixture namespace. */
|
|
export const namespaceBearingNestedTypes = () => {
|
|
const bytes = buildManagedNestedTypeFixture();
|
|
const pe = readManagedPeLayout(bytes);
|
|
if (pe.cli === null) throw new Error("Missing fixture CLI");
|
|
const layout = readManagedMetadataLayout(
|
|
bytes,
|
|
pe.rvaToOffset(pe.cli.metadata.rva, pe.cli.metadata.size, "fixture"),
|
|
pe.cli.metadata.size,
|
|
);
|
|
const column = 4 + layout.stringIndexSize;
|
|
const namespace = bytes.readUInt16LE(
|
|
metadataRowOffset(layout, 2, 2) + column,
|
|
);
|
|
bytes.writeUInt16LE(namespace, metadataRowOffset(layout, 2, 4) + column);
|
|
return bytes;
|
|
};
|
|
|
|
/** Same selected display, different enclosing owner, primitive signatures and CIL. */
|
|
export const distinctSelectedNestedOwners = () => {
|
|
const left = namespaceBearingNestedTypes();
|
|
const right = Buffer.from(left);
|
|
for (const [index, bytes] of [left, right].entries()) {
|
|
const pe = readManagedPeLayout(bytes);
|
|
if (pe.cli === null) throw new Error("Missing fixture CLI");
|
|
const layout = readManagedMetadataLayout(
|
|
bytes,
|
|
pe.rvaToOffset(pe.cli.metadata.rva, pe.cli.metadata.size, "fixture"),
|
|
pe.cli.metadata.size,
|
|
);
|
|
const method = readMethodDefinitionRow(bytes, layout, 1);
|
|
if (index === 1) {
|
|
bytes.writeUInt16LE(3, metadataRowOffset(layout, 41, 1) + 2);
|
|
readMetadataBlob(bytes, layout, method.signatureIndex)[2] = 0x0a;
|
|
const field = metadataRowCursor(bytes, layout, 4, 1);
|
|
field.u16();
|
|
field.readIndex(layout.stringIndexSize);
|
|
readMetadataBlob(
|
|
bytes,
|
|
layout,
|
|
field.readIndex(layout.blobIndexSize),
|
|
)[1] = 0x0a;
|
|
}
|
|
// All three MethodDefs share this fixture body and signature. Tiny bodies
|
|
// avoid unresolved MemberRefs and keep the two signatures and shapes distinct.
|
|
const body =
|
|
index === 0
|
|
? Buffer.from([0x0a, 0x17, 0x2a])
|
|
: Buffer.from([0x2a, 0x21, 2, 0, 0, 0, 0, 0, 0, 0, 0x2a]);
|
|
bytes.set(body, pe.rvaToOffset(method.rva, body.length, "fixture CIL"));
|
|
}
|
|
return { left, right };
|
|
};
|