Skip to content

Instantly share code, notes, and snippets.

@pardeike
Last active March 25, 2020 14:11
Show Gist options
  • Save pardeike/e74016517ac6785cc78f22bbe2ddb91d to your computer and use it in GitHub Desktop.
Save pardeike/e74016517ac6785cc78f22bbe2ddb91d to your computer and use it in GitHub Desktop.
using HarmonyLib;
using System;
using System.Net;
namespace TestProcessResponse
{
class Program
{
static void Main(string[] args)
{
_ = args;
var harmony = new Harmony("test");
harmony.PatchAll();
var t_CoreResponseData = AccessTools.TypeByName("System.Net.CoreResponseData");
var m_SetResponse = AccessTools.Method("System.Net.HttpWebRequest:SetResponse", new[] { t_CoreResponseData });
_ = harmony.Patch(m_SetResponse);
var client = new WebClient();
_ = client.DownloadString("http://www.google.com");
_ = Console.ReadKey();
}
[HarmonyPatch(typeof(HttpWebRequest))]
[HarmonyPatch("ProcessResponse")]
class ProcessResponse_Patch
{
public static void Prefix()
{
Console.WriteLine("ProcessResponse called!");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment