DEV Community

DLL injection of managed code into native process

This project demonstrates DLL injection, a technique to inject code into another process. DLL injection is used by malware but also has legitimate uses like creating software plugins. The process involves opening the target process, allocating memory, writing the DLL path, and loading the DLL using LoadLibrary. Function hooking allows intercepting and modifying API calls within the injected process. The Windows API relies on libraries like kernel32.dll and ntdll.dll, interacting with the kernel via the SSDT. A DLL's DllMain function executes upon successful injection. This example injects a C library, then loads the CoreCLR runtime and a managed C# DLL into a native process (like notepad.exe). The C# DLL displays a message box showing process information. The GitHub repository contains the complete code. The provided C# code shows the injected DLL's functionality. The project requires modifying the code with correct paths to CoreCLR and the injected library.
favicon
dev.to
dev.to
Create attached notes ...