---
title: writeBytes
framework: kernel
role: symbol
role_heading: Instance Method
path: kernel/iomemorydescriptor/1442038-writebytes
---

# writeBytes

Copy data to the memory descriptor's buffer from the specified buffer.

## Declaration

```occ
virtual IOByteCount writeBytes(IOByteCount offset, const void *bytes, IOByteCount withLength);
```

## Parameters

- `offset`: A byte offset into the memory descriptor's memory.
- `bytes`: The caller supplied buffer to copy the data from.
- `withLength`: The length of the data to copy.

## Return Value

Return Value The number of bytes copied, zero will be returned if the specified offset is beyond the length of the descriptor. Development/debug kernel builds will assert if the offset is beyond the length of the descriptor.

## Discussion

Discussion This method copies data to the memory descriptor's memory at the given offset, from the caller's buffer. The memory descriptor MUST have the kIODirectionIn direcction bit set and be prepared. kIODirectionIn means that this memory descriptor will be input from an external device, so writeBytes is used to write memory into the descriptor for PIO drivers.

## See Also

### Reading and Writing Buffer Data

- [readBytes](kernel/iomemorydescriptor/1812854-readbytes.md)
- [readBytes](kernel/iomemorydescriptor/1441823-readbytes.md)
- [writeBytes](kernel/iomemorydescriptor/1812910-writebytes.md)
