Fast AVX2 based search
| 266 | |
| 267 | // Fast AVX2 based search |
| 268 | int SigSearch::SearchAVX2(uint8_t* input, size_t inputLen, const Signature &sig, ptrdiff_t* output_offset) |
| 269 | { |
| 270 | size_t sigSize = sig.bytes.size(); |
| 271 | size_t len = inputLen - sigSize; |
| 272 | size_t count = 0; |
| 273 | bool hasWildcards = sig.hasMask(); |
| 274 | |
| 275 | inputLen -= sigSize; |
| 276 | |
| 277 | uint8_t* match = FindAVX2(input, len, sig, hasWildcards); |
| 278 | while (match) |
| 279 | { |
| 280 | *output_offset = (ptrdiff_t) (match - input); |
| 281 | ++count; |
| 282 | // if (++count >= 2) |
| 283 | // break; |
| 284 | |
| 285 | ++match; |
| 286 | len = (inputLen - (int) (match - input)); |
| 287 | if (len < sigSize) |
| 288 | break; |
| 289 | |
| 290 | match = FindAVX2(match, len, sig, hasWildcards); |
| 291 | }; |
| 292 | |
| 293 | return count; |
| 294 | } |
| 295 | |
| 296 | // Search for signature pattern, returning a status result |
| 297 | int SigSearch::Search(uint8_t* input, size_t inputLen, const Signature &sig, ptrdiff_t* output_offset) |