//---------------------------------------------------------------------------// // 1100101 |_ mov #0, r4 __ // // 11 |_ <0xb380 %5c4> / _|_ _____ ___ // // 0110 |_ 3.50 -> 3.60 | _\ \ / _ (_-< // // |_ base# + offset |_| /_\_\___/__/ // //---------------------------------------------------------------------------// // fxos/vspace: Virtual address space with loaded code and analyses // // This is the main structure/entry point of fxos. A virtual space emulates the // virtual memory of the MPU and can have files loaded ("bound") at chosen // positions. Usually, there is one virtual space for each OS being studied. // // Technically, each virtual space should also come with platform information, // but currently only the MPU is specified and it's unused. // // Virtual spaces also centralize information related to analyses. //--- #ifndef FXOS_VSPACE_H #define FXOS_VSPACE_H #include #include #include #include #include #include #include #include #include #include #include namespace FxOS { /* A binding of a data buffer into a memory region of the target. */ struct Binding: public AbstractMemory { /* Constructor from data buffer. An error is raised if the buffer is not at least of the size of the region. In this case, a new buffer can be constructed with the required size. */ Binding(MemoryRegion region, Buffer const &buffer); /* Targeted region, might overlap with other bindings */ MemoryRegion region; /* Underlying buffer (copy of the original one) */ Buffer buffer; // - AbstractMemory interface char const *translate_dynamic(uint32_t addr, int *size) override; }; /* A composite space where regions can be bound dynamically */ class VirtualSpace: public AbstractMemory { public: /* Create an empty space with no regions */ VirtualSpace(); /* MPU used by this target, or an empty string if unspecified */ std::string mpu; /* List of bindings (most recent first) */ std::vector bindings; /* Bind a buffer to a standard or custom memory region. Functions in the library tend to assume that bindings don't overlap and are not immediately consecutive in memory. If the buffer is smaller than the region, it is 0-padded to the proper size. */ void bind_region(MemoryRegion const ®ion, Buffer const &buffer); /* Cursor position, used by the interactive shell */ uint32_t cursor; /* Symbol table */ SymbolTable symbols; // - AbstractMemory interface char const *translate_dynamic(uint32_t addr, int *size) override; // Analysis tools and data /* Main disassembly; holds disassembled code for large-scale analyses. */ Disassembly disasm; /* OS analysis; created on-demand. Returns the new or cached OS analysis, nullptr OS analysis fails. */ OS *os_analysis(bool force = false); private: /* OS analysis results */ std::unique_ptr m_os; }; } /* namespace FxOS */ #endif /* FXOS_VSPACE_H */