C# 单细胞盲肠生产“;无效的CIL“;

C# 单细胞盲肠生产“;无效的CIL“;,c#,mono,cil,mono.cecil,C#,Mono,Cil,Mono.cecil,目标: private static void PatchStartup(TypeDefinition definition) { ILProcessor il = definition.Methods.First(x => x.Name == "Start").Body.GetILProcessor(); int index = default(int); for (int i = il.Body.Instruction

目标:

    private static void PatchStartup(TypeDefinition definition)
    {
        ILProcessor il = definition.Methods.First(x => x.Name == "Start").Body.GetILProcessor();

        int index = default(int);

        for (int i = il.Body.Instructions.Count - 1; i != 0; i--)
            if (il.Body.Instructions[i].OpCode == OpCodes.Newobj)
            {
                index = i + 2;
                break;
            }

        List<Instruction> removedInstructions = new List<Instruction>();

        for (int i = index; i < il.Body.Instructions.Count; i++)
            removedInstructions.Add(il.Body.Instructions[i]);

        foreach (var i in removedInstructions) il.Remove(i); 

        il.InsertAfter(il.Body.Instructions[il.Body.Instructions.Count - 1], il.Create(OpCodes.Ret));

        il.Body.Variables.Clear();
        il.Body.InitLocals = false;

        il.Body.Optimize();
        il.Body.OptimizeMacros();
    }
// Token: 0x06000029 RID: 41 RVA: 0x00002DE0 File Offset: 0x00000FE0
.method public hidebysig static 
    void Start (
        string[] args
    ) cil managed 
{
// Header Size: 12 bytes
// Code Size: 258 (0x102) bytes
// LocalVarSig Token: 0x1100000C RID: 12
.maxstack 3
.locals init (
    [0] string,
    [1] class [mscorlib]System.Exception
)

/* 0x00000FEC 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
/* 0x00000FF1 286300000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
/* 0x00000FF6 284700000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
/* 0x00000FFB 286400000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
/* 0x00001000 02           */ IL_0014: ldarg.0
/* 0x00001001 286500000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
/* 0x00001006 14           */ IL_001A: ldnull
/* 0x00001007 FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
/* 0x0000100D 736700000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
/* 0x00001012 286800000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001017 14           */ IL_002B: ldnull
/* 0x00001018 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
/* 0x0000101E 736900000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
/* 0x00001023 286A00000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001028 14           */ IL_003C: ldnull
/* 0x00001029 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
/* 0x0000102F 736B00000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
/* 0x00001034 286C00000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001039 14           */ IL_004D: ldnull
/* 0x0000103A FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
/* 0x00001040 736D00000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
/* 0x00001045 286E00000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x0000104A 16           */ IL_005E: ldc.i4.0
/* 0x0000104B 286F00000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
/* 0x00001050 D080000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
/* 0x00001055 280E00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
/* 0x0000105A 287000000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
/* 0x0000105F 14           */ IL_0073: ldnull
/* 0x00001060 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
/* 0x00001066 737100000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
/* 0x0000106B 287200000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
/* 0x00001070 285600000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
/* 0x00001075 14           */ IL_0089: ldnull
/* 0x00001076 FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
/* 0x0000107C 737300000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
/* 0x00001081 6F7400000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
/* 0x00001086 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
/* 0x0000108B 2D01         */ IL_009F: brtrue.s  IL_00A2

/* 0x0000108D 2A           */ IL_00A1: ret

/* 0x0000108E 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
/* 0x00001093 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
/* 0x00001098 26           */ IL_00AC: pop
.try
{
    /* 0x00001099 7E7500000A   */ IL_00AD: ldsfld    string [mscorlib]System.String::Empty
    /* 0x0000109E 0A           */ IL_00B2: stloc.0
    /* 0x0000109F 2B06         */ IL_00B3: br.s      IL_00BB
    // loop start (head: IL_00BB)
        /* 0x000010A1 287600000A   */ IL_00B5: call      string [mscorlib]System.Console::ReadLine()
        /* 0x000010A6 0A           */ IL_00BA: stloc.0

        /* 0x000010A7 06           */ IL_00BB: ldloc.0
        /* 0x000010A8 728C020070   */ IL_00BC: ldstr     "exit"
        /* 0x000010AD 6F7700000A   */ IL_00C1: callvirt  instance bool [mscorlib]System.String::Contains(string)
        /* 0x000010B2 2CED         */ IL_00C6: brfalse.s IL_00B5
    // end loop

    /* 0x000010B4 7296020070   */ IL_00C8: ldstr     "Saving..."
    /* 0x000010B9 287800000A   */ IL_00CD: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010BE 287900000A   */ IL_00D2: call      void [Eco.Core]Eco.Core.Plugins.StorageManager::SaveAndFlush()
    /* 0x000010C3 72AA020070   */ IL_00D7: ldstr     "Done"
    /* 0x000010C8 287800000A   */ IL_00DC: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010CD 16           */ IL_00E1: ldc.i4.0
    /* 0x000010CE 287A00000A   */ IL_00E2: call      void [mscorlib]System.Environment::Exit(int32)
    /* 0x000010D3 DE18         */ IL_00E7: leave.s   IL_0101
} // end .try
catch [mscorlib]System.Exception
{
    /* 0x000010D5 0B           */ IL_00E9: stloc.1
    /* 0x000010D6 72B4020070   */ IL_00EA: ldstr     "Caught an exception checking for console input, console input disabled. (probably safe to ignore)"
    /* 0x000010DB 287800000A   */ IL_00EF: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010E0 07           */ IL_00F4: ldloc.1
    /* 0x000010E1 6F7B00000A   */ IL_00F5: callvirt  instance string [mscorlib]System.Exception::get_Message()
    /* 0x000010E6 287800000A   */ IL_00FA: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010EB DE00         */ IL_00FF: leave.s   IL_0101
} // end handler

/* 0x000010ED 2A           */ IL_0101: ret
} // end of method Startup::Start
// Token: 0x06000029 RID: 41 RVA: 0x00002DE0 File Offset: 0x00000FE0
.method public hidebysig static 
    void Start (
        string[] args
    ) cil managed 
{
    // Header Size: 12 bytes
    // Code Size: 174 (0xAE) bytes
    .maxstack 3

    /* 0x00000FEC 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
    /* 0x00000FF1 286300000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
    /* 0x00000FF6 284700000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
    /* 0x00000FFB 286400000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
    /* 0x00001000 02           */ IL_0014: ldarg.0
    /* 0x00001001 286500000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
    /* 0x00001006 14           */ IL_001A: ldnull
    /* 0x00001007 FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
    /* 0x0000100D 736700000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
    /* 0x00001012 286800000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001017 14           */ IL_002B: ldnull
    /* 0x00001018 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
    /* 0x0000101E 736900000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
    /* 0x00001023 286A00000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001028 14           */ IL_003C: ldnull
    /* 0x00001029 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
    /* 0x0000102F 736B00000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
    /* 0x00001034 286C00000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001039 14           */ IL_004D: ldnull
    /* 0x0000103A FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
    /* 0x00001040 736D00000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
    /* 0x00001045 286E00000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x0000104A 16           */ IL_005E: ldc.i4.0
    /* 0x0000104B 286F00000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
    /* 0x00001050 D07F000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
    /* 0x00001055 280E00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    /* 0x0000105A 287000000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
    /* 0x0000105F 14           */ IL_0073: ldnull
    /* 0x00001060 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
    /* 0x00001066 737100000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
    /* 0x0000106B 287200000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
    /* 0x00001070 285600000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
    /* 0x00001075 14           */ IL_0089: ldnull
    /* 0x00001076 FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
    /* 0x0000107C 737300000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
    /* 0x00001081 6F7400000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
    /* 0x00001086 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
    /* 0x0000108B 2D01         */ IL_009F: brtrue.s  IL_00A2

    /* 0x0000108D 2A           */ IL_00A1: ret

    /* 0x0000108E 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
    /* 0x00001093 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
    /* 0x00001098 26           */ IL_00AC: pop
    /* 0x00001099 2A           */ IL_00AD: ret
} // end of method Startup::Start
// Token: 0x06000029 RID: 41 RVA: 0x000030A8 File Offset: 0x000012A8
.method public hidebysig static 
    void Start (
        string[] args
    ) cil managed 
{
    // Header Size: 12 bytes
    // Code Size: 174 (0xAE) bytes
    .maxstack 3

    /* 0x000012B4 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
    /* 0x000012B9 287D00000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
    /* 0x000012BE 286200000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
    /* 0x000012C3 287E00000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
    /* 0x000012C8 02           */ IL_0014: ldarg.0
    /* 0x000012C9 287F00000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
    /* 0x000012CE 14           */ IL_001A: ldnull
    /* 0x000012CF FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
    /* 0x000012D5 738100000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
    /* 0x000012DA 288200000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x000012DF 14           */ IL_002B: ldnull
    /* 0x000012E0 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
    /* 0x000012E6 738300000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
    /* 0x000012EB 288400000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x000012F0 14           */ IL_003C: ldnull
    /* 0x000012F1 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
    /* 0x000012F7 738500000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
    /* 0x000012FC 288600000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001301 14           */ IL_004D: ldnull
    /* 0x00001302 FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
    /* 0x00001308 738700000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
    /* 0x0000130D 288800000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001312 16           */ IL_005E: ldc.i4.0
    /* 0x00001313 288900000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
    /* 0x00001318 D0BC000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
    /* 0x0000131D 282C00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    /* 0x00001322 288A00000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
    /* 0x00001327 14           */ IL_0073: ldnull
    /* 0x00001328 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
    /* 0x0000132E 738B00000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
    /* 0x00001333 288C00000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
    /* 0x00001338 287000000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
    /* 0x0000133D 14           */ IL_0089: ldnull
    /* 0x0000133E FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
    /* 0x00001344 738D00000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
    /* 0x00001349 6F8E00000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
    /* 0x0000134E 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
    /* 0x00001353 2D01         */ IL_009F: brtrue.s  IL_00A2

    /* 0x00001355 2A           */ IL_00A1: ret

    /* 0x00001356 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
    /* 0x0000135B 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
    /* 0x00001360 26           */ IL_00AC: pop
    /* 0x00001361 2A           */ IL_00AD: ret
} // end of method Startup::Start
此代码段的目标是在运行时创建可执行文件的修改版本,以防止其阻塞线程

问题:

    private static void PatchStartup(TypeDefinition definition)
    {
        ILProcessor il = definition.Methods.First(x => x.Name == "Start").Body.GetILProcessor();

        int index = default(int);

        for (int i = il.Body.Instructions.Count - 1; i != 0; i--)
            if (il.Body.Instructions[i].OpCode == OpCodes.Newobj)
            {
                index = i + 2;
                break;
            }

        List<Instruction> removedInstructions = new List<Instruction>();

        for (int i = index; i < il.Body.Instructions.Count; i++)
            removedInstructions.Add(il.Body.Instructions[i]);

        foreach (var i in removedInstructions) il.Remove(i); 

        il.InsertAfter(il.Body.Instructions[il.Body.Instructions.Count - 1], il.Create(OpCodes.Ret));

        il.Body.Variables.Clear();
        il.Body.InitLocals = false;

        il.Body.Optimize();
        il.Body.OptimizeMacros();
    }
// Token: 0x06000029 RID: 41 RVA: 0x00002DE0 File Offset: 0x00000FE0
.method public hidebysig static 
    void Start (
        string[] args
    ) cil managed 
{
// Header Size: 12 bytes
// Code Size: 258 (0x102) bytes
// LocalVarSig Token: 0x1100000C RID: 12
.maxstack 3
.locals init (
    [0] string,
    [1] class [mscorlib]System.Exception
)

/* 0x00000FEC 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
/* 0x00000FF1 286300000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
/* 0x00000FF6 284700000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
/* 0x00000FFB 286400000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
/* 0x00001000 02           */ IL_0014: ldarg.0
/* 0x00001001 286500000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
/* 0x00001006 14           */ IL_001A: ldnull
/* 0x00001007 FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
/* 0x0000100D 736700000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
/* 0x00001012 286800000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001017 14           */ IL_002B: ldnull
/* 0x00001018 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
/* 0x0000101E 736900000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
/* 0x00001023 286A00000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001028 14           */ IL_003C: ldnull
/* 0x00001029 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
/* 0x0000102F 736B00000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
/* 0x00001034 286C00000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001039 14           */ IL_004D: ldnull
/* 0x0000103A FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
/* 0x00001040 736D00000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
/* 0x00001045 286E00000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x0000104A 16           */ IL_005E: ldc.i4.0
/* 0x0000104B 286F00000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
/* 0x00001050 D080000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
/* 0x00001055 280E00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
/* 0x0000105A 287000000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
/* 0x0000105F 14           */ IL_0073: ldnull
/* 0x00001060 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
/* 0x00001066 737100000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
/* 0x0000106B 287200000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
/* 0x00001070 285600000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
/* 0x00001075 14           */ IL_0089: ldnull
/* 0x00001076 FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
/* 0x0000107C 737300000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
/* 0x00001081 6F7400000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
/* 0x00001086 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
/* 0x0000108B 2D01         */ IL_009F: brtrue.s  IL_00A2

/* 0x0000108D 2A           */ IL_00A1: ret

/* 0x0000108E 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
/* 0x00001093 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
/* 0x00001098 26           */ IL_00AC: pop
.try
{
    /* 0x00001099 7E7500000A   */ IL_00AD: ldsfld    string [mscorlib]System.String::Empty
    /* 0x0000109E 0A           */ IL_00B2: stloc.0
    /* 0x0000109F 2B06         */ IL_00B3: br.s      IL_00BB
    // loop start (head: IL_00BB)
        /* 0x000010A1 287600000A   */ IL_00B5: call      string [mscorlib]System.Console::ReadLine()
        /* 0x000010A6 0A           */ IL_00BA: stloc.0

        /* 0x000010A7 06           */ IL_00BB: ldloc.0
        /* 0x000010A8 728C020070   */ IL_00BC: ldstr     "exit"
        /* 0x000010AD 6F7700000A   */ IL_00C1: callvirt  instance bool [mscorlib]System.String::Contains(string)
        /* 0x000010B2 2CED         */ IL_00C6: brfalse.s IL_00B5
    // end loop

    /* 0x000010B4 7296020070   */ IL_00C8: ldstr     "Saving..."
    /* 0x000010B9 287800000A   */ IL_00CD: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010BE 287900000A   */ IL_00D2: call      void [Eco.Core]Eco.Core.Plugins.StorageManager::SaveAndFlush()
    /* 0x000010C3 72AA020070   */ IL_00D7: ldstr     "Done"
    /* 0x000010C8 287800000A   */ IL_00DC: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010CD 16           */ IL_00E1: ldc.i4.0
    /* 0x000010CE 287A00000A   */ IL_00E2: call      void [mscorlib]System.Environment::Exit(int32)
    /* 0x000010D3 DE18         */ IL_00E7: leave.s   IL_0101
} // end .try
catch [mscorlib]System.Exception
{
    /* 0x000010D5 0B           */ IL_00E9: stloc.1
    /* 0x000010D6 72B4020070   */ IL_00EA: ldstr     "Caught an exception checking for console input, console input disabled. (probably safe to ignore)"
    /* 0x000010DB 287800000A   */ IL_00EF: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010E0 07           */ IL_00F4: ldloc.1
    /* 0x000010E1 6F7B00000A   */ IL_00F5: callvirt  instance string [mscorlib]System.Exception::get_Message()
    /* 0x000010E6 287800000A   */ IL_00FA: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010EB DE00         */ IL_00FF: leave.s   IL_0101
} // end handler

/* 0x000010ED 2A           */ IL_0101: ret
} // end of method Startup::Start
// Token: 0x06000029 RID: 41 RVA: 0x00002DE0 File Offset: 0x00000FE0
.method public hidebysig static 
    void Start (
        string[] args
    ) cil managed 
{
    // Header Size: 12 bytes
    // Code Size: 174 (0xAE) bytes
    .maxstack 3

    /* 0x00000FEC 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
    /* 0x00000FF1 286300000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
    /* 0x00000FF6 284700000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
    /* 0x00000FFB 286400000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
    /* 0x00001000 02           */ IL_0014: ldarg.0
    /* 0x00001001 286500000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
    /* 0x00001006 14           */ IL_001A: ldnull
    /* 0x00001007 FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
    /* 0x0000100D 736700000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
    /* 0x00001012 286800000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001017 14           */ IL_002B: ldnull
    /* 0x00001018 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
    /* 0x0000101E 736900000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
    /* 0x00001023 286A00000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001028 14           */ IL_003C: ldnull
    /* 0x00001029 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
    /* 0x0000102F 736B00000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
    /* 0x00001034 286C00000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001039 14           */ IL_004D: ldnull
    /* 0x0000103A FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
    /* 0x00001040 736D00000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
    /* 0x00001045 286E00000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x0000104A 16           */ IL_005E: ldc.i4.0
    /* 0x0000104B 286F00000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
    /* 0x00001050 D07F000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
    /* 0x00001055 280E00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    /* 0x0000105A 287000000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
    /* 0x0000105F 14           */ IL_0073: ldnull
    /* 0x00001060 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
    /* 0x00001066 737100000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
    /* 0x0000106B 287200000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
    /* 0x00001070 285600000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
    /* 0x00001075 14           */ IL_0089: ldnull
    /* 0x00001076 FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
    /* 0x0000107C 737300000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
    /* 0x00001081 6F7400000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
    /* 0x00001086 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
    /* 0x0000108B 2D01         */ IL_009F: brtrue.s  IL_00A2

    /* 0x0000108D 2A           */ IL_00A1: ret

    /* 0x0000108E 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
    /* 0x00001093 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
    /* 0x00001098 26           */ IL_00AC: pop
    /* 0x00001099 2A           */ IL_00AD: ret
} // end of method Startup::Start
// Token: 0x06000029 RID: 41 RVA: 0x000030A8 File Offset: 0x000012A8
.method public hidebysig static 
    void Start (
        string[] args
    ) cil managed 
{
    // Header Size: 12 bytes
    // Code Size: 174 (0xAE) bytes
    .maxstack 3

    /* 0x000012B4 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
    /* 0x000012B9 287D00000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
    /* 0x000012BE 286200000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
    /* 0x000012C3 287E00000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
    /* 0x000012C8 02           */ IL_0014: ldarg.0
    /* 0x000012C9 287F00000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
    /* 0x000012CE 14           */ IL_001A: ldnull
    /* 0x000012CF FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
    /* 0x000012D5 738100000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
    /* 0x000012DA 288200000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x000012DF 14           */ IL_002B: ldnull
    /* 0x000012E0 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
    /* 0x000012E6 738300000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
    /* 0x000012EB 288400000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x000012F0 14           */ IL_003C: ldnull
    /* 0x000012F1 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
    /* 0x000012F7 738500000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
    /* 0x000012FC 288600000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001301 14           */ IL_004D: ldnull
    /* 0x00001302 FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
    /* 0x00001308 738700000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
    /* 0x0000130D 288800000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001312 16           */ IL_005E: ldc.i4.0
    /* 0x00001313 288900000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
    /* 0x00001318 D0BC000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
    /* 0x0000131D 282C00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    /* 0x00001322 288A00000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
    /* 0x00001327 14           */ IL_0073: ldnull
    /* 0x00001328 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
    /* 0x0000132E 738B00000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
    /* 0x00001333 288C00000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
    /* 0x00001338 287000000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
    /* 0x0000133D 14           */ IL_0089: ldnull
    /* 0x0000133E FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
    /* 0x00001344 738D00000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
    /* 0x00001349 6F8E00000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
    /* 0x0000134E 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
    /* 0x00001353 2D01         */ IL_009F: brtrue.s  IL_00A2

    /* 0x00001355 2A           */ IL_00A1: ret

    /* 0x00001356 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
    /* 0x0000135B 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
    /* 0x00001360 26           */ IL_00AC: pop
    /* 0x00001361 2A           */ IL_00AD: ret
} // end of method Startup::Start
我正在使用Mono.Cecil来执行补丁;但是,它的重新编译方式会导致任何修改过的方法抛出
invalidProgrammeException
。为了证明这个程序不是无效的,我继续用C#中我想要的修改重写了它,并重新编译了它。手工编译程序,修改后效果良好;但是,除了文件对齐方式外,修补方法的IL完全相同

代码:

    private static void PatchStartup(TypeDefinition definition)
    {
        ILProcessor il = definition.Methods.First(x => x.Name == "Start").Body.GetILProcessor();

        int index = default(int);

        for (int i = il.Body.Instructions.Count - 1; i != 0; i--)
            if (il.Body.Instructions[i].OpCode == OpCodes.Newobj)
            {
                index = i + 2;
                break;
            }

        List<Instruction> removedInstructions = new List<Instruction>();

        for (int i = index; i < il.Body.Instructions.Count; i++)
            removedInstructions.Add(il.Body.Instructions[i]);

        foreach (var i in removedInstructions) il.Remove(i); 

        il.InsertAfter(il.Body.Instructions[il.Body.Instructions.Count - 1], il.Create(OpCodes.Ret));

        il.Body.Variables.Clear();
        il.Body.InitLocals = false;

        il.Body.Optimize();
        il.Body.OptimizeMacros();
    }
// Token: 0x06000029 RID: 41 RVA: 0x00002DE0 File Offset: 0x00000FE0
.method public hidebysig static 
    void Start (
        string[] args
    ) cil managed 
{
// Header Size: 12 bytes
// Code Size: 258 (0x102) bytes
// LocalVarSig Token: 0x1100000C RID: 12
.maxstack 3
.locals init (
    [0] string,
    [1] class [mscorlib]System.Exception
)

/* 0x00000FEC 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
/* 0x00000FF1 286300000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
/* 0x00000FF6 284700000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
/* 0x00000FFB 286400000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
/* 0x00001000 02           */ IL_0014: ldarg.0
/* 0x00001001 286500000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
/* 0x00001006 14           */ IL_001A: ldnull
/* 0x00001007 FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
/* 0x0000100D 736700000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
/* 0x00001012 286800000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001017 14           */ IL_002B: ldnull
/* 0x00001018 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
/* 0x0000101E 736900000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
/* 0x00001023 286A00000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001028 14           */ IL_003C: ldnull
/* 0x00001029 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
/* 0x0000102F 736B00000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
/* 0x00001034 286C00000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001039 14           */ IL_004D: ldnull
/* 0x0000103A FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
/* 0x00001040 736D00000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
/* 0x00001045 286E00000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x0000104A 16           */ IL_005E: ldc.i4.0
/* 0x0000104B 286F00000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
/* 0x00001050 D080000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
/* 0x00001055 280E00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
/* 0x0000105A 287000000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
/* 0x0000105F 14           */ IL_0073: ldnull
/* 0x00001060 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
/* 0x00001066 737100000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
/* 0x0000106B 287200000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
/* 0x00001070 285600000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
/* 0x00001075 14           */ IL_0089: ldnull
/* 0x00001076 FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
/* 0x0000107C 737300000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
/* 0x00001081 6F7400000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
/* 0x00001086 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
/* 0x0000108B 2D01         */ IL_009F: brtrue.s  IL_00A2

/* 0x0000108D 2A           */ IL_00A1: ret

/* 0x0000108E 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
/* 0x00001093 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
/* 0x00001098 26           */ IL_00AC: pop
.try
{
    /* 0x00001099 7E7500000A   */ IL_00AD: ldsfld    string [mscorlib]System.String::Empty
    /* 0x0000109E 0A           */ IL_00B2: stloc.0
    /* 0x0000109F 2B06         */ IL_00B3: br.s      IL_00BB
    // loop start (head: IL_00BB)
        /* 0x000010A1 287600000A   */ IL_00B5: call      string [mscorlib]System.Console::ReadLine()
        /* 0x000010A6 0A           */ IL_00BA: stloc.0

        /* 0x000010A7 06           */ IL_00BB: ldloc.0
        /* 0x000010A8 728C020070   */ IL_00BC: ldstr     "exit"
        /* 0x000010AD 6F7700000A   */ IL_00C1: callvirt  instance bool [mscorlib]System.String::Contains(string)
        /* 0x000010B2 2CED         */ IL_00C6: brfalse.s IL_00B5
    // end loop

    /* 0x000010B4 7296020070   */ IL_00C8: ldstr     "Saving..."
    /* 0x000010B9 287800000A   */ IL_00CD: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010BE 287900000A   */ IL_00D2: call      void [Eco.Core]Eco.Core.Plugins.StorageManager::SaveAndFlush()
    /* 0x000010C3 72AA020070   */ IL_00D7: ldstr     "Done"
    /* 0x000010C8 287800000A   */ IL_00DC: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010CD 16           */ IL_00E1: ldc.i4.0
    /* 0x000010CE 287A00000A   */ IL_00E2: call      void [mscorlib]System.Environment::Exit(int32)
    /* 0x000010D3 DE18         */ IL_00E7: leave.s   IL_0101
} // end .try
catch [mscorlib]System.Exception
{
    /* 0x000010D5 0B           */ IL_00E9: stloc.1
    /* 0x000010D6 72B4020070   */ IL_00EA: ldstr     "Caught an exception checking for console input, console input disabled. (probably safe to ignore)"
    /* 0x000010DB 287800000A   */ IL_00EF: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010E0 07           */ IL_00F4: ldloc.1
    /* 0x000010E1 6F7B00000A   */ IL_00F5: callvirt  instance string [mscorlib]System.Exception::get_Message()
    /* 0x000010E6 287800000A   */ IL_00FA: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010EB DE00         */ IL_00FF: leave.s   IL_0101
} // end handler

/* 0x000010ED 2A           */ IL_0101: ret
} // end of method Startup::Start
// Token: 0x06000029 RID: 41 RVA: 0x00002DE0 File Offset: 0x00000FE0
.method public hidebysig static 
    void Start (
        string[] args
    ) cil managed 
{
    // Header Size: 12 bytes
    // Code Size: 174 (0xAE) bytes
    .maxstack 3

    /* 0x00000FEC 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
    /* 0x00000FF1 286300000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
    /* 0x00000FF6 284700000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
    /* 0x00000FFB 286400000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
    /* 0x00001000 02           */ IL_0014: ldarg.0
    /* 0x00001001 286500000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
    /* 0x00001006 14           */ IL_001A: ldnull
    /* 0x00001007 FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
    /* 0x0000100D 736700000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
    /* 0x00001012 286800000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001017 14           */ IL_002B: ldnull
    /* 0x00001018 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
    /* 0x0000101E 736900000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
    /* 0x00001023 286A00000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001028 14           */ IL_003C: ldnull
    /* 0x00001029 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
    /* 0x0000102F 736B00000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
    /* 0x00001034 286C00000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001039 14           */ IL_004D: ldnull
    /* 0x0000103A FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
    /* 0x00001040 736D00000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
    /* 0x00001045 286E00000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x0000104A 16           */ IL_005E: ldc.i4.0
    /* 0x0000104B 286F00000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
    /* 0x00001050 D07F000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
    /* 0x00001055 280E00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    /* 0x0000105A 287000000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
    /* 0x0000105F 14           */ IL_0073: ldnull
    /* 0x00001060 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
    /* 0x00001066 737100000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
    /* 0x0000106B 287200000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
    /* 0x00001070 285600000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
    /* 0x00001075 14           */ IL_0089: ldnull
    /* 0x00001076 FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
    /* 0x0000107C 737300000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
    /* 0x00001081 6F7400000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
    /* 0x00001086 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
    /* 0x0000108B 2D01         */ IL_009F: brtrue.s  IL_00A2

    /* 0x0000108D 2A           */ IL_00A1: ret

    /* 0x0000108E 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
    /* 0x00001093 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
    /* 0x00001098 26           */ IL_00AC: pop
    /* 0x00001099 2A           */ IL_00AD: ret
} // end of method Startup::Start
// Token: 0x06000029 RID: 41 RVA: 0x000030A8 File Offset: 0x000012A8
.method public hidebysig static 
    void Start (
        string[] args
    ) cil managed 
{
    // Header Size: 12 bytes
    // Code Size: 174 (0xAE) bytes
    .maxstack 3

    /* 0x000012B4 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
    /* 0x000012B9 287D00000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
    /* 0x000012BE 286200000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
    /* 0x000012C3 287E00000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
    /* 0x000012C8 02           */ IL_0014: ldarg.0
    /* 0x000012C9 287F00000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
    /* 0x000012CE 14           */ IL_001A: ldnull
    /* 0x000012CF FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
    /* 0x000012D5 738100000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
    /* 0x000012DA 288200000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x000012DF 14           */ IL_002B: ldnull
    /* 0x000012E0 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
    /* 0x000012E6 738300000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
    /* 0x000012EB 288400000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x000012F0 14           */ IL_003C: ldnull
    /* 0x000012F1 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
    /* 0x000012F7 738500000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
    /* 0x000012FC 288600000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001301 14           */ IL_004D: ldnull
    /* 0x00001302 FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
    /* 0x00001308 738700000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
    /* 0x0000130D 288800000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001312 16           */ IL_005E: ldc.i4.0
    /* 0x00001313 288900000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
    /* 0x00001318 D0BC000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
    /* 0x0000131D 282C00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    /* 0x00001322 288A00000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
    /* 0x00001327 14           */ IL_0073: ldnull
    /* 0x00001328 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
    /* 0x0000132E 738B00000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
    /* 0x00001333 288C00000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
    /* 0x00001338 287000000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
    /* 0x0000133D 14           */ IL_0089: ldnull
    /* 0x0000133E FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
    /* 0x00001344 738D00000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
    /* 0x00001349 6F8E00000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
    /* 0x0000134E 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
    /* 0x00001353 2D01         */ IL_009F: brtrue.s  IL_00A2

    /* 0x00001355 2A           */ IL_00A1: ret

    /* 0x00001356 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
    /* 0x0000135B 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
    /* 0x00001360 26           */ IL_00AC: pop
    /* 0x00001361 2A           */ IL_00AD: ret
} // end of method Startup::Start
private static void PatchStartup(类型定义)
{
ILProcessor il=definition.Methods.First(x=>x.Name==“Start”).Body.GetILProcessor();
int index=默认值(int);
对于(int i=il.Body.Instructions.Count-1;i!=0;i--)
if(il.Body.Instructions[i].OpCode==OpCode.Newobj)
{
指数=i+2;
打破
}
List removedInstructions=新列表();
for(int i=索引;i
原始IL:

    private static void PatchStartup(TypeDefinition definition)
    {
        ILProcessor il = definition.Methods.First(x => x.Name == "Start").Body.GetILProcessor();

        int index = default(int);

        for (int i = il.Body.Instructions.Count - 1; i != 0; i--)
            if (il.Body.Instructions[i].OpCode == OpCodes.Newobj)
            {
                index = i + 2;
                break;
            }

        List<Instruction> removedInstructions = new List<Instruction>();

        for (int i = index; i < il.Body.Instructions.Count; i++)
            removedInstructions.Add(il.Body.Instructions[i]);

        foreach (var i in removedInstructions) il.Remove(i); 

        il.InsertAfter(il.Body.Instructions[il.Body.Instructions.Count - 1], il.Create(OpCodes.Ret));

        il.Body.Variables.Clear();
        il.Body.InitLocals = false;

        il.Body.Optimize();
        il.Body.OptimizeMacros();
    }
// Token: 0x06000029 RID: 41 RVA: 0x00002DE0 File Offset: 0x00000FE0
.method public hidebysig static 
    void Start (
        string[] args
    ) cil managed 
{
// Header Size: 12 bytes
// Code Size: 258 (0x102) bytes
// LocalVarSig Token: 0x1100000C RID: 12
.maxstack 3
.locals init (
    [0] string,
    [1] class [mscorlib]System.Exception
)

/* 0x00000FEC 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
/* 0x00000FF1 286300000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
/* 0x00000FF6 284700000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
/* 0x00000FFB 286400000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
/* 0x00001000 02           */ IL_0014: ldarg.0
/* 0x00001001 286500000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
/* 0x00001006 14           */ IL_001A: ldnull
/* 0x00001007 FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
/* 0x0000100D 736700000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
/* 0x00001012 286800000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001017 14           */ IL_002B: ldnull
/* 0x00001018 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
/* 0x0000101E 736900000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
/* 0x00001023 286A00000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001028 14           */ IL_003C: ldnull
/* 0x00001029 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
/* 0x0000102F 736B00000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
/* 0x00001034 286C00000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001039 14           */ IL_004D: ldnull
/* 0x0000103A FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
/* 0x00001040 736D00000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
/* 0x00001045 286E00000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x0000104A 16           */ IL_005E: ldc.i4.0
/* 0x0000104B 286F00000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
/* 0x00001050 D080000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
/* 0x00001055 280E00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
/* 0x0000105A 287000000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
/* 0x0000105F 14           */ IL_0073: ldnull
/* 0x00001060 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
/* 0x00001066 737100000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
/* 0x0000106B 287200000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
/* 0x00001070 285600000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
/* 0x00001075 14           */ IL_0089: ldnull
/* 0x00001076 FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
/* 0x0000107C 737300000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
/* 0x00001081 6F7400000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
/* 0x00001086 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
/* 0x0000108B 2D01         */ IL_009F: brtrue.s  IL_00A2

/* 0x0000108D 2A           */ IL_00A1: ret

/* 0x0000108E 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
/* 0x00001093 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
/* 0x00001098 26           */ IL_00AC: pop
.try
{
    /* 0x00001099 7E7500000A   */ IL_00AD: ldsfld    string [mscorlib]System.String::Empty
    /* 0x0000109E 0A           */ IL_00B2: stloc.0
    /* 0x0000109F 2B06         */ IL_00B3: br.s      IL_00BB
    // loop start (head: IL_00BB)
        /* 0x000010A1 287600000A   */ IL_00B5: call      string [mscorlib]System.Console::ReadLine()
        /* 0x000010A6 0A           */ IL_00BA: stloc.0

        /* 0x000010A7 06           */ IL_00BB: ldloc.0
        /* 0x000010A8 728C020070   */ IL_00BC: ldstr     "exit"
        /* 0x000010AD 6F7700000A   */ IL_00C1: callvirt  instance bool [mscorlib]System.String::Contains(string)
        /* 0x000010B2 2CED         */ IL_00C6: brfalse.s IL_00B5
    // end loop

    /* 0x000010B4 7296020070   */ IL_00C8: ldstr     "Saving..."
    /* 0x000010B9 287800000A   */ IL_00CD: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010BE 287900000A   */ IL_00D2: call      void [Eco.Core]Eco.Core.Plugins.StorageManager::SaveAndFlush()
    /* 0x000010C3 72AA020070   */ IL_00D7: ldstr     "Done"
    /* 0x000010C8 287800000A   */ IL_00DC: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010CD 16           */ IL_00E1: ldc.i4.0
    /* 0x000010CE 287A00000A   */ IL_00E2: call      void [mscorlib]System.Environment::Exit(int32)
    /* 0x000010D3 DE18         */ IL_00E7: leave.s   IL_0101
} // end .try
catch [mscorlib]System.Exception
{
    /* 0x000010D5 0B           */ IL_00E9: stloc.1
    /* 0x000010D6 72B4020070   */ IL_00EA: ldstr     "Caught an exception checking for console input, console input disabled. (probably safe to ignore)"
    /* 0x000010DB 287800000A   */ IL_00EF: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010E0 07           */ IL_00F4: ldloc.1
    /* 0x000010E1 6F7B00000A   */ IL_00F5: callvirt  instance string [mscorlib]System.Exception::get_Message()
    /* 0x000010E6 287800000A   */ IL_00FA: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010EB DE00         */ IL_00FF: leave.s   IL_0101
} // end handler

/* 0x000010ED 2A           */ IL_0101: ret
} // end of method Startup::Start
// Token: 0x06000029 RID: 41 RVA: 0x00002DE0 File Offset: 0x00000FE0
.method public hidebysig static 
    void Start (
        string[] args
    ) cil managed 
{
    // Header Size: 12 bytes
    // Code Size: 174 (0xAE) bytes
    .maxstack 3

    /* 0x00000FEC 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
    /* 0x00000FF1 286300000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
    /* 0x00000FF6 284700000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
    /* 0x00000FFB 286400000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
    /* 0x00001000 02           */ IL_0014: ldarg.0
    /* 0x00001001 286500000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
    /* 0x00001006 14           */ IL_001A: ldnull
    /* 0x00001007 FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
    /* 0x0000100D 736700000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
    /* 0x00001012 286800000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001017 14           */ IL_002B: ldnull
    /* 0x00001018 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
    /* 0x0000101E 736900000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
    /* 0x00001023 286A00000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001028 14           */ IL_003C: ldnull
    /* 0x00001029 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
    /* 0x0000102F 736B00000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
    /* 0x00001034 286C00000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001039 14           */ IL_004D: ldnull
    /* 0x0000103A FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
    /* 0x00001040 736D00000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
    /* 0x00001045 286E00000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x0000104A 16           */ IL_005E: ldc.i4.0
    /* 0x0000104B 286F00000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
    /* 0x00001050 D07F000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
    /* 0x00001055 280E00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    /* 0x0000105A 287000000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
    /* 0x0000105F 14           */ IL_0073: ldnull
    /* 0x00001060 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
    /* 0x00001066 737100000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
    /* 0x0000106B 287200000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
    /* 0x00001070 285600000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
    /* 0x00001075 14           */ IL_0089: ldnull
    /* 0x00001076 FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
    /* 0x0000107C 737300000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
    /* 0x00001081 6F7400000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
    /* 0x00001086 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
    /* 0x0000108B 2D01         */ IL_009F: brtrue.s  IL_00A2

    /* 0x0000108D 2A           */ IL_00A1: ret

    /* 0x0000108E 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
    /* 0x00001093 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
    /* 0x00001098 26           */ IL_00AC: pop
    /* 0x00001099 2A           */ IL_00AD: ret
} // end of method Startup::Start
// Token: 0x06000029 RID: 41 RVA: 0x000030A8 File Offset: 0x000012A8
.method public hidebysig static 
    void Start (
        string[] args
    ) cil managed 
{
    // Header Size: 12 bytes
    // Code Size: 174 (0xAE) bytes
    .maxstack 3

    /* 0x000012B4 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
    /* 0x000012B9 287D00000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
    /* 0x000012BE 286200000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
    /* 0x000012C3 287E00000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
    /* 0x000012C8 02           */ IL_0014: ldarg.0
    /* 0x000012C9 287F00000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
    /* 0x000012CE 14           */ IL_001A: ldnull
    /* 0x000012CF FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
    /* 0x000012D5 738100000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
    /* 0x000012DA 288200000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x000012DF 14           */ IL_002B: ldnull
    /* 0x000012E0 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
    /* 0x000012E6 738300000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
    /* 0x000012EB 288400000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x000012F0 14           */ IL_003C: ldnull
    /* 0x000012F1 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
    /* 0x000012F7 738500000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
    /* 0x000012FC 288600000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001301 14           */ IL_004D: ldnull
    /* 0x00001302 FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
    /* 0x00001308 738700000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
    /* 0x0000130D 288800000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001312 16           */ IL_005E: ldc.i4.0
    /* 0x00001313 288900000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
    /* 0x00001318 D0BC000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
    /* 0x0000131D 282C00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    /* 0x00001322 288A00000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
    /* 0x00001327 14           */ IL_0073: ldnull
    /* 0x00001328 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
    /* 0x0000132E 738B00000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
    /* 0x00001333 288C00000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
    /* 0x00001338 287000000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
    /* 0x0000133D 14           */ IL_0089: ldnull
    /* 0x0000133E FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
    /* 0x00001344 738D00000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
    /* 0x00001349 6F8E00000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
    /* 0x0000134E 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
    /* 0x00001353 2D01         */ IL_009F: brtrue.s  IL_00A2

    /* 0x00001355 2A           */ IL_00A1: ret

    /* 0x00001356 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
    /* 0x0000135B 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
    /* 0x00001360 26           */ IL_00AC: pop
    /* 0x00001361 2A           */ IL_00AD: ret
} // end of method Startup::Start
//令牌:0x06000029 RID:41 RVA:0x00002DE0文件偏移量:0x00000FE0
.方法公共隐藏静态
无效启动(
字符串[]args
)cil管理
{
//标题大小:12字节
//代码大小:258(0x102)字节
//LocalVarSig令牌:0x1100000C RID:12
.maxstack 3
.init(
[0]字符串,
[1] 类[mscorlib]System.Exception
)
/*0x00000FEC 726E020070*/IL_0000:ldstr“生态服务器{0}”
/*0x00000FF1 2863000000A*/IL_0005:调用字符串[Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
/*0x00000FF6 284700000A*/IL_000A:调用字符串[mscorlib]系统。字符串::格式(字符串,对象)
/*0x00000FFB 286400000A*/IL_000F:调用void[Eco.Shared]Eco.Shared.Utils.Log::WriteLine(字符串)
/*0x000010002*/IL_0014:ldarg.0
/*0x00001001 286500000A*/IL_0015:调用void[Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(字符串[])
/*0x00001006 14*/IL_001A:ldnull
/*0x00001007 FE062D00002B*/IL_001B:ldftn!!0[Eco.Core]Eco.Core.Serialization.SerializationUtils::反序列化JSON(字符串)
/*0x0000100D 736700000A*/IL_0021:newobj实例无效类[mscorlib]System.Func`2::.ctor(对象,本机int)
/*0x00001012 286800000A*/IL_0026:调用void类[Eco.Shared]Eco.Shared.Serialization.JsonUtil`1::set_反序列化(类[mscorlib]System.Func`2)
/*0x00001017 14*/IL_002B:ldnull
/*0x00001018 FE062E00002B*/IL_002C:ldftn!!0[Eco.Core]Eco.Core.Serialization.SerializationUtils::反序列化JSON(字符串)
/*0x0000101E 736900000A*/IL_0032:newobj实例无效类[mscorlib]System.Func`2::.ctor(对象,本机int)
/*0x00001023 286A00000A*/IL_0037:调用void类[Eco.Shared]Eco.Shared.Serialization.JsonUtil`1::set_反序列化(类[mscorlib]System.Func`2)
/*0x00001028 14*/IL_003C:ldnull
/*0x00001029 FE062F00002B*/IL_003D:ldftn!!0[Eco.Core]Eco.Core.Serialization.SerializationUtils::反序列化JSON(字符串)
/*0x0000102F 736B0000A*/IL_0043:newobj实例无效类[mscorlib]System.Func`2::.ctor(对象,本机int)
/*0x00001034 286C00000A*/IL_0048:调用void类[Eco.Shared]Eco.Shared.Serialization.JsonUtil`1::set_反序列化(类[mscorlib]System.Func`2)
/*0x00001039 14*/IL_004D:ldnull
/*0x0000103A FE063000002B*/IL_004E:ldftn!!0[Eco.Core]Eco.Core.Serialization.SerializationUtils::反序列化JSON(字符串)
/*0x00001040 736D00000A*/IL_0054:newobj实例无效类[mscorlib]System.Func`2::.ctor(对象,本机int)
/*0x00001045 286E00000A*/IL_0059:调用void类[Eco.Shared]Eco.Shared.Serialization.JsonUtil`1::set_反序列化(类[mscorlib]System.Func`2)
/*0x0000104A 16*/IL_005E:ldc.i4.0
/*0x0000104B 286F00000A*/IL_005F:调用void[Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
/*0x00001050 D080000001*/IL_0064:ldtoken[Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
/*0x00001055 280E00000A*/IL_0069:调用类[mscorlib]System.Type[mscorlib]System.Type::GetTypeFromHandle(值类型[mscorlib]System.RuntimeTypeHandle)
/*0x0000105A 287000000A*/IL_006E:调用void[Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(类[mscorlib]System.Type)
/*0x0000105F 14*/IL_0073:ldnull
/*0x00001060 FE062B00006*/IL_0074:ldftn void Eco.Server.Startup::ApplicationReadException(对象,类[System]System.Threading.ThreadExceptionEventArgs)
/*0x00001066 737100000A*/IL_007A:newobj实例void[System]System.Threading.ThreadExceptionEventHandler::.ctor(对象,本机int)
/*0x0000106B 287200000A*/IL_007F:调用void[System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(类[System]System.Threading.ThreadExceptionEventHandler)
/*0x00001070 2856000A*/IL_0084:调用类[mscorlib]System.AppDomain[mscorlib]System.AppDomain::get_CurrentDomain()
/*0x00001075 14*/IL_0089:ldnull
/*0x00001076 FE062A00006*/IL_008A:ldftn void Eco.Server.Startup::CurrentDomainUnhandledException(对象,类[mscorlib]系统。UnhandledExceptionEventArgs)
/*0x0000107C 737300000A*/IL_0090:newobj实例无效[mscorlib]系统。未处理的异常venthandler::.ctor(对象,本机int)
/*0x00001081 6F740000