| 67 | *info_out = cachedRegions_[last_region_index_]; |
| 68 | return true; |
| 69 | } |
| 70 | |
| 71 | size_t left = 0; |
| 72 | size_t right = cachedRegions_.size(); |
| 73 | size_t best_match = right; |
| 74 | |
| 75 | while (left < right) |
| 76 | { |
| 77 | size_t mid = left + (right - left) / 2; |
| 78 | if (cachedRegions_[mid].end <= addr) |
| 79 | { |
| 80 | left = mid + 1; |
| 81 | } |
| 82 | else |
| 83 | { |
| 84 | best_match = mid; |
| 85 | right = mid; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | if (best_match < cachedRegions_.size() && cachedRegions_[best_match].start <= addr && |
| 90 | addr < cachedRegions_[best_match].end) |
| 91 | { |
| 92 | last_region_index_ = best_match; |
| 93 | *info_out = cachedRegions_[best_match]; |
| 94 | return true; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | return false; |
| 99 | } |
| 100 | |
| 101 | void KittyPtrValidator::refreshRegionCache() |
| 102 | { |
| 103 | cachedRegions_.clear(); |
| 104 | mach_vm_address_t address = 0; |
| 105 | natural_t depth = 0; |
| 106 | |
| 107 | while (true) |
| 108 | { |
| 109 | mach_vm_size_t size = 0; |
| 110 | vm_region_submap_short_info_data_64_t info{}; |
| 111 | mach_msg_type_number_t count = VM_REGION_SUBMAP_SHORT_INFO_COUNT_64; |
| 112 | kern_return_t kr = mach_vm_region_recurse(task_, |
| 113 | &address, |
| 114 | &size, |
| 115 | &depth, |
| 116 | (vm_region_recurse_info_t)&info, |
| 117 | &count); |
nothing calls this directly
no test coverage detected