change: ObfuscationMethodWhitelist::IsInWhiteList(MethodDef)对于带有`[RuntimeInitializeOnLoadMethod]`的函数,如果LoadType等于或者早于AfterAssembliesLoaded,就不对函数进行混淆

before-split
walon 2025-05-23 09:25:44 +08:00
parent 3fe3a6b302
commit 05c3fd24bf
1 changed files with 11 additions and 1 deletions

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine;
namespace Obfuz namespace Obfuz
{ {
@ -15,7 +16,7 @@ namespace Obfuz
public bool IsInWhiteList(ModuleDef module) public bool IsInWhiteList(ModuleDef module)
{ {
string modName = module.Assembly.Name; string modName = module.Assembly.Name;
if (modName == "Obfuz.Runtime") if (modName == ConstValues.ObfuzRuntimeAssemblyName)
{ {
return true; return true;
} }
@ -40,6 +41,15 @@ namespace Obfuz
{ {
return true; return true;
} }
CustomAttribute ca = method.CustomAttributes.Find("UnityEngine.RuntimeInitializeOnLoadMethodAttribute");
if (ca != null && ca.ConstructorArguments.Count > 0)
{
RuntimeInitializeLoadType loadType = (RuntimeInitializeLoadType)ca.ConstructorArguments[0].Value;
if (loadType >= RuntimeInitializeLoadType.AfterAssembliesLoaded)
{
return true;
}
}
return false; return false;
} }