What is code injection in .net (as a programming skill)?

In the most common sense, of course, "this is a method that affects the behavior of a program in a way that its authors did not intend to" (wiki).

Then, all reflections and type builders using methods can also be called "code injection," but no one does.

When I always thought that “code injection” was something like “runtime”: how to start a thread in another process to get some interesting data, I was surprised how Reflexil understood this: “convert C # instructions to IL on” ', save the edited assembly and replace the old assembly with a new one "(10%, which I missed something).

So now I wonder what methods in .NET are called with the term "code injection"?

BTW. I am interested to know: is it possible to replace the "pointer to a virtual method" in the "table of virtual methods" with a very, very private, several times nested system class, with a pointer to my own method at runtime. Pure code injection from my understanding.

+3
source share
3 answers

Entering code in .NET is quite difficult. Mostly because the code does not exist until the last moment. The fraction of a second before it starts the execution generated by the JIT compiler.

Practical approaches use AI correspondence, common in AOP, for example. This happens offline before the program even starts execution. This is no longer an "injection", you are physically changing the program on disk.

IL, . , , , . , API- . , .

+4

- (AOP) .

+1

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


All Articles