diff --git a/SilentPatch/Patterns.cpp b/SilentPatch/Patterns.cpp index 07d13b5..59b8901 100644 --- a/SilentPatch/Patterns.cpp +++ b/SilentPatch/Patterns.cpp @@ -11,7 +11,6 @@ #define NOMINMAX #include #include -#include #if PATTERNS_USE_HINTS #include @@ -138,15 +137,15 @@ public: inline uintptr_t end() const { return m_end; } }; -void pattern::Initialize(const char* pattern, size_t length) +void pattern::Initialize(std::string_view pattern) { // get the hash for the base pattern #if PATTERNS_USE_HINTS - m_hash = fnv_1()(std::string_view(pattern, length)); + m_hash = fnv_1()(pattern); #endif // transform the base pattern from IDA format to canonical format - TransformPattern(std::string_view(pattern, length), m_bytes, m_mask); + TransformPattern(pattern, m_bytes, m_mask); #if PATTERNS_USE_HINTS // if there's hints, try those first diff --git a/SilentPatch/Patterns.h b/SilentPatch/Patterns.h index d517da1..0663c60 100644 --- a/SilentPatch/Patterns.h +++ b/SilentPatch/Patterns.h @@ -9,6 +9,7 @@ #include #include +#include #pragma warning(push) #pragma warning(disable:4201) @@ -98,7 +99,7 @@ namespace hook { } - void Initialize(const char* pattern, size_t length); + void Initialize(std::string_view pattern); private: bool ConsiderHint(uintptr_t offset); @@ -115,7 +116,7 @@ namespace hook pattern(const char (&pattern)[Len]) : pattern(getRVA(0)) { - Initialize(pattern, Len-1); + Initialize(std::string_view(pattern, Len-1)); } inline pattern&& count(uint32_t expected) @@ -203,7 +204,7 @@ namespace hook range_pattern(uintptr_t begin, uintptr_t end, const char(&pattern)[Len]) : pattern(begin, end) { - Initialize(pattern, Len-1); + Initialize(std::string_view(pattern, Len-1)); } };