功能字节代码执行 [英] function byte code execution

查看:85
本文介绍了功能字节代码执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得一个以字节码实现等效功能的函数(也许在byte []数组中获得该函数)并执行它?
另外,如果我从可执行文件中读取字节并将其放在byte []选项卡中,该如何执行?
谢谢你的帮助!! :-)

how to get a function implementing equivalent in bytecode (maybe get it in byte[] array) , and execute it?
also if i read bytes from an executable file and put them in a byte[] tab, how can i execute it?
thanks for any help!! :-)

推荐答案

快速解答:您无法做到.而且,整个程序集上下文之外的字节码没有完全定义的含义.试图解决这个问题根本没有任何意义.

也许您可以解释自己的最终目标;在这种情况下,您可能会得到一些有用的建议.

—SA
Quick answer: you cannot do it. Moreover, a byte code outside of the whole context of the assembly does not make fully defined meaning. An attempt to solve this problem simply makes no sense.

Perhaps you can explain your ultimate goal; in this case you could possibly get some useful advice.

—SA


如果它是.net可执行文件中的完整字节[],请使用Assembly.Load(byte [])或AppDomain.Current.Load (byte []),然后使用Reflection找到对象或所需的任何对象. (与从文件加载没有什么不同)当然,您可以调用随后找到的任何方法.

如果byte []是IL字节代码或类似的代码,则可以使用ILGenerator.Emit()创建一个可执行的委托,然后执行它.但是我想您要使其正常工作会遇到很多麻烦.
If it is the full byte[] from an .net executable file, use Assembly.Load(byte[]) or AppDomain.Current.Load(byte[]) and then use Reflection to locate the object or anything you want. (It got no different from loading from a file) Of course you can invoke any of the method found then.

If the byte[] is the IL byte code or similar, you may be able to use ILGenerator.Emit() and create a executable delegate, and then execute it. But I guess you will have a lot of trouble get it working properly.


这篇关于功能字节代码执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆