Helper.cpp revision 5ce202824bd2fbece9bc3b1b3de6a7abfa6b8f9a
/** @file
*
* VBoxGuest -- VirtualBox Win 2000/XP guest video driver
*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
// enable backdoor logging
//#define LOG_ENABLED
#ifndef VBOXWDDM
extern "C"
{
# include <ntddk.h>
}
#else
# include "VBoxVideo.h"
#endif
#include <VBox/VBoxGuestLib.h>
#ifndef VBOXWDDM
/* the video miniport headers not compatible with the NT DDK headers */
typedef struct _VIDEO_POINTER_ATTRIBUTES
{
// supported.
#endif /* #ifndef VBOXWDDM */
#include "Helper.h"
#ifdef DEBUG_misha
bool g_bVBoxVDbgBreakF = true;
bool g_bVBoxVDbgBreakFv = false;
#endif
/**
* Globals
*/
/* note: should not do that but we can't use these datatypes in the global header */
BOOLEAN vboxQueryDisplayRequest(uint32_t *xres, uint32_t *yres, uint32_t *bpp, uint32_t *pDisplayId)
{
dprintf(("VBoxVideo::vboxQueryDisplayRequest: xres = 0x%p, yres = 0x%p bpp = 0x%p\n", xres, yres, bpp));
int rc = VbglGRAlloc ((VMMDevRequestHeader **)&req, sizeof (VMMDevDisplayChangeRequest2), VMMDevReq_GetDisplayChangeRequest2);
if (RT_FAILURE(rc))
{
}
else
{
if (RT_SUCCESS(rc))
{
if (xres)
if (yres)
if (bpp)
if (pDisplayId)
dprintf(("VBoxVideo::vboxQueryDisplayRequest: returning %d x %d @ %d for %d\n",
}
else
{
dprintf(("VBoxVideo::vboxQueryDisplayRequest: ERROR querying display request from VMMDev. "
"rc = %Rrc\n", rc));
}
}
return bRC;
}
{
int rc = VbglGRAlloc((VMMDevRequestHeader**)&req, sizeof(VMMDevVideoModeSupportedRequest), VMMDevReq_VideoModeSupported);
if (RT_FAILURE(rc))
{
/* Most likely the VBoxGuest driver is not loaded.
* To get at least the video working, report the mode as supported.
*/
}
else
{
if (RT_SUCCESS(rc))
{
}
else
{
dprintf(("VBoxVideo::vboxLikesVideoMode: ERROR querying video mode supported status from VMMDev."
"rc = %Rrc\n", rc));
}
}
dprintf(("VBoxVideo::vboxLikesVideoMode: width: %d, height: %d, bpp: %d -> %s\n", width, height, bpp, (bRC == 1) ? "OK" : "FALSE"));
return bRC;
}
{
dprintf(("VBoxVideo::vboxGetHeightReduction\n"));
int rc = VbglGRAlloc((VMMDevRequestHeader**)&req, sizeof(VMMDevGetHeightReductionRequest), VMMDevReq_GetHeightReduction);
if (RT_FAILURE(rc))
{
}
else
{
if (RT_SUCCESS(rc))
{
}
else
{
dprintf(("VBoxVideo::vboxGetHeightReduction: ERROR querying height reduction value from VMMDev. "
"rc = %Rrc\n", rc));
}
}
return retHeight;
}
{
/* Activate next line only when really needed; floods the log very quickly! */
/*dprintf(("VBoxVideo::vboxQueryPointerPosInternal: pointerXPos = %p, pointerYPos = %p\n", pointerXPos, pointerYPos));*/
int rc = VbglGRAlloc ((VMMDevRequestHeader **)&req, sizeof (VMMDevReqMouseStatus), VMMDevReq_GetMouseStatus);
if (RT_FAILURE(rc))
{
}
else
{
if (RT_SUCCESS(rc))
{
{
if (pointerXPos)
{
}
if (pointerYPos)
{
}
}
}
else
{
dprintf(("VBoxVideo::vboxQueryPointerPosInternal: ERROR querying mouse capabilities from VMMDev. "
"rc = %Rrc\n", rc));
}
}
return bRC;
}
/**
* Return the current absolute mouse position in normalized format
* (between 0 and 0xFFFF).
*
* @returns BOOLEAN success indicator
* @param pointerXPos address of result variable for x pos
* @param pointerYPos address of result variable for y pos
*/
{
if (!pointerXPos || !pointerYPos)
{
return FALSE;
}
}
/**
* Returns whether the host wants us to take absolute coordinates.
*
* @returns BOOLEAN TRUE if the host wants to send absolute coordinates.
*/
{
}
{
if (winVersion != UNKNOWN_WINVERSION)
return winVersion;
dprintf(("VBoxVideo::vboxQueryWinVersion: running on Windows NT version %d.%d, build %d\n",
if(majorVersion == 6)
{
if (minorVersion == 1)
winVersion = WIN7;
else if (minorVersion == 0)
}
else if (majorVersion == 5)
{
if (minorVersion >= 1)
{
winVersion = WINXP;
} else
{
winVersion = WIN2K;
}
}
else if (majorVersion == 4)
{
winVersion = WINNT4;
}
else
{
dprintf(("VBoxVideo::vboxQueryWinVersion: NT4 required!\n"));
}
return winVersion;
}
#ifndef VBOX_WITH_HGSMI
/**
* Sends the pointer shape to the VMMDev
*
* @returns success indicator
* @param pointerAttr pointer description
*/
{
{
}
{
dprintf(("vboxUpdatePointerShape: calculated pointer data size is too big (%d bytes, limit %d)\n",
return FALSE;
}
int rc = VbglGRAlloc ((VMMDevRequestHeader **)&req, sizeof (VMMDevReqMousePointer) + cbData, VMMDevReq_SetPointerShape);
if (RT_FAILURE(rc))
{
}
else
{
/* Activate next line only when really needed; floods the log very quickly! */
/*dprintf(("VBoxVideo::vboxUpdatePointerShape: req->u32Version = %08X\n", req->header.version));*/
/* We have our custom flags in the field */
/* Even if pointer is invisible, we have to pass following data,
* so host could create the pointer with initial status - invisible
*/
{
/* copy the actual pointer data */
}
{
}
else
{
dprintf(("VBoxVideo::vboxUpdatePointerShape: ERROR querying mouse capabilities from VMMDev. "
"rc = %Rrc\n", rc));
}
}
return bRC;
}
#endif /* VBOX_WITH_HGSMI */