Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJb Evain <jbevain@gmail.com>2017-11-16 22:25:24 +0300
committerGitHub <noreply@github.com>2017-11-16 22:25:24 +0300
commitb4f4571a7f45df013c32f3ccd3939b8852819b04 (patch)
tree3e241b5624e113581437753d88201b99d37da55a /Mono.Cecil.Cil
parent14e6162ae535afacb69eb6df399bbc46779a4587 (diff)
Fix reading mdb scope end (#466)
* Fix reading mdb scope end
Diffstat (limited to 'Mono.Cecil.Cil')
-rw-r--r--Mono.Cecil.Cil/CodeReader.cs26
1 files changed, 25 insertions, 1 deletions
diff --git a/Mono.Cecil.Cil/CodeReader.cs b/Mono.Cecil.Cil/CodeReader.cs
index 76add4d..ab6d900 100644
--- a/Mono.Cecil.Cil/CodeReader.cs
+++ b/Mono.Cecil.Cil/CodeReader.cs
@@ -62,6 +62,30 @@ namespace Mono.Cecil.Cil {
return this.body;
}
+ public int ReadCodeSize (MethodDefinition method)
+ {
+ var position = MoveTo (method);
+
+ var code_size = ReadCodeSize ();
+
+ MoveBackTo (position);
+ return code_size;
+ }
+
+ int ReadCodeSize ()
+ {
+ var flags = ReadByte ();
+ switch (flags & 0x3) {
+ case 0x2: // tiny
+ return flags >> 2;
+ case 0x3: // fat
+ Advance (-1 + 2 + 2); // go back, 2 bytes flags, 2 bytes stack size
+ return (int) ReadUInt32 ();
+ default:
+ throw new InvalidOperationException ();
+ }
+ }
+
void ReadMethodBody ()
{
var flags = ReadByte ();
@@ -161,7 +185,7 @@ namespace Mono.Cecil.Cil {
{
var start_instruction = GetInstruction (scope.Start.Offset);
if (start_instruction != null)
- scope.Start = new InstructionOffset (start_instruction);
+ scope.Start = new InstructionOffset (start_instruction);
var end_instruction = GetInstruction (scope.End.Offset);
scope.End = end_instruction != null