Don't unseal classes for the launcher, resolves launcher not starting

This commit is contained in:
Cj 2024-11-02 22:08:27 -04:00
parent c1a36ee8e3
commit e9b1649d55
2 changed files with 10 additions and 10 deletions

View File

@ -76,7 +76,7 @@ public static class Deobfuscator
if (isLauncher) if (isLauncher)
{ {
SPTPublicizer.PublicizeClasses(assemblyRewrite); SPTPublicizer.PublicizeClasses(assemblyRewrite, true);
} }
} }

View File

@ -7,7 +7,7 @@ internal static class SPTPublicizer
{ {
private static ModuleDefMD MainModule; private static ModuleDefMD MainModule;
public static void PublicizeClasses(ModuleDefMD definition) public static void PublicizeClasses(ModuleDefMD definition, bool isLauncher = false)
{ {
var types = definition.GetTypes(); var types = definition.GetTypes();
@ -15,11 +15,11 @@ internal static class SPTPublicizer
{ {
if (type.IsNested) continue; // Nested types are handled when publicizing the parent type 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 == // if (type.CustomAttributes.Any(a => a.AttributeType.Name ==
// nameof(CompilerGeneratedAttribute))) { return; } // nameof(CompilerGeneratedAttribute))) { return; }
@ -33,7 +33,7 @@ internal static class SPTPublicizer
} }
} }
if (type.IsSealed) if (type.IsSealed && !isLauncher)
{ {
type.Attributes &= ~TypeAttributes.Sealed; // Remove the Sealed attribute if it exists type.Attributes &= ~TypeAttributes.Sealed; // Remove the Sealed attribute if it exists
} }
@ -69,7 +69,7 @@ internal static class SPTPublicizer
*/ */
foreach (var nestedType in type.NestedTypes) foreach (var nestedType in type.NestedTypes)
{ {
PublicizeType(nestedType); PublicizeType(nestedType, isLauncher);
} }
} }