English 中文(简体)
为何修改后的组件不运行? (JIT 编译器遇到内部限制 。 )
原标题:Why this modified assembly does not run? (JIT Compiler encountered an internal limitation.)

I ve modified the bytecode of an assembly to get rid off of an error and now when I try to use it I get a InvalidProgramException. All I ve done is replace this code with 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
}

有什么想法 为什么这是错的?

谢谢!

最佳回答

您原来的 captain captain block 总是会抛出。 也就是说, 无法“ 正常地” 退出区块 。

您修改过的 capt block 并不丢弃, 所以您需要正常退出该区块 。 您需要使用 < a href=" http:// msdn. microsoft. com/ en- us/ library/ system. reflection. emit. opcodes. leave" {code> leave 或 < a href=> http://msdn. microsoftr. com/ en- us/library/ system. reflection. emit. opcodes. left_ s" {code> lift.s 。

(你也许还需要 < a href=>" http://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.pop"\ code>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
问题回答

暂无回答




相关问题
How to protect Python source code?

Is it possible to distribute only the bytecode version (.pyc file) of a Python script instead of the original .py file? My app embeds the Python interpreter and calls PyImport_Import to load a script. ...

What optimizations does Python do without the -O flags?

I had always assumed that the Python interpreter did no optimizations without a -O flag, but the following is a bit strange: >>> def foo(): ... print %s % Hello world ... >>>...

Byte code to Java source code

Is it possible to convert a .class file to .java file? How can this be done? What about the correctness of the code extracted from this option?

Generating .class file for JVM

I am working on a project that requires me to generate a java ".class" file on the go that can be later on compiled on the JVM. After learning and working with MSIL (Microsoft IL) which is also a ...

What is the difference between assembly code and bytecode?

While in the search for the various differences in the meanings of source code, bytecode, assembly code, machine code, compilers, linkers, interpreters, assemblers and all the rest, I only got ...

Local variables in java bytecode

I am trying to learn java bytecode and I stumbled on this: I compiled this very simple code with the -g option: public class Test { public static void main(String args[]) { double a = 1.0; int ...

热门标签