修复 裁剪后aot dll不含一些类型,导致resolve失败的Bug
parent
d80c83d1e9
commit
4986705b95
|
@ -186,11 +186,6 @@ namespace Obfuz.ObfusPasses.SymbolObfus
|
||||||
RenameEvents();
|
RenameEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<AssemblyReferenceInfo> GetReferenceMeAssemblies(ModuleDef mod)
|
|
||||||
{
|
|
||||||
return _obfuzAssemblies.Find(ass => ass.module == mod).referenceMeAssemblies;
|
|
||||||
}
|
|
||||||
|
|
||||||
class RefTypeDefMetas
|
class RefTypeDefMetas
|
||||||
{
|
{
|
||||||
public readonly List<TypeRef> typeRefs = new List<TypeRef>();
|
public readonly List<TypeRef> typeRefs = new List<TypeRef>();
|
||||||
|
@ -200,10 +195,14 @@ namespace Obfuz.ObfusPasses.SymbolObfus
|
||||||
|
|
||||||
private void BuildRefTypeDefMetasMap(Dictionary<TypeDef, RefTypeDefMetas> refTypeDefMetasMap)
|
private void BuildRefTypeDefMetasMap(Dictionary<TypeDef, RefTypeDefMetas> refTypeDefMetasMap)
|
||||||
{
|
{
|
||||||
foreach (ModuleDef mod in _toObfuscatedModules)
|
foreach (ModuleDef mod in _obfuscatedAndNotObfuscatedModules)
|
||||||
{
|
{
|
||||||
foreach (TypeRef typeRef in mod.GetTypeRefs())
|
foreach (TypeRef typeRef in mod.GetTypeRefs())
|
||||||
{
|
{
|
||||||
|
if (typeRef.DefinitionAssembly.IsCorLib())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
TypeDef typeDef = typeRef.ResolveThrow();
|
TypeDef typeDef = typeRef.ResolveThrow();
|
||||||
if (!refTypeDefMetasMap.TryGetValue(typeDef, out var typeDefMetas))
|
if (!refTypeDefMetasMap.TryGetValue(typeDef, out var typeDefMetas))
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,6 +107,24 @@ namespace Obfuz
|
||||||
return new Obfuscator(this);
|
return new Obfuscator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<string> BuildUnityAssemblySearchPaths()
|
||||||
|
{
|
||||||
|
string applicationContentsPath = EditorApplication.applicationContentsPath;
|
||||||
|
return new List<string>
|
||||||
|
{
|
||||||
|
#if UNITY_2021_1_OR_NEWER
|
||||||
|
Path.Combine(applicationContentsPath, "UnityReferenceAssemblies/unity-4.8-api/Facades"),
|
||||||
|
Path.Combine(applicationContentsPath, "UnityReferenceAssemblies/unity-4.8-api"),
|
||||||
|
#elif UNITY_2020 || UNITY_2019
|
||||||
|
Path.Combine(applicationContentsPath, "MonoBleedingEdge/lib/mono/4.7.1-api/Facades"),
|
||||||
|
Path.Combine(applicationContentsPath, "MonoBleedingEdge/lib/mono/4.7.1-api"),
|
||||||
|
#else
|
||||||
|
#error "Unsupported Unity version"
|
||||||
|
#endif
|
||||||
|
Path.Combine(applicationContentsPath, "Managed/UnityEngine"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static ObfuscatorBuilder FromObfuzSettings(ObfuzSettings settings, BuildTarget target)
|
public static ObfuscatorBuilder FromObfuzSettings(ObfuzSettings settings, BuildTarget target)
|
||||||
{
|
{
|
||||||
var builder = new ObfuscatorBuilder
|
var builder = new ObfuscatorBuilder
|
||||||
|
@ -119,7 +137,7 @@ namespace Obfuz
|
||||||
_encryptionVmCodeFile = settings.encryptionVMSettings.codeOutputPath,
|
_encryptionVmCodeFile = settings.encryptionVMSettings.codeOutputPath,
|
||||||
_toObfuscatedAssemblyNames = settings.assemblySettings.toObfuscatedAssemblyNames.ToList(),
|
_toObfuscatedAssemblyNames = settings.assemblySettings.toObfuscatedAssemblyNames.ToList(),
|
||||||
_notObfuscatedAssemblyNamesReferencingObfuscated = settings.assemblySettings.notObfuscatedAssemblyNamesReferencingObfuscated.ToList(),
|
_notObfuscatedAssemblyNamesReferencingObfuscated = settings.assemblySettings.notObfuscatedAssemblyNamesReferencingObfuscated.ToList(),
|
||||||
_assemblySearchDirs = settings.assemblySettings.extraAssemblySearchDirs.ToList(),
|
_assemblySearchDirs = BuildUnityAssemblySearchPaths().Concat(settings.assemblySettings.extraAssemblySearchDirs).ToList(),
|
||||||
_obfuscatedAssemblyOutputDir = settings.GetObfuscatedAssemblyOutputDir(target),
|
_obfuscatedAssemblyOutputDir = settings.GetObfuscatedAssemblyOutputDir(target),
|
||||||
};
|
};
|
||||||
ObfuscationPassType obfuscationPasses = settings.obfuscationPassSettings.enabledPasses;
|
ObfuscationPassType obfuscationPasses = settings.obfuscationPassSettings.enabledPasses;
|
||||||
|
|
|
@ -88,16 +88,6 @@ namespace Obfuz.Unity
|
||||||
|
|
||||||
var assemblySearchDirs = new List<string>
|
var assemblySearchDirs = new List<string>
|
||||||
{
|
{
|
||||||
#if UNITY_2021_1_OR_NEWER
|
|
||||||
Path.Combine(applicationContentsPath, "UnityReferenceAssemblies/unity-4.8-api/Facades"),
|
|
||||||
Path.Combine(applicationContentsPath, "UnityReferenceAssemblies/unity-4.8-api"),
|
|
||||||
#elif UNITY_2020 || UNITY_2019
|
|
||||||
Path.Combine(applicationContentsPath, "MonoBleedingEdge/lib/mono/4.7.1-api/Facades"),
|
|
||||||
Path.Combine(applicationContentsPath, "MonoBleedingEdge/lib/mono/4.7.1-api"),
|
|
||||||
#else
|
|
||||||
#error "Unsupported Unity version"
|
|
||||||
#endif
|
|
||||||
Path.Combine(applicationContentsPath, "Managed/UnityEngine"),
|
|
||||||
backupPlayerScriptAssembliesPath,
|
backupPlayerScriptAssembliesPath,
|
||||||
};
|
};
|
||||||
obfuscatorBuilder.InsertTopPriorityAssemblySearchDirs(assemblySearchDirs);
|
obfuscatorBuilder.InsertTopPriorityAssemblySearchDirs(assemblySearchDirs);
|
||||||
|
@ -115,7 +105,7 @@ namespace Obfuz.Unity
|
||||||
Obfuscator obfuz = obfuscatorBuilder.Build();
|
Obfuscator obfuz = obfuscatorBuilder.Build();
|
||||||
obfuz.Run();
|
obfuz.Run();
|
||||||
|
|
||||||
foreach (var dllName in settings.assemblySettings.toObfuscatedAssemblyNames)
|
foreach (var dllName in settings.assemblySettings.toObfuscatedAssemblyNames.Concat(settings.assemblySettings.notObfuscatedAssemblyNamesReferencingObfuscated))
|
||||||
{
|
{
|
||||||
string src = $"{obfuscatorBuilder.ObfuscatedAssemblyOutputDir}/{dllName}.dll";
|
string src = $"{obfuscatorBuilder.ObfuscatedAssemblyOutputDir}/{dllName}.dll";
|
||||||
string dst = $"{scriptAssembliesPath}/{dllName}.dll";
|
string dst = $"{scriptAssembliesPath}/{dllName}.dll";
|
||||||
|
@ -147,4 +137,4 @@ namespace Obfuz.Unity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue