From 7f08117cfeb48a8f48d08e14cb498ee028efcef2 Mon Sep 17 00:00:00 2001 From: Zichuan Li <34680029+river-li@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:53:05 -0400 Subject: Move EFI Resolver to API Support all existing features in EFI Resolver, 1. Doesn't support running on existing BNDBs (though we tried to support this in python plugins, it doesn't work well) 2. Perform analysis on MLIL rather than HLIL, previous pattern matching on HLIL constains many false negatives --- platform/efi/efi_resolver/include/Utils.h | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 platform/efi/efi_resolver/include/Utils.h (limited to 'platform/efi/efi_resolver/include/Utils.h') diff --git a/platform/efi/efi_resolver/include/Utils.h b/platform/efi/efi_resolver/include/Utils.h new file mode 100644 index 00000000..f2c371a8 --- /dev/null +++ b/platform/efi/efi_resolver/include/Utils.h @@ -0,0 +1,36 @@ +#pragma once + +#include "binaryninjaapi.h" + +using namespace BinaryNinja; + +static inline std::string GetOriginalTypeName(Ref type) +{ + std::string result; + if (type->IsPointer()) { + if (type->GetChildType().GetValue()->IsNamedTypeRefer()) { + return type->GetChildType().GetValue()->GetNamedTypeReference()->GetName().GetString(); + } + return type->GetTypeName().GetString(); + } + if (type->IsNamedTypeRefer()) + return type->GetNamedTypeReference()->GetName().GetString(); + + return type->GetTypeName().GetString(); +} + +static inline std::string GetVarNameForTypeStr(const std::string typeStr) +{ + std::istringstream iss(typeStr); + std::string word; + std::string result; + + while (std::getline(iss, word, '_')) { + if (!word.empty()) { + word[0] = std::toupper(word[0]); + std::transform(word.begin() + 1, word.end(), word.begin() + 1, ::tolower); + result += word; + } + } + return result; +} -- cgit v1.3.1