Reference version search
| 234 | |
| 235 | // Reference version search |
| 236 | int SigSearch::SearchCommon(uint8_t* input, size_t inputLen, const Signature &sig, ptrdiff_t* output_offset) |
| 237 | { |
| 238 | size_t sigSize = sig.bytes.size(); |
| 239 | size_t len = inputLen - sigSize; |
| 240 | size_t count = 0; |
| 241 | bool hasWildcards = sig.hasMask(); |
| 242 | |
| 243 | inputLen -= sigSize; |
| 244 | |
| 245 | // Search for signature match.. |
| 246 | uint8_t* match = FindCommon(input, len, sig, hasWildcards); |
| 247 | while (match) |
| 248 | { |
| 249 | *output_offset = (ptrdiff_t) (match - input); |
| 250 | ++count; |
| 251 | // Stop now if we've hit two matches |
| 252 | // if (++count >= 2) |
| 253 | // break; |
| 254 | |
| 255 | ++match; |
| 256 | len = (inputLen - (int) (match - input)); |
| 257 | if (len < sigSize) |
| 258 | break; |
| 259 | |
| 260 | // Next search |
| 261 | match = FindCommon(match, len, sig, hasWildcards); |
| 262 | }; |
| 263 | |
| 264 | return count; |
| 265 | } |
| 266 | |
| 267 | // Fast AVX2 based search |
| 268 | int SigSearch::SearchAVX2(uint8_t* input, size_t inputLen, const Signature &sig, ptrdiff_t* output_offset) |