1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 12:42:30 +04:00
Files
unleashed-firmware/lib/flipper_application/api_hashtable/api_hashtable.cpp
Nick Mooney f6eb79e1e5 NFC: Add support for Gallagher access control (MIFARE Classic only) (#3306)
* Merge remote-tracking branch 'origin/dev' into dev
* Add basic API interface (inspired by advanced plugins example), modify NfcSupportedCardsLoadContext to contain a pointer to a resolver
* WIP: API resolver implemented / passed to plugin via context, still having resolution issues
* Attempt to add constants to the nfc_app_api_table list
* WIP: We're defining the constants directly in nfc_app_api.c to see if this fixes our woes, which it does not.
* WIP: Remove furi_assert(false) (lmao)
* Working implementation of Gallagher decoding via exposed plugin API
* lib: api_hashtable: change log level for symbol not found message
* nfc app: alloc composite resolver along with supported cards
* nfc app: rework nfc api structure
* nfc app: fix memory leakage in supported cards

Co-authored-by: gornekich <n.gorbadey@gmail.com>
2024-02-09 15:00:17 +07:00

37 lines
955 B
C++

#include "api_hashtable.h"
#include <furi.h>
#include <algorithm>
#define TAG "ApiHashtable"
bool elf_resolve_from_hashtable(
const ElfApiInterface* interface,
uint32_t hash,
Elf32_Addr* address) {
bool result = false;
const HashtableApiInterface* hashtable_interface =
static_cast<const HashtableApiInterface*>(interface);
sym_entry key = {
.hash = hash,
.address = 0,
};
auto find_res =
std::lower_bound(hashtable_interface->table_cbegin, hashtable_interface->table_cend, key);
if((find_res == hashtable_interface->table_cend || (find_res->hash != hash))) {
FURI_LOG_T(
TAG, "Can't find symbol with hash %lx @ %p!", hash, hashtable_interface->table_cbegin);
result = false;
} else {
result = true;
*address = find_res->address;
}
return result;
}
uint32_t elf_symbolname_hash(const char* s) {
return elf_gnu_hash(s);
}