mirror of
https://github.com/morluto/rea.git
synced 2026-12-01 00:29:08 +00:00
fix(errors)!: align unsupported-signature status and split invalid-method-token at its producer (#14230)
* fix(managed)!: report an unsupported signature as partial metadata, not malformed The refusal path already treats `unsupported-signature` as a valid form outside decoder coverage, but `managedMetadataFailureStatus` still called it malformed. One predicate, `isManagedCoverageGap`, now owns that split for both the refusal and the inventory status. Value retention no longer reads the inventory status: one value's unsupported signature is still retained locally, while a budget or an unsupported metadata layout still stops the whole read. BREAKING CHANGE: when a managed reader stops on `unsupported-signature`, `metadata.status` is `partial` (was `malformed`) in managed artifact, member and native-boundary inspection, and the artifact `classification.status` is `managed` (was `malformed`). The field names and enum members are unchanged. * fix(il2cpp)!: refuse a reused or non-MethodDef token as malformed metadata `invalid-method-token` covered two facts. A MethodDef row reused within one image, or a token that is not a nonzero MethodDef row, is in the metadata's own records; a row past the module's method pointers is a disagreement between two files that both parse. The metadata reader now checks each image's tokens while reading link facts and raises `invalid-method-definition-token`, which the provider already refuses as a malformed target at the metadata's path. The linker keeps `invalid-method-token` for the cross-file range check only and drops its own duplicate scan. BREAKING CHANGE: a duplicate or non-MethodDef method token found while linking is `unsupported_target` with `details.path` the metadata file, `details.format` `il2cpp-metadata`, `details.format_failure` `malformed` and `details.reason` starting `invalid-method-definition-token:` (was an `invalid_request` link conflict naming `path` and `binary_path` with reason `invalid-method-token`). A token past the module's method pointers keeps the conflict and the `invalid-method-token` reason.
This commit is contained in:
1 parent
0af067d766
commit
eb6c281fec
12 files changed
+239
-71
No files matched your search
@@ -148,25 +148,6 @@ function* linkImageSteps(
|
||||
methodImage[type.method_start + method] = index;
|
||||
}
|
||||
}
|
||||
const methodByImageAndRow = metadata.images.map(
|
||||
() => new Map<number, number>(),
|
||||
);
|
||||
for (let index = 0; index < methodImage.length; index++) {
|
||||
if (index % LINK_BATCH === 0) yield;
|
||||
const owner = methodImage[index]!;
|
||||
if (owner === -1) continue;
|
||||
const token = facts.methodTokens[index]!;
|
||||
const row = token & 0xffffff;
|
||||
if (token >>> 24 !== 0x06 || row === 0) continue;
|
||||
const methodsByRow = methodByImageAndRow[owner]!;
|
||||
const earlier = methodsByRow.get(row);
|
||||
if (earlier !== undefined)
|
||||
throw new Il2cppBinaryFormatFailure(
|
||||
"invalid-method-token",
|
||||
`methods ${earlier} and ${index} in image ${metadata.images[owner]!.name} share MethodDef token 0x${token.toString(16)}`,
|
||||
);
|
||||
methodsByRow.set(row, index);
|
||||
}
|
||||
yield;
|
||||
const methodAddress = (index: number): Il2cppMethodCode => {
|
||||
const owner = methodImage[index]!;
|
||||
@@ -175,7 +156,9 @@ function* linkImageSteps(
|
||||
const module = modules[owner]!;
|
||||
const token = facts.methodTokens[index]!;
|
||||
const row = token & 0xffffff;
|
||||
if (token >>> 24 !== 0x06 || row === 0 || row > module.method_pointer_count)
|
||||
// The metadata reader admitted every owned token as a nonzero MethodDef
|
||||
// row unique within its image; only the binary's row count is left.
|
||||
if (row > module.method_pointer_count)
|
||||
throw new Il2cppBinaryFormatFailure(
|
||||
"invalid-method-token",
|
||||
`method ${index} token 0x${token.toString(16)} is outside module ${metadata.images[owner]!.name}'s ${module.method_pointer_count} method pointers`,
|
||||
|
||||
@@ -655,6 +655,46 @@ function* checkMethodOwners(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Native linking reads each image's methods by MethodDef row, so every method
|
||||
* an image owns must carry a nonzero MethodDef token that no other method in
|
||||
* that image uses. The images and tokens are both this file's own records, so
|
||||
* a violation makes the metadata malformed whichever binary is selected.
|
||||
* Reuse across images is allowed: each image numbers its own rows.
|
||||
*/
|
||||
function* checkMethodTokens(
|
||||
images: Il2cppMetadataDecoded["images"],
|
||||
types: Il2cppMetadataDecoded["types"],
|
||||
methodTokens: Uint32Array,
|
||||
) {
|
||||
let work = 0;
|
||||
for (const image of images) {
|
||||
const methodByRow = new Map<number, number>();
|
||||
for (let offset = 0; offset < image.type_count; offset++) {
|
||||
const type = types[image.type_start + offset]!;
|
||||
if (work++ % 256 === 0) yield;
|
||||
for (let index = 0; index < type.method_count; index++) {
|
||||
if (work++ % 256 === 0) yield;
|
||||
const method = type.method_start + index;
|
||||
const token = methodTokens[method]!;
|
||||
const row = token & 0xffffff;
|
||||
if (token >>> 24 !== 0x06 || row === 0)
|
||||
throw new Il2cppMetadataFormatFailure(
|
||||
"invalid-method-definition-token",
|
||||
`method ${method} in image ${image.name} has token 0x${token.toString(16)}, which is not a MethodDef row`,
|
||||
);
|
||||
const earlier = methodByRow.get(row);
|
||||
if (earlier !== undefined)
|
||||
throw new Il2cppMetadataFormatFailure(
|
||||
"invalid-method-definition-token",
|
||||
`methods ${earlier} and ${method} in image ${image.name} share MethodDef token 0x${token.toString(16)}`,
|
||||
);
|
||||
methodByRow.set(row, method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Each type belongs to at most one image. */
|
||||
function* checkImageRanges(images: Il2cppMetadataDecoded["images"]) {
|
||||
const ranges: { start: number; end: number; index: number }[] = [];
|
||||
@@ -918,6 +958,8 @@ function* readMetadataCoreSteps(
|
||||
const { types, memberRanges } = yield* readTypes(tables);
|
||||
const { methods, parameterRanges } = yield* readMethods(tables);
|
||||
yield* checkMethodOwners(types, methods);
|
||||
if (tables.linkFacts !== undefined)
|
||||
yield* checkMethodTokens(images, types, tables.linkFacts.methodTokens);
|
||||
const members = yield* readIl2cppMembers(tables, {
|
||||
...memberRanges,
|
||||
parameters: parameterRanges,
|
||||
|
||||
@@ -14,6 +14,7 @@ export const IL2CPP_METADATA_FAILURE_REASONS = {
|
||||
"declaring-type-mismatch",
|
||||
"image-range-overlap",
|
||||
"invalid-string",
|
||||
"invalid-method-definition-token",
|
||||
],
|
||||
} as const;
|
||||
export type Il2cppMetadataFailureReason =
|
||||
|
||||
Reference in new issue
Block a user