| 33 | } |
| 34 | |
| 35 | std::vector<PAddr> scan_swapper(const PhysicalLayer& phys) { |
| 36 | std::vector<PAddr> hits; |
| 37 | std::vector<u8> buf(kScanChunk + 16); |
| 38 | PAddr maxa = phys.max_address(); |
| 39 | PAddr pa = 0; |
| 40 | log::debug("Scanning {:.1f} MB for swapper signature...", maxa / (1024.0 * 1024)); |
| 41 | while (pa < maxa) { |
| 42 | std::size_t want = std::min<u64>(kScanChunk + 16, maxa - pa); |
| 43 | std::size_t got = phys.read(pa, buf.data(), want); |
| 44 | if (got == 0) { pa += kScanChunk; continue; } |
| 45 | std::size_t scan_end = (got >= 16) ? (got - 16) : 0; |
| 46 | for (std::size_t i = 0; i < scan_end; ++i) { |
| 47 | if (match_swapper(buf.data() + i, got - i)) { |
| 48 | hits.push_back(pa + i); |
| 49 | } |
| 50 | } |
| 51 | pa += kScanChunk; // overlap of 16 handled by reading want=CHUNK+16 |
| 52 | } |
| 53 | log::debug("Found {} swapper candidates", hits.size()); |
| 54 | return hits; |
| 55 | } |
| 56 | |
| 57 | bool read_string(const PhysicalLayer& phys, PAddr pa, std::size_t max, std::string& out) { |
| 58 | std::vector<u8> b(max); |
no test coverage detected