feature (utils): Implemented a function to resolve symbols by their name

This commit is contained in:
antifallobst 2023-03-02 13:34:05 +01:00
parent 66006032b9
commit 437d7ba819
2 changed files with 12 additions and 1 deletions

View File

@ -38,6 +38,7 @@ typedef struct {
uint64_t address; uint64_t address;
} symbol_T; } 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 #endif //NOX_SYMBOLS_H

View File

@ -23,6 +23,16 @@
#include "utils/symbol.h" #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_resolve_function_from_rip(symbol_T* symbols, uint64_t num_symbols, uint64_t rip) {
symbol_T* symbol = NULL; symbol_T* symbol = NULL;