Skip to content

Commit

Permalink
Updated the module checker bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
TheUnknownMelon committed Nov 3, 2022
1 parent ddf8e46 commit 25a9e31
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions Deobfuscator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ namespace SNBypass;
internal static class Deobfuscator
{
public const string ModuleCheckerTypeName = nameof(ObjectPublicLi1StInUnique);
public const string ModuleCheckerCheckMethod = nameof(ModuleChecker.Method_Public_Boolean_0);
}
2 changes: 1 addition & 1 deletion Info/ModInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace SNBypass.Info;

public static class ModInfo
{
public const string Version = "1.0.0";
public const string Version = "1.1.0";
public const string Name = "SNBypass";
public const string Author = "SN Modding";
public const string GitLink = "https://github.com/NeighborGameModding/SNBypass";
Expand Down
15 changes: 11 additions & 4 deletions ModuleCheckBypass.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using HarmonyLib;
using MelonLoader;
using System.Linq;
using System.Reflection;

namespace SNBypass;
Expand All @@ -20,15 +21,21 @@ internal static void Initialize()
return;
}

var checkMethod = moduleCheckerType.GetMethod(nameof(ModuleChecker.Method_Public_Boolean_0));
if (checkMethod == null)
var nameStart = ModuleCheckerCheckMethod.Remove(ModuleCheckerCheckMethod.Length - 1);
var checkMethods = moduleCheckerType.GetMethods().Where(x => x.Name.StartsWith(nameStart)).ToArray();
if (checkMethods.Length == 0)
{
Melon<SNBypassMod>.Logger.Warning("Module Checker Version Unsupported");
return;
}

Melon<SNBypassMod>.Instance.HarmonyInstance.Patch(checkMethod, new HarmonyMethod(new PatchDel(Patch).Method));
Melon<SNBypassMod>.Logger.Msg("Module Checker Patched");
var patch = new HarmonyMethod(new PatchDel(Patch).Method);
foreach (var checkMethod in checkMethods)
{
Melon<SNBypassMod>.Instance.HarmonyInstance.Patch(checkMethod, patch);
}

Melon<SNBypassMod>.Logger.Msg($"Module Checker Patched ({checkMethods.Length} {(checkMethods.Length == 1 ? "method" : "methods")})");

_initialized = true;
}
Expand Down

0 comments on commit 25a9e31

Please sign in to comment.