| 76 | } |
| 77 | |
| 78 | static void* ScanModule(OSTPlatform::DynamicLibrary::ModuleHandle module, |
| 79 | const std::vector<uint8_t>& bytes, |
| 80 | const std::vector<uint8_t>& mask) |
| 81 | { |
| 82 | const auto image = OSTPlatform::Memory::GetModuleImage(module); |
| 83 | if (!image) return nullptr; |
| 84 | |
| 85 | auto* base = image->base; |
| 86 | size_t size = image->size; |
| 87 | size_t patLen = bytes.size(); |
| 88 | if (size < patLen) return nullptr; |
| 89 | |
| 90 | for (size_t i = 0; i <= size - patLen; ++i) { |
| 91 | bool found = true; |
| 92 | for (size_t j = 0; j < patLen; ++j) { |
| 93 | if (mask[j] && base[i + j] != bytes[j]) { found = false; break; } |
| 94 | } |
| 95 | if (found) return base + i; |
| 96 | } |
| 97 | return nullptr; |
| 98 | } |
| 99 | |
| 100 | // ---- TOML pattern parser ---- |
| 101 |
no test coverage detected