Created
January 16, 2021 19:35
-
-
Save Manuel-S/4508b8291c31ea7caf3719382360cf10 to your computer and use it in GitHub Desktop.
How to inject into any .net application (unless AoT compiled)
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
<configuration> | |
<runtime> | |
<appDomainManagerType value="LauncherPatcher" /> | |
<appDomainManagerAssembly value="LauncherPatcher, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> | |
</runtime> | |
</configuration> |
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 System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Reflection; | |
using System.Threading; | |
class LauncherPatcher : AppDomainManager { | |
public override void InitializeNewDomain(AppDomainSetup appDomainInfo) | |
{ | |
AppDomain.CurrentDomain.AssemblyLoad += (sender, args) => { | |
var name = args.LoadedAssembly.GetName().Name; | |
// wait for relevant assemblies we want to hook into to be loaded | |
switch(name) | |
{ | |
case "Application.Library": | |
//hook here | |
break; | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment