Last active
March 25, 2020 14:11
-
-
Save pardeike/e74016517ac6785cc78f22bbe2ddb91d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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