diff options
| author | Zichuan Li <34680029+river-li@users.noreply.github.com> | 2024-08-15 11:53:05 -0400 |
|---|---|---|
| committer | Brandon Miller <brandon@vector35.com> | 2025-05-08 07:23:08 -0400 |
| commit | 7f08117cfeb48a8f48d08e14cb498ee028efcef2 (patch) | |
| tree | 345eab220c00cfa098e94fa261dce092fc8d5182 /platform/efi/efi_resolver/include/Utils.h | |
| parent | 64de95854f9ad4da90b9cf2ee69a80f5dddd7a18 (diff) | |
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
Diffstat (limited to 'platform/efi/efi_resolver/include/Utils.h')
| -rw-r--r-- | platform/efi/efi_resolver/include/Utils.h | 36 |
1 files changed, 36 insertions, 0 deletions
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> 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; +} |
