From 437d7ba819542e61c9ef7568f40cd9326938846a Mon Sep 17 00:00:00 2001 From: antifallobst Date: Thu, 2 Mar 2023 13:34:05 +0100 Subject: [PATCH] feature (utils): Implemented a function to resolve symbols by their name --- kernel/inc/utils/symbol.h | 3 ++- kernel/src/utils/symbol.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kernel/inc/utils/symbol.h b/kernel/inc/utils/symbol.h index 0ba0bc4..21b3ac5 100644 --- a/kernel/inc/utils/symbol.h +++ b/kernel/inc/utils/symbol.h @@ -38,6 +38,7 @@ typedef struct { uint64_t address; } symbol_T; -symbol_T* symbol_resolve_function_from_rip(symbol_T* symbols, uint64_t num_symbols, uint64_t rip); +symbol_T* symbol_resolve_from_name (symbol_T* symbols, uint64_t num_symbols, string_t name); +symbol_T* symbol_resolve_function_from_rip (symbol_T* symbols, uint64_t num_symbols, uint64_t rip); #endif //NOX_SYMBOLS_H diff --git a/kernel/src/utils/symbol.c b/kernel/src/utils/symbol.c index 7ac0d55..63fc4cd 100644 --- a/kernel/src/utils/symbol.c +++ b/kernel/src/utils/symbol.c @@ -23,6 +23,16 @@ #include "utils/symbol.h" +symbol_T* symbol_resolve_from_name(symbol_T* symbols, uint64_t num_symbols, string_t name) { + for (uint64_t i = 0; i < num_symbols; i++) { + if (string_compare(name, symbols[i].name)) { + return &symbols[i]; + } + } + + return NULL; +} + symbol_T* symbol_resolve_function_from_rip(symbol_T* symbols, uint64_t num_symbols, uint64_t rip) { symbol_T* symbol = NULL;