{"record":{"id":"35e025181133c558","repo":"Perfare/Il2CppDumper","slug":"error-metadata-file-supplied-is-not-valid-metadat","errorCode":null,"errorMessage":"ERROR: Metadata file supplied is not valid metadata file.","messagePattern":"ERROR: Metadata file supplied is not valid metadata file\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"Il2CppDumper/Il2Cpp/Metadata.cs","lineNumber":48,"sourceCode":"        public Dictionary<Il2CppMetadataUsage, SortedDictionary<uint, uint>> metadataUsageDic;\n        public long metadataUsagesCount;\n        public int[] nestedTypeIndices;\n        public Il2CppEventDefinition[] eventDefs;\n        public Il2CppGenericContainer[] genericContainers;\n        public Il2CppFieldRef[] fieldRefs;\n        public Il2CppGenericParameter[] genericParameters;\n        public int[] constraintIndices;\n        public uint[] vtableMethods;\n        public Il2CppRGCTXDefinition[] rgctxEntries;\n\n        private readonly Dictionary<uint, string> stringCache = new();\n\n        public Metadata(Stream stream) : base(stream)\n        {\n            var sanity = ReadUInt32();\n            if (sanity != 0xFAB11BAF)\n            {\n                throw new InvalidDataException(\"ERROR: Metadata file supplied is not valid metadata file.\");\n            }\n            var version = ReadInt32();\n            if (version < 0 || version > 1000)\n            {\n                throw new InvalidDataException(\"ERROR: Metadata file supplied is not valid metadata file.\");\n            }\n            if (version < 16 || version > 31)\n            {\n                throw new NotSupportedException($\"ERROR: Metadata file supplied is not a supported version[{version}].\");\n            }\n            Version = version;\n            header = ReadClass<Il2CppGlobalMetadataHeader>(0);\n            if (version == 24)\n            {\n                if (header.stringLiteralOffset == 264)\n                {\n                    Version = 24.2;\n                    header = ReadClass<Il2CppGlobalMetadataHeader>(0);","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/Perfare/Il2CppDumper/blob/4741d46ba9cd6159c5d853eb9d6fc48b4bfa2b1a/Il2CppDumper/Il2Cpp/Metadata.cs#L30-L66","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the first 4 bytes of the file are AF 1B B1 FA (little-endian 0xFAB11BAF).","Make sure the second CLI argument is global-metadata.dat, not the binary.","If the game encrypts metadata at rest, decrypt it first (search for known protection-specific dumpers).","Re-extract metadata from the APK/AAB/IPA to rule out corruption."],"exampleFix":"// before\nMetadata m = new Metadata(File.OpenRead(\"GameAssembly.dll\")); // wrong file\n// after\nMetadata m = new Metadata(File.OpenRead(\"global-metadata.dat\")); // starts with 0xFAB11BAF","handlingStrategy":"validation","validationCode":"byte[] b = File.ReadAllBytes(metadataPath);\nuint sanity = BitConverter.ToUInt32(b, 0);\nbool isMetadata = sanity == 0xFAB11BAF;","typeGuard":"static bool IsIl2CppMetadata(byte[] b) => b.Length >= 4 && BitConverter.ToUInt32(b, 0) == 0xFAB11BAF;","tryCatchPattern":"try { var md = new Metadata(stream); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"not valid metadata file\")) { /* wrong or encrypted metadata file */ }","preventionTips":["Check the first 4 bytes equal AF 1B B1 FA before dumping.","If the game encrypts metadata, decrypt it before running the dumper.","Keep the two CLI arguments in order: binary first, metadata second."],"tags":["metadata","magic-number","wrong-file"],"backgroundTag":"schema-validation-failed","analyzedSha":"4741d46ba9cd6159c5d853eb9d6fc48b4bfa2b1a","analyzedAt":"2026-09-11T16:52:42.117Z","contentChangedAt":"2026-09-11T16:52:42.117Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}