ConsoleVRDPServer.cpp revision 6ef36e19210a6d8b4d90b881f155581cb3cb3979
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * VBox Console VRDP Helper class
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Copyright (C) 2006-2010 Oracle Corporation
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * available from http://www.virtualbox.org. This file is free software;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * you can redistribute it and/or modify it under the terms of the GNU
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * General Public License (GPL) as published by the Free Software
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent * aEvent)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ComPtr<IMousePointerShapeChangedEvent> mpscev = aEvent;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync mpscev->COMGETTER(Shape)(ComSafeArrayAsOutParam(shape));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync OnMousePointerShapeChange(visible, alpha, xHot, yHot, width, height, ComSafeArrayAsInParam(shape));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ComPtr<IMouseCapabilityChangedEvent> mccev = aEvent;
if (m_server)
AssertFailed();
return S_OK;
#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)
LogSunlover(("VRDPConsoleListener::OnMousePointerShapeChange: %d, %d, %lux%lu, @%lu,%lu\n", visible, alpha, width, height, xHot, yHot));
if (m_server)
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;
DECLCALLBACK(int) ConsoleVRDPServer::VRDPCallbackQueryProperty(void *pvCallback, uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut)
switch (index)
case VRDE_QP_NETWORK_PORT:
case VRDE_QP_NETWORK_ADDRESS:
case VRDE_QP_NUMBER_MONITORS:
HRESULT hrc = server->mConsole->getVRDEServer()->GetVRDEProperty(Bstr("TCP/Ports").raw(), bstr.asOutParam());
#ifdef VBOX_WITH_VRDP_VIDEO_CHANNEL
case VRDE_QP_VIDEO_CHANNEL:
case VRDE_QP_FEATURE:
HRESULT hrc = server->mConsole->getVRDEServer()->GetVRDEProperty(Bstr(pszPropertyName).raw(), bstrValue.asOutParam());
if (pcbOut)
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)
if (pPort)
AssertFailed();
DECLCALLBACK(int) ConsoleVRDPServer::VRDPCallbackIntercept(void *pvCallback, uint32_t u32ClientId, uint32_t fu32Intercept, void **ppvIntercept)
switch (fu32Intercept)
if (ppvIntercept)
if (ppvIntercept)
if (pPort)
if (ppvIntercept)
AssertFailed();
Log(("AUDIOIN: ignored client %u, active client %u\n", u32ClientId, server->mu32AudioInputClientId));
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, VRDEFRAMEBUFFERINFO *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 VRDE_INPUT_SCANCODE:
case VRDE_INPUT_POINT:
int mouseButtons = 0;
int iWheel = 0;
pConsole->getMouse()->PutMouseEventAbsolute(pInputPoint->x + 1, pInputPoint->y + 1, iWheel, 0 /* Horizontal wheel */, mouseButtons);
case VRDE_INPUT_CAD:
case VRDE_INPUT_RESET:
case VRDE_INPUT_SYNCH:
DECLCALLBACK(void) ConsoleVRDPServer::VRDPCallbackVideoModeHint(void *pvCallback, unsigned cWidth, unsigned cHeight, unsigned cBitsPerPixel, unsigned uScreenId)
void *pvCtx,
const void *pvData,
switch (u32Event)
case VRDE_AUDIOIN_BEGIN:
case VRDE_AUDIOIN_DATA:
case VRDE_AUDIOIN_END:
mcClipboardRefs = 0;
#ifdef VBOX_WITH_USB
mhServer = 0;
m_fGuestWantsAbsolute = false;
m_mousex = 0;
m_mousey = 0;
mAuthLibrary = 0;
Stop();
if (mConsoleListener)
if (maFramebuffers[i])
if (!fEnabled)
return VINF_SUCCESS;
return VINF_NOT_SUPPORTED;
#ifdef VBOX_WITH_EXTPACK
vrc = mpfnVRDECreateServer(&mCallbacks.header, this, (VRDEINTERFACEHDR **)&pEntryPoints3, &mhServer);
vrc = mpfnVRDECreateServer(&sCallbacks.header, this, (VRDEINTERFACEHDR **)&pEntryPoints1, &mhServer);
#ifdef VBOX_WITH_USB
return vrc;
Assert(VALID_PTR(this)); /** @todo r=bird: there are(/was) some odd cases where this buster was invalid on
if (mhServer)
mhServer = 0;
#ifdef VBOX_WITH_USB
if (mAuthLibrary)
mAuthLibrary = 0;
#ifdef VBOX_WITH_USB
return VINF_SUCCESS;
AssertFailed();
LogFlow(("ConsoleVRDPServer::Authenticate: uuid = %RTuuid, guestJudgement = %d, pszUser = %s, pszPassword = %s, pszDomain = %s, u32ClientId = %d\n",
if (!mAuthLibrary)
LogRel(("AUTH: ConsoleVRDPServer::Authenticate: loading external authentication library '%ls'\n", authLibrary.raw()));
int rc;
typedef struct AuthEntryInfo
const char *pszName;
void **ppvAddress;
pEntryInfo++;
rc);
if (mAuthLibrary)
mAuthLibrary = 0;
return AuthResultAccessDenied;
if (mpfnAuthEntry3)
result = mpfnAuthEntry3("vrde", &rawuuid, guestJudgement, pszUser, pszPassword, pszDomain, true, u32ClientId);
else if (mpfnAuthEntry2)
result = mpfnAuthEntry2(&rawuuid, guestJudgement, pszUser, pszPassword, pszDomain, true, u32ClientId);
else if (mpfnAuthEntry)
switch (result)
case AuthResultAccessDenied:
case AuthResultAccessGranted:
return result;
if (mpfnAuthEntry3)
else 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,
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
void ConsoleVRDPServer::SendUpdateBitmap(unsigned uScreenId, uint32_t x, uint32_t y, uint32_t w, uint32_t h) const
update.x = x;
update.y = y;
update.w = w;
update.h = h;
void ConsoleVRDPServer::SendAudioSamples(void *pvSamples, uint32_t cSamples, VRDEAUDIOFORMAT format) const
void *pvContext,
cSamples);
return VINF_SUCCESS;
return VERR_NOT_SUPPORTED;
void ConsoleVRDPServer::QueryInfo(uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut) const
struct SymbolEntry
const char *name;
void **ppfn;
if (szErr[0])
return rc;
return S_OK;
uninit();
return S_OK;
if (!a##_aName) \
return E_POINTER; \
return S_OK; \
extern void IMPL_GETTER_BOOL_DUMMY(void)
if (!a##_aName) \
return E_POINTER; \
return S_OK; \
extern void IMPL_GETTER_SCALAR_DUMMY(void)
if (!a##_aName) \
return E_POINTER; \
if (cbOut == 0) \
return S_OK; \
if (!pchBuffer) \
#_aName \
return E_OUTOFMEMORY; \
return S_OK; \
extern void IMPL_GETTER_BSTR_DUMMY(void)