From fd1ac8a1cf3c05ccdbf8762e22e9b7f01bd2abd4 Mon Sep 17 00:00:00 2001 From: Brandon Miller Date: Wed, 2 Apr 2025 11:24:06 -0400 Subject: 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 --- view/pe/coffview.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'view/pe/coffview.cpp') 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("loader.platform", this); - platform = Platform::GetByName(platformName); + BNSettingsScope scope = SettingsAutoScope; + Ref platform = Platform::GetByName(settings->Get("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()); -- cgit v1.3.1