This repository has been archived by the owner on Jun 24, 2022. It is now read-only.
forked from Ta8Success/Archive-Azur-Lane-Scripts-Autopatcher
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Readd lua recompiling, for the last(TM) time
Again, a dirty and lazy way to include 64 bit compiler, if you have a better idea (maybe an if check in both patcher and cli)
- Loading branch information
Showing
20 changed files
with
2,468 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Reflection; | ||
|
||
namespace Azurlane | ||
{ | ||
public class AssetBundleMgr | ||
{ | ||
private static readonly List<byte[]> DPatterns, EPatterns; | ||
|
||
private static readonly object Instance; | ||
|
||
static AssetBundleMgr() | ||
{ | ||
if (DPatterns == null) | ||
{ | ||
DPatterns = new List<byte[]> | ||
{ | ||
new byte[] | ||
{ | ||
0x55, 0x6E, 0x69, 0x74, 0x79, 0x46, 0x53, 0x00, | ||
0x00, 0x00, 0x00, 0x06, 0x35, 0x2E, 0x78, 0x2E | ||
} | ||
}; | ||
} | ||
|
||
if (EPatterns == null) | ||
{ | ||
EPatterns = new List<byte[]> | ||
{ | ||
new byte[] | ||
{ | ||
0xC7, 0xD5, 0xFC, 0x1F, 0x4C, 0x92, 0x94, 0x55, | ||
0x85, 0x03, 0x16, 0xA3, 0x7F, 0x7B, 0x8B, 0x55 | ||
} | ||
}; | ||
} | ||
|
||
if (DPatterns == null || EPatterns == null) | ||
return; | ||
|
||
var assembly = Assembly.Load(Properties.Resources.Salt); | ||
Instance = Activator.CreateInstance(assembly.GetType("LL.Salt")); | ||
} | ||
|
||
internal static bool Compare(byte[] b1, List<byte[]> b2) | ||
{ | ||
try | ||
{ | ||
foreach (var b in b2) | ||
{ | ||
for (var i = 0; i < b.Length; i++) | ||
{ | ||
if (b1[i] != b[i]) | ||
return false; | ||
} | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
Utils.LogException("Exception detected during Compare.2", e); | ||
} | ||
return true; | ||
} | ||
|
||
internal static void Initialize(string path, Tasks task) | ||
{ | ||
var bytes = File.ReadAllBytes(path); | ||
if (Compare(bytes, EPatterns)) | ||
{ | ||
if (task == Tasks.Encrypt) | ||
{ | ||
Utils.LogInfo("AssetBundle is already encrypted... <aborted>", true, true); | ||
return; | ||
} | ||
if (task == Tasks.Unpack || task == Tasks.Repack) | ||
Execute(bytes, path, Tasks.Decrypt); | ||
} | ||
else if (Compare(bytes, DPatterns)) | ||
{ | ||
if (task == Tasks.Decrypt) | ||
{ | ||
Utils.LogInfo("AssetBundle is already decrypted... <aborted>", true, true); | ||
return; | ||
} | ||
} | ||
else | ||
{ | ||
Utils.LogInfo("Not a valid/damaged AssetBundle... <aborted>", true, true); | ||
return; | ||
} | ||
|
||
if (task == Tasks.Decrypt || task == Tasks.Encrypt) | ||
{ | ||
Execute(bytes, path, task); | ||
} | ||
else if (task == Tasks.Unpack || task == Tasks.Repack) | ||
{ | ||
Execute(path, task); | ||
} | ||
Program.IsValid = true; | ||
} | ||
|
||
private static void Execute(byte[] bytes, string path, Tasks task) | ||
{ | ||
Utils.LogInfo("{0} {1}...", true, false, task == Tasks.Decrypt ? "Decrypting" : "Encrypting", Path.GetFileName(path)); | ||
|
||
var method = Instance.GetType().GetMethod("Make", BindingFlags.Static | BindingFlags.Public); | ||
bytes = (byte[])method.Invoke(Instance, new object[] { bytes, task == Tasks.Encrypt }); | ||
|
||
File.WriteAllBytes(path, bytes); | ||
Utils.Write(" <done>", false, true); | ||
} | ||
|
||
private static void Execute(string path, Tasks task) | ||
{ | ||
Utils.LogInfo("{0} {1}...", true, false, task == Tasks.Unpack ? "Unpacking" : "Repacking", Path.GetFileName(path)); | ||
Utils.Command($"UnityEX.exe {(task == Tasks.Unpack ? "export" : "import")} \"{path}\"", PathMgr.Thirdparty("unityex")); | ||
Utils.Write(" <done>", false, true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace Azurlane | ||
{ | ||
internal static class ConfigMgr | ||
{ | ||
internal static readonly Dictionary<Key, object> Instance; | ||
|
||
static ConfigMgr() | ||
{ | ||
if (Instance == null) | ||
Instance = new Dictionary<Key, object>(); | ||
} | ||
|
||
internal enum Key | ||
{ | ||
Version, | ||
Thirdparty | ||
} | ||
|
||
internal static object GetValue(Key key) => Instance[key]; | ||
|
||
internal static void Initialize() | ||
{ | ||
var iniPath = PathMgr.Local("Configuration.ini"); | ||
|
||
foreach (var line in File.ReadAllLines(iniPath)) | ||
{ | ||
if (line.Contains("=")) | ||
{ | ||
var s = line.Split('='); | ||
var key = s[0]; | ||
object value = s[1]; | ||
|
||
foreach (Key keyName in Enum.GetValues(typeof(Key))) | ||
{ | ||
if (key.Compare(keyName)) | ||
Add(keyName, value.GetValue()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private static void Add(Key key, object obj) => Instance.Add(key, obj); | ||
|
||
private static bool Compare(this string s, Key key) => s == key.ToString(); | ||
|
||
private static object GetValue(this object o) => ((string)o).ToLower() == "true" ? true : ((string)o).ToLower() == "ignore" || ((string)o).ToLower() == "false" ? false : o; | ||
} | ||
} |
Oops, something went wrong.