SymbolObfus: 不混淆Unity.Behaviour.BlackboardEnum特性标注的枚举类型名及其枚举项名
parent
c1beb962f5
commit
e19dbe1dc8
|
@ -125,17 +125,35 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
|
|||
"OnSubmit",
|
||||
"OnCancel",
|
||||
};
|
||||
|
||||
private bool IsUnitySourceGeneratedAssemblyType(TypeDef typeDef)
|
||||
{
|
||||
if (typeDef.Name.StartsWith("UnitySourceGeneratedAssemblyMonoScriptTypes_"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (typeDef.DeclaringType != null)
|
||||
{
|
||||
return IsUnitySourceGeneratedAssemblyType(typeDef.DeclaringType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool NeedRename(TypeDef typeDef)
|
||||
{
|
||||
if (MetaUtil.IsScriptOrSerializableType(typeDef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (typeDef.FullName.StartsWith("UnitySourceGeneratedAssemblyMonoScriptTypes_"))
|
||||
if (typeDef.Methods.Any(m => MetaUtil.HasRuntimeInitializeOnLoadMethodAttribute(m)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (typeDef.Methods.Any(m => MetaUtil.HasRuntimeInitializeOnLoadMethodAttribute(m)))
|
||||
if (typeDef.IsEnum && MetaUtil.HasBlackboardEnumAttribute(typeDef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (IsUnitySourceGeneratedAssemblyType(typeDef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -144,7 +162,8 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
|
|||
|
||||
public override bool NeedRename(MethodDef methodDef)
|
||||
{
|
||||
if (MetaUtil.IsInheritFromUnityObject(methodDef.DeclaringType))
|
||||
TypeDef typeDef = methodDef.DeclaringType;
|
||||
if (MetaUtil.IsInheritFromUnityObject(typeDef))
|
||||
{
|
||||
return !s_monoBehaviourEvents.Contains(methodDef.Name);
|
||||
}
|
||||
|
@ -152,7 +171,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
|
|||
{
|
||||
return false;
|
||||
}
|
||||
if (methodDef.DeclaringType.FullName.StartsWith("UnitySourceGeneratedAssemblyMonoScriptTypes_"))
|
||||
if (IsUnitySourceGeneratedAssemblyType(typeDef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -166,7 +185,11 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
|
|||
{
|
||||
return !MetaUtil.IsSerializableField(fieldDef);
|
||||
}
|
||||
if (fieldDef.DeclaringType.FullName.StartsWith("UnitySourceGeneratedAssemblyMonoScriptTypes_"))
|
||||
if (typeDef.IsEnum && MetaUtil.HasBlackboardEnumAttribute(typeDef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (IsUnitySourceGeneratedAssemblyType(typeDef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -853,17 +853,22 @@ namespace Obfuz.Utils
|
|||
|
||||
public static bool HasCompilerGeneratedAttribute(IHasCustomAttribute obj)
|
||||
{
|
||||
return obj.CustomAttributes.Any(ca => ca.AttributeType.FullName == "System.Runtime.CompilerServices.CompilerGeneratedAttribute");
|
||||
return obj.CustomAttributes.Find("System.Runtime.CompilerServices.CompilerGeneratedAttribute") != null;
|
||||
}
|
||||
|
||||
public static bool HasEncryptFieldAttribute(IHasCustomAttribute obj)
|
||||
{
|
||||
return obj.CustomAttributes.Any(ca => ca.AttributeType.FullName == "Obfuz.EncryptFieldAttribute");
|
||||
return obj.CustomAttributes.Find("Obfuz.EncryptFieldAttribute") != null;
|
||||
}
|
||||
|
||||
public static bool HasRuntimeInitializeOnLoadMethodAttribute(MethodDef method)
|
||||
{
|
||||
return method.CustomAttributes.Any(ca => ca.AttributeType.FullName == "UnityEngine.RuntimeInitializeOnLoadMethodAttribute");
|
||||
return method.CustomAttributes.Find("UnityEngine.RuntimeInitializeOnLoadMethodAttribute") != null;
|
||||
}
|
||||
|
||||
public static bool HasBlackboardEnumAttribute(TypeDef typeDef)
|
||||
{
|
||||
return typeDef.CustomAttributes.Find("Unity.Behavior.BlackboardEnumAttribute") != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue