难道Mono.Cecil能做到照顾分支机构等的位置? [英] Does Mono.Cecil take care of branches etc location?
问题描述
那么这个问题可能看上去很奇怪,但它的简单 - 我的意思是,如果我有一个GOTO(brtrue等)的反编译code像例如
Well this question may seem odd but its simple - my point is if i have a "goto" (brtrue etc) in the decompiled code like example
br IL_0003
call *****
IL_0003: ret
和我添加命令后的 * 的*通话将BR顶部点沤像它应该或者是code。
and i add a command after that ** call will the br at the top point to ret like it should or to that code.
不塞西尔去做自己或我必须采取所有这些分支的照顾? :/ 它不会是很难解决这些问题,但如果塞西尔犯规的话,我根本不会启动这个项目,我已经没有时间(或知识)的高级IL魔法:P
does Cecil do it by itself or i have to take care of all those branches ? :/ it wouldnt be very hard to fix them but if Cecil doesnt then i simply wont start this project, ive no time (or knowledge) for advanced IL magic :P
PS。抱歉,如果即时通讯混乱的东西,但即时通讯在.NET中的东西一个初学者; /我是八方通通过其击退同Java或任何有一个虚拟机TBH
PS. sorry if im confusing things but im a begginer in .NET stuff ;/ i was allways repulsed by it same as Java or anything that has a VM TBH.
*(是的,我知道这不会是IL_0003它只是举例)*
*(yes i know it wont be IL_0003 its just for example)*
推荐答案
是的,丝丝将更新分支你。
Yes, Cecil will update the branch for you.
你要好好照顾,唯一的情况是该分支是一个短期形式的分支的情况。如果注入太多的说明,它可能会溢出。
The only case you have to take care of, is the case where the branch is a short form branch. If you inject too much instructions, it might overflow.
有一个非常简单的方法来处理这个问题。注射前code,只需调用扩展方法从Mono.Cecil.Rocks SimplifyMacros,像这样的:
There's a very simple way to handle this. Before injecting code, simply call the extension methods SimplifyMacros from the Mono.Cecil.Rocks, like this:
method.Body.SimplifyMacros ();
这将会把br.s变成BR
This will turn the br.s into br.
当你完成注入code,只需拨打:
And when you're done injecting code, simply call:
method.Body.OptimizeMacros ();
哪个是相反的操作,即,它将尝试把BR成br.s如果可能的话。
Which is the opposite operation, that is, it will try to turn br into br.s if possible.
这篇关于难道Mono.Cecil能做到照顾分支机构等的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!