少年修仙传客户端基础资源
hch
2024-04-11 4c71d74b77c9eb62a0323698c9a0db3b641a917e
0312 加密处理
2个文件已修改
67 ■■■■■ 已修改文件
Assets/Editor/AssetBundleBrowser/AssetBundleBuildTab.cs 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Launch/LoadDll.cs 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/AssetBundleBrowser/AssetBundleBuildTab.cs
@@ -14,6 +14,7 @@
using Path = System.IO.Path;
using HybridCLR.Editor.HotUpdate;
using HybridCLR.Editor;
using System.Text;
namespace UnityEngine.AssetBundles
{
@@ -699,6 +700,7 @@
        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);
@@ -909,9 +911,59 @@
            var fileInfos = new List<FileInfo>();
            FileExtersion.GetAllDirectoryFileInfos(m_UserData.m_OutputPath, fileInfos);
            AssetsVersionMaker.WriteAssetsVersionFile(Path.Combine(Directory.GetParent(Application.dataPath).FullName, m_UserData.m_OutputPath), fileInfos);
            Debug.Log("生成AssetsVersion.txt文件完毕");
        }
        void ChangeBytes()
        {
            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";
            // 要写入的字符串"abc"
            string contentToWrite = "abc";
            // 将"abc"转换为字节数组
            byte[] abcBytes = Encoding.ASCII.GetBytes(contentToWrite);
            // 读取原始DLL字节内容到字节数组
            byte[] originalDllBytes = File.ReadAllBytes(originalDllBytesFilePath);
            // 将"abc"写入临时文件
            using (FileStream fs = new FileStream(tempFilePath, FileMode.Create, FileAccess.Write))
            {
                fs.Write(abcBytes, 0, abcBytes.Length);
                // 追加原始DLL字节内容到临时文件
                fs.Write(originalDllBytes, 0, originalDllBytes.Length);
            }
            ReplaceFile(tempFilePath, originalDllBytesFilePath);
        }
        public void ReplaceFile(string sourceFile, string targetFile)
        {
            // 确保源文件存在
            if (!File.Exists(sourceFile))
            {
                throw new FileNotFoundException("源文件未找到:" + sourceFile);
            }
            // 如果目标文件存在,则删除它
            if (File.Exists(targetFile))
            {
                File.Delete(targetFile);
            }
            // 将源文件重命名为目标文件
            File.Move(sourceFile, targetFile);
        }
        static int packageIndex
        {
            get { return LocalSave.GetInt("ClientPackageIndex", 1); }
Assets/Launch/LoadDll.cs
@@ -106,8 +106,19 @@
#endif
                else
                {
                    // Or retrieve results as binary data
                    byte[] assetData = www.downloadHandler.data;
                    // 特殊处理
                    byte[] assetData;
                    if (asset == "Assembly-CSharp.dll.bytes")
                    {
                        assetData = new byte[www.downloadHandler.data.Length - 3];
                        Array.Copy(assetData, 3, www.downloadHandler.data, 0, www.downloadHandler.data.Length);
                    }
                    else
                    {
                        assetData = www.downloadHandler.data;
                    }
                    Debug.Log($"dll:{asset}  size:{assetData.Length}");
                    s_assetDatas[asset] = assetData;
                }