如何从 CIL 指令判断某个字段是读取还是写入?
我目前正在使用 Mono Cecil 从 C# 项目中提取数据。现在我需要检查每个方法中是否读取或写入了某个字段。
如何从 CIL 指令 正在读取或写入字段?
因为我怀疑 Mono Cecil 中有一个类似于 Eclipse JDT 中的赋值 允许我提取左侧和右侧。如果有的话,我就可以从那里开始工作。
I am currently using Mono Cecil to extract data from C# projects. Now I need to check whether a field is read or written to in each method.
How can tell from the CIL instruction that a field is being read or written to?
Because I doubt there a library in Mono Cecil similar to Assignment in Eclipse's JDT that allows me to extract the left hand side and right hand side. If there is, then I can just work from there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
直接字段存储的指令是
stfld
,因此您必须注意这一点。请注意,字段也可以通过指针(
*
和&
类型)间接写入,这在最一般的情况下是不可能检测到的(因为指针可以来自外面)。The instruction for direct field stores is
stfld
, so you'll have to look out for that.Note that fields can also be indirectly written to via pointers (both
*
and&
kind), which is impossible to detect in the most general case (as pointer can come from the outside).