summaryrefslogtreecommitdiff
path: root/view/pe
diff options
context:
space:
mode:
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());