ConsoleVRDPServer.cpp revision 240f7d7012a5f64bcde850bcf048531a710d81cf
70N/A * available from http://www.virtualbox.org. This file is free software;
70N/A * Clara, CA 95054 USA or visit http://www.sun.com if you need
70N/A#include "ConsoleVRDPServer.h"
70N/A#include "ConsoleImpl.h"
70N/A#include "DisplayImpl.h"
70N/A#include "KeyboardImpl.h"
70N/A#include "MouseImpl.h"
70N/A#ifdef VBOX_WITH_VRDP
70N/A#ifndef VBOX_WITH_XPCOM
70N/A virtual ~VRDPConsoleCallback() {}
70N/A#ifndef VBOX_WITH_XPCOM
if (cnt == 0)
return cnt;
*ppObj = this;
AddRef();
return S_OK;
*ppObj = this;
AddRef();
return S_OK;
return E_NOINTERFACE;
if (m_server)
return S_OK;
if (m_server)
return S_OK;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
if (!canShow)
return E_POINTER;
return S_OK;
if (!winId)
return E_POINTER;
*winId = 0;
return S_OK;
#ifndef VBOX_WITH_XPCOM
long refcnt;
#ifdef VBOX_WITH_XPCOM
#include <nsMemory.h>
#ifdef DEBUG_sunlover
for (i = 0; i < height; i++)
pu8And++;
if (fXorMaskRGB32)
for (i = 0; i < height; i++)
for (j = 0; j < width; j++)
for (i = 0; i < height; i++)
for (j = 0; j < width; j++)
#define dumpPointer(a, b, c, d) do {} while (0)
static void findTopLeftBorder (const uint8_t *pu8AndMask, const uint8_t *pu8XorMask, uint32_t width, uint32_t height, uint32_t *pxSkip, uint32_t *pySkip)
ySkipAnd = y;
ySkipAnd = y;
ySkipAnd = 0;
xSkipAnd = x;
xSkipAnd = 0;
for (x = 0; x < width; x++)
if (pu32Xor[x] != 0)
ySkipXor = y;
ySkipXor = 0;
if (*pu32Xor != 0)
xSkipXor = x;
xSkipXor = 0;
static void mousePointerGenerateANDMask (uint8_t *pu8DstAndMask, int cbDstAndMask, const uint8_t *pu8SrcAlpha, int w, int h)
if (bitmask == 0)
STDMETHODIMP VRDPConsoleCallback::OnMousePointerShapeChange (BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot,
LogSunlover(("VRDPConsoleCallback::OnMousePointerShapeChange: %d, %d, %dx%d, @%d,%d\n", visible, alpha, width, height, xHot, yHot));
if (m_server)
if (!shape)
if (!visible)
if (alpha)
if (pointer)
for (y = 0; y < minheight; y++)
for (x = 0; x < minwidth; x++)
if (!bit)
for (y = 0; y < minheight ; y++)
for (x = 0; x < minwidth; x++)
return S_OK;
#ifdef VBOX_WITH_VRDP
DECLCALLBACK(int) ConsoleVRDPServer::VRDPCallbackQueryProperty (void *pvCallback, uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut)
switch (index)
case VRDP_QP_NETWORK_PORT:
if (port == 0)
case VRDP_QP_NETWORK_ADDRESS:
if (cbAddress > 0)
case VRDP_QP_NUMBER_MONITORS:
return rc;
DECLCALLBACK(int) ConsoleVRDPServer::VRDPCallbackClientLogon (void *pvCallback, uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain)
DECLCALLBACK(void) ConsoleVRDPServer::VRDPCallbackClientConnect (void *pvCallback, uint32_t u32ClientId)
DECLCALLBACK(void) ConsoleVRDPServer::VRDPCallbackClientDisconnect (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercepted)
DECLCALLBACK(int) ConsoleVRDPServer::VRDPCallbackIntercept (void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercept, void **ppvIntercept)
switch (fu32Intercept)
if (ppvIntercept)
if (ppvIntercept)
return rc;
DECLCALLBACK(int) ConsoleVRDPServer::VRDPCallbackUSB (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint8_t u8Code, const void *pvRet, uint32_t cbRet)
#ifdef VBOX_WITH_USB
return VERR_NOT_SUPPORTED;
DECLCALLBACK(int) ConsoleVRDPServer::VRDPCallbackClipboard (void *pvCallback, void *pvIntercept, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData)
DECLCALLBACK(bool) ConsoleVRDPServer::VRDPCallbackFramebufferQuery (void *pvCallback, unsigned uScreenId, VRDPFRAMEBUFFERINFO *pInfo)
bool fAvailable = false;
if (pfb)
fAvailable = true;
return fAvailable;
DECLCALLBACK(void) ConsoleVRDPServer::VRDPCallbackFramebufferLock (void *pvCallback, unsigned uScreenId)
DECLCALLBACK(void) ConsoleVRDPServer::VRDPCallbackFramebufferUnlock (void *pvCallback, unsigned uScreenId)
DECLCALLBACK(void) ConsoleVRDPServer::VRDPCallbackInput (void *pvCallback, int type, const void *pvInput, unsigned cbInput)
switch (type)
case VRDP_INPUT_SCANCODE:
case VRDP_INPUT_POINT:
int mouseButtons = 0;
int iWheel = 0;
pConsole->getMouse()->PutMouseEventAbsolute (pInputPoint->x + 1, pInputPoint->y + 1, iWheel, mouseButtons);
case VRDP_INPUT_CAD:
case VRDP_INPUT_RESET:
case VRDP_INPUT_SYNCH:
DECLCALLBACK(void) ConsoleVRDPServer::VRDPCallbackVideoModeHint (void *pvCallback, unsigned cWidth, unsigned cHeight, unsigned cBitsPerPixel, unsigned uScreenId)
mcClipboardRefs = 0;
#ifdef VBOX_WITH_USB
#ifdef VBOX_WITH_VRDP
mhServer = 0;
m_fGuestWantsAbsolute = false;
m_mousex = 0;
m_mousey = 0;
mAuthLibrary = 0;
Stop ();
#ifdef VBOX_WITH_VRDP
if (mConsoleCallback)
if (maFramebuffers[i])
#ifdef VBOX_WITH_VRDP
if (loadVRDPLibrary ())
rc = mpfnVRDPCreateServer (&mCallbacks.header, this, (VRDPINTERFACEHDR **)&mpEntryPoints, &mhServer);
#ifdef VBOX_WITH_USB
return rc;
#ifdef VBOX_WITH_VRDP
#ifdef VBOX_WITH_VRDP
#ifdef VBOX_WITH_VRDP
#ifdef VBOX_WITH_VRDP
Assert(VALID_PTR(this)); /** @todo r=bird: there are(/was) some odd cases where this buster was invalid on
#ifdef VBOX_WITH_VRDP
if (mhServer)
mhServer = 0;
#ifdef VBOX_WITH_USB
if (mAuthLibrary)
mAuthLibrary = 0;
#ifdef VBOX_WITH_USB
return VINF_SUCCESS;
AssertFailed ();
VRDPAuthResult ConsoleVRDPServer::Authenticate (const Guid &uuid, VRDPAuthGuestJudgement guestJudgement,
LogFlow(("ConsoleVRDPServer::Authenticate: uuid = %Vuuid, guestJudgement = %d, pszUser = %s, pszPassword = %s, pszDomain = %s, u32ClientId = %d\n",
if (!mAuthLibrary)
LogRel(("VRDPAUTH: ConsoleVRDPServer::Authenticate: loading external authentication library '%ls'\n", authLibrary.raw()));
if (mAuthLibrary)
mAuthLibrary = 0;
return VRDPAuthAccessDenied;
switch (result)
case VRDPAuthAccessDenied:
case VRDPAuthAccessGranted:
case VRDPAuthDelegateToGuest:
return result;
if (mpfnAuthEntry2)
return rc;
const void *pvData,
LogFlowFunc(("pvCallback = %p, u32ClientId = %d, u32Function = %d, u32Format = 0x%08X, pvData = %p, cbData = %d\n",
switch (u32Function)
(void *)pvData,
cbData);
(void *)pvData,
cbData);
return rc;
void *pvParms,
#ifdef VBOX_WITH_VRDP
switch (u32Function)
NULL,
NULL);
NULL);
return rc;
if (mcClipboardRefs == 0)
rc = HGCMHostRegisterServiceExtension (&mhClipboard, "VBoxSharedClipboard", ClipboardServiceExtension, this);
if (mcClipboardRefs == 0)
#ifdef VBOX_WITH_USB
if (pRemoteUSBBackend)
if (ppvIntercept)
#ifdef VBOX_WITH_USB
if (pRemoteUSBBackend)
if (pRemoteUSBBackend)
#ifdef VBOX_WITH_USB
if (pRemoteUSBBackend)
if (fAdded)
if (pRemoteUSBBackend)
return NULL;
#ifdef VBOX_WITH_USB
if (pRemoteUSBBackend)
if (pRemoteUSBBackend)
#ifdef VBOX_WITH_USB
if (pRemoteUSBBackend)
return pNextRemoteUSBBackend;
#ifdef VBOX_WITH_USB
while (pRemoteUSBBackend)
return pRemoteUSBBackend;
while (pRemoteUSBBackend)
return pRemoteUSBBackend;
#ifdef VBOX_WITH_USB
#ifdef VBOX_WITH_VRDP
#ifdef VBOX_WITH_VRDP
void ConsoleVRDPServer::SendUpdateBitmap (unsigned uScreenId, uint32_t x, uint32_t y, uint32_t w, uint32_t h) const
#ifdef VBOX_WITH_VRDP
update.x = x;
update.y = y;
update.w = w;
update.h = h;
void ConsoleVRDPServer::SendAudioSamples (void *pvSamples, uint32_t cSamples, VRDPAUDIOFORMAT format) const
#ifdef VBOX_WITH_VRDP
#ifdef VBOX_WITH_VRDP
void ConsoleVRDPServer::SendUSBRequest (uint32_t u32ClientId, void *pvParms, uint32_t cbParms) const
#ifdef VBOX_WITH_VRDP
void ConsoleVRDPServer::QueryInfo (uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut) const
#ifdef VBOX_WITH_VRDP
#ifdef VBOX_WITH_VRDP
if (!mVRDPLibrary)
struct SymbolEntry
const char *name;
void **ppfn;
LogRel(("VRDPServer::loadLibrary(): failed to load VRDP library! VRDP not available: rc = %Vrc\n", rc));
if (mVRDPLibrary)
return S_OK;
uninit ();
return S_OK;
if (!a##_aName) \
return E_POINTER; \
return S_OK; \
if (!a##_aName) \
return E_POINTER; \
return S_OK; \
if (!a##_aName) \
return E_POINTER; \
if (cbOut == 0) \
return S_OK; \
if (!pchBuffer) \
#_aName \
return E_OUTOFMEMORY; \
return S_OK; \