From dbd501379cde5499a2186287f54e76ca0d7d8572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=92=E6=9E=9C=E7=B3=AF=E7=B1=B3=E7=B3=8D?= Date: Thu, 15 Aug 2024 22:21:00 +0800 Subject: [PATCH] fix getPlatformCtxWithArgV --- Il2cppHook/agent/base/breaker.ts | 32 +++++++++++++++++++++++++------- Il2cppHook/agent/java/dialog.ts | 4 ++++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Il2cppHook/agent/base/breaker.ts b/Il2cppHook/agent/base/breaker.ts index 3803fb7..9c4fa73 100644 --- a/Il2cppHook/agent/base/breaker.ts +++ b/Il2cppHook/agent/base/breaker.ts @@ -99,7 +99,7 @@ export class Breaker { FC.printTitile(`Found : ClassName: ${clsTmp.name} @ ${clsTmp.handle}`) innerImage(clsTmp.handle) // innerImage(Il2Cpp.Domain.assembly("UnityEngine.AndroidJNIModule").image.class("UnityEngine.AndroidJNIHelper").handle) - } else if ("AUI") { + } else if (type == "AUI") { innerImage(Il2Cpp.Domain.assembly("Assembly-CSharp").image.handle) setTimeout(() => h("Update"), 3000) } else if (type == "Soon") { @@ -560,13 +560,31 @@ globalThis.BFA = (filterStr: string, allImg: boolean = true): void => { * @returns */ globalThis.getPlatformCtxWithArgV = (ctx: T, argIndex: number): NativePointer | undefined => { - if ((ctx as ArmCpuContext).r0 != undefined) { - if (argIndex > 15 || argIndex < 0) throw new Error(`ARM32 -> argIndex ${argIndex} is out of range`) - return eval(`(ctx as ArmCpuContext).r${argIndex}`) as NativePointer - } else { - if (argIndex > 32 || argIndex < 0) throw new Error(`ARM64 -> argIndex ${argIndex} is out of range`) - return eval(`(ctx as Arm64CpuContext).x${argIndex}`) as NativePointer + if (Process.arch == "arm" || Process.arch == "arm64"){ + if ((ctx as ArmCpuContext).r0 != undefined) { + // case arm32 + if (argIndex >= 0 && argIndex <= 12) { + return eval(`ctx.r${argIndex}`) as NativePointer + } else { + if (argIndex == 13) return (ctx as ArmCpuContext).sp + if (argIndex == 14) return (ctx as ArmCpuContext).lr + if (argIndex == 15) return (ctx as ArmCpuContext).pc + } + throw new Error(`ARM32 -> argIndex ${argIndex} is out of range`) + } else { + // case arm64 + if (argIndex >= 0 && argIndex <= 28) { + return eval(`ctx.x${argIndex}`) as NativePointer + } else { + if (argIndex == 29) return (ctx as Arm64CpuContext).fp + if (argIndex == 30) return (ctx as Arm64CpuContext).sp + if (argIndex == 31) return (ctx as Arm64CpuContext).lr + if (argIndex == 32) return (ctx as Arm64CpuContext).pc + } + throw new Error(`ARM64 -> argIndex ${argIndex} is out of range`) + } } + throw new Error(`ARCH NOT IMPL`) } declare global { diff --git a/Il2cppHook/agent/java/dialog.ts b/Il2cppHook/agent/java/dialog.ts index 956b394..1e1261d 100644 --- a/Il2cppHook/agent/java/dialog.ts +++ b/Il2cppHook/agent/java/dialog.ts @@ -11,6 +11,7 @@ globalThis.HookDialog = () => { /// // public void show(String message) + LOGD("[*] HOOK androidx.appcompat.app.AlertDialog") Java.use("androidx.appcompat.app.AlertDialog").show.implementation = function () { let params: string = arguments.length == 0 ? '' : JSON.stringify(arguments) LOGW(`CALLED -> ${this.toString()}`) @@ -21,6 +22,7 @@ globalThis.HookDialog = () => { /// ↓↓↓↓↓↓↓ androidx.fragment.app.DialogFragment ↓↓↓↓↓↓↓ + LOGD("[*] HOOK androidx.fragment.app.FragmentTransaction") /// // public int show(FragmentTransaction transaction, String tag) DialogFragment.show.overload('androidx.fragment.app.FragmentTransaction', 'java.lang.String').implementation = function () { @@ -46,6 +48,7 @@ globalThis.HookDialog = () => { /// ↓↓↓↓↓↓↓ android.app.Dialog ↓↓↓↓↓↓↓ + LOGD("[*] HOOK android.app.Dialog") Java.use('android.app.Dialog').show.overload().implementation = function () { let params: string = arguments.length == 0 ? '' : JSON.stringify(arguments) LOGW(`CALLED -> ${this.toString()}`) @@ -58,6 +61,7 @@ globalThis.HookDialog = () => { let PopupWindow = Java.use("android.widget.PopupWindow") + LOGD("[*] HOOK android.widget.PopupWindow") /// // public void showAsDropDown(View anchor) PopupWindow.showAsDropDown.overload('android.view.View').implementation = function () {