Washi1337 / OldRod

An automated KoiVM disassembler and devirtualisation utility
GNU General Public License v3.0
352 stars 80 forks source link

Virtualized parameterless constructors cause errors in the recompilation process #19

Closed Washi1337 closed 5 years ago

Washi1337 commented 5 years ago

Describe the bug When a protected binary contains a virtualized parameterless constructor, OldRod cannot infer the declaring type, and makes it static. This results in the recompiler failing as well since the this parameter does not exist, resulting in an IndexOutOfRangeException.

To Reproduce Sample code that triggers the error:

using System;

namespace MyProgram
{
    public class MyClass
    {
        public int X;

        public MyClass()
        {
            X = 1234;
        }
    }

    public static class Program
    {
        public static void Main(string[] args)
        {
            var x = new MyClass();
            Console.WriteLine(x.X);
        }
    }
}

Expected behavior A proper declaring type inference + proper recompilation.

Additional context Related to #17