diff --git a/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs b/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs index e98fd4e..e3990b4 100644 --- a/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs +++ b/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/Policies/UnityRenamePolicy.cs @@ -132,6 +132,18 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies { return true; } + if (typeDef.FullName == "Unity.Entities.CodeGeneratedRegistry.AssemblyTypeRegistry") + { + return true; + } + if (typeDef.Name.StartsWith("__JobReflectionRegistrationOutput")) + { + return true; + } + if (typeDef.CustomAttributes.Find("Unity.Jobs.DOTSCompilerGeneratedAttribute") != null) + { + return true; + } if (typeDef.DeclaringType != null) { return IsUnitySourceGeneratedAssemblyType(typeDef.DeclaringType); @@ -145,6 +157,10 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies { return false; } + if (MetaUtil.IsInheritFromDOTSTypes(typeDef)) + { + return false; + } if (typeDef.Methods.Any(m => MetaUtil.HasRuntimeInitializeOnLoadMethodAttribute(m))) { return false; @@ -167,6 +183,10 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies { return false; } + if (MetaUtil.IsInheritFromDOTSTypes(typeDef)) + { + return false; + } if (MetaUtil.HasRuntimeInitializeOnLoadMethodAttribute(methodDef)) { return false; @@ -185,6 +205,10 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies { return !MetaUtil.IsSerializableField(fieldDef); } + if (MetaUtil.IsInheritFromDOTSTypes(typeDef)) + { + return false; + } if (typeDef.IsEnum && MetaUtil.HasBlackboardEnumAttribute(typeDef)) { return false; diff --git a/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs b/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs index 470c943..0da450a 100644 --- a/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs +++ b/com.code-philosophy.obfuz/Editor/Utils/MetaUtil.cs @@ -116,6 +116,36 @@ namespace Obfuz.Utils return null; } + public static bool IsInheritFromDOTSTypes(TypeDef typeDef) + { + TypeDef cur = typeDef; + while (true) + { + if (cur.Namespace.StartsWith("Unity.Entities") || + //cur.Namespace.StartsWith("Unity.Jobs") || + cur.Namespace.StartsWith("Unity.Burst")) + { + return true; + } + foreach (var interfaceType in cur.Interfaces) + { + TypeDef interfaceTypeDef = interfaceType.Interface.ResolveTypeDef(); + if (interfaceTypeDef != null && (interfaceTypeDef.Namespace.StartsWith("Unity.Entities") || + //interfaceTypeDef.Namespace.StartsWith("Unity.Jobs") || + interfaceTypeDef.Namespace.StartsWith("Unity.Burst"))) + { + return true; + } + } + + cur = GetBaseTypeDef(cur); + if (cur == null) + { + return false; + } + } + } + public static bool IsInheritFromMonoBehaviour(TypeDef typeDef) { TypeDef cur = typeDef;