So with this technique, could I say, develop a macro in my language of choice to execute a snippet of .net code such that the clr runtime is created and the snippet run in that context?
What's the difference between this and simply exporting a method of a .net assembly via https://www.nuget.org/packages/UnmanagedExports/ besides having more control over the CLR/.net environment with the method posted here?
didn't click the link, but this has been possible since .Net 2.0. back when EasyHook was still in alpha I was using it to inject the entire CLR into unmanaged processes. My ridiculous self was writing intel ASM in C# byte arrays, changing permissions on memory pages to make them executable, pausing the process, then injecting my code. After that I discovered C and my life became much simpler.
It’s not so unusual. I learned assembly before I learned C, mostly because I didn’t have a C compiler—or even know that I needed one! My family’s Windows 95 computer had QBASIC preinstalled (which amazingly I learned mostly by browsing the interactive help) and I discovered that in order to speed up my graphics routines, I had to write them in assembly in MASM (and DEBUG), also preinstalled. The fact that they were just there already, without requiring any installation or configuration, was enormously helpful as a beginner.
At ~10 years old, I didn’t have any frame of reference for how difficult this tack was compared to other languages, so I just accepted it as “this is what programming is like”. I only picked up C several years later as I got into programming languages and studied as many different languages as I could. Now I work in programming language technology as both a career and a hobby. :)
yup. taught myself ASM through countless hours debugging/tracing/reversing code (and also reading Intel's docs). i learned how to reverse before i really got interested in programming. i had a tiny bit of C++/Pascal experience from high school. C# came out and I saw an easy way to bust out quick windows apps with a decent GUI. made a hacking/macroing framework for Ultima Online in C#, really hideous, horrible, awful code....but I came up with some decent patches for the many different UO clients.
Oh man, I did something similar to inject controls into IE9's statusbar for a BHO that never got released. As unholy as it seems, having to learn MFC seemed worse
9 comments
[ 2.5 ms ] story [ 25.5 ms ] threadI hope I’m reading it right - you knew intel asm but not C? I’m little surprised. Sorry
At ~10 years old, I didn’t have any frame of reference for how difficult this tack was compared to other languages, so I just accepted it as “this is what programming is like”. I only picked up C several years later as I got into programming languages and studied as many different languages as I could. Now I work in programming language technology as both a career and a hobby. :)
The technique in the OP is slightly different but the end result should be the same if you inject a IJW DLL into any process.
1. https://www.codeproject.com/Articles/10020/Using-managed-cod...