1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-14 11:49:26 +08:00

ref: auto detect game lib and arch

This commit is contained in:
0O0o0oOoO00
2026-02-07 11:46:11 +08:00
parent 6adc8ad835
commit 4d4b36dedc
10 changed files with 49 additions and 19 deletions

View File

@@ -780,9 +780,8 @@
},
"Architecture": {
"type": "select",
"value": "auto",
"value": "x86_64",
"option": [
"auto",
"x86",
"x86_64",
"arm64-v8a",
@@ -17200,6 +17199,7 @@
"type": "select",
"value": "apply",
"option": [
"detect",
"inject",
"apply"
]

View File

@@ -826,8 +826,8 @@ HookGeneral:
UpdateEveryTime: true
PushEveryTime: true
Architecture:
value: auto
option: [ auto, x86, x86_64, arm64-v8a, armeabi-v7a ]
value: x86_64
option: [ x86, x86_64, arm64-v8a, armeabi-v7a ]
InjectMethod:
value: local_patch
option: [local_patch, global_patch, outer_inject]
@@ -1031,7 +1031,7 @@ Comment:
HookOp:
Operation:
value: apply
option: [ inject, apply ]
option: [ detect, inject, apply ]
# ==================== EventShop ======================

View File

@@ -489,7 +489,7 @@ class GeneratedConfig:
HookGeneral_RestartEveryTime = True
HookGeneral_UpdateEveryTime = True
HookGeneral_PushEveryTime = True
HookGeneral_Architecture = 'auto' # auto, x86, x86_64, arm64-v8a, armeabi-v7a
HookGeneral_Architecture = 'x86_64' # x86, x86_64, arm64-v8a, armeabi-v7a
HookGeneral_InjectMethod = 'local_patch' # local_patch, global_patch, outer_inject
HookGeneral_RequestTimeLimit = 10
HookGeneral_UpdateServer = None
@@ -661,7 +661,7 @@ class GeneratedConfig:
Comment_Content = None
# Group `HookOp`
HookOp_Operation = 'apply' # inject, apply
HookOp_Operation = 'apply' # detect, inject, apply
# Group `EventShop`
EventShop_UnlockSSRShip = True

View File

@@ -2914,7 +2914,6 @@
"Architecture": {
"name": "HookGeneral.Architecture.name",
"help": "HookGeneral.Architecture.help",
"auto": "auto",
"x86": "x86",
"x86_64": "x86_64",
"arm64-v8a": "arm64-v8a",
@@ -3569,6 +3568,7 @@
"Operation": {
"name": "HookOp.Operation.name",
"help": "HookOp.Operation.help",
"detect": "detect",
"inject": "inject",
"apply": "apply"
}

View File

@@ -2914,7 +2914,6 @@
"Architecture": {
"name": "HookGeneral.Architecture.name",
"help": "HookGeneral.Architecture.help",
"auto": "auto",
"x86": "x86",
"x86_64": "x86_64",
"arm64-v8a": "arm64-v8a",
@@ -3569,6 +3568,7 @@
"Operation": {
"name": "HookOp.Operation.name",
"help": "HookOp.Operation.help",
"detect": "detect",
"inject": "inject",
"apply": "apply"
}

View File

@@ -2913,8 +2913,7 @@
},
"Architecture": {
"name": "架构",
"help": "选择使用的架构,如果自动检测失败,请手动选择\n游戏库目录中看到的架构和选项的对应关系一般如下\nx86 -> x86\nx86_64 -> x86_64\narm -> armeabi-v7a\narm64 -> arm64-v8a",
"auto": "自动检测",
"help": "选择使用的架构,如果需要自动探测那么在“工具-Hook操作”中使用自动探测\n游戏库目录中看到的架构和选项的对应关系一般如下\nx86 -> x86\nx86_64 -> x86_64\narm -> armeabi-v7a\narm64 -> arm64-v8a",
"x86": "x86",
"x86_64": "x86_64",
"arm64-v8a": "arm64-v8a",
@@ -3569,6 +3568,7 @@
"Operation": {
"name": "操作",
"help": "",
"detect": "自动探测",
"inject": "注入",
"apply": "设置Hook"
}

View File

@@ -2914,7 +2914,6 @@
"Architecture": {
"name": "HookGeneral.Architecture.name",
"help": "HookGeneral.Architecture.help",
"auto": "auto",
"x86": "x86",
"x86_64": "x86_64",
"arm64-v8a": "arm64-v8a",
@@ -3569,6 +3568,7 @@
"Operation": {
"name": "HookOp.Operation.name",
"help": "HookOp.Operation.help",
"detect": "detect",
"inject": "inject",
"apply": "apply"
}

View File

@@ -1,6 +1,7 @@
import hashlib
import json
import os
import time
from pathlib import Path
from typing import Union, List, Type
@@ -179,6 +180,7 @@ class CrackResource:
"x86": "x86",
"x86_64": "x86",
"armv7": "armeabi-v7a",
"arm": "armeabi-v7a",
"arm64": "arm64-v8a",
"aarch64": "arm64-v8a",
"aarch": "armeabi-v7a",
@@ -191,11 +193,9 @@ class CrackResource:
arch_conf = config.full_config.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}")
logger.warning("Please Tools-HookOp to auto detect, use default x86_64")
config.full_config.Hook_HookGeneral_Architecture = "x86_64"
self.arch = "x86_64"
else:
self.arch = arch_conf
logger.info(f"Use arch: {self.arch}")
@@ -339,6 +339,34 @@ class CrackResource:
return self.__is_exist(f"{self.game_lib_dir}/libil2cpp.so") and self.__is_exist(
f"{self.game_lib_dir}/libtolua.so")
def auto_detect(self):
if not self.device.app_is_running():
self.device.app_start()
time.sleep(5)
self.__adb_root()
pid = self.device.adb_shell(f"pidof {self.device.package}")
maps = self.device.adb_shell(f"cat /proc/{pid}/maps")
image_list = maps.splitlines()
libtolua_path = None
for image in image_list:
if image.find("libtolua.so") != -1:
libtolua_path = image.split(" ")[-1]
break
if libtolua_path is None:
logger.error("Cannot find libtolua.so path")
return
game_lib_path = libtolua_path.replace("/libtolua.so", "")
arch = CrackResource.ARCH_MAP[game_lib_path.rsplit("/", maxsplit=1)[-1]]
logger.info(f"Game lib path: {game_lib_path}")
logger.info(f"Game arch: {arch}")
full_config = self.config.full_config
full_config.Hook_HookGeneral_Architecture = arch
full_config.Hook_HookGeneral_GameLibDir = game_lib_path
def ensure(self):
if not self.config.full_config.Hook_HookGeneral_Enable:
return