Does Mono.Cecil take care of branches etc location?

半世苍凉 提交于 2019-11-30 12:43:25

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.

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 ();

This will turn the br.s into br.

And when you're done injecting code, simply call:

method.Body.OptimizeMacros ();

Which is the opposite operation, that is, it will try to turn br into br.s if possible.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!