Skip to content

Commit c72bd21

Browse files
committed
add additional heuristics for metadata registration
closes #35
1 parent 73b1594 commit c72bd21

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Il2CppInspector.Common/IL2CPP/ImageScan.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,18 @@ ulong FindCodeRegistration()
282282
// but I know of at least one binary where this will break detection.
283283
// Testing showed that we can just use the same heuristic used for v27+
284284
// on older versions as well, so we'll just use it for all cases.
285+
286+
// On some 32-bit (arm) binaries, just checking fields with the type count is not sufficient
287+
// for uniquely identifying the metareg. We assume that all binaries have at least one generic class + inst
288+
// and use this for an additional heuristic, though this is kinda jank and might not be enough for all binaries
285289
if (Image.Version >= MetadataVersions.V190)
286290
{
287291
foreach (var va in vas)
288292
{
289293
var mr = Image.ReadMappedVersionedObject<Il2CppMetadataRegistration>(va);
290294
if (mr.TypeDefinitionsSizesCount == metadata.Types.Length
291-
&& mr.FieldOffsetsCount == metadata.Types.Length)
295+
&& mr.FieldOffsetsCount == metadata.Types.Length
296+
&& mr is { GenericInstsCount: > 0, GenericClassesCount: > 0 })
292297
{
293298
metadataRegistration = va;
294299
break;

0 commit comments

Comments
 (0)