From e9b1649d55dfc2f79b2af273843c141b5bdf8eb2 Mon Sep 17 00:00:00 2001 From: Cj <161484149+CJ-SPT@users.noreply.github.com> Date: Sat, 2 Nov 2024 22:08:27 -0400 Subject: [PATCH] Don't unseal classes for the launcher, resolves launcher not starting --- RecodeItLib/Remapper/DeObfuscator.cs | 2 +- RecodeItLib/Remapper/Publicizer.cs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/RecodeItLib/Remapper/DeObfuscator.cs b/RecodeItLib/Remapper/DeObfuscator.cs index 085c66b..af6650c 100644 --- a/RecodeItLib/Remapper/DeObfuscator.cs +++ b/RecodeItLib/Remapper/DeObfuscator.cs @@ -76,7 +76,7 @@ public static class Deobfuscator if (isLauncher) { - SPTPublicizer.PublicizeClasses(assemblyRewrite); + SPTPublicizer.PublicizeClasses(assemblyRewrite, true); } } diff --git a/RecodeItLib/Remapper/Publicizer.cs b/RecodeItLib/Remapper/Publicizer.cs index 384b303..dc72173 100644 --- a/RecodeItLib/Remapper/Publicizer.cs +++ b/RecodeItLib/Remapper/Publicizer.cs @@ -7,7 +7,7 @@ internal static class SPTPublicizer { private static ModuleDefMD MainModule; - public static void PublicizeClasses(ModuleDefMD definition) + public static void PublicizeClasses(ModuleDefMD definition, bool isLauncher = false) { var types = definition.GetTypes(); @@ -15,15 +15,15 @@ internal static class SPTPublicizer { if (type.IsNested) continue; // Nested types are handled when publicizing the parent type - PublicizeType(type); + PublicizeType(type, isLauncher); } } - private static void PublicizeType(TypeDef type) + private static void PublicizeType(TypeDef type, bool isLauncher) { // if (type.CustomAttributes.Any(a => a.AttributeType.Name == // nameof(CompilerGeneratedAttribute))) { return; } - + if (!type.IsNested && !type.IsPublic || type.IsNested && !type.IsNestedPublic) { if (!type.Interfaces.Any(i => i.Interface.Name == "IEffect")) @@ -32,17 +32,17 @@ internal static class SPTPublicizer type.Attributes |= type.IsNested ? TypeAttributes.NestedPublic : TypeAttributes.Public; // Apply a public visibility attribute } } - - if (type.IsSealed) + + if (type.IsSealed && !isLauncher) { type.Attributes &= ~TypeAttributes.Sealed; // Remove the Sealed attribute if it exists } - + foreach (var method in type.Methods) { PublicizeMethod(method); } - + foreach (var property in type.Properties) { if (property.GetMethod != null) PublicizeMethod(property.GetMethod); @@ -69,7 +69,7 @@ internal static class SPTPublicizer */ foreach (var nestedType in type.NestedTypes) { - PublicizeType(nestedType); + PublicizeType(nestedType, isLauncher); } }