Working with HybridCLR
HybridCLR workflow does not consider code obfuscation scenarios, so using it directly will encounter some issues.
Issues Encountered
Plugin Conflicts Between Obfuz and HybridCLR dnlib Plugins
Both Obfuz and HybridCLR plugins include the dnlib plugin. For Unity, errors occur when two packages contain plugins with the same name. The solution is to download HybridCLR locally, remove the included dnlib.dll, and then place it in the Packages directory.
Trimming Issues for Obfuscated AOT Assemblies
HybridCLR's default HybridCLR/Generate/All
command generates link.xml based on unobfuscated assemblies. If some AOT assemblies are obfuscated, the types and functions preserved in link.xml generated from unobfuscated code are all pre-obfuscation names,
which causes link.xml to be unable to truly preserve those obfuscated AOT types and functions. After building, running hot update code may encounter situations where types and functions are trimmed.
How to Obfuscate Hot Update DLLs
Hot update dlls generated by HybridCLR/CompileDll/XXX
are not obfuscated and require additional obfuscation of hot update code.
Solutions
We provide the com.code-philosophy.obfuz4hybridclr extension package to solve hybridclr hot update workflow issues.
URL installation addresses for Unity Package:
https://github.com/focus-creative-games/obfuz4hybridclr.git
https://gitee.com/focus-creative-games/obfuz4hybridclr.git
Replace HybridCLR/Generate/All
obfuz4hybridclr provides a GenerateAll command suitable for obfuscation workflows. Please replace the HybridCLR/Generate/All
command with HybridCLR/ObfuzExtension/GenerateAll
in the build process.
If calling HybridCLR.Editor.Commands.PrebuildCommand::GenerateAll()
in code, replace it with Obfuz4HybridCLR.PrebuildCommandExt.GenerateAll()
.
Replace HybridCLR/CompileDll/XXXX
obfuz4hybridclr provides commands that simultaneously complete compilation and obfuscation of hot update code. Please replace HybridCLR/Generate/ActiveBuildTarget
with HybridCLR/Obfuz/Extension/CompileAndObfuscateDll
.
If calling HybridCLR.Editor.Commands.CompileDllCommand.CompileDll
in code, replace it with Obfuz4HybridCLR.PrebuildCommandExt.CompileAndObfuscateDll
.
Using Polymorphic DLLs
Polymorphic dlls are a brand new custom file structure that supports randomization and can effectively counter malicious cracking and tampering. For detailed documentation, see Polymorphic DLL Files.