/// <summary> /// Change power state /// </summary> /// <param name="state">Power state</param> public unsafe static void ChangePowerState(VboxDevPowerState state) { RequestPowerState *req = (RequestPowerState *)Heap.Alloc(sizeof(RequestPowerState)); req->header.Size = (uint)sizeof(RequestPowerState); req->header.Version = 0x10001; req->header.requestType = VboxDevRequestTypes.VMMDevReq_SetPowerStatus; req->header.rc = 0xFFFFF; req->PowerState = state; PortIO.Out32((ushort)m_dev.BAR0.Address, (uint)Paging.GetPhysicalFromVirtual(req)); }
/// <summary> /// Write method for filesystem /// </summary> /// <param name="node">The node</param> /// <param name="offset">The offset</param> /// <param name="size">The size</param> /// <param name="buffer">The buffer</param> /// <returns>The amount of bytes written</returns> private static unsafe uint writeImpl(Node node, uint offset, uint size, byte[] buffer) { IDCookie cookie = (IDCookie)node.Cookie; VboxDevRequestTypes request = (VboxDevRequestTypes)cookie.ID; switch (request) { case VboxDevRequestTypes.VMMDevReq_SetPowerStatus: if (size < 4) { return(0); } int state = Byte.ToInt(buffer); VboxDevPowerState stateConverted = (VboxDevPowerState)state; VboxDev.ChangePowerState(stateConverted); return(4); } return(0); }