Skip to content

Instantly share code, notes, and snippets.

Kevin Gosse kevingosse

Block or report user

Report or block kevingosse

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Commands.cs
[DllExport("helloworld")]
public static void HelloWorld(IntPtr client, [MarshalAs(UnmanagedType.LPStr)] string args)
{
DebuggingContext.Execute(client, args, HelloWorld);
}
private static void HelloWorld(ClrRuntime runtime, string args)
{
Console.WriteLine("The first 10 types on the heap are: ");
View Commands.cs
[DllExport("helloworld")]
public static void HelloWorld(IntPtr client, [MarshalAs(UnmanagedType.LPStr)] string args)
{
}
View Commands.cs
public static void HelloWorld(IntPtr client, [MarshalAs(UnmanagedType.LPStr)] string args)
{
}
View ThreadPoolTaskScheduler.cs
protected override void QueueTask(Task task)
{
MutateState(task);
var newScheduler = new ThreadPoolTaskScheduler();
typeof(Task).GetField("m_taskScheduler", BindingFlags.Instance | BindingFlags.NonPublic)
.SetValue(task, newScheduler);
ThreadPool.UnsafeQueueUserWorkItem(t => newScheduler.ExecuteTask((Task)t), task);
View Program.cs
class Program
{
static void Main(string[] args)
{
Task.Run(Test);
Console.ReadLine();
}
static async Task Test()
View MutateState.cs
var continuationWrapper = func.Target;
var continuation = continuationWrapper.GetType().GetField("_continuation", BindingFlags.Instance | BindingFlags.NonPublic)
.GetValue(continuationWrapper) as Action;
if (continuation != null)
{
var asyncStateMachineBox = continuation.Target;
var stateMachineField = asyncStateMachineBox?.GetType().GetField("StateMachine");
View MutateState.cs
private void MutateState(Task task)
{
var continuationWrapperType = Type.GetType("System.Runtime.CompilerServices.AsyncMethodBuilderCore+ContinuationWrapper");
var taskAction = typeof(Task).GetField("m_action", BindingFlags.Instance | BindingFlags.NonPublic)
.GetValue(task);
Delegate func = task.AsyncState as Delegate ?? taskAction as Delegate;
if (func?.Target?.GetType() == continuationWrapperType)
View StartupHook.cs
internal class StartupHook
{
public static void Initialize()
{
typeof(Task).GetField("s_asyncDebuggingEnabled", BindingFlags.Static | BindingFlags.NonPublic)
.SetValue(null, true);
typeof(TaskScheduler).GetField("s_defaultTaskScheduler", BindingFlags.Static | BindingFlags.NonPublic)
.SetValue(null, new ThreadPoolTaskScheduler());
}
View Params.cs
public void PrintArgs(params string[] args)
{
foreach (var arg in args)
{
Console.WriteLine(arg);
}
}
View StartupHook.cs
internal class StartupHook
{
public static void Initialize()
{
var type = Type.GetType("System.Array+EmptyArray`1");
var arrayStringType = type.MakeGenericType(typeof(string));
var field = arrayStringType.GetField("Value", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
You can’t perform that action at this time.