comeillfoo / clr-profiler

A CLR (.NET Runtime) profiler written purely in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Brainstorming

How to create the Profiler COM object in Rust

Basic flow is:

  1. Some COM client (CLR in this case) calls DllGetClassObject, which populates a pointer ([out] parameter) to an instance of a struct that adheres to IClassFactory
  2. The COM client then calls CreateInstance on the IClassFactory that it now has a handle to. This populates a pointer ([out] parameter) to an instance of a struct that adheres to ICorProfilerCallback9.
  3. Now the COM client can call function pointers in this struct that it know will exist. Neat!

Some Helpful Resources:

Some Links

TODO

  • Create facility to run tests against multiple .net versions. For example, here is linux setup for side-by-side .net core installations.
  • A potential source of bugs in the ProfilerInfo struct, is when an S_OK hresult is returned, but one of the out pointer parameters can be null. These need explicitly checked if they are null and wrapped in an Option. If we just dereference, this is undefined behavior! The Microsoft documentation is spotty on which out parameters can be null. Sometimes it is mentioned in the remarks.

About

A CLR (.NET Runtime) profiler written purely in Rust.

License:MIT License


Languages

Language:Rust 99.0%Language:C# 1.0%