1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-14 11:19: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

@@ -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