Implement high-level .NET API Translation and JIT Metadata Tracing (PR-2) - #174
Merged
kevoreilly merged 2 commits intoAug 21, 2026
Merged
Conversation
…R-2) Surgically implements the second PR of our .NET modernization roadmap inside hook_clr.c: 1. Implements a crash-safe, SEH-protected SafeGetMethodName helper function that accesses the getMethodName virtual method (index 0) from the ICorJitInfo/ICorMethodInfo vtable. 2. Incorporates robust pointer-read validation probe checks to guarantee absolute crash-protection across all .NET Framework and .NET Core versions. 3. Automatically translates and logs the exact fully qualified Class and Method names (e.g. System.Net.WebClient.DownloadData) being JITcompiled inside compileMethod to the behavioral log under the "dotnet" category, providing a powerful, high-level API execution trace.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview of .NET API Translation inside opt/dotnet-api-translation:
Currently, capemon JIT monitoring operates strictly at the binary bytecode level, logging only generic messages like "Dumped decrypted .NET JIT MSIL bytecode at 0x%p". While valuable for payload recovery, it
provides the analyst with zero context regarding the meaning of the executing code.
To elevate this to High-Level .NET API Translation, we engineered a highly sophisticated, crash-safe metadata resolution engine directly inside hook_clr.c:
During JIT compilation, the Common Language Runtime (CLR) passes a pointer compHnd (an ICorJitInfo C++ class) to compileMethod.
To execute this safely from pure C without risking crashes due to version-dependent VTable shifts between different .NET Framework and .NET Core runtimes, we implemented SafeGetMethodName:
When a method is compiled, we now extract its fully qualified name (e.g., System.Net.WebClient.DownloadData) and write it directly to the behavioral log under the unifed "dotnet" category using LOQ_string:
1 LOQ_string("dotnet", "ss", "Class", className ? className : "UnknownClass", "Method", methodName);
Impact:
Analysts now get a high-fidelity, readable execution trace of the .NET binary's inner workings on the CAPE timeline, showing exactly which classes and APIs are being compiled and executed in real-time!