diff options
| author | Zichuan Li <34680029+river-li@users.noreply.github.com> | 2024-08-06 18:05:53 -0400 |
|---|---|---|
| committer | Brandon Miller <brandon@vector35.com> | 2025-05-08 07:23:08 -0400 |
| commit | 64de95854f9ad4da90b9cf2ee69a80f5dddd7a18 (patch) | |
| tree | 1c9e026ae791ed9b31e8de253a8f54ba343a5dcf /platform/efi | |
| parent | 63536b58536277d6c837e2b0025777385a56548d (diff) | |
Change type for TPIDR_EL0 and run the plugin automatically
Diffstat (limited to 'platform/efi')
| -rw-r--r-- | platform/efi/platform_efi.cpp | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/platform/efi/platform_efi.cpp b/platform/efi/platform_efi.cpp index 4f30cc35..9f9840b2 100644 --- a/platform/efi/platform_efi.cpp +++ b/platform/efi/platform_efi.cpp @@ -60,6 +60,17 @@ public: { if (!m_idtrtype) m_idtrtype = Type::NamedType(QualifiedName("IDTR32"), GetTypeByName(QualifiedName("IDTR32"))); + + auto ctx = PluginCommandContext(); + ctx.binaryView = view; + auto commandList = PluginCommand::GetValidList(ctx); + for (auto command : commandList) + { + if (command.GetName() == "EFI Resolver\\Resolve EFI Types And Protocols") + { + command.Execute(ctx); + } + } } virtual Ref<Type> GetGlobalRegisterType(uint32_t reg) override @@ -124,6 +135,17 @@ public: { if (!m_idtrtype) m_idtrtype = Type::NamedType(QualifiedName("IDTR32"), GetTypeByName(QualifiedName("IDTR32"))); + + auto ctx = PluginCommandContext(); + ctx.binaryView = view; + auto commandList = PluginCommand::GetValidList(ctx); + for (auto command : commandList) + { + if (command.GetName() == "EFI Resolver\\Resolve EFI Types And Protocols") + { + command.Execute(ctx); + } + } } virtual Ref<Type> GetGlobalRegisterType(uint32_t reg) override @@ -171,6 +193,17 @@ public: { if (!m_idtrtype) m_idtrtype = Type::NamedType(QualifiedName("IDTR64"), GetTypeByName(QualifiedName("IDTR64"))); + + auto ctx = PluginCommandContext(); + ctx.binaryView = view; + auto commandList = PluginCommand::GetValidList(ctx); + for (auto command : commandList) + { + if (command.GetName() == "EFI Resolver\\Resolve EFI Types And Protocols") + { + command.Execute(ctx); + } + } } virtual Ref<Type> GetGlobalRegisterType(uint32_t reg) override @@ -218,6 +251,17 @@ public: { if (!m_idtrtype) m_idtrtype = Type::NamedType(QualifiedName("IDTR64"), GetTypeByName(QualifiedName("IDTR64"))); + + auto ctx = PluginCommandContext(); + ctx.binaryView = view; + auto commandList = PluginCommand::GetValidList(ctx); + for (auto command : commandList) + { + if (command.GetName() == "EFI Resolver\\Resolve EFI Types And Protocols") + { + command.Execute(ctx); + } + } } virtual Ref<Type> GetGlobalRegisterType(uint32_t reg) override @@ -261,11 +305,15 @@ public: class EFIArm64Platform : public Platform { + uint32_t m_tpidrel0; + Ref<Type> m_tpidrel0type; + public: EFIArm64Platform(Architecture* arch) : Platform(arch, "efi-aarch64") { Ref<CallingConvention> cc; + m_tpidrel0 = arch->GetRegisterByName("tpidr_el0"); cc = arch->GetCallingConventionByName("cdecl"); if (cc) { @@ -276,6 +324,26 @@ public: } } + virtual void BinaryViewInit(BinaryView* view) override + { + if (!m_tpidrel0type) + m_tpidrel0type = Type::NamedType(QualifiedName("EFI_PEI_SERVICES"), + Type::PointerType(view->GetDefaultArchitecture(), + Type::PointerType( + view->GetDefaultArchitecture(), GetTypeByName(QualifiedName("EFI_PEI_SERVICES"))))); + + auto ctx = PluginCommandContext(); + ctx.binaryView = view; + auto commandList = PluginCommand::GetValidList(ctx); + for (auto command : commandList) + { + if (command.GetName() == "EFI Resolver\\Resolve EFI Types And Protocols") + { + command.Execute(ctx); + } + } + } + static Ref<Platform> Recognize(BinaryView* view, Metadata* metadata) { Ref<Metadata> subsystem = metadata->Get("Subsystem"); @@ -285,16 +353,27 @@ public: return g_efiArm64; return nullptr; } + + virtual Ref<Type> GetGlobalRegisterType(uint32_t reg) override + { + if (reg == m_tpidrel0) + return m_tpidrel0type; + + return nullptr; + } }; class EFIArm64WindowsPlatform : public Platform { + uint32_t m_tpidrel0; + Ref<Type> m_tpidrel0type; public: EFIArm64WindowsPlatform(Architecture* arch) : Platform(arch, "efi-windows-aarch64") { Ref<CallingConvention> cc; + m_tpidrel0 = arch->GetRegisterByName("tpidr_el0"); cc = arch->GetCallingConventionByName("cdecl"); if (cc) { @@ -305,6 +384,26 @@ public: } } + virtual void BinaryViewInit(BinaryView* view) override + { + if (!m_tpidrel0type) + m_tpidrel0type = Type::NamedType(QualifiedName("EFI_PEI_SERVICES"), + Type::PointerType(view->GetDefaultArchitecture(), + Type::PointerType( + view->GetDefaultArchitecture(), GetTypeByName(QualifiedName("EFI_PEI_SERVICES"))))); + + auto ctx = PluginCommandContext(); + ctx.binaryView = view; + auto commandList = PluginCommand::GetValidList(ctx); + for (auto command : commandList) + { + if (command.GetName() == "EFI Resolver\\Resolve EFI Types And Protocols") + { + command.Execute(ctx); + } + } + } + static Ref<Platform> Recognize(BinaryView* view, Metadata* metadata) { Ref<Metadata> subsystem = metadata->Get("Subsystem"); @@ -314,6 +413,14 @@ public: return g_efiArm64Windows; return nullptr; } + + virtual Ref<Type> GetGlobalRegisterType(uint32_t reg) override + { + if (reg == m_tpidrel0) + return m_tpidrel0type; + + return nullptr; + } }; extern "C" |
