From 1f831c3f5f9f1fe089110d364a0ec6abcb93fd5f Mon Sep 17 00:00:00 2001 From: hyugogirubato <65763543+hyugogirubato@users.noreply.github.com> Date: Tue, 16 Jul 2024 22:52:15 +0200 Subject: [PATCH] Fixed multiple hook --- CHANGELOG.md | 5 +++++ keydive/keydive.js | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d6256a..608b613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [2.0.7] - Not released +### Changed + +- Updated display of library disabler. + ### Fixed - Fix disabled library address. +- Fixed multiple hook for library disabler. ### New Contributors diff --git a/keydive/keydive.js b/keydive/keydive.js index e4aa94d..16377e7 100644 --- a/keydive/keydive.js +++ b/keydive/keydive.js @@ -95,20 +95,27 @@ const disableLibrary = (name) => { // Disables all functions in the specified library by replacing their implementations. const library = getLibrary(name); if (library) { + // https://github.com/hyugogirubato/KeyDive/issues/23#issuecomment-2230374415 const functions = getFunctions(library); + const disabled = []; + functions.forEach(func => { - if (func.type !== 'function') return; + const {name: funcName, address: funcAddr} = func; + if (func.type !== 'function' || disabled.includes(funcAddr)) return; + try { - Interceptor.replace(func.address, new NativeCallback(function () { + Interceptor.replace(funcAddr, new NativeCallback(function () { return 0; }, 'int', [])); + + disabled.push(funcAddr); } catch (e) { - print(Level.ERROR, `${e.message} for ${func.name}`); + print(Level.DEBUG, `${e.message} for ${funcName}`); } }); print(Level.INFO, `The library ${library.name} (${library.base}) has been disabled`); } else { - print(Level.DEBUG, `The library ${name} was not found`); + print(Level.INFO, `The library ${name} was not found`); } }