1. kern_return_t krc = KERN_SUCCESS;
  2. vm_address_t address = 0;
  3. vm_size_t size = 0;
  4. uint32_t depth = 1;
  5. while (1) {
  6. struct vm_region_submap_info_64 info;
  7. mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT_64;
  8. krc = vm_region_recurse_64(port, &address, &size, &depth, (vm_region_info_64_t)&info, &count);
  9. if (krc == KERN_INVALID_ADDRESS){
  10. break;
  11. }
  12. if (info.is_submap){
  13. depth++;
  14. }
  15. else {
  16. //do stuff
  17. printf ("Found region: %08x to %08xn", (uint32_t)address, (uint32_t)address+size);
  18. address += size;
  19. }
  20. }