From e251497edc22a4dbfe441de98f9097b495583621 Mon Sep 17 00:00:00 2001 From: REL <25654009+34736384@users.noreply.github.com> Date: Wed, 12 Feb 2025 04:24:43 -0500 Subject: [PATCH] fix player store id resolver --- lib/YaeAchievementLib.vcxproj | 8 ++------ lib/src/il2cpp-init.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/YaeAchievementLib.vcxproj b/lib/YaeAchievementLib.vcxproj index 30eeace..078aa21 100644 --- a/lib/YaeAchievementLib.vcxproj +++ b/lib/YaeAchievementLib.vcxproj @@ -69,9 +69,7 @@ NotSet DebugFull - - copy $(TargetPath) C:\ProgramData\Yae\YaeAchievement.dll /y - + @@ -93,9 +91,7 @@ true DebugFull - - copy $(TargetPath) C:\ProgramData\Yae\YaeAchievement.dll /y - + diff --git a/lib/src/il2cpp-init.cpp b/lib/src/il2cpp-init.cpp index af93317..a328dee 100644 --- a/lib/src/il2cpp-init.cpp +++ b/lib/src/il2cpp-init.cpp @@ -488,9 +488,17 @@ namespace immValue = static_cast(i.Operands[1].imm.value.u); } - if (i.Instruction.meta.branch_type == ZYDIS_BRANCH_TYPE_NEAR && i.Operands.size() == 1) { + if (i.Instruction.meta.branch_type == ZYDIS_BRANCH_TYPE_NEAR && i.Operands.size() == 1 && + (i.Instruction.mnemonic == ZYDIS_MNEMONIC_JZ || i.Instruction.mnemonic == ZYDIS_MNEMONIC_JNZ)) // jz for true branch, jnz for false branch + { + // assume the branching is jz uintptr_t branchAddr = Globals::BaseAddress + i.RVA + i.Instruction.length + i.Operands[0].imm.value.s; + // check if the branch is jnz and adjust the branch address + if (i.Instruction.mnemonic == ZYDIS_MNEMONIC_JNZ) { + branchAddr = Globals::BaseAddress + i.RVA + i.Instruction.length; + } + // decode the branch address immediately const auto instructions = DecodeFunction(branchAddr, 10); const auto isMatch = std::ranges::any_of(instructions, [pOnPlayerStoreNotify](const DecodedInstruction& instr) {