MCPcopy Create free account
hub / github.com/Do0ks/GSpots / findPatternMask

Function findPatternMask

GOffsets/GOffsets.cpp:183–200  ·  view source on GitHub ↗

Searches for a pattern.

Source from the content-addressed store, hash-verified

181
182// Searches for a pattern.
183size_t findPatternMask(const std::vector<Byte>& data,
184 const std::vector<Byte>& pattern,
185 const std::string& mask) {
186 if (pattern.size() != mask.size() || pattern.empty() || data.empty())
187 return std::string::npos;
188 for (size_t i = 0; i <= data.size() - pattern.size(); ++i) {
189 bool found = true;
190 for (size_t j = 0; j < pattern.size(); ++j) {
191 if (mask[j] == 'x' && data[i + j] != pattern[j]) {
192 found = false;
193 break;
194 }
195 }
196 if (found)
197 return i;
198 }
199 return std::string::npos;
200}
201
202// Calculates adjustments to convert offsets within the PE.
203uint32_t getSectionDelta(const std::vector<Byte>& data, size_t offset) {

Callers 2

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected