How do microsoft linings really work inside?

Therefore, I am interested in the method of its implementation. Basically: how can I implement the same thing again? ... which I am not going to do. Just get it.

The main question: How can (?) Generally intercept an instance of a class? And how can it be replaced in one case by one implementation and in another case with the original or even another implementation?

How can you intercept static methods or private classes.

It's all about gaskets / roles, not so much about plugs.

+5
source share
1 answer

This is done by modifying the Common Intermediate Language (IL) code that is emitted by the compiler. You can perform pre-packaged IL modifications using the Fody library. Fody internally uses the mono.cecil library to manipulate low-level IL. The IL generated by the compiler is modified and saved on disk as an assembly.

I found this reference publication on Moles [pdf file]. Section 4 explains the mechanism of the code toolkit.

+6
source

Source: https://habr.com/ru/post/1200203/


All Articles