---
title: "hv_vcpu_write_register(_:_:_:)"
framework: Hypervisor
role: symbol
role_heading: Function
platforms: [macOS 10.10+]
path: "hypervisor/hv_vcpu_write_register(_:_:_:)"
---

# hv_vcpu_write_register(_:_:_:)

Sets the value of an architectural x86 register of a vCPU.

## Declaration

```swift
func hv_vcpu_write_register(_ vcpu: hv_vcpuid_t, _ reg: hv_x86_reg_t, _ value: UInt64) -> hv_return_t
```

## Parameters

- `vcpu`: The instance of the vCPU.
- `reg`: The ID of the register. For possible values, see doc://com.apple.hypervisor/documentation/Hypervisor/hv_x86_reg_t.
- `value`: The new value of the register reg.

## Return Value

Return Value HV_SUCCESS if the operation was successful, otherwise an error code specified in hv_return_t.

## Discussion

Discussion important: This function must be called by the owning thread.

## See Also

### CPU Registers

- [hv_vcpu_read_register(_:_:_:)](hypervisor/hv_vcpu_read_register(_:_:_:).md)
- [hv_x86_reg_t](hypervisor/hv_x86_reg_t.md)
