MCPcopy Create free account
hub / github.com/OpenSteam001/OpenSteamTool / Find

Method Find

src/OSTPlatform/Windows/ByteSearch.cpp:31–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29 }
30
31 std::optional<size_t> Find(std::span<const uint8_t> bytes) const {
32 const size_t patternSize = pattern_.size();
33 if (patternSize == 0 || bytes.size() < patternSize) return std::nullopt;
34
35 size_t offset = 0;
36 while (offset <= bytes.size() - patternSize) {
37 const uint8_t tail = bytes[offset + patternSize - 1];
38 if (tail == pattern_[patternSize - 1]) {
39 size_t i = patternSize - 1;
40 while (i > 0 && bytes[offset + i - 1] == pattern_[i - 1]) {
41 --i;
42 }
43 if (i == 0) return offset;
44 }
45
46 offset += skip_[tail];
47 }
48
49 return std::nullopt;
50 }
51
52 size_t PatternSize() const { return pattern_.size(); }
53

Callers 2

FindFunction · 0.45
FindInFileRangeFunction · 0.45

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected