How to overcome the error message while trying to open the exe in ILSpy:

System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid.
   at Mono.Cecil.PE.ImageReader.ReadOptionalHeaders(UInt16& subsystem, UInt16& dll_characteristics)
   at Mono.Cecil.PE.ImageReader.ReadImage()
   at Mono.Cecil.PE.ImageReader.ReadImage(Disposable`1 stream, String file_name)
   at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
   at ICSharpCode.ILSpy.LoadedAssembly.LoadAssembly(Object state)
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

Is the executable packed or what to do?

  • What about you posting the exe so we can know what's wrong in your particular case? – user202729 Dec 1 at 13:30
  • (either the exe is corrupted, or ILSpy cannot read it) – user202729 Dec 1 at 13:30
  • By the way: it suffices to tag the question with appropriate tags. It's not necessary to put (ILSpy) in the title. – user202729 Dec 1 at 13:31

If the program runs, it should be possible to dump the module from memory, after it was reconstructed to original state while loading it to memory.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.