| 408 | } |
| 409 | |
| 410 | remote_addr_t |
| 411 | AbstractProcessManager::scanMemoryAreaForDebugOffsets(const VirtualMap& map) const |
| 412 | { |
| 413 | size_t size = map.Size(); |
| 414 | std::vector<char> memory_buffer(size); |
| 415 | remote_addr_t base = map.Start(); |
| 416 | copyMemoryFromProcess(base, size, memory_buffer.data()); |
| 417 | |
| 418 | LOG(INFO) << std::showbase << std::hex << "Searching for debug offsets in memory area spanning from " |
| 419 | << map.Start() << " to " << map.End(); |
| 420 | |
| 421 | uint64_t* lower_bound = (uint64_t*)&memory_buffer.data()[0]; |
| 422 | uint64_t* upper_bound = (uint64_t*)&memory_buffer.data()[size]; |
| 423 | |
| 424 | uint64_t cookie; |
| 425 | memcpy(&cookie, "xdebugpy", sizeof(cookie)); |
| 426 | |
| 427 | for (uint64_t* raddr = lower_bound; raddr < upper_bound; raddr++) { |
| 428 | if (raddr[0] == cookie) { |
| 429 | uint64_t version = raddr[1]; |
| 430 | |
| 431 | ParsedPyVersion parsed; |
| 432 | if (parsePyVersionHex(version, parsed) && parsed.major == 3 && parsed.minor >= 13) { |
| 433 | auto offset = (remote_addr_t)raddr - (remote_addr_t)memory_buffer.data(); |
| 434 | auto addr = offset + base; |
| 435 | LOG(DEBUG) << std::hex << std::showbase << "Possible debug offsets found at address " |
| 436 | << addr << " in a mapping of " << map.Path(); |
| 437 | return addr; |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | return 0; |
| 442 | } |
| 443 | |
| 444 | remote_addr_t |
| 445 | AbstractProcessManager::scanBSS() const |
nothing calls this directly
no test coverage detected