## vm_copy

Function - Copy a region of virtual memory.

### SYNOPSIS

    kern_return_t   vm_copy
                    (vm_task_t            target_task,
                     vm_address_t      source_address,
                     vm_size_t                  count,
                     vm_address_t        dest_address);

### PARAMETERS

target_task
  [in task send right] The port for the task whose memory is to be copied.

source_address
  [in scalar] The starting address for the source region. The address must be on a page boundary.

count
  [in scalar] The number of bytes in the source region. The number of bytes must convert to an integral number of virtual pages.

dest_address
  [in scalar] The starting address for the destination region. The address must be on a page boundary.

### DESCRIPTION

The vm_copy function copies a source region to a destination region within the same task's virtual memory. It is semantically equivalent to vm_read followed by vm_write. The destination region can overlap the source region.

The destination region must already be allocated. The source region must be readable, and the destination region must be writable.

### NOTES

This interface is machine word length specific because of the virtual address parameter.

### RETURN VALUES

KERN_PROTECTION_FAILURE
  The source region is protected against reading, or the destination region is protected against writing.

KERN_INVALID_ADDRESS
  An address is illegal or specifies a non-allocated region, or there is not enough memory following one of the addresses.

### RELATED INFORMATION

Functions: vm_protect, vm_read, vm_write, host_page_size.