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`); } }