{"record":{"id":"6b57b6785fffaa18","repo":"lucasg/Dependencies","slug":"x-malformed-pe-manifest-for-file-0-s-1-s","errorCode":null,"errorMessage":"[x] \"Malformed\" pe manifest for file {0:s} : {1:s}","messagePattern":"\\[x\\] \"Malformed\" pe manifest for file (.+?) : (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"Dependencies/Program.cs","lineNumber":140,"sourceCode":"                    Exception = e.ToString();\n                }\n            }\n        }\n\n\n        public void PrettyPrint()\n        {\n            Console.WriteLine(\"[-] Manifest for file : {0}\", Application.Filepath);\n\n            if (Manifest.Length == 0)\n            {\n                Console.WriteLine(\"[x] No embedded pe manifest for file {0:s}\", Application.Filepath);\n                return;\n            }\n\n            if (Exception.Length != 0)\n            {\n                Console.Error.WriteLine(\"[x] \\\"Malformed\\\" pe manifest for file {0:s} : {1:s}\", Application.Filepath, Manifest);\n                Console.Error.WriteLine(\"[x] Exception : {0:s}\", Exception);\n                return;\n            }\n\n            Console.WriteLine(XmlManifest);\n        }\n\n        public string Manifest;\n        public XDocument XmlManifest;\n\n        // stays private in order not end up in the json output\n        private PE Application;\n        private string Exception;\n    }\n\n    class PEImports : IPrettyPrintable\n    {\n        public PEImports(PE _Application)","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/lucasg/Dependencies/blob/1997a40000b77bd3326cbc33672a7b9f78bb23f3/Dependencies/Program.cs#L122-L158","documentation":"Emitted by PEManifest.PrettyPrint() (Dependencies/Program.cs:140) when a PE has an embedded side-by-side manifest resource (Manifest.Length != 0) whose XML failed to parse at construction time. The constructor (Program.cs:107-123) wraps SxsManifest.ParseSxsManifest in try/catch(XmlException) and stores the failure string in the private Exception field; PrettyPrint then surfaces the raw manifest text plus that stored exception to stderr and returns early. It is a diagnostic warning, not a thrown exception, so the CLI keeps running.","triggerScenarios":"Running `Dependencies.exe -manifest <file>` (Main -> DumpManifest -> new PEManifest(pe) -> Printer -> PrettyPrint) against a PE whose RT_MANIFEST resource exists but is not well-formed XML.","commonSituations":"PEs built with a truncated or hand-edited manifest; manifests whose encoding is mangled by the constructor's UTF-8 round-trip (Program.cs:110); resources altered by packers/obfuscators or broken by older mt.exe toolchains.","solutions":["Read the raw Manifest text printed alongside this message to locate the XML defect (unclosed tag, stray BOM, invalid entity) and fix the manifest source in your build.","Re-extract and validate the manifest independently with `mt.exe -inputresource:<file> -out:check.manifest` or Resource Hacker to confirm the resource is genuinely malformed.","If the non-XML manifest is intentional, ignore the warning and ensure downstream consumers tolerate XmlManifest == null."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// After constructing a PEManifest, check parse success before relying on the XML\nvar pm = new PEManifest(pe);\nif (!string.IsNullOrEmpty(pm.Manifest) && pm.XmlManifest == null)\n{\n    // Manifest resource present but unparseable - handle gracefully\n    Console.Error.WriteLine($\"Skipping unparseable manifest for {pe.Filepath}\");\n    return;\n}\n// safe to use pm.XmlManifest here","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate embedded manifests at build time with mt.exe / sigcheck so corrupted resources never ship.","Never dereference PEManifest.XmlManifest without a null check - the constructor explicitly sets it null on XmlException (Program.cs:121)."],"tags":["pe-manifest","xml","stderr","cli"],"backgroundTag":null,"analyzedSha":"1997a40000b77bd3326cbc33672a7b9f78bb23f3","analyzedAt":"2026-08-13T18:14:41.696Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}