fxos: make Binary::OSAnalysis const (slight hack)

This commit is contained in:
Lephenixnoir 2023-11-04 10:30:56 +01:00
parent 6b4a122866
commit 06a9d7e5af
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
2 changed files with 8 additions and 4 deletions

View File

@ -49,7 +49,7 @@ struct Binary
/* OS analysis (performed on-demand). Returns the new or cached OS
analysis results, nullptr if analysis failed. */
OS *OSAnalysis(bool force = false);
OS *OSAnalysis(bool force = false) const;
// TODO: Platform information in a binary
// TODO: Implement OS analysis
@ -82,7 +82,7 @@ private:
VirtualSpace m_vspace;
/* OS analysis results */
std::unique_ptr<OS> m_os;
mutable std::unique_ptr<OS> m_os;
/* All binary objects */
std::multimap<u32, std::unique_ptr<BinaryObject>> m_objects;

View File

@ -44,10 +44,14 @@ void Binary::deserialize(BSON const &b)
}
}
OS *Binary::OSAnalysis(bool force)
OS *Binary::OSAnalysis(bool force) const
{
if(!m_os || force) {
m_os = std::make_unique<OS>(m_vspace);
/* We break constness a little bit here. We allow access to the OS
analysis for const Binary, even though it uses the VirtualSpace and
technically AbstractMemory allows implementations to modify the
memory in response to reads. */
m_os = std::make_unique<OS>(const_cast<VirtualSpace &>(m_vspace));
/* We don't keep an OS analysis result that failed */
if(m_os->type == OS::UNKNOWN)
m_os = nullptr;