---
title: withAddressRanges
framework: kernel
role: symbol
role_heading: Type Method
path: kernel/iomemorydescriptor/1441794-withaddressranges
---

# withAddressRanges

Creates an IOMemoryDescriptor to describe one or more virtual ranges.

## Declaration

```occ
static OSPtr<IOMemoryDescriptor> withAddressRanges(IOAddressRange *ranges, UInt32 rangeCount, IOOptionBits options, task_t task);
```

## Parameters

- `ranges`: An array of IOAddressRange structures which specify the virtual ranges in the specified map which make up the memory to be described. IOAddressRange is the 64bit version of IOVirtualRange.
- `rangeCount`: The member count of the ranges array.
- `options`: kIOMemoryDirectionMask (options:direction) This nibble indicates the I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures. kIOMemoryAsReference For options:type = Virtual or Physical this indicate that the memory descriptor need not copy the ranges array into local memory. This is an optimisation to try to minimise unnecessary allocations.
- `task`: The task each of the virtual ranges are mapped into. Note that unlike IOMemoryDescriptor::withAddress(), kernel_task memory must be explicitly prepared when passed to this api. The task argument may be NULL to specify memory by physical address.

## Return Value

Return Value The created IOMemoryDescriptor on success, to be released by the caller, or zero on failure.

## Discussion

Discussion This method creates and initializes an IOMemoryDescriptor for memory consisting of an array of virtual memory ranges each mapped into a specified source task. This memory descriptor needs to be prepared before it can be used to extract data from the memory described.

## See Also

### Creating the Memory Buffer

- [initWithOptions](kernel/iomemorydescriptor/1812826-initwithoptions.md)
- [initWithOptions](kernel/iomemorydescriptor/1441969-initwithoptions.md)
- [withOptions](kernel/iomemorydescriptor/1812897-withoptions.md)
- [withOptions](kernel/iomemorydescriptor/1441825-withoptions.md)
- [withAddress](kernel/iomemorydescriptor/1812881-withaddress.md)
- [withAddress](kernel/iomemorydescriptor/1442032-withaddress.md)
- [withAddressRange](kernel/iomemorydescriptor/1812885-withaddressrange.md)
- [withAddressRange](kernel/iomemorydescriptor/1441897-withaddressrange.md)
- [withAddressRanges](kernel/iomemorydescriptor/1812892-withaddressranges.md)
- [withPersistentMemoryDescriptor](kernel/iomemorydescriptor/1812901-withpersistentmemorydescriptor.md)
- [withPersistentMemoryDescriptor](kernel/iomemorydescriptor/1441983-withpersistentmemorydescriptor.md)
- [withPhysicalAddress](kernel/iomemorydescriptor/1812908-withphysicaladdress.md)
- [withPhysicalAddress](kernel/iomemorydescriptor/1441877-withphysicaladdress.md)
- [free](driverkit/iomemorydescriptor/free.md)
