#pragma once #include "../Include/Types.h" #include #include #include namespace blackbone { class PatternSearch { public: BLACKBONE_API PatternSearch( const std::vector& pattern ); BLACKBONE_API PatternSearch( const std::initializer_list&& pattern ); BLACKBONE_API PatternSearch( const std::string& pattern ); BLACKBONE_API PatternSearch( const char* pattern, size_t len = 0 ); BLACKBONE_API PatternSearch( const uint8_t* pattern, size_t len = 0 ); BLACKBONE_API ~PatternSearch() = default; /// /// Default pattern matching with wildcards. /// std::search is approximately 2x faster than naive approach. /// /// Pattern wildcard /// Starting address /// Size of region to scan /// Found results /// Value that will be added to resulting addresses /// Number of found addresses BLACKBONE_API size_t Search( uint8_t wildcard, void* scanStart, size_t scanSize, std::vector& out, ptr_t value_offset = 0 ) const; /// /// Full pattern match, no wildcards. /// Uses Boyer–Moore–Horspool algorithm. /// /// Starting address /// Size of region to scan /// Found results /// Value that will be added to resulting addresses /// Number of found addresses BLACKBONE_API size_t Search( void* scanStart, size_t scanSize, std::vector& out, ptr_t value_offset = 0 ) const; /// /// Search pattern in remote process /// /// Remote process /// Pattern wildcard /// Starting address /// Size of region to scan /// Found results /// Number of found addresses BLACKBONE_API size_t SearchRemote( class Process& remote, uint8_t wildcard, ptr_t scanStart, size_t scanSize, std::vector& out ) const; /// /// Search pattern in remote process /// /// Remote process /// Starting address /// Size of region to scan /// Found results /// Number of found addresses BLACKBONE_API size_t SearchRemote( class Process& remote, ptr_t scanStart, size_t scanSize, std::vector& out ) const; /// /// Search pattern in whole address space of remote process /// /// Remote process /// True if pattern contains wildcards /// Pattern wildcard /// Found results /// Number of found addresses BLACKBONE_API size_t SearchRemoteWhole( class Process& remote, bool useWildcard, uint8_t wildcard, std::vector& out ) const; private: std::vector _pattern; // Pattern to search }; }