mirror of
https://github.com/morluto/rea
synced 2026-10-26 06:16:17 -04:00
fix(managed): distinguish metadata handles from member accesses (#607)
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
adc07f5eaa
commit
c73742f300
@@ -182,6 +182,7 @@ export const edges = (
|
||||
const fieldAccesses: ManagedFieldAccess[] = [];
|
||||
for (const method of methods) {
|
||||
for (const anchor of method.body.anchors) {
|
||||
if (anchor.opcode === "ldtoken") continue;
|
||||
if (anchor.operand_kind === "method" && anchor.operand !== null) {
|
||||
const named =
|
||||
methodCore.get(anchor.operand)?.name ??
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { inspectManagedMembersBytes } from "./ManagedMemberInspector.js";
|
||||
import {
|
||||
buildManagedPeFixture,
|
||||
managedPeFixtureTarget,
|
||||
} from "./ManagedPe.fixture.js";
|
||||
|
||||
it("retains metadata handles without reporting calls or field accesses", () => {
|
||||
const il = Buffer.from([
|
||||
0xd0, 0x01, 0, 0, 0x06, 0x26, 0xd0, 0x01, 0, 0, 0x04, 0x26, 0x28, 0x01, 0,
|
||||
0, 0x0a, 0x7b, 0x01, 0, 0, 0x04, 0x26, 0x2a,
|
||||
]);
|
||||
const bytes = buildManagedPeFixture({
|
||||
ilBody: Buffer.concat([Buffer.from([(il.length << 2) | 2]), il]),
|
||||
});
|
||||
const result = inspectManagedMembersBytes(
|
||||
bytes,
|
||||
managedPeFixtureTarget(bytes),
|
||||
);
|
||||
expect(
|
||||
result.methods[0]?.body.anchors.map((anchor) => anchor.opcode),
|
||||
).toEqual(["ldtoken", "ldtoken", "call", "ldfld"]);
|
||||
expect(result.call_edges.map((edge) => edge.opcode)).toEqual(["call"]);
|
||||
expect(result.field_accesses.map((access) => access.opcode)).toEqual([
|
||||
"ldfld",
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user