This C# example demonstrates injecting a DLL into a target process using direct syscalls via the SysCaller bindings, built as a NativeAOT .NET 8 console application.
- .NET 8 SDK (NativeAOT support)
- Windows x64
SysCaller.dllpresent in the same directory as the published executable and built with required exports
- Build the project:
$ dotnet build -c Release- Publish as a NativeAOT self contained executable:
$ dotnet publish -c Release -r win-x64 /p:PublishAot=true --self-contained true- The output executable will be in
bin\Release\net8.0\win-x64\publish\. - Copy
SysCaller.dllto the same directory as the published executable.
$ InjectDLL.exe <pid> <dll_path><pid>: The process ID of the target process.<dll_path>: Path to the DLL you want to inject (e.g.,test.dll).
Example:
$ InjectDLL.exe 4242 test.dll- Make sure
SysCaller.dllis in the same directory as the published executable or in your system PATH. - The DLL path can be relative or absolute; the injector will resolve it.
- Requires appropriate privileges to open the target process and inject code.
- Tested & Works only on Windows x64 with .NET 8 NativeAOT.