This repository has been archived by the owner on Oct 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
161 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Reflection; | ||
using HarmonyLib; | ||
|
||
namespace Marsey.Handbreak; | ||
|
||
/// <summary> | ||
/// In some cases we are required to patch functions publicly | ||
/// </summary> | ||
public static class Manual | ||
{ | ||
public static void ManualPrefix(MethodInfo method, MethodInfo prefix) | ||
{ | ||
Harmony? harm = HarmonyManager.GetHarmony(); | ||
harm?.Patch(method, prefix: prefix); | ||
} | ||
|
||
public static void ManualPostfix(MethodInfo method, MethodInfo postfix) | ||
{ | ||
Harmony? harm = HarmonyManager.GetHarmony(); | ||
harm?.Patch(method, postfix: postfix); | ||
} | ||
|
||
public static void ManualTranspiler(MethodInfo method, MethodInfo transpiler) | ||
{ | ||
Harmony? harm = HarmonyManager.GetHarmony(); | ||
harm?.Patch(method, transpiler: transpiler); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Runtime.Loader; | ||
using Marsey.Handbreak; | ||
using Marsey.Subversion; | ||
|
||
namespace Marsey.Stealthsey; | ||
|
||
/// <summary> | ||
/// Hides marseys from the game | ||
/// </summary> | ||
public static class Hidesey | ||
{ | ||
private static List<Assembly> _hideseys = new List<Assembly>(); | ||
|
||
/// <summary> | ||
/// Hides 0Harmony from assembly list | ||
/// Finally, a patch loader that loads with a patch | ||
/// </summary> | ||
public static void Initialize() | ||
{ | ||
Hide("0Harmony"); | ||
AppDomain.CurrentDomain.GetAssemblies(); | ||
// Is it really insane to patch system functions? | ||
MethodInfo? target = typeof(AppDomain) | ||
.GetMethod("GetAssemblies", BindingFlags.Public | BindingFlags.Instance); | ||
MethodInfo? postfix = | ||
typeof(HideseyPatches) | ||
.GetMethod("LieLoader", BindingFlags.Public | BindingFlags.Static); | ||
|
||
if (target == null || postfix == null) return; | ||
|
||
Manual.ManualPostfix(target, postfix); | ||
|
||
MarseyLogger.Log(MarseyLogger.LogType.DEBG, "Hidesey started."); | ||
} | ||
|
||
/// <summary> | ||
/// Add assembly to _hideseys list | ||
/// </summary> | ||
/// <param name="marsey">string of assembly name</param> | ||
public static void Hide(string marsey) | ||
{ | ||
Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies(); | ||
foreach (Assembly asm in asms) | ||
{ | ||
if (asm.FullName != null && asm.FullName.Contains(marsey)) | ||
{ | ||
Hide(asm); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// If we have the assembly object | ||
/// </summary> | ||
/// <param name="marsey">marsey assembly</param> | ||
public static void Hide(Assembly marsey) | ||
{ | ||
_hideseys.Add(marsey); | ||
} | ||
|
||
public static Assembly[] LyingDomain(Assembly[] original) | ||
{ | ||
return original.Where(assembly => !_hideseys.Contains(assembly)).ToArray(); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Reflection; | ||
|
||
namespace Marsey.Stealthsey; | ||
|
||
public static class HideseyPatches | ||
{ | ||
/// <summary> | ||
/// This is a postfix patch which swaps an assembly list with a less honest one | ||
/// </summary> | ||
/// <returns></returns> | ||
public static void LieLoader(ref Assembly[] __result) | ||
{ | ||
__result = Hidesey.LyingDomain(__result); | ||
} | ||
} |
This file contains 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