From 5442c328be12e7742b26e0210793c0791aa7c4f6 Mon Sep 17 00:00:00 2001 From: wlt233 <1486185683@qq.com> Date: Sat, 29 Apr 2023 23:45:59 +0800 Subject: [PATCH] add pmmtool work status check --- .../java/moe/tqlwsl/aicemu/SettingActivity.kt | 33 ++++++++++++++++++- app/src/main/jni/main.cpp | 3 ++ app/src/main/jni/main.h | 2 ++ app/src/main/res/layout/activity_setting.xml | 11 +++++++ app/src/main/res/values-zh/strings.xml | 7 ++-- app/src/main/res/values/strings.xml | 3 ++ 6 files changed, 56 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/moe/tqlwsl/aicemu/SettingActivity.kt b/app/src/main/java/moe/tqlwsl/aicemu/SettingActivity.kt index dfb8c1f..2b0ebab 100644 --- a/app/src/main/java/moe/tqlwsl/aicemu/SettingActivity.kt +++ b/app/src/main/java/moe/tqlwsl/aicemu/SettingActivity.kt @@ -4,15 +4,17 @@ import android.annotation.SuppressLint import android.content.pm.PackageManager import android.graphics.Color import android.os.Build -import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.util.Log import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity import org.lsposed.hiddenapibypass.HiddenApiBypass +import java.lang.reflect.Method class SettingActivity : AppCompatActivity() { private var isHCEFSupported: Boolean = false private var isHCEFUnlocked: Boolean = false + private var pmmtoolStatus: String? = "" val TAG: String = "AICEmu" override fun onCreate(savedInstanceState: Bundle?) { @@ -49,6 +51,22 @@ class SettingActivity : AppCompatActivity() { e.printStackTrace() textUnlocker.setText(R.string.Unlocker_work_error) } + + val textPmmtool = findViewById(R.id.pmmtool_work_text) + pmmtoolStatus = getProperty("tmp.AICEmu.pmmtool"); + if (pmmtoolStatus == "") { + textPmmtool.setText(R.string.Pmmtool_work_false) + textPmmtool.setTextColor(Color.RED) + } + else if (pmmtoolStatus == "0") { + textPmmtool.setText(R.string.Pmmtool_work_hook_failed) + textPmmtool.setTextColor(Color.RED) + } + else if (pmmtoolStatus == "1") { + textPmmtool.setText(R.string.Pmmtool_work_true) + textPmmtool.setTextColor(Color.GREEN) + } + } } @@ -63,5 +81,18 @@ class SettingActivity : AppCompatActivity() { HiddenApiBypass.invoke(clazz, null, "isValidSystemCode", systemCode) as Boolean } } + + @SuppressLint("PrivateApi") + fun getProperty(key: String?): String? { + try { + val c = Class.forName("android.os.SystemProperties") + val set: Method = c.getMethod("get", String::class.java) + return set.invoke(c, key)?.toString() + } catch (e: java.lang.Exception) { + Log.d("AICEmu", "getProperty exception") + e.printStackTrace() + return "" + } + } } } \ No newline at end of file diff --git a/app/src/main/jni/main.cpp b/app/src/main/jni/main.cpp index 182a1e7..c7c0d59 100644 --- a/app/src/main/jni/main.cpp +++ b/app/src/main/jni/main.cpp @@ -38,6 +38,7 @@ void *new_func(u_int8_t a1, u_int8_t *a2, int a3) { for (int j = 0; j < 8; ++j) sprintf(pmm_str + j * 3, "%02x ", *(char *)(a2 + i + 2 + j)); __android_log_print(6, "AICEmu-pmmtool", "[1] new PMm: %s", pmm_str); + __system_property_set("tmp.AICEmu.pmmtool", "1"); } } @@ -59,6 +60,7 @@ void *new_func(u_int8_t a1, u_int8_t *a2, int a3) { for (int j = 0; j < 8; ++j) sprintf(pmm_str + j * 3, "%02x ", *(char *)(a2 + i + j)); __android_log_print(6, "AICEmu-pmmtool", "[2] new PMm: %s", pmm_str); + __system_property_set("tmp.AICEmu.pmmtool", "1"); } } //} @@ -70,6 +72,7 @@ void *new_func(u_int8_t a1, u_int8_t *a2, int a3) { jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { __android_log_print(6, "AICEmu-pmmtool", "Inside JNI_OnLoad"); + __system_property_set("tmp.AICEmu.pmmtool", "0"); JNIEnv *env = nullptr; if (vm->GetEnv((void **) &env, JNI_VERSION_1_6) == JNI_OK) { //void *func_addr = DobbySymbolResolver("libnfc-nci.so", "_Z23nfa_dm_check_set_confighPhb"); diff --git a/app/src/main/jni/main.h b/app/src/main/jni/main.h index 631b8cc..ab1a3d6 100644 --- a/app/src/main/jni/main.h +++ b/app/src/main/jni/main.h @@ -13,6 +13,8 @@ #include #include +#include + void *(*old_func)(u_int8_t, u_int8_t *, int) = nullptr; #endif //MAIN_H diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml index 2597402..d1a7923 100644 --- a/app/src/main/res/layout/activity_setting.xml +++ b/app/src/main/res/layout/activity_setting.xml @@ -28,5 +28,16 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/hcef_support_text" /> + + \ No newline at end of file diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 5ee142b..201e767 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -15,6 +15,9 @@ 设备不支持 HCE-F... 设备支持 HCE-F! Unlocker 运行中! - Unlocker 没在工作... - Unlocker 出错了! + Unlocker 炸了... + Unlocker 出现了错误! + Pmmtool 运行中! + Pmmtool 炸了... + Hook 失败了... \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 739e5d9..10d1302 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,4 +23,7 @@ Unlocker is working! Unlocker not working... Unlocker Error! + Pmmtool is working! + Pmmtool not working... + Hook failed... \ No newline at end of file