#ifndef _library__memorysearch__hpp__included__ #define _library__memorysearch__hpp__included__ #include "memoryspace.hpp" #include #include #include #include #include /** * Context for memory search. Each individual context is independent. */ class memory_search { public: /** * Creates a new memory search context with all addresses. * * Parameter space: The memory space. */ memory_search(memory_space& space) throw(std::bad_alloc); /** * Reset the context so all addresses are candidates again. */ void reset() throw(std::bad_alloc); /** * This searches the memory space, leaving those addresses for which condition object returns true. * * Parameter obj The condition to search for. */ template void search(const T& obj) throw(); /** * DQ a range of addresses (inclusive on both ends!). */ void dq_range(uint64_t first, uint64_t last); /** * Search for all bytes (update values) */ void update() throw(); /** * Get number of memory addresses that are still candidates */ uint64_t get_candidate_count() throw(); /** * Returns list of all candidates. This function isn't lazy, so be careful when calling with many candidates. */ std::list get_candidates() throw(std::bad_alloc); /** * Is specified address a candidate? */ bool is_candidate(uint64_t addr) throw(); /** * Next candidate in VMA. */ uint64_t cycle_candidate_vma(uint64_t addr, bool next) throw(); template void s_value(T value) throw(); template void s_difference(T value) throw(); template void s_lt() throw(); template void s_le() throw(); template void s_eq() throw(); template void s_ne() throw(); template void s_ge() throw(); template void s_gt() throw(); template void s_seqlt() throw(); template void s_seqle() throw(); template void s_seqge() throw(); template void s_seqgt() throw(); template T v_read(uint64_t addr) throw(); template T v_readold(uint64_t addr) throw(); template void v_write(uint64_t addr, T val) throw(); static bool searchable_region(memory_region* r) { return (r && !r->readonly && !r->special); } /** * Savestate type. */ enum savestate_type { ST_PREVMEM, ST_SET, ST_ALL }; /** * Save state. */ void savestate(std::vector& buffer, enum savestate_type type) const; /** * Load state. */ void loadstate(const std::vector& buffer); private: memory_space& mspace; std::vector previous_content; std::vector still_in; uint64_t candidates; }; #endif