Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

IndexOutOfRange exception

Open
#4,203 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp

Research direction

Reproduce the failure with ILSpyCmd 11.1.0.9782, using the packed sample and the reported -il -o ./disasm command. Start in ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs at WriteParameters line 1147 and DisassemblePropertyHeaderInternal line 1456; done means the affected child CIL components no longer terminate with either reported exception.

Written by the indexing model from the issue text.

Description

Bug Obfuscated
Steps to reproduce

I've encountered an error using ILSpyCmd to disassemble CIL components of this packed sample from VirusTotal: https://www.virustotal.com/gui/file/ee38d2feb95a01c192ef7b60631b78e6feab9360a0af2fc2d0518c68a63686c6/details

I've unpacked the exe, deobfuscated the CIL components with DE4Dot, and tried to disassemble them with ILSpyCmd using ilspycmd -il -o ./disasm path/to/exec.

Error message shown
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Collections.Immutable.ImmutableArray`1.get_Item(Int32 index)
   at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.WriteParameters(MetadataReader metadata, IEnumerable`1 parameters, MethodSignature`1 signature) in /_/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs:line 1147
   at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.DisassembleMethodHeaderInternal(MetadataFile module, MethodDefinitionHandle handle, MetadataGenericContext genericContext) in /_/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs:line 305
   at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.DisassembleMethod(MetadataFile module, MethodDefinitionHandle handle) in /_/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs:line 159
   at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.DisassembleType(MetadataFile module, TypeDefinitionHandle type) in /_/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs:line 1688
   at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.WriteModuleContents(MetadataFile module) in /_/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs:line 2203
   at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.ShowIL(String assemblyFileName, TextWriter output) in D:\a\ILSpy\ILSpy\ICSharpCode.ILSpyCmd\IlspyCmdProgram.cs:line 682
   at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.<OnExecuteAsync>g__PerformPerFileAction|114_0(String fileName, <>c__DisplayClass114_0&, <>c__DisplayClass114_1&) in D:\a\ILSpy\ILSpy\ICSharpCode.ILSpyCmd\IlspyCmdProgram.cs:line 368
   at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.OnExecuteAsync(CommandLineApplication app) in D:\a\ILSpy\ILSpy\ICSharpCode.ILSpyCmd\IlspyCmdProgram.cs:line 314

or

System.BadImageFormatException: Read out of bounds.
   at System.Reflection.Throw.OutOfBounds()
   at System.Reflection.Metadata.BlobReader.ReadSignatureHeader()
   at System.Reflection.Metadata.Ecma335.SignatureDecoder`2.DecodeMethodSignature(BlobReader& blobReader)
   at System.Reflection.Metadata.PropertyDefinition.DecodeSignature[TType,TGenericContext](ISignatureTypeProvider`2 provider, TGenericContext genericContext)
   at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.DisassemblePropertyHeaderInternal(MetadataFile module, PropertyDefinitionHandle handle, MetadataReader metadata, PropertyDefinition propertyDefinition) in /_/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs:line 1456
   at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.DisassembleProperty(MetadataFile module, PropertyDefinitionHandle property) in /_/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs:line 1428
   at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.DisassembleType(MetadataFile module, TypeDefinitionHandle type) in /_/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs:line 1711
   at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.WriteModuleContents(MetadataFile module) in /_/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs:line 2203
   at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.ShowIL(String assemblyFileName, TextWriter output) in D:\a\ILSpy\ILSpy\ICSharpCode.ILSpyCmd\IlspyCmdProgram.cs:line 682
   at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.<OnExecuteAsync>g__PerformPerFileAction|114_0(String fileName, <>c__DisplayClass114_0&, <>c__DisplayClass114_1&) in D:\a\ILSpy\ILSpy\ICSharpCode.ILSpyCmd\IlspyCmdProgram.cs:line 368
   at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.OnExecuteAsync(CommandLineApplication app) in D:\a\ILSpy\ILSpy\ICSharpCode.ILSpyCmd\IlspyCmdProgram.cs:line 314

depending on which child CIL component of the packed exe I'm trying to analyze.

Details

I am using ILSpyCmd version 11.1.0.9782.

Dominant language
C#
Stars
26.6k
Forks
3.8k
Avg merge
1d 16h
Merged PRs (30d)
76

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from icsharpcode/ILSpy

All issues in icsharpcode/ILSpy

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.