/// <summary> /// Read 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 read</returns> private static unsafe uint readImpl(Node node, uint offset, uint size, byte[] buffer) { IDCookie cookie = (IDCookie)node.Cookie; VboxDevRequestTypes request = (VboxDevRequestTypes)cookie.ID; switch (request) { case VboxDevRequestTypes.VMMDevReq_GetSessionId: if (size != 8) { return(0); } ulong sessionID = VboxDev.GetSessionID(); Byte.ToBytes((long)sessionID, buffer); return(8); case VboxDevRequestTypes.VMMDevReq_GetHostTime: if (size != 8) { return(0); } ulong time = VboxDev.GetHostTime(); Byte.ToBytes((long)time, buffer); return(8); } return(0); }
/// <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); }