From 3d8755756860c8178d64370a35d11ed51916e5ef Mon Sep 17 00:00:00 2001 From: LA_DI_DA <11174151+0O0o0oOoO00@users.noreply.github.com> Date: Fri, 21 Mar 2025 19:42:04 +0800 Subject: [PATCH] add: select arch manually --- config/template.json | 1 + module/config/argument/args.json | 10 ++++++++++ module/config/argument/argument.yaml | 3 +++ module/config/config_generated.py | 1 + module/config/i18n/en-US.json | 8 ++++++++ module/config/i18n/ja-JP.json | 8 ++++++++ module/config/i18n/zh-CN.json | 8 ++++++++ module/config/i18n/zh-TW.json | 8 ++++++++ module/luahook/crack.py | 16 +++++++++++----- 9 files changed, 58 insertions(+), 5 deletions(-) diff --git a/config/template.json b/config/template.json index 495b6ded5..9996422ec 100644 --- a/config/template.json +++ b/config/template.json @@ -97,6 +97,7 @@ "HookGeneral": { "Enable": false, "RestartEverytime": true, + "Architecture": "auto", "InjectMethod": "local_patch", "RequestTimeLimit": 10, "UpdateServer": null, diff --git a/module/config/argument/args.json b/module/config/argument/args.json index a72047143..95295d2fe 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -486,6 +486,16 @@ "type": "checkbox", "value": true }, + "Architecture": { + "type": "select", + "value": "auto", + "option": [ + "auto", + "x86", + "arm64-v8a", + "armeabi-v7a" + ] + }, "InjectMethod": { "type": "select", "value": "local_patch", diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 02f4de9ee..5159f8f68 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -152,6 +152,9 @@ OldRetire: HookGeneral: Enable: false RestartEverytime: true + Architecture: + value: auto + option: [ auto, x86, arm64-v8a, armeabi-v7a ] InjectMethod: value: local_patch option: [local_patch, global_patch, outer_inject] diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 4944de6dc..3317c3c44 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -80,6 +80,7 @@ class GeneratedConfig: # Group `HookGeneral` HookGeneral_Enable = False HookGeneral_RestartEverytime = True + HookGeneral_Architecture = 'auto' # auto, x86, arm64-v8a, armeabi-v7a HookGeneral_InjectMethod = 'local_patch' # local_patch, global_patch, outer_inject HookGeneral_RequestTimeLimit = 10 HookGeneral_UpdateServer = None diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 660a88391..c9eb76c19 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -735,6 +735,14 @@ "name": "HookGeneral.RestartEverytime.name", "help": "HookGeneral.RestartEverytime.help" }, + "Architecture": { + "name": "HookGeneral.Architecture.name", + "help": "HookGeneral.Architecture.help", + "auto": "auto", + "x86": "x86", + "arm64-v8a": "arm64-v8a", + "armeabi-v7a": "armeabi-v7a" + }, "InjectMethod": { "name": "HookGeneral.InjectMethod.name", "help": "HookGeneral.InjectMethod.help", diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index d08a0022e..b97e7a13a 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -735,6 +735,14 @@ "name": "HookGeneral.RestartEverytime.name", "help": "HookGeneral.RestartEverytime.help" }, + "Architecture": { + "name": "HookGeneral.Architecture.name", + "help": "HookGeneral.Architecture.help", + "auto": "auto", + "x86": "x86", + "arm64-v8a": "arm64-v8a", + "armeabi-v7a": "armeabi-v7a" + }, "InjectMethod": { "name": "HookGeneral.InjectMethod.name", "help": "HookGeneral.InjectMethod.help", diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 4e5a4fe2f..4667715f6 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -735,6 +735,14 @@ "name": "每次启动Alas时重启", "help": "推荐打开" }, + "Architecture": { + "name": "架构", + "help": "选择使用的架构,如果自动检测失败,请手动选择\n注意如果你修改了架构,需要手动删除/data/tmp的所有文件\n游戏库目录中看到的架构和选项的对应关系一般如下:\nx86 -> x86\nx86_64 -> x86\narm -> armeabi-v7a\narm64 -> arm64-v8a", + "auto": "自动检测", + "x86": "x86", + "arm64-v8a": "arm64-v8a", + "armeabi-v7a": "armeabi-v7a" + }, "InjectMethod": { "name": "注入方式", "help": "", diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 89419c590..454d401ef 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -735,6 +735,14 @@ "name": "HookGeneral.RestartEverytime.name", "help": "HookGeneral.RestartEverytime.help" }, + "Architecture": { + "name": "HookGeneral.Architecture.name", + "help": "HookGeneral.Architecture.help", + "auto": "auto", + "x86": "x86", + "arm64-v8a": "arm64-v8a", + "armeabi-v7a": "armeabi-v7a" + }, "InjectMethod": { "name": "HookGeneral.InjectMethod.name", "help": "HookGeneral.InjectMethod.help", diff --git a/module/luahook/crack.py b/module/luahook/crack.py index 2dad5a111..fa8720771 100644 --- a/module/luahook/crack.py +++ b/module/luahook/crack.py @@ -249,12 +249,18 @@ class CrackResource: def __init__(self, config: AzurLaneConfig, device: Device): self.config = config self.device = device - arch_ret = device.adb_shell("uname -m").lower() - self.arch = self.ARCH_MAP.get(arch_ret, "") - if not self.arch: - raise CrackerError(f"Unsupported arch: {arch_ret}") - logger.info(f"Arch: {arch_ret} -> {self.arch}") + arch_conf = deep_get(config.data, "Hook.HookGeneral.Architecture") + + if arch_conf == "auto": + arch_ret = device.adb_shell("uname -m").lower() + self.arch = self.ARCH_MAP.get(arch_ret, "") + if not self.arch: + raise CrackerError(f"Unsupported arch: {arch_ret}") + logger.info(f"Arch: {arch_ret} -> {self.arch}") + else: + logger.info(f"Use arch: {self.arch}") + self.arch = arch_conf self.resource_root = f"./bin/hook" self.resource_dir = f"{self.resource_root}/{self.arch}"