| 258 | bytes.push_back(0); |
| 259 | mask.push_back('?'); |
| 260 | i += (i + 1 < len && pattern[i + 1] == '?') ? 2 : 1; |
| 261 | continue; |
| 262 | } |
| 263 | |
| 264 | if (i + 1 < len && std::isxdigit(static_cast<unsigned char>(pattern[i])) && |
| 265 | std::isxdigit(static_cast<unsigned char>(pattern[i + 1]))) |
| 266 | { |
| 267 | bytes.push_back(static_cast<char>((hexValue(pattern[i]) << 4) | hexValue(pattern[i + 1]))); |
| 268 | mask.push_back('x'); |
| 269 | i += 2; |
| 270 | continue; |
| 271 | } |
| 272 | |
| 273 | // invalid character |
| 274 | i++; |
| 275 | } |
| 276 | |
| 277 | if (bytes.empty() || bytes.size() != mask.size()) |
| 278 | return results; |
| 279 | |
| 280 | return findBytesAll(start, end, bytes.data(), mask); |
| 281 | } |
| 282 | |
| 283 | |
| 284 | uintptr_t KittyScannerMgr::findIdaPatternFirst(uintptr_t start, uintptr_t end, const std::string &pattern) const |
| 285 | { |
| 286 | if (!_pMem || start >= end || pattern.empty()) |
| 287 | return 0; |
| 288 | |
| 289 | std::vector<char> bytes; |
| 290 | std::string mask; |
| 291 | |
| 292 | bytes.reserve(pattern.size() / 2); |
| 293 | mask.reserve(pattern.size() / 2); |
| 294 | |
| 295 | auto hexValue = [](char c) -> uint8_t { |
| 296 | if (c >= '0' && c <= '9') |
| 297 | return c - '0'; |
| 298 | |
| 299 | if (c >= 'a' && c <= 'f') |
| 300 | return c - 'a' + 10; |
| 301 | |
| 302 | if (c >= 'A' && c <= 'F') |
| 303 | return c - 'A' + 10; |
| 304 | |
| 305 | return 0; |
| 306 | }; |
| 307 | |
| 308 | const size_t len = pattern.size(); |
| 309 | |
| 310 | for (size_t i = 0; i < len;) |
| 311 | { |
| 312 | if (pattern[i] == ' ') |
| 313 | { |
| 314 | i++; |
| 315 | continue; |
| 316 | } |
| 317 |
nothing calls this directly
no test coverage detected