这里没用ILGenerator的方式添加ILCode指令,而是直接恢复ILCode指令块字节。
先获得DynamicMethod的DynamicILInfo
DynamicMethod.GetDynamicILInfo()
Returns a DynamicILInfo object that can be used to generate a method body from metadata tokens, scopes, and Microsoft intermediate language (MSIL) streams.
再调用DynamicILInfo.SetCode()设置代码字节数组
Sets the code body of the associated dynamic method.
public void SetCode (byte[]? code, int maxStackSize);
某处直接调用DynamicILInfo.SetCode恢复代码,省略代码解密部分。