//
// PortSet features
//
set<Port> PortSet::members() const
{
	mach_port_array_t members;
	mach_msg_type_number_t count;
	check(::mach_port_get_set_status(self(), mPort, &members, &count));
	try {
		set<Port> result;
		copy(members, members+count, inserter(result, result.begin()));
		vm_deallocate(self(), vm_address_t(members), count * sizeof(members[0]));
		return result;
	} catch (...) {
		vm_deallocate(self(), vm_address_t(members), count * sizeof(members[0]));
		throw;
	}
}
Exemple #2
0
/* Returns the starting address and the protection. Pass in mach_task_self() and the starting address. */
static bool GetRegionInfo( mach_port_t self, const void *address, vm_address_t &startOut, vm_prot_t &protectionOut )
{
	struct vm_region_basic_info_64 info;
	mach_msg_type_number_t infoCnt = VM_REGION_BASIC_INFO_COUNT_64;
	mach_port_t unused;
	vm_size_t size = 0;
	vm_address_t start = vm_address_t( address );
	kern_return_t ret = vm_region( self, &start, &size, VM_REGION_BASIC_INFO_64,
				       (vm_region_info_t)&info, &infoCnt, &unused );
	
	if( ret != KERN_SUCCESS ||
		start >= (vm_address_t)address ||
		(vm_address_t)address >= start + size )
	{
		return false;
	}
	startOut = start;
	protectionOut = info.protection;
	return true;
}