diff options
| author | Mark Rowe <mark@vector35.com> | 2026-02-07 12:04:49 -0800 |
|---|---|---|
| committer | Mark Rowe <mark@vector35.com> | 2026-03-16 17:45:00 -0700 |
| commit | 9b008755f81cf3019c81af9f59d82b05ade0d9b5 (patch) | |
| tree | 53ee79494e4cec81cb5e983b4d5d88900bb79b4c /view/macho/universaltransform.cpp | |
| parent | 25213a836b1423cbc1aeef1f23aebc2167154e56 (diff) | |
Refactor where architecture selection is performed for universal binaries
Responsibility for selecting an architecture is moved out of
`UniversalTransform` and into a new `ContainerOpenRequest` class.
`UniversalTransform` still handles architecture selection in headless
operation (for now).
Diffstat (limited to 'view/macho/universaltransform.cpp')
| -rw-r--r-- | view/macho/universaltransform.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/view/macho/universaltransform.cpp b/view/macho/universaltransform.cpp index 3309d853..33164215 100644 --- a/view/macho/universaltransform.cpp +++ b/view/macho/universaltransform.cpp @@ -266,19 +266,20 @@ bool UniversalTransform::DecodeWithContext(Ref<TransformContext> context, const architectures.push_back(archName); } - if (!context->IsInteractive()) + // TODO: It is surprising that this is UniversalTransform's responsibility. + if (!BinaryNinja::IsUIEnabled()) { + // When headless, filter to the preferred architecture if one is configured. vector<string> archPref = context->GetSettings()->Get<vector<string>>("files.universal.architecturePreference"); if (auto result = find_first_of(archPref.begin(), archPref.end(), architectures.begin(), architectures.end()); result != archPref.end()) { - // Filter to preferred architecture to support container auto-open policy size_t archIndex = find(architectures.begin(), architectures.end(), *result) - architectures.begin(); context->SetAvailableFiles({architectures[archIndex]}); return false; } - // Preserve original headless load behavior when no architecturePreference is specified - if (!BinaryNinja::IsUIEnabled() && archPref.empty() && architectures.size()) + // Load the first architecture if no preference is found. + if (archPref.empty() && architectures.size()) { context->SetAvailableFiles({architectures[0]}); return false; |
