{"record":{"id":"fd49b85b542cd3ee","repo":"lucasg/Dependencies","slug":"x-could-not-load-file-0-s-as-a-pe","errorCode":null,"errorMessage":"[x] Could not load file {0:s} as a PE","messagePattern":"\\[x\\] Could not load file (.+?) as a PE","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"Dependencies/Program.cs","lineNumber":884,"sourceCode":"                Console.Error.WriteLine(\"[x] Command {0:s} needs to have a PE <FILE> argument\", command.Method.Name);\n                Console.Error.WriteLine(\"\");\n\n                DumpUsage();\n                return;\n            }\n\n\t\t\tString FileName = eps[0];\n            if (!NativeFile.Exists(FileName))\n            {\n                Console.Error.WriteLine(\"[x] Could not find file {0:s} on disk\", FileName);\n                return;\n            }\n\n\t\t\tDebug.WriteLine(\"[-] Loading file {0:s} \", FileName);\n\t\t\tPE Pe = new PE(FileName);\n            if (!Pe.Load())\n            {\n                Console.Error.WriteLine(\"[x] Could not load file {0:s} as a PE\", FileName);\n                return;\n            }\n\n            command(Pe, GetObjectPrinter(export_as_json), recursion_depth);\n\n        }\n    }\n}\n","sourceCodeStart":866,"sourceCodeEnd":893,"githubUrl":"https://github.com/lucasg/Dependencies/blob/1997a40000b77bd3326cbc33672a7b9f78bb23f3/Dependencies/Program.cs#L866-L893","documentation":"Printed by Main (Program.cs:884) when `new PE(FileName)` followed by Pe.Load() returns false. The file exists on disk but phlib could not parse it as a valid PE/COFF image (bad DOS/PE header, truncated, unsupported architecture). The process returns without running the selected command.","triggerScenarios":"Pointing Dependencies at a file that exists but is not a PE: a text file, a Mach-O/ELF binary, a corrupted/truncated image, or a PE for an architecture phlib rejects.","commonSituations":"Analysing a non-Windows binary by mistake; a download that was truncated; a packed image whose headers were corrupted; cross-platform binaries (.NET Core self-contained linux builds).","solutions":["Confirm the file is a PE image with `dumpbin /headers <file>` or another PE-aware tool.","Re-download/rebuild the binary if it is truncated or corrupted.","Ensure you are using the Dependencies build (x86/x64) appropriate for the target image."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var pe = new PE(fileName);\nif (!pe.Load())\n{\n    Console.Error.WriteLine($\"[x] Could not load file {fileName} as a PE\");\n    return;\n}\n// pe.LoadSuccessful is true here; safe to call GetImports/GetExports/etc.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always check the bool returned by PE.Load() before using the PE instance - a constructed PE is not necessarily loaded.","Match the Dependencies build bitness (x86/x64) to the target image to avoid spurious parse failures."],"tags":["cli","pe-invalid","load-failure"],"backgroundTag":null,"analyzedSha":"1997a40000b77bd3326cbc33672a7b9f78bb23f3","analyzedAt":"2026-08-13T18:14:41.696Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}