问题描述
我正在尝试使jmp操作码在Cil中工作
I'm trying to get the jmp opcode to work in Cil
jmp void ILTest.Program::MyFunc2(int32)
ilasm很好用,但是当我运行程序时,我总是得到公共语言运行时检测到无效的程序异常。
ilasm is fine with it, but when I run the program I always get "common language runtime detects an invalid program" exception.
我知道这是不可验证的代码,所以我尝试授予权限
I know this is unverifiable code so I have tried to give permissions
SecurityPermission烫发=
新的SecurityPermission(SecurityPermissionFlag.Execution |
SecurityPermissionFlag.SkipVerification |
SecurityPermissionFlag.UnmanagedCode);
,但似乎没有任何作用。
but it does not seem to have any effect.
有人有使用'jmp'工作的程序吗?
Has anyone got a program using 'jmp' working?
推荐答案
只能跳转到与当前方法具有相同参数的方法。确保您已经在使用 int32
作为参数的方法中,并且没有任何内容压入堆栈:它必须为空。另外,请确保您不在 try / catch / filter / finally
块中。
jmp
can only jump to a method with the same arguments as the current method. Make sure you're already in a method taking an int32
as a parameter, and that you've nothing pushed on the stack: it must be empty. Also ensure you're not in a try/catch/filter/finally
block.
如果不能满足这些条件,请改为使用呼叫
。
If you can't meet those criteria, use a call
instead.
这篇关于如何使用.net cil jmp操作码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!