| 348 | } |
| 349 | |
| 350 | static void searchWorkerByteArray(DebugInterface* cpu, SearchType searchType, SearchComparison searchComparison, std::vector<SearchResult>& searchResults, u32 start, u32 end, QByteArray searchValue) |
| 351 | { |
| 352 | const bool isSearchingRange = searchResults.size() <= 0; |
| 353 | if (isSearchingRange) |
| 354 | { |
| 355 | for (u32 addr = start; addr < end; addr += 1) |
| 356 | { |
| 357 | if (!cpu->isValidAddress(addr)) |
| 358 | continue; |
| 359 | if (handleArraySearchComparison(cpu, searchComparison, addr, nullptr, searchValue)) |
| 360 | { |
| 361 | searchResults.push_back(MemorySearchView::SearchResult(addr, searchValue, searchType)); |
| 362 | addr += searchValue.length() - 1; |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | else |
| 367 | { |
| 368 | auto removeIt = std::remove_if(searchResults.begin(), searchResults.end(), [searchComparison, searchType, searchValue, cpu](SearchResult& searchResult) -> bool { |
| 369 | const u32 addr = searchResult.getAddress(); |
| 370 | if (!cpu->isValidAddress(addr)) |
| 371 | return true; |
| 372 | |
| 373 | const bool doesMatch = handleArraySearchComparison(cpu, searchComparison, addr, &searchResult, searchValue); |
| 374 | if (doesMatch) |
| 375 | { |
| 376 | QByteArray matchValue; |
| 377 | if (searchComparison == SearchComparison::Equals) |
| 378 | matchValue = searchValue; |
| 379 | else if (searchComparison == SearchComparison::NotChanged) |
| 380 | matchValue = searchResult.getArrayValue(); |
| 381 | else |
| 382 | matchValue = readArrayAtAddress(cpu, addr, searchValue.length() - 1); |
| 383 | searchResult = MemorySearchView::SearchResult(addr, matchValue, searchType); |
| 384 | } |
| 385 | return !doesMatch; |
| 386 | }); |
| 387 | searchResults.erase(removeIt, searchResults.end()); |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | std::vector<SearchResult> startWorker(DebugInterface* cpu, const SearchType type, const SearchComparison comparison, std::vector<SearchResult> searchResults, u32 start, u32 end, QString value, int base) |
| 392 | { |
no test coverage detected