Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Readd lua recompiling, for the last(TM) time
Browse files Browse the repository at this point in the history
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
n0k0m3 committed Jan 28, 2020
1 parent 64ae664 commit 0f47991
Show file tree
Hide file tree
Showing 20 changed files with 2,468 additions and 9 deletions.
2 changes: 1 addition & 1 deletion v3.x.x/main/autopatcher32/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ private static void Main(string[] args)
foreach (var lua in ListOfLua) {
tasks.Add(Task.Factory.StartNew(() =>
{
//Utils.Command($"Azcli.exe --dev --recompile \"{PathMgr.Lua(modName,lua)}\"");
Utils.Command($"Azcli.exe --dev --recompile \"{PathMgr.Lua(modName,lua)}\"");
}));
}
}
Expand Down
16 changes: 8 additions & 8 deletions v3.x.x/main/autopatcher64/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private static void Main(string[] args)
{
try {
Utils.LogInfo("Decrypting AssetBundle...", true, false);
Utils.Command($"Azcli.exe --dev --decrypt \"{PathMgr.Temp(fileName)}\"");
Utils.Command($"Azcli64.exe --dev --decrypt \"{PathMgr.Temp(fileName)}\"");
Utils.Write(" <done>", false, true);
}
catch (Exception e)
Expand All @@ -285,7 +285,7 @@ private static void Main(string[] args)
{
try {
Utils.LogInfo("Unpacking AssetBundle...", true, false);
Utils.Command($"Azcli.exe --dev --unpack \"{PathMgr.Temp(fileName)}\"");
Utils.Command($"Azcli64.exe --dev --unpack \"{PathMgr.Temp(fileName)}\"");
Utils.Write(" <done>", false, true);
}
catch (Exception e)
Expand All @@ -300,7 +300,7 @@ private static void Main(string[] args)
var showDoneMessage = true;
Utils.LogInfo("Decrypting Lua...", true, false);
foreach (var lua in ListOfLua) {
Utils.Command($"Azcli.exe --dev --unlock \"{PathMgr.Lua(fileName, lua)}\"");
Utils.Command($"Azcli64.exe --dev --unlock \"{PathMgr.Lua(fileName, lua)}\"");
if (LuaMgr.CheckLuaState(PathMgr.Lua(fileName, lua)) != LuaMgr.State.Encrypted)
break;
Expand All @@ -326,7 +326,7 @@ private static void Main(string[] args)
foreach (var lua in ListOfLua) {
tasks.Add(Task.Factory.StartNew(() =>
{
Utils.Command($"Azcli.exe --dev --decompile \"{PathMgr.Lua(fileName, lua)}\"");
Utils.Command($"Azcli64.exe --dev --decompile \"{PathMgr.Lua(fileName, lua)}\"");
Utils.Write($@" {index}/{ListOfLua.Count}", false, false);
index++;
}));
Expand Down Expand Up @@ -416,7 +416,7 @@ private static void Main(string[] args)
foreach (var lua in ListOfLua) {
tasks.Add(Task.Factory.StartNew(() =>
{
//Utils.Command($"Azcli.exe --dev --recompile \"{PathMgr.Lua(modName,lua)}\"");
Utils.Command($"Azcli64.exe --dev --recompile \"{PathMgr.Lua(modName,lua)}\"");
}));
}
}
Expand All @@ -442,7 +442,7 @@ private static void Main(string[] args)
var modName = ("scripts64-" + mod.Key).ToLower().Replace("_", "-");
foreach (var lua in ListOfLua) {
Utils.Command($"Azcli.exe --dev --lock \"{PathMgr.Lua(modName, lua)}\"");
Utils.Command($"Azcli64.exe --dev --lock \"{PathMgr.Lua(modName, lua)}\"");
if (LuaMgr.CheckLuaState(PathMgr.Lua(modName, lua)) != LuaMgr.State.Decrypted)
break;
Expand Down Expand Up @@ -476,7 +476,7 @@ private static void Main(string[] args)
tasks.Add(Task.Factory.StartNew(() =>
{
Utils.Command($"Azcli.exe --dev --repack \"{PathMgr.Temp(modName)}\"");
Utils.Command($"Azcli64.exe --dev --repack \"{PathMgr.Temp(modName)}\"");
Utils.Write($@" {index}/{ListOfMod.Count(x => x.Value)}", false, false);
index++;
}));
Expand All @@ -500,7 +500,7 @@ private static void Main(string[] args)
if (mod.Value)
{
var modName = ("scripts64-" + mod.Key).ToLower().Replace("_", "-");
Utils.Command($"Azcli.exe --dev --encrypt \"{PathMgr.Temp(modName)}\"");
Utils.Command($"Azcli64.exe --dev --encrypt \"{PathMgr.Temp(modName)}\"");
}
}
Utils.Write(" <done>", false, true);
Expand Down
123 changes: 123 additions & 0 deletions v3.x.x/main/cli64/AssetBundleMgr.cs
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);
}
}
}
52 changes: 52 additions & 0 deletions v3.x.x/main/cli64/ConfigMgr.cs
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;
}
}
Loading

0 comments on commit 0f47991

Please sign in to comment.