#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); 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(); static bool searchable_region(memory_region* r) { return (r && !r->readonly && !r->special); } private: memory_space& mspace; std::vector previous_content; std::vector still_in; uint64_t candidates; }; #endif