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
31 changed files
with
342 additions
and
144 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
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
7 changes: 2 additions & 5 deletions
7
Marsey/GameAssembly/GameAssemblyManager.cs → Marsey/Game/Managers/GameAssemblyManager.cs
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
2 changes: 1 addition & 1 deletion
2
Marsey/GameAssembly/HarmonyManager.cs → Marsey/Game/Managers/HarmonyManager.cs
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
2 changes: 1 addition & 1 deletion
2
Marsey/GameAssembly/Doorbreak.cs → Marsey/Game/Misc/Doorbreak.cs
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
3 changes: 2 additions & 1 deletion
3
Marsey/GameAssembly/GameAssemblies.cs → Marsey/Game/Misc/GameAssemblies.cs
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,35 @@ | ||
using Marsey.Misc; | ||
|
||
namespace Marsey.Game.Misc; | ||
|
||
/// <summary> | ||
/// Closes the game right before content pack is started. | ||
/// EntryPoint of the content pack is assumed to be the start. | ||
/// <seealso cref="Game.Patches.Sentry"/> | ||
/// </summary> | ||
public static class Preclusion | ||
{ | ||
private static bool _flag = false; | ||
|
||
/// <summary> | ||
/// Signal to marseyloader to close the game before the game starts | ||
/// </summary> | ||
public static void Trigger(string reason) | ||
{ | ||
if (_flag) | ||
{ | ||
MarseyLogger.Log(MarseyLogger.LogType.INFO, "Preclusion", $"Preclusion was triggered more than once, reason: {reason}"); | ||
return; | ||
} | ||
|
||
MarseyLogger.Log(MarseyLogger.LogType.INFO, "Preclusion", $"Stopping content boot, reason: {reason}"); | ||
_flag = true; | ||
} | ||
|
||
public static bool State => _flag; | ||
|
||
public static void Fire() | ||
{ | ||
Environment.Exit(0); | ||
} | ||
} |
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
3 changes: 1 addition & 2 deletions
3
Marsey/GameAssembly/Patches/Blackhole.cs → Marsey/Game/Patches/Blackhole.cs
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
4 changes: 1 addition & 3 deletions
4
Marsey/GameAssembly/Patches/DiscordRPC.cs → Marsey/Game/Patches/DiscordRPC.cs
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,34 @@ | ||
using System.Reflection; | ||
using Marsey.Misc; | ||
using Marsey.Stealthsey; | ||
|
||
namespace Marsey.Game.Patches; | ||
|
||
static class AsmDumpPatches | ||
{ | ||
private static short _counter; | ||
|
||
/// <summary> | ||
/// Intercept assemblies, save to disk | ||
/// </summary> | ||
// ReSharper disable once UnusedMember.Local | ||
private static bool LGAPrefix(ref Stream assembly) | ||
{ | ||
FileHandler.SaveAssembly(Dumper.path, $"{_counter}.dll", assembly); | ||
_counter++; | ||
|
||
return true; | ||
} | ||
|
||
/// <summary> | ||
/// Assemblies finished loading, close the game | ||
/// </summary> | ||
// ReSharper disable once UnusedMember.Local | ||
private static void TLMPostfix() | ||
{ | ||
MarseyLogger.Log(MarseyLogger.LogType.DEBG, "Dumper", $"Dumps saved to {Dumper.path}"); | ||
MarseyLogger.Log(MarseyLogger.LogType.INFO, "Dumper", $"Exited with {_counter} assemblies."); | ||
Environment.Exit(0); | ||
} | ||
|
||
} |
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,39 @@ | ||
using HarmonyLib; | ||
using Marsey.Config; | ||
using Marsey.Handbreak; | ||
using Marsey.Misc; | ||
|
||
namespace Marsey.Game.Patches; | ||
|
||
/// <summary> | ||
/// Deprecated by accident, ResourceDumper does this and better | ||
/// <see cref="ResourceDumper"/> | ||
/// </summary> | ||
public class AssemblyDumper | ||
{ | ||
public void Patch() | ||
{ | ||
Type? ModLoader = Helpers.TypeFromQualifiedName("Robust.Shared.ContentPack.ModLoader"); | ||
|
||
if (ModLoader == null) | ||
{ | ||
MarseyLogger.Log(MarseyLogger.LogType.ERRO, "ModLoader is null."); | ||
return; | ||
} | ||
|
||
MarseyLogger.Log(MarseyLogger.LogType.DEBG, "Dumper", "Patching TLM"); | ||
Helpers.PatchMethod(ModLoader, | ||
"TryLoadModules", | ||
typeof(AsmDumpPatches), | ||
"TLMPostfix", | ||
HarmonyPatchType.Postfix); | ||
|
||
MarseyLogger.Log(MarseyLogger.LogType.DEBG, "Dumper", "Patching LGA"); | ||
Helpers.PatchMethod(ModLoader, | ||
"LoadGameAssembly", | ||
typeof(AsmDumpPatches), | ||
"LGAPrefix", | ||
HarmonyPatchType.Prefix, | ||
new[] { typeof(Stream), typeof(Stream), typeof(bool) }); | ||
} | ||
} |
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,34 @@ | ||
using System.Reflection; | ||
using Marsey.Stealthsey; | ||
|
||
namespace Marsey.Game.Patches; | ||
|
||
/// <summary> | ||
/// Dumps game content | ||
/// </summary> | ||
public static class Dumper | ||
{ | ||
private static ResourceDumper _res = new ResourceDumper(); | ||
public static string path = "marsey"; | ||
|
||
public static void Start() | ||
{ | ||
//Preclusion.Trigger("Dumper started."); | ||
GetExactPath(); | ||
Patch(); | ||
} | ||
|
||
private static void GetExactPath() | ||
{ | ||
string fork = Environment.GetEnvironmentVariable("MARSEY_DUMP_FORKID") ?? "marsey"; | ||
Envsey.CleanFlag(fork); | ||
|
||
string loc = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!; | ||
path = Path.Combine(loc, "Dumper/", $"{fork}/"); | ||
} | ||
|
||
private static void Patch() | ||
{ | ||
_res.Patch(); | ||
} | ||
} |
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,42 @@ | ||
using System.Diagnostics; | ||
using Marsey.Misc; | ||
|
||
namespace Marsey.Game.Patches; | ||
|
||
static class ResDumpPatches | ||
{ | ||
// Okay so this is so schizo I will comment every line from memory | ||
public static void PostfixCFF(ref object __instance, ref dynamic __result) | ||
{ | ||
if (ResourceDumper.CFRMi == null) return; // Do we have a handle on FileReader? | ||
|
||
foreach (dynamic file in __result) // Since we're patching FindFiles were receiving the full list of resources | ||
{ | ||
string canonPath = file.CanonPath; // We get the entire path | ||
if (canonPath.StartsWith("/")) // And remove the first slash else were writing to root and fuck that | ||
{ | ||
canonPath = canonPath.Substring(1); | ||
} | ||
|
||
string fullpath = Path.Combine(Dumper.path, canonPath); | ||
|
||
// Create directory if it doesn't exist | ||
string? directoryName = Path.GetDirectoryName(fullpath); | ||
if (directoryName != null && !Directory.Exists(directoryName)) | ||
{ | ||
Directory.CreateDirectory(directoryName); | ||
} | ||
|
||
// This is where we get the actual file - CFR stands for ContentFileRead | ||
// Since its not a static method we use __instance as the called, which is very convenient, thanks PJB! | ||
object? CFRout = ResourceDumper.CFRMi.Invoke(__instance, new object?[] {file}); | ||
|
||
if (CFRout is not MemoryStream stream) return; // Cast as MemoryStream (CFROut is MemoryStream as is but whatever | ||
|
||
// Save the thing | ||
using FileStream st = new FileStream(fullpath, FileMode.Create, FileAccess.Write); | ||
MarseyLogger.Log(MarseyLogger.LogType.DEBG, $"Saving to {fullpath}"); | ||
stream.WriteTo(st); | ||
} | ||
} | ||
} |
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,42 @@ | ||
using System.Reflection; | ||
using HarmonyLib; | ||
using Marsey.Handbreak; | ||
using Marsey.Misc; | ||
|
||
namespace Marsey.Game.Patches; | ||
|
||
/// <summary> | ||
/// By complete accident this dumps everything | ||
/// </summary> | ||
public class ResourceDumper | ||
{ | ||
public static MethodInfo? CFRMi; | ||
public void Patch() | ||
{ | ||
Type? ProtoMan = Helpers.TypeFromQualifiedName("Robust.Shared.ContentPack.ResourceManager"); | ||
Type? ResPath = Helpers.TypeFromQualifiedName("Robust.Shared.Utility.ResPath"); | ||
|
||
CFRMi = AccessTools.Method(ProtoMan, "ContentFileRead", new[] { ResPath }); | ||
|
||
if (ProtoMan == null) | ||
{ | ||
MarseyLogger.Log(MarseyLogger.LogType.ERRO, "PrototypeManager is null."); | ||
return; | ||
} | ||
|
||
if (ResPath == null) | ||
{ | ||
MarseyLogger.Log(MarseyLogger.LogType.ERRO, "ResPath is null."); | ||
return; | ||
} | ||
|
||
Helpers.PatchMethod( | ||
targetType: ProtoMan, | ||
targetMethodName: "ContentFindFiles", | ||
patchType: typeof(ResDumpPatches), | ||
patchMethodName: "PostfixCFF", | ||
patchingType: HarmonyPatchType.Postfix, | ||
new Type[]{ ResPath } | ||
); | ||
} | ||
} |
6 changes: 1 addition & 5 deletions
6
Marsey/GameAssembly/Patches/HWID.cs → Marsey/Game/Patches/HWID.cs
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
Oops, something went wrong.