When emitting pinvokes, GetCLRProfilerPath uses CORECLR_PROFILER_PATH to figure out the location of the native profiler module. While this works in most cases, it can cause issues in some scenarios:
Raw Profiler Hook scenarios will not work, since the environment variable is set to the CLR Instrumentation Engine.
It's possible for the process to change its environment variables, changing the behavior of GetCLRProfilerPath.
On Windows this could be done using GetModuleHandleEx/GetModuleFileName.
On Linux this could be done using dladdr.
When emitting pinvokes, GetCLRProfilerPath uses
CORECLR_PROFILER_PATH
to figure out the location of the native profiler module. While this works in most cases, it can cause issues in some scenarios:GetCLRProfilerPath
.On Windows this could be done using
GetModuleHandleEx/GetModuleFileName
. On Linux this could be done usingdladdr
.