Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with 0xffff parameters #914

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Mono.Cecil/AssemblyReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -987,15 +987,21 @@ Range ReadListRange (uint current_index, Table current, Table target)
uint next_index;
var current_table = image.TableHeap [current];

var last_index = image.TableHeap [target].Length + 1;

if (current_index == current_table.Length)
next_index = image.TableHeap [target].Length + 1;
next_index = last_index;
else {
var position = this.position;
this.position += (int) (current_table.RowSize - image.GetTableIndexSize (target));
next_index = ReadTableIndex (target);
this.position = position;
}

if (next_index == 0 && current_index + 1 == current_table.Length && image.TableHeap [target].Length == 0xffff) {
next_index = last_index;
}

list.Start = start;
list.Length = next_index - start;

Expand Down
12 changes: 12 additions & 0 deletions Test/Mono.Cecil.Tests/ParameterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,5 +270,17 @@ public void NullablePrimitiveParameterConstant ()
Assert.AreEqual (12, param.Constant);
});
}

[Test]
public void ModuleWith0xFFFFParameters ()
{
TestModule ("param0xffff.dll", module => {
var test = module.GetType ("Program");
var method = test.GetMethod ("F_65534");

Assert.AreEqual (1, method.Parameters.Count);
Assert.AreEqual ("a", method.Parameters [0].Name);
}, verify: false);
}
}
}
Binary file added Test/Resources/assemblies/param0xffff.dll
Binary file not shown.