summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/efi/platform_efi.cpp107
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"