Searches for a pattern.
| 181 | |
| 182 | // Searches for a pattern. |
| 183 | size_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. |
| 203 | uint32_t getSectionDelta(const std::vector<Byte>& data, size_t offset) { |
no outgoing calls
no test coverage detected