Perfare/Il2CppDumper · error · InvalidDataException

ERROR: Metadata file supplied is not valid metadata file.

Error message

ERROR: Metadata file supplied is not valid metadata file.

What it means

Thrown by the Metadata constructor when the first 4 bytes of the stream are not the sanity magic 0xFAB11BAF. Every valid Il2Cpp global-metadata.dat starts with this constant, so the file being read is not an il2cpp metadata file.

Solutions

  1. Check the first 4 bytes of the file are AF 1B B1 FA (little-endian 0xFAB11BAF).
  2. Make sure the second CLI argument is global-metadata.dat, not the binary.
  3. If the game encrypts metadata at rest, decrypt it first (search for known protection-specific dumpers).
  4. Re-extract metadata from the APK/AAB/IPA to rule out corruption.

Example fix

// before
Metadata m = new Metadata(File.OpenRead("GameAssembly.dll")); // wrong file
// after
Metadata m = new Metadata(File.OpenRead("global-metadata.dat")); // starts with 0xFAB11BAF
Defensive patterns

Strategy: validation

Validate before calling

byte[] b = File.ReadAllBytes(metadataPath);
uint sanity = BitConverter.ToUInt32(b, 0);
bool isMetadata = sanity == 0xFAB11BAF;

Type guard

static bool IsIl2CppMetadata(byte[] b) => b.Length >= 4 && BitConverter.ToUInt32(b, 0) == 0xFAB11BAF;

Try / catch

try { var md = new Metadata(stream); }
catch (InvalidDataException ex) when (ex.Message.Contains("not valid metadata file")) { /* wrong or encrypted metadata file */ }

Prevention

When it happens

Trigger: Calling new Metadata(stream) where stream's first uint != 0xFAB11BAF — passing the wrong file (a binary, text, or encrypted metadata), or a stripped/re-encrypted metadata file.

Common situations: Pointing the dumper at the game binary instead of global-metadata.dat, or the game ships an encrypted metadata file that some protectors (e.g. custom packing) modify at rest.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Perfare/Il2CppDumper@4741d46ba9 (2026-09-11). Data as JSON: /api/errors/35e025181133c558. Report an issue: GitHub.

Appendix: source

Thrown at Il2CppDumper/Il2Cpp/Metadata.cs:48

        public Dictionary<Il2CppMetadataUsage, SortedDictionary<uint, uint>> metadataUsageDic;
        public long metadataUsagesCount;
        public int[] nestedTypeIndices;
        public Il2CppEventDefinition[] eventDefs;
        public Il2CppGenericContainer[] genericContainers;
        public Il2CppFieldRef[] fieldRefs;
        public Il2CppGenericParameter[] genericParameters;
        public int[] constraintIndices;
        public uint[] vtableMethods;
        public Il2CppRGCTXDefinition[] rgctxEntries;

        private readonly Dictionary<uint, string> stringCache = new();

        public Metadata(Stream stream) : base(stream)
        {
            var sanity = ReadUInt32();
            if (sanity != 0xFAB11BAF)
            {
                throw new InvalidDataException("ERROR: Metadata file supplied is not valid metadata file.");
            }
            var version = ReadInt32();
            if (version < 0 || version > 1000)
            {
                throw new InvalidDataException("ERROR: Metadata file supplied is not valid metadata file.");
            }
            if (version < 16 || version > 31)
            {
                throw new NotSupportedException($"ERROR: Metadata file supplied is not a supported version[{version}].");
            }
            Version = version;
            header = ReadClass<Il2CppGlobalMetadataHeader>(0);
            if (version == 24)
            {
                if (header.stringLiteralOffset == 264)
                {
                    Version = 24.2;
                    header = ReadClass<Il2CppGlobalMetadataHeader>(0);

View on GitHub (pinned to 4741d46ba9)