Mono.Cecil 是否负责分支机构等地点的管理?
好吧,这个问题可能看起来很奇怪,但很简单 - 我的观点是,如果我在反编译代码中有一个“goto”(brtrue等),比如示例
br IL_0003
call *****
IL_0003: ret
,我在 **** 调用之后添加一个命令,将顶部的 br 指向ret 像它应该的那样或该代码。
塞西尔自己做还是我必须照顾所有这些分支? :/ 修复它们并不难,但如果 Cecil 不这样做,我就不会开始这个项目,我没有时间(或知识)进行高级 IL 魔法:P
(是的,我知道它赢了不是 IL_0003,这只是举例)
Well this question may seem odd but it's simple - my point is if i have a "goto" (brtrue etc) in the decompiled code like example
br IL_0003
call *****
IL_0003: ret
and I add a command after that **** call will the br at the top point to ret like it should or to that code.
does Cecil do it by itself or I have to take care of all those branches ? :/
it wouldn't be very hard to fix them but if Cecil doesn't then I simply won't start this project, I've no time (or knowledge) for advanced IL magic :P
(yes I know it won't be IL_0003 it's just for example)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,Cecil 会为您更新分支。
您必须注意的唯一情况是分支是短形式分支的情况。如果注入太多指令,可能会溢出。
有一个非常简单的方法来处理这个问题。在注入代码之前,只需从 Mono.Cecil.Rocks 调用扩展方法 SimplifyMacros,如下所示:
这会将 br.s 变成 br。
当你完成代码注入后,只需调用:
这是相反的操作,也就是说,如果可能的话,它会尝试将 br 转换为 br.s。
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:
This will turn the br.s into br.
And when you're done injecting code, simply call:
Which is the opposite operation, that is, it will try to turn br into br.s if possible.