
Frida-based .NET Framework injector and managed method hooking toolkit for runtime tracing, native entrypoint resolution, and dynamic analysis of Windows processes.
This repository contains two projects that are designed to be used together:
Frida.dll)These projects target Windows and assume you are instrumenting processes you own or have permission to test.
Frida hooks native code addresses. On .NET Framework, managed methods are JIT-compiled into native code, but:
So the overall pattern is:
InjectorCli to attach/spawn a target and load a Frida JavaScript agent.ManagedHookHostProj.dll to:
RuntimeHelpers.PrepareMethod)GetFunctionPointer)Interceptor.attach(entrypoint, ...) to trace calls/ log args/ (optionally) alter behavior.InjectorCli (C#)
Frida.DeviceManager and selects a deviceFrida.Script from your JavaScript file and loads itscript.MessageAgent (JavaScript)
CreateFileW, MessageBoxW)Module.load() the managed helper DLLResolveMethod) via NativeFunctionDescribeObjectUtf16 + FreeUtf16) instead of CLR string layout parsingGetLastErrorUtf16 when resolution failsManagedHookHostProj (C# class library with exports)
ReadInt32 / WriteInt32 / WriteBool)GetLastErrorUtf16, ClearLastError)To illustrate how all these work, we will assume that the target process is compiled to target 32-bit (WoW64) CPU architecture.
frida-clr x86Frida.dll to inject into an x86 target process.cd C:\path\to\frida-clr
configure.bat --prefix="%CD%\dist-x86" --build=windows-x86-md
cd build
make.bat
make.bat install
Confirm you have:
dist-x86\bin\Frida.dll (PE32)InjectorCli (x86)You need to open InjectorCli.sln in Visual Studio, and set build target to Release | x86.
Or from a Developer Command Prompt:
msbuild \InjectorCli\InjectorCli.sln /p:Configuration=Release /p:Platform=x86
Frida.dll is not at dist-x86\bin\Frida.dll, update the reference in InjectorCli.csproj accordingly.ManagedHookHostProj (x86)You need to open ManagedHookHostProj.sln in Visual Studio, and set build target to Release | x86.
Or from a Developer Command Prompt:
msbuild \ManagedHookHostProj\ManagedHookHostProj.sln /p:Configuration=Release /p:Platform=x86
dumpbin /exports examples\ManagedHookHostProj\bin\Release\ManagedHookHostProj.dll
Note: on x86 + StdCall you may see decorated export names (e.g. _ResolveMethod@16). The provided agent script includes a fallback that locates decorated names.
FridaClrInjector.exe --pid 1234 --script hooks\hook_createfilew.js
FridaClrInjector.exe --spawn "C:\Windows\SysWOW64\notepad.exe" --script hooks\hook_messagebox.js
You should first edit hook_managed.js, by setting:
helperDllPath to the built ManagedHookHostProj.dlltargetAssemblyPath, targetTypeName, targetMethodName, paramSigThen run:
FridaClrInjector.exe --pid 1234 --script "C:\path\to\hook_managed.js"
paramSig to select the correct overload, otherwise you may hook the wrong one.Frida.dll + x86 helper DLL.MakeString/Box*/DescribeObject) should be treated as compatibility-only.Injector docs:
Helper DLL docs:
Example Test Target docs: