mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
接入obfuz->2.0
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
"name": "Launcher",
|
||||
"rootNamespace": "Launcher",
|
||||
"references": [
|
||||
"GUID:13ba8ce62aa80c74598530029cb2d649"
|
||||
"GUID:13ba8ce62aa80c74598530029cb2d649",
|
||||
"GUID:4140bd2e2764f1f47ab93125ecb61942"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
8
UnityProject/Assets/Obfuz.meta
Normal file
8
UnityProject/Assets/Obfuz.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2daec965c12426d4c81fd26f8cf380e4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
4522
UnityProject/Assets/Obfuz/GeneratedEncryptionVirtualMachine.cs
Normal file
4522
UnityProject/Assets/Obfuz/GeneratedEncryptionVirtualMachine.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 673c197d012a9c549be6c6991ad3fb30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
UnityProject/Assets/Obfuz/ObfuzInitialize.cs
Normal file
24
UnityProject/Assets/Obfuz/ObfuzInitialize.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Obfuz;
|
||||
using Obfuz.EncryptionVM;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Launcher
|
||||
{
|
||||
public class ObfuzInitialize : MonoBehaviour
|
||||
{
|
||||
// 初始化EncryptionService后被混淆的代码才能正常运行,
|
||||
// 因此尽可能地早地初始化它。
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
|
||||
private static void SetUpStaticSecretKey()
|
||||
{
|
||||
#if ENABLE_OBFUZ
|
||||
Debug.Log("Enable Obfuz");
|
||||
Debug.Log("SetUpStaticSecret begin");
|
||||
EncryptionService<DefaultStaticEncryptionScope>.Encryptor = new GeneratedEncryptionVirtualMachine(Resources.Load<TextAsset>("Obfuz/defaultStaticSecretKey").bytes);
|
||||
Debug.Log("SetUpStaticSecret end");
|
||||
#else
|
||||
Debug.Log("Disable Obfuz");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
3
UnityProject/Assets/Obfuz/ObfuzInitialize.cs.meta
Normal file
3
UnityProject/Assets/Obfuz/ObfuzInitialize.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 883bcac172734133a1972a05275df53b
|
||||
timeCreated: 1753458333
|
8
UnityProject/Assets/Obfuz/SymbolObfus.meta
Normal file
8
UnityProject/Assets/Obfuz/SymbolObfus.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25a2e7cc325e1054db9d6fd1189d5474
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9389
UnityProject/Assets/Obfuz/SymbolObfus/symbol-mapping.xml
Normal file
9389
UnityProject/Assets/Obfuz/SymbolObfus/symbol-mapping.xml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b16602403e80c24f85f2d87b7db8bcf
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
UnityProject/Assets/Resources.meta
Normal file
8
UnityProject/Assets/Resources.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca6f6fb6ba786e14fb3096bd01f61ac5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
UnityProject/Assets/Resources/Obfuz.meta
Normal file
8
UnityProject/Assets/Resources/Obfuz.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 029862980bde3c9489ef31bf924728e3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ed52d75209dd9e4c81e0cab914d053c
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
UnityProject/Assets/Resources/Obfuz/defaultStaticSecretKey.bytes
Normal file
BIN
UnityProject/Assets/Resources/Obfuz/defaultStaticSecretKey.bytes
Normal file
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1c5d75e786680342b0e358f67064ac8
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -38,7 +38,6 @@ RenderSettings:
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
|
@@ -2,6 +2,10 @@
|
||||
using HybridCLR.Editor;
|
||||
using HybridCLR.Editor.Commands;
|
||||
#endif
|
||||
using System.IO;
|
||||
using Obfuz.Settings;
|
||||
using Obfuz4HybridCLR;
|
||||
using System.Collections.Generic;
|
||||
using TEngine.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
@@ -9,12 +13,14 @@ using UnityEngine;
|
||||
public static class BuildDLLCommand
|
||||
{
|
||||
private const string EnableHybridClrScriptingDefineSymbol = "ENABLE_HYBRIDCLR";
|
||||
private const string EnableObfuzScriptingDefineSymbol = "ENABLE_OBFUZ";
|
||||
|
||||
#region HybridCLR/Define Symbols
|
||||
/// <summary>
|
||||
/// 禁用HybridCLR宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("HybridCLR/Define Symbols/Disable HybridCLR", false, 30)]
|
||||
public static void Disable()
|
||||
public static void DisableHybridCLR()
|
||||
{
|
||||
ScriptingDefineSymbols.RemoveScriptingDefineSymbol(EnableHybridClrScriptingDefineSymbol);
|
||||
#if ENABLE_HYBRIDCLR
|
||||
@@ -27,7 +33,7 @@ public static class BuildDLLCommand
|
||||
/// 开启HybridCLR宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("HybridCLR/Define Symbols/Enable HybridCLR", false, 31)]
|
||||
public static void Enable()
|
||||
public static void EnableHybridCLR()
|
||||
{
|
||||
ScriptingDefineSymbols.RemoveScriptingDefineSymbol(EnableHybridClrScriptingDefineSymbol);
|
||||
ScriptingDefineSymbols.AddScriptingDefineSymbol(EnableHybridClrScriptingDefineSymbol);
|
||||
@@ -36,6 +42,31 @@ public static class BuildDLLCommand
|
||||
UpdateSettingEditor.ForceUpdateAssemblies();
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Obfuz/Define Symbols
|
||||
/// <summary>
|
||||
/// 禁用Obfuz宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("HybridCLR/Define Symbols/Disable Obfuz", false, 30)]
|
||||
public static void DisableObfuz()
|
||||
{
|
||||
ScriptingDefineSymbols.RemoveScriptingDefineSymbol(EnableObfuzScriptingDefineSymbol);
|
||||
ObfuzSettings.Instance.buildPipelineSettings.enable = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启Obfuz宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("HybridCLR/Define Symbols/Enable Obfuz", false, 31)]
|
||||
public static void EnableObfuz()
|
||||
{
|
||||
ScriptingDefineSymbols.RemoveScriptingDefineSymbol(EnableObfuzScriptingDefineSymbol);
|
||||
ScriptingDefineSymbols.AddScriptingDefineSymbol(EnableObfuzScriptingDefineSymbol);
|
||||
ObfuzSettings.Instance.buildPipelineSettings.enable = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
[MenuItem("HybridCLR/Build/BuildAssets And CopyTo AssemblyTextAssetPath")]
|
||||
public static void BuildAndCopyDlls()
|
||||
@@ -59,6 +90,31 @@ public static class BuildDLLCommand
|
||||
{
|
||||
CopyAOTAssembliesToAssetPath();
|
||||
CopyHotUpdateAssembliesToAssetPath();
|
||||
|
||||
#if ENABLE_HYBRIDCLR && ENABLE_OBFUZ
|
||||
CompileDllCommand.CompileDll(target);
|
||||
|
||||
string obfuscatedHotUpdateDllPath = PrebuildCommandExt.GetObfuscatedHotUpdateAssemblyOutputPath(target);
|
||||
ObfuscateUtil.ObfuscateHotUpdateAssemblies(target, obfuscatedHotUpdateDllPath);
|
||||
|
||||
Directory.CreateDirectory(Application.streamingAssetsPath);
|
||||
|
||||
string hotUpdateDllPath = $"{SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target)}";
|
||||
List<string> obfuscationRelativeAssemblyNames = ObfuzSettings.Instance.assemblySettings.GetObfuscationRelativeAssemblyNames();
|
||||
|
||||
foreach (string assName in SettingsUtil.HotUpdateAssemblyNamesIncludePreserved)
|
||||
{
|
||||
string srcDir = obfuscationRelativeAssemblyNames.Contains(assName) ? obfuscatedHotUpdateDllPath : hotUpdateDllPath;
|
||||
string srcFile = $"{srcDir}/{assName}.dll";
|
||||
string dstFile = Application.dataPath +"/"+ TEngine.Settings.UpdateSetting.AssemblyTextAssetPath + $"/{assName}.dll.bytes";
|
||||
if (File.Exists(srcFile))
|
||||
{
|
||||
File.Copy(srcFile, dstFile, true);
|
||||
Debug.Log($"[CompileAndObfuscate] Copy {srcFile} to {dstFile}");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,9 @@
|
||||
"GUID:4d1926c9df5b052469a1c63448b7609a",
|
||||
"GUID:6e76b07590314a543b982daed6af2509",
|
||||
"GUID:2373f786d14518f44b0f475db77ba4de",
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f"
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||
"GUID:3743e71edcd5bd8499007797ef02cbfb",
|
||||
"GUID:66e09fc524ec6594b8d6ca1d91aa1a41"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
|
@@ -47,6 +47,50 @@ MonoBehaviour:
|
||||
innerLocalizationCsv: {fileID: 0}
|
||||
allLanguage: []
|
||||
useRuntimeModule: 1
|
||||
--- !u!1 &7471325143993775112
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5905096077013678464}
|
||||
- component: {fileID: 7968529201080193016}
|
||||
m_Layer: 0
|
||||
m_Name: Obfuz
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5905096077013678464
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7471325143993775112}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 7696541955266276700}
|
||||
m_RootOrder: 6
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &7968529201080193016
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7471325143993775112}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 883bcac172734133a1972a05275df53b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &7696541953913300370
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -208,6 +252,7 @@ MonoBehaviour:
|
||||
useSystemUnloadUnusedAssets: 1
|
||||
packageName: DefaultPackage
|
||||
playMode: 0
|
||||
encryptionType: 0
|
||||
updatableWhilePlaying: 0
|
||||
milliseconds: 30
|
||||
downloadingMaxNum: 10
|
||||
@@ -266,6 +311,7 @@ Transform:
|
||||
- {fileID: 7696541955235861479}
|
||||
- {fileID: 404609667950854598}
|
||||
- {fileID: 5550035055454355162}
|
||||
- {fileID: 5905096077013678464}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
Reference in New Issue
Block a user