fix symbols analysis crash

This commit is contained in:
hyugogirubato 2025-03-01 14:16:02 +01:00
parent 7c2f27df44
commit 3628e42f45
2 changed files with 9 additions and 7 deletions

View File

@ -215,7 +215,9 @@ class Core:
elif not minimum and vendor.oem > 17 and not self.functions:
self.logger.warning("For OEM API > 17, specifying '--functions' is required. Refer to https://github.com/hyugogirubato/KeyDive/blob/main/docs/FUNCTIONS.md")
return script.exports_sync.hooklibrary(library["name"])
# Enable dynamic analysis (symbols) only when necessary
dynamic = minimum and vendor.oem > 17 and not self.functions
return script.exports_sync.hooklibrary(library["name"], dynamic)
# Unload the script if the target library is not found.
script.unload()

View File

@ -84,14 +84,14 @@ const getLibrary = (name) => {
return libraries.length === 1 ? libraries[0] : undefined;
}
const getFunctions = (library) => {
const getFunctions = (library, dynamic) => {
try {
// https://frida.re/news/2025/01/09/frida-16-6-0-released/
const functions = library.enumerateSymbols().map(item => ({
const functions = dynamic ? library.enumerateSymbols().map(item => ({
type: item.type,
name: item.name,
address: item.address
}));
})) : [];
library.enumerateExports().forEach(item => {
if (!functions.includes(item)) {
@ -111,7 +111,7 @@ const disableLibrary = (name) => {
const library = getLibrary(name);
if (library) {
// https://github.com/hyugogirubato/KeyDive/issues/23#issuecomment-2230374415
const functions = getFunctions(library);
const functions = getFunctions(library, false);
const disabled = [];
functions.forEach(func => {
@ -395,7 +395,7 @@ const RunningCRC = (address) => {
// @Hooks
const hookLibrary = (name) => {
const hookLibrary = (name, dynamic) => {
// https://github.com/poxyran/misc/blob/master/frida-enumerate-imports.py
let library = getLibrary(name);
if (!library) return false;
@ -409,7 +409,7 @@ const hookLibrary = (name) => {
address: library.base.add(s.address)
}));
} else {
functions = getFunctions(library);
functions = getFunctions(library, dynamic);
}
functions = functions.filter(f => !NATIVE_C_API.includes(f.name));