Skip to content

Commit

Permalink
A potential error in System.Guid.NewGuid is now caught instead of bub…
Browse files Browse the repository at this point in the history
…bling up to the error handler
  • Loading branch information
nike4613 committed Feb 5, 2021
1 parent 2a9a269 commit 078ff43
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion IPA.Injector/Injector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal static void Main(string[] args)
CriticalSection.Configure();

injector.Debug("Prepping bootstrapper");

// updates backup
InstallBootstrapPatch();

Expand Down
19 changes: 14 additions & 5 deletions IPA.Loader/Logging/StdoutInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,21 @@ public static void Patch(Harmony harmony)
var setFg = foregroundProperty?.GetSetMethod();
var getFg = foregroundProperty?.GetGetMethod();

if (resetColor != null)
harmony.Patch(resetColor, transpiler: new HarmonyMethod(typeof(ConsoleHarmonyPatches), nameof(PatchResetColor)));
if (foregroundProperty != null)
try
{
harmony.Patch(setFg, transpiler: new HarmonyMethod(typeof(ConsoleHarmonyPatches), nameof(PatchSetForegroundColor)));
harmony.Patch(getFg, transpiler: new HarmonyMethod(typeof(ConsoleHarmonyPatches), nameof(PatchGetForegroundColor)));
if (resetColor != null)
harmony.Patch(resetColor, transpiler: new HarmonyMethod(typeof(ConsoleHarmonyPatches), nameof(PatchResetColor)));
if (foregroundProperty != null)
{
harmony.Patch(setFg, transpiler: new HarmonyMethod(typeof(ConsoleHarmonyPatches), nameof(PatchSetForegroundColor)));
harmony.Patch(getFg, transpiler: new HarmonyMethod(typeof(ConsoleHarmonyPatches), nameof(PatchGetForegroundColor)));
}
}
catch (Exception e)
{
// Harmony might be fucked because of wierdness in Guid.NewGuid, don't let that kill us
Logger.log.Error("Error installing harmony patches to intercept Console color properties:");
Logger.log.Error(e);
}
}

Expand Down
Binary file modified Refs/UnityEngine.CoreModule.Net4.dll
Binary file not shown.

0 comments on commit 078ff43

Please sign in to comment.