0312 对sdkFileName = hyenglish_ios的分支进行自定义混淆
| | |
| | | set { LocalSave.SetString("APKOutPutPath", value); }
|
| | | }
|
| | |
|
| | | string m_Publishers;
|
| | | public string publishers
|
| | | {
|
| | | get { return LocalSave.GetString("APKPublishers"); }
|
| | | set { LocalSave.SetString("APKPublishers", value); }
|
| | | set {
|
| | | if (m_Publishers != value)
|
| | | { |
| | | LocalSave.SetString("APKPublishers", value);
|
| | | m_Publishers = value;
|
| | | SetVersionConfig(m_Publishers);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | List<ToggleData> m_ToggleData;
|
| | |
| | | {
|
| | | ResetPathToDefault();
|
| | | }
|
| | | }
|
| | |
|
| | | private static void SetVersionConfig(string _publisher)
|
| | | {
|
| | | var versionName = string.Empty;
|
| | | var fromVersionConfig = ClientPackage.GetVersionConfig(_publisher, out versionName);
|
| | |
|
| | | var versionConfig = VersionConfig.Get();
|
| | |
|
| | | VersionConfig.Copy(fromVersionConfig, versionConfig);
|
| | |
|
| | | EditorUtility.SetDirty(versionConfig);
|
| | | }
|
| | |
|
| | | public void OnGUI(Rect pos)
|
| | |
| | |
|
| | | private void MakeBytesVersionFile()
|
| | | {
|
| | | ChangeBytes();
|
| | | var fileInfos = new List<FileInfo>();
|
| | | FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(m_UserData.m_OutputPath, "/logicbytes"), fileInfos);
|
| | | BytesVersionMaker.WriteAssetsVersionFile(Path.Combine(Directory.GetParent(Application.dataPath).FullName, m_UserData.m_OutputPath), fileInfos);
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | FileExtersion.MakeSureDirectory(outDllFile);
|
| | | File.Copy(dllFile, outDllFile, true);
|
| | | //FileExtersion.MakeSureDirectory(outDllFile);
|
| | | //File.Copy(dllFile, outDllFile, true);
|
| | | ChangeBytes(dllFile, outDllFile);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | DebugEx.LogErrorFormat("错误:{0} 不存在", dllFile);
|
| | | return;
|
| | | }
|
| | | FileExtersion.MakeSureDirectory(outDllFile);
|
| | | File.Copy(dllFile, outDllFile, true);
|
| | | //FileExtersion.MakeSureDirectory(outDllFile);
|
| | | //File.Copy(dllFile, outDllFile, true);
|
| | | ChangeBytes(dllFile, outDllFile);
|
| | | }
|
| | |
|
| | | //HybridCLR的Settings面板上设置的要热更的DLL资源
|
| | |
| | | DebugEx.LogErrorFormat("错误:{0} 不存在", dllFile);
|
| | | return;
|
| | | }
|
| | | FileExtersion.MakeSureDirectory(outDllFile);
|
| | | File.Copy(dllFile, outDllFile, true);
|
| | | //FileExtersion.MakeSureDirectory(outDllFile);
|
| | | //File.Copy(dllFile, outDllFile, true);
|
| | | ChangeBytes(dllFile, outDllFile);
|
| | | }
|
| | |
|
| | | //HybridCLR的Settings面板上设置的预留的热更新dlls
|
| | |
| | | DebugEx.LogWarningFormat("警告:预留的热更新dll: {0} 不存在", dllFile);
|
| | | continue;
|
| | | }
|
| | | FileExtersion.MakeSureDirectory(outDllFile);
|
| | | File.Copy(dllFile, outDllFile, true);
|
| | | //FileExtersion.MakeSureDirectory(outDllFile);
|
| | | //File.Copy(dllFile, outDllFile, true);
|
| | | ChangeBytes(dllFile, outDllFile);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | Debug.Log("生成AssetsVersion.txt文件完毕");
|
| | | }
|
| | |
|
| | | void ChangeBytes()
|
| | | void ChangeBytes(string originalDllBytesFilePath, string outDllFile)
|
| | | {
|
| | | string path = StringUtility.Contact(m_UserData.m_OutputPath, "/logicbytes/");
|
| | | // 原始DLL字节内容文件的路径 |
| | | string originalDllBytesFilePath = path + "Assembly-CSharp.dll.bytes";
|
| | |
|
| | | // 临时文件的路径,用于写入"abc"后再追加原始DLL字节内容
|
| | | string tempFilePath = path + "temp_Assembly-CSharp.dll.bytes";
|
| | | string tempFilePath;
|
| | | if (AssetVersionUtility.IsOpenDMHunxiao())
|
| | | tempFilePath = AssetVersionUtility.EncodeFileName(outDllFile);
|
| | | else |
| | | { |
| | | tempFilePath = outDllFile; |
| | | // 只有Assembly-CSharp.dll.bytes文件才需要加密 |
| | | if (!outDllFile.Contains("Assembly-CSharp.dll.bytes")) |
| | | { |
| | | FileExtersion.MakeSureDirectory(tempFilePath); |
| | | File.Copy(originalDllBytesFilePath, outDllFile, true); |
| | | return; |
| | | } |
| | | }
|
| | |
|
| | | // 要写入的字符串"abc" |
| | | string contentToWrite = "abc";
|
| | | FileExtersion.MakeSureDirectory(tempFilePath);
|
| | |
|
| | | // 如果目标文件存在,则删除它 |
| | | if (File.Exists(tempFilePath))
|
| | | {
|
| | | File.Delete(tempFilePath);
|
| | | }
|
| | |
|
| | | // 要写入的字符串
|
| | | string contentToWrite = "sgg";
|
| | |
|
| | | // 将"abc"转换为字节数组
|
| | | byte[] abcBytes = Encoding.ASCII.GetBytes(contentToWrite);
|
| | |
| | | fs.Write(originalDllBytes, 0, originalDllBytes.Length);
|
| | | }
|
| | |
|
| | | ReplaceFile(tempFilePath, originalDllBytesFilePath);
|
| | | //ReplaceFile(tempFilePath, originalDllBytesFilePath);
|
| | | }
|
| | |
|
| | | public void ReplaceFile(string sourceFile, string targetFile)
|
| | |
| | | for (int i = 0; i < targetAssetBundles.Count; i++)
|
| | | {
|
| | | var assetBundleBuild = new AssetBundleBuild();
|
| | | assetBundleBuild.assetBundleName = targetAssetBundles[i];
|
| | | assetBundleBuild.assetBundleName = AssetVersionUtility.EncodeFileName(targetAssetBundles[i]);
|
| | | assetBundleBuild.assetNames = AssetDatabase.GetAssetPathsFromAssetBundle(targetAssetBundles[i]);
|
| | | assets.Add(assetBundleBuild);
|
| | | }
|
| | |
|
| | | var rootPath = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, category);
|
| | | var mainFile = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, GetMainFestFileName(buildTarget));//改名字前
|
| | | var mainFileRename = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, category, "_assetbundle");//改名字后
|
| | | var mainFileRename = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, AssetVersionUtility.EncodeFileName(category), "_assetbundle");//改名字后
|
| | | var manifest = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, GetMainFestFileName(buildTarget), ".manifest");
|
| | | var manifestRename = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, category, "_assetbundle.manifest");
|
| | | var manifestRename = StringUtility.Contact(output, Path.AltDirectorySeparatorChar, AssetVersionUtility.EncodeFileName(category), "_assetbundle.manifest");
|
| | |
|
| | | if (rebuild && Directory.Exists(rootPath))
|
| | | Directory.Delete(rootPath, true);
|
| | |
| | | continue;
|
| | | }
|
| | |
|
| | | if (ConfigInitiator.builtinConfig.Contains(fileName))
|
| | | if (ConfigInitiator.builtinConfig.Contains(AssetVersionUtility.DecodeFileName(fileName)))
|
| | | {
|
| | | builtInFiles.Add(file);
|
| | | continue;
|
| | |
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Mob, fileName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Mob, AssetVersionUtility.DecodeFileName(fileName));
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | |
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Scene, fileName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Scene, AssetVersionUtility.DecodeFileName(fileName));
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | |
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Audio, fileName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Audio, AssetVersionUtility.DecodeFileName(fileName));
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | |
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Effect, fileName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Effect, AssetVersionUtility.DecodeFileName(fileName));
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | |
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Video, fileName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Video, AssetVersionUtility.DecodeFileName(fileName));
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | |
| | | SetIconAndSplashImage(versionName);
|
| | | //SetCreateRoleAnimation();
|
| | |
|
| | | PlayerSettings.companyName = "SW";
|
| | | PlayerSettings.companyName = "xmsw";
|
| | | PlayerSettings.productName = newVersionConfig.productName;
|
| | | PlayerSettings.applicationIdentifier = newVersionConfig.bundleIdentifier;
|
| | | PlayerSettings.defaultInterfaceOrientation = UIOrientation.AutoRotation;
|
| | |
| | | AssetDatabase.Refresh();
|
| | | }
|
| | |
|
| | | static VersionConfig GetVersionConfig(string _publisher, out string _versionName)
|
| | | public static VersionConfig GetVersionConfig(string _publisher, out string _versionName)
|
| | | {
|
| | | var lines = File.ReadAllLines(versionsFilePath);
|
| | |
|
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Linq;
|
| | | using System.Text;
|
| | | using System.Windows.Forms;
|
| | | using UnityEditor;
|
| | |
| | | foreach (var file in configFiles)
|
| | | {
|
| | | var fileInfo = new FileInfo(file.FullName);
|
| | | CopyTxt(fileInfo);
|
| | | if (AssetVersionUtility.IsOpenDMHunxiao())
|
| | | CopyTxtBuild(fileInfo);
|
| | | else
|
| | | CopyTxt(fileInfo);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | File.Copy(fileInfo.FullName, filePath);
|
| | | }
|
| | |
|
| | | private static void CopyTxtBuild(FileInfo fileInfo)
|
| | | {
|
| | | string fileName = fileInfo.Name.Split('.')[0];
|
| | |
|
| | | if (!Directory.Exists(configOutPutPath))
|
| | | {
|
| | | Directory.CreateDirectory(configOutPutPath);
|
| | | }
|
| | |
|
| | | string filePath = configOutPutPath + "/" + AssetVersionUtility.EncodeFileName(fileName) + ".txt";
|
| | | if (File.Exists(filePath))
|
| | | {
|
| | | File.Delete(filePath);
|
| | | }
|
| | |
|
| | | if (fileName.Contains("MapData_"))
|
| | | {
|
| | | //File.Copy(fileInfo.FullName, filePath);
|
| | | WriteAndCopyMapdata(fileInfo.FullName, filePath);
|
| | | }
|
| | | else
|
| | | {
|
| | | //按行读取文件,并将每行内容倒序写入新文件
|
| | | using (StreamReader sr = new StreamReader(fileInfo.FullName, Encoding.UTF8))
|
| | | {
|
| | | using (StreamWriter sw = new StreamWriter(filePath, false, Encoding.UTF8))
|
| | | {
|
| | | string line;
|
| | | int index = 0;
|
| | | while ((line = sr.ReadLine()) != null)
|
| | | {
|
| | | //第一行在前面加 字母,其他行不变
|
| | | if (index == 0)
|
| | | {
|
| | | sw.WriteLine("_dip" + line);
|
| | | }
|
| | | else
|
| | | {
|
| | | sw.WriteLine(line);
|
| | | }
|
| | |
|
| | | index++;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | static void WriteAndCopyMapdata(string srcFile, string descFile)
|
| | | {
|
| | | int newValue = 12345; // 要插入的int值
|
| | |
|
| | | // 读取原文件内容
|
| | | byte[] originalData;
|
| | | using (FileStream fs = new FileStream(srcFile, FileMode.Open, FileAccess.Read))
|
| | | using (BinaryReader br = new BinaryReader(fs))
|
| | | {
|
| | | originalData = br.ReadBytes((int)fs.Length);
|
| | | }
|
| | |
|
| | | // 准备新数据(int值转换为字节数组)
|
| | | byte[] newData = BitConverter.GetBytes(newValue);
|
| | |
|
| | | // 组合数据
|
| | | byte[] combinedData = new byte[newData.Length + originalData.Length];
|
| | | Buffer.BlockCopy(newData, 0, combinedData, 0, newData.Length);
|
| | | Buffer.BlockCopy(originalData, 0, combinedData, newData.Length, originalData.Length);
|
| | |
|
| | | // 写回文件
|
| | | using (FileStream fs = new FileStream(descFile, FileMode.Create, FileAccess.Write))
|
| | | {
|
| | | fs.Write(combinedData, 0, combinedData.Length);
|
| | | }
|
| | |
|
| | | Debug.Log("地图数据插入完成!");
|
| | | }
|
| | |
|
| | |
|
| | | /// <summary>
|
| | | /// 生成所有表模型
|
| | | /// </summary>
|
| | |
| | |
|
| | | private string GetWebRequestPath(string asset)
|
| | | {
|
| | | var path = ResourcesModel.Instance.GetAssetFilePath(string.Concat(ResourcesModel.bytesFolderName, asset));
|
| | | var path = ResourcesModel.Instance.GetAssetFilePath(string.Concat(ResourcesModel.bytesFolderName, asset), false);
|
| | |
|
| | | if (!path.Contains("file:"))
|
| | | {
|
| | |
| | | {
|
| | | // 特殊处理
|
| | | byte[] assetData;
|
| | | if (asset == "Assembly-CSharp.dll.bytes")
|
| | |
|
| | | if (ResourcesModel.Instance.IsOpenDMHunxiao())
|
| | | {
|
| | | assetData = new byte[www.downloadHandler.data.Length - 3];
|
| | | Array.Copy(www.downloadHandler.data, 3, assetData, 0, assetData.Length);
|
| | | }
|
| | | else
|
| | | {
|
| | | assetData = www.downloadHandler.data;
|
| | | { |
| | | if (asset == "Assembly-CSharp.dll.bytes")
|
| | | {
|
| | | assetData = new byte[www.downloadHandler.data.Length - 3];
|
| | | Array.Copy(www.downloadHandler.data, 3, assetData, 0, assetData.Length);
|
| | | }
|
| | | else
|
| | | {
|
| | | assetData = www.downloadHandler.data;
|
| | | }
|
| | | }
|
| | |
|
| | | Debug.Log($"dll:{asset} size:{assetData.Length}");
|
| | |
| | | HomologousImageMode mode = HomologousImageMode.SuperSet;
|
| | | foreach (var aotDllName in AOTMetaAssemblyFiles)
|
| | | {
|
| | | if (aotDllName == "Assembly-CSharp.dll.bytes")
|
| | | if (aotDllName == ResourcesModel.Instance.EncodeFileName("Assembly-CSharp.dll.bytes"))
|
| | | continue;
|
| | | // 加载assembly对应的dll,会自动为它hook。一旦aot泛型函数的native函数不存在,用解释器版本代码
|
| | | LoadImageErrorCode err = RuntimeApi.LoadMetadataForAOTAssembly(ReadBytesFromStreamingAssets(aotDllName), mode);
|
| | |
| | | {
|
| | | #if !UNITY_EDITOR
|
| | | LoadMetadataForAOTAssemblies();
|
| | | _hotUpdateAss = Assembly.Load(ReadBytesFromStreamingAssets("Assembly-CSharp.dll.bytes"));
|
| | | _hotUpdateAss = Assembly.Load(ReadBytesFromStreamingAssets(ResourcesModel.Instance.EncodeFileName("Assembly-CSharp.dll.bytes")));
|
| | | s_assetDatas = null;
|
| | | #else
|
| | | if (_hotUpdateAss == null)
|
| | |
| | | using UnityEngine.Networking;
|
| | | using StartAotSDK;
|
| | | using UnityEngine.U2D;
|
| | | using System.Linq;
|
| | |
|
| | |
|
| | | namespace StartAot
|
| | |
| | | HttpRequest.Instance.RequestHttpGet(url, HttpRequest.defaultHttpContentType, 1, OnVersionCheckResult);
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | private void OnVersionCheckResult(bool _ok, string _result)
|
| | | {
|
| | | if (_ok)
|
| | |
| | | }
|
| | |
|
| | |
|
| | | public string GetAssetFilePath(string _assetKey)
|
| | |
|
| | | //是否开启自定义的代码混淆, 需同步修改AssetVersionUtility.cs
|
| | | public bool IsOpenDMHunxiao()
|
| | | {
|
| | | //不用宏定义的原因是还需要运维感知切换操作,不新增字段的原因是线上版本不新增
|
| | | //需要开关需通知程序修改
|
| | | var versionConfig = VersionConfigEx.Get();
|
| | | if (versionConfig.sdkFileName == "hyenglish_ios")
|
| | | {
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | const string fixFileName = "_dip";
|
| | | //将文件名倒序,加上后缀 fixFileName
|
| | | public string EncodeFileName(string name)
|
| | | {
|
| | | if (!IsOpenDMHunxiao())
|
| | | return name;
|
| | |
|
| | | name = name.Replace("\\", "/");
|
| | | int index = name.LastIndexOf("/");
|
| | | string headString;
|
| | | if (index >= 0)
|
| | | {
|
| | | int dotLastIndex = name.LastIndexOf(".");
|
| | | if (dotLastIndex == -1)
|
| | | {
|
| | | headString = name.Substring(0, index);
|
| | | name = name.Substring(index + 1);
|
| | | return StringUtility.Contact(headString, "/", new string(name.Reverse().ToArray()), fixFileName);
|
| | | }
|
| | | else
|
| | | {
|
| | | headString = name.Substring(0, index);
|
| | | var ext = name.Substring(dotLastIndex);
|
| | | name = name.Substring(index + 1, dotLastIndex - index - 1);
|
| | | return StringUtility.Contact(headString, "/", new string(name.Reverse().ToArray()), fixFileName, ext);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | int dotLastIndex = name.LastIndexOf(".");
|
| | | if (dotLastIndex == -1)
|
| | | return StringUtility.Contact(new string(name.Reverse().ToArray()), fixFileName);
|
| | | else
|
| | | {
|
| | | var ext = name.Substring(dotLastIndex);
|
| | | name = name.Substring(0, dotLastIndex);
|
| | | return StringUtility.Contact(new string(name.Reverse().ToArray()), fixFileName, ext);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public string GetAssetFilePath(string _assetKey, bool reverse = true)
|
| | | {
|
| | | if (reverse)
|
| | | _assetKey = EncodeFileName(_assetKey);
|
| | | var path = Path.Combine(ExternalStorePath, _assetKey);
|
| | | if (!File.Exists(path))
|
| | | {
|