Compare commits

...

2 Commits

Author SHA1 Message Date
Bigjango13 dc848d6fe7 More consistent lookup for sounds 2024-02-06 20:42:42 -05:00
Bigjango13 a31641d106 Fix load_symbol ignoring source when a previous source has already been loaded 2024-01-30 19:44:07 -05:00
1 changed files with 5 additions and 3 deletions

View File

@ -13,10 +13,12 @@
// Load Symbol From ELF File
static void load_symbol(const char *source, const char *name, std::function<void(const unsigned char *, uint32_t)> callback) {
static std::unique_ptr<LIEF::ELF::Binary> binary = NULL;
if (binary == NULL) {
binary = LIEF::ELF::Parser::parse(source);
static std::unordered_map<std::string, std::unique_ptr<LIEF::ELF::Binary>> sources = {};
std::string cpp_source = source;
if (sources.count(cpp_source) == 0) {
sources[cpp_source] = LIEF::ELF::Parser::parse(source);
}
std::unique_ptr<LIEF::ELF::Binary> &binary = sources[cpp_source];
const LIEF::ELF::Symbol *symbol = binary->get_dynamic_symbol(name);
if (symbol != NULL) {
LIEF::span<const uint8_t> data = binary->get_content_from_virtual_address(symbol->value(), symbol->size(), LIEF::Binary::VA_TYPES::VA);