gpt4 book ai didi

bytecode - 为什么这个修改后的程序集不运行? (JIT 编译器遇到内部限制。)

转载 作者:行者123 更新时间:2023-12-02 22:41:45 28 4
gpt4 key购买 nike

我修改了程序集的字节码以消除错误,现在当我尝试使用它时,我得到了一个 InvalidProgramException。我所做的就是用 NOPS 替换这段代码:

catch (Exception exception1)
{
Exception exception = exception1;
if (exception as InvalidValueException == null)
{
throw new InvalidGenerationException(2);
}
else
{
throw exception;
}
}

IL 之前:

catch [mscorlib]System.Exception
{
IL_022f: stloc.s exception
IL_0231: ldloc.s exception
IL_0233: isinst Custom.InvalidValueException
IL_0238: brfalse.s IL_023d

IL_023a: ldloc.s exception
IL_023c: throw

IL_023d: ldc.i4.1
IL_023e: newobj instance void Custom.InvalidGenerationException ...
IL_0243: throw
}

IL 之后:

catch [mscorlib]System.Exception
{
IL_022f: nop
IL_0230: nop
IL_0231: nop
IL_0232: nop
IL_0233: nop
IL_0234: nop
IL_0235: nop
IL_0236: nop
IL_0237: nop
IL_0238: nop
IL_0239: nop
IL_023a: nop
IL_023b: nop
IL_023c: nop
IL_023d: nop
IL_023e: nop
IL_023f: nop
IL_0240: nop
IL_0241: nop
IL_0242: nop
IL_0243: nop
}

关于为什么这是错误的任何想法?

谢谢!

最佳答案

你原来的 catch block 总是会抛出。也就是说,没有办法“正常”退出该 block 。

您修改后的 catch block 不会抛出异常,因此您需要正常退出该 block 。您需要使用 leaveleave.s这样做。

(您可能还需要 pop 将捕获的异常从堆栈中取出以保持整洁。不过我不确定这一点,您必须自己尝试一下。)

catch [mscorlib]System.Exception
{
IL_022f: pop // not certain if pop is necessary
IL_0230: leave.s IL_0244
IL_0232: nop
IL_0233: nop
IL_0234: nop
IL_0235: nop
IL_0236: nop
IL_0237: nop
IL_0238: nop
IL_0239: nop
IL_023a: nop
IL_023b: nop
IL_023c: nop
IL_023d: nop
IL_023e: nop
IL_023f: nop
IL_0240: nop
IL_0241: nop
IL_0242: nop
IL_0243: nop
}
IL_0244: ret // or whatever

关于bytecode - 为什么这个修改后的程序集不运行? (JIT 编译器遇到内部限制。),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10703277/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com