Skip to content

Instantly share code, notes, and snippets.

@hypeartist
Created February 7, 2020 22:29
Show Gist options
  • Save hypeartist/b06c0c59d0e9d175efc199e0211ca867 to your computer and use it in GitHub Desktop.
Save hypeartist/b06c0c59d0e9d175efc199e0211ca867 to your computer and use it in GitHub Desktop.
CoreClrImageBase
namespace ConsoleApp1
{
internal static class Program
{
private static unsafe void Main(string[] args)
{
var tp = new ThreadPrivateAccessor {Thread = Thread.CurrentThread};
var currentThreadHandle = (void**)tp.ThreadExposer._DONT_USE_InternalThread;
var someProcFromCoreClr = *currentThreadHandle;
var coreClrImageBase = (byte*)someProcFromCoreClr - 0x3ec4c0;
}
}
public sealed class ThreadExposer
{
internal ExecutionContext? _executionContext;
internal SynchronizationContext? _synchronizationContext;
private string? _name;
private Delegate? _delegate;
private object? _threadStartArg;
public/*Sic!*/ IntPtr _DONT_USE_InternalThread;
}
[StructLayout(LayoutKind.Explicit)]
public struct ThreadPrivateAccessor
{
[FieldOffset(0)]
public Thread Thread;
[FieldOffset(0)]
public ThreadExposer ThreadExposer;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment