开发者

How to tell from a CIL instruction whether a field is read or written to?

开发者 https://www.devze.com 2022-12-15 05:40 出处:网络
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.

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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号