summaryrefslogtreecommitdiff
path: root/view/pe
diff options
context:
space:
mode:
authorBrandon Miller <brandon@vector35.com>2025-04-02 11:24:06 -0400
committerBrandon Miller <brandon@vector35.com>2025-04-03 07:03:33 -0400
commitfd1ac8a1cf3c05ccdbf8762e22e9b7f01bd2abd4 (patch)
tree29e54b50b3e8a741f78e1f0d575473f0eb6ff8e0 /view/pe
parent67e5ac0aa51db4fd52da786a6227c8bc649814e5 (diff)
Fix user platform override between armv7 and thumb
Only override the default platform based on the entry point architecture in cases where the user didn't explicitly set loader.platform
Diffstat (limited to 'view/pe')
-rw-r--r--view/pe/coffview.cpp15
-rw-r--r--view/pe/peview.cpp9
2 files changed, 14 insertions, 10 deletions
diff --git a/view/pe/coffview.cpp b/view/pe/coffview.cpp
index 4296917a..54d72f92 100644
--- a/view/pe/coffview.cpp
+++ b/view/pe/coffview.cpp
@@ -197,6 +197,7 @@ bool COFFView::Init()
m_is64 = m_arch->GetAddressSize() == 8;
m_imageBase = 0; // 0 for COFF? opt.imageBase;
+ bool platformSetByUser = false;
settings = GetLoadSettings(GetTypeName());
if (settings)
{
@@ -205,16 +206,12 @@ bool COFFView::Init()
if (settings->Contains("loader.platform"))
{
- auto platformName = settings->Get<string>("loader.platform", this);
- platform = Platform::GetByName(platformName);
+ BNSettingsScope scope = SettingsAutoScope;
+ Ref<Platform> platform = Platform::GetByName(settings->Get<string>("loader.platform", this, &scope));
if (platform)
{
m_arch = platform->GetArchitecture();
- m_logger->LogDebug("COFF: loader.platform override (%#x, arch: %s): %s", header.machine, m_arch->GetName().c_str(), platformName.c_str());
- }
- else
- {
- m_logger->LogError("COFF: Cannot find platform \"%s\" specified in loader.platform override", platformName.c_str());
+ platformSetByUser = (scope == SettingsResourceScope);
}
}
}
@@ -489,7 +486,9 @@ bool COFFView::Init()
m_logger->LogDebug("COFF: initial platform (%#x, arch: %s): %s", header.machine, m_arch->GetName().c_str(), platform->GetName().c_str());
}
- platform = platform->GetAssociatedPlatformByAddress(entryPointAddress);
+ if (!platformSetByUser)
+ platform = platform->GetAssociatedPlatformByAddress(entryPointAddress);
+
entryPointAddress = m_entryPoint;
m_logger->LogDebug("COFF: entry point %#" PRIx64 " associated platform (%#x, arch: %s): %s", entryPointAddress, header.machine, m_arch->GetName().c_str(), platform->GetName().c_str());
diff --git a/view/pe/peview.cpp b/view/pe/peview.cpp
index 77c52da8..96103155 100644
--- a/view/pe/peview.cpp
+++ b/view/pe/peview.cpp
@@ -597,6 +597,7 @@ bool PEView::Init()
m_extractMangledTypes = viewSettings->Get<bool>("analysis.extractTypesFromMangledNames", this);
m_simplifyTemplates = viewSettings->Get<bool>("analysis.types.templateSimplifier", this);
+ bool platformSetByUser = false;
settings = GetLoadSettings(GetTypeName());
if (settings)
{
@@ -605,11 +606,13 @@ bool PEView::Init()
if (settings->Contains("loader.platform"))
{
- Ref<Platform> platformOverride = Platform::GetByName(settings->Get<string>("loader.platform", this));
+ BNSettingsScope scope = SettingsAutoScope;
+ Ref<Platform> platformOverride = Platform::GetByName(settings->Get<string>("loader.platform", this, &scope));
if (platformOverride)
{
platform = platformOverride;
m_arch = platform->GetArchitecture();
+ platformSetByUser = (scope == SettingsResourceScope);
}
}
}
@@ -647,7 +650,9 @@ bool PEView::Init()
return false;
}
- platform = platform->GetAssociatedPlatformByAddress(m_entryPoint);
+ if (!platformSetByUser)
+ platform = platform->GetAssociatedPlatformByAddress(m_entryPoint);
+
SetDefaultPlatform(platform);
SetDefaultArchitecture(platform->GetArchitecture());