Fixed multiple hook

This commit is contained in:
hyugogirubato 2024-07-16 22:52:15 +02:00
parent a9ab9551cd
commit 1f831c3f5f
2 changed files with 16 additions and 4 deletions

View File

@ -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

View File

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