e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * VBoxVRDP - VBox VRDP connection notification
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync * Copyright (C) 2006-2014 Oracle Corporation
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * available from http://www.virtualbox.org. This file is free software;
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * you can redistribute it and/or modify it under the terms of the GNU
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * General Public License (GPL) as published by the Free Software
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync/* 0x0501 for SPI_SETDROPSHADOW */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync/* The guest receives VRDP_ACTIVE/VRDP_INACTIVE notifications.
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * When VRDP_ACTIVE is received, the guest asks host about the experience level.
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * The experience level is an integer value, different values disable some GUI effects.
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * On VRDP_INACTIVE the original values are restored.
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * Note: that this is not controlled from the client, that is a per VM settings.
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * Note: theming is disabled separately by EnableTheming.
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync uint32_t level; /* The parameter remain enabled at this or higher level. */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync char achSavedValue[2 * MAX_PATH]; /* Large enough to save the bitmap path. */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync#define SPI_(l, a) #a, SPI_SET##a, SPI_GET##a, VRDP_EXPERIENCE_LEVEL_##l
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync { SPI_(MEDIUM, DESKWALLPAPER), VBOX_SPI_STRING, "" },
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync { SPI_(FULL, COMBOBOXANIMATION), VBOX_SPI_BOOL_PTR, },
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync { SPI_(HIGH, GRADIENTCAPTIONS), VBOX_SPI_BOOL_PTR, },
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync { SPI_(FULL, LISTBOXSMOOTHSCROLLING), VBOX_SPI_BOOL_PTR, },
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync { SPI_(FULL, TOOLTIPANIMATION), VBOX_SPI_BOOL_PTR, },
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync { SPI_(FULL, ANIMATION), VBOX_SPI_PTR, &animationInfoDisable, sizeof (ANIMATIONINFO) },
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * The parameter has to be disabled.
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* Save the current value. */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* The 2nd parameter is size in characters of the buffer.
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync * The 3rd parameter points to the buffer.
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* The 3rd parameter points to BOOL. */
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync /* The 3rd parameter points to the structure.
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * The cbSize member of this structure must be set.
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * The uiParam parameter must alos be set.
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync if (parameters[i].cbSavedValue > sizeof (parameters[i].achSavedValue))
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync LogFlowFunc(("Not enough space %d > %d\n", parameters[i].cbSavedValue, sizeof (parameters[i].achSavedValue)));
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync *(UINT *)¶meters[i].achSavedValue[0] = parameters[i].cbSavedValue;
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync LogFlowFunc(("Disabling %s\n", parameters[i].name));
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* Disable the feature. */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* The 3rd parameter points to the string. */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* The 2nd parameter is BOOL. */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* The 3rd parameter is NULL to disable. */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* The 3rd parameter points to the structure. */
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync LogFlowFunc(("Restoring %s\n", parameters[i].name));
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* Restore the feature. */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* The 3rd parameter points to the string. */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* The 2nd parameter is BOOL. */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* The 3rd parameter is NULL to disable. */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync BOOL fSaved = *(BOOL *)¶meters[i].achSavedValue[0];
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* The 3rd parameter points to the structure. */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsyncint VBoxVRDPInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread)
71955773a7f477f9a159a491f765ba97e1f00e1avboxsync int rc = RTLdrLoadSystem("UxTheme.dll", false /*fNoUnload*/, &gCtx.hModUxTheme);
71955773a7f477f9a159a491f765ba97e1f00e1avboxsync *(PFNRT *)&gCtx.pfnEnableTheming = RTLdrGetFunction(gCtx.hModUxTheme, "EnableTheming");
71955773a7f477f9a159a491f765ba97e1f00e1avboxsync *(PFNRT *)&gCtx.pfnIsThemeActive = RTLdrGetFunction(gCtx.hModUxTheme, "IsThemeActive");
e62cb87bae732e9968199a3ad153cc94004b7182vboxsyncvoid VBoxVRDPDestroy(const VBOXSERVICEENV *pEnv, void *pInstance)
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync VBOXVRDPCONTEXT *pCtx = (VBOXVRDPCONTEXT *)pInstance;
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync * Thread function to wait for and process mode change requests
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync VBOXVRDPCONTEXT *pCtx = (VBOXVRDPCONTEXT *)pInstance;
b357df727b216b85d4517efecf466a7b14c2e80cvboxsync if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync LogFlowFunc(("DeviceIOControl(CtlMask - or) succeeded\n"));
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync LogFlowFunc(("DeviceIOControl(CtlMask) failed\n"));
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* wait for the event */
b357df727b216b85d4517efecf466a7b14c2e80cvboxsync if (DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent), &waitEvent, sizeof(waitEvent), &cbReturned, NULL))
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* are we supposed to stop? */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync if (WaitForSingleObject(pCtx->pEnv->hStopEvent, 0) == WAIT_OBJECT_0)
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* did we get the right event? */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_VRDP)
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* Call the host to get VRDP status and the experience level. */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync vrdpChangeRequest.header.size = sizeof(VMMDevVRDPChangeRequest);
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync vrdpChangeRequest.header.version = VMMDEV_REQUEST_HEADER_VERSION;
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync vrdpChangeRequest.header.requestType = VMMDevReq_GetVRDPChangeRequest;
ba2e65ca2c6ee70366bca6b355a22b44899490e7vboxsync VBOXGUEST_IOCTL_VMMREQUEST(sizeof(VMMDevVRDPChangeRequest)),
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync LogFlowFunc(("u8VRDPActive = %d, level %d\n", vrdpChangeRequest.u8VRDPActive, vrdpChangeRequest.u32VRDPExperienceLevel));
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync pCtx->level = vrdpChangeRequest.u32VRDPExperienceLevel;
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync pCtx->fSavedThemeEnabled = pCtx->pfnIsThemeActive ();
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync LogFlowFunc(("pCtx->fSavedThemeEnabled = %d\n", pCtx->fSavedThemeEnabled));
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* @todo the call returns S_OK but theming remains disabled. */
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync LogFlowFunc(("enabling theme rc = 0x%08X\n", hrc));
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync LogFlowFunc(("Error from DeviceIoControl VBOXGUEST_IOCTL_VMMREQUEST\n"));
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* sleep a bit to not eat too much CPU in case the above call always fails */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync if (WaitForSingleObject(pCtx->pEnv->hStopEvent, 10) == WAIT_OBJECT_0)
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync LogFlowFunc(("Error from DeviceIoControl VBOXGUEST_IOCTL_WAITEVENT\n"));
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync /* sleep a bit to not eat too much CPU in case the above call always fails */
e62cb87bae732e9968199a3ad153cc94004b7182vboxsync if (WaitForSingleObject(pCtx->pEnv->hStopEvent, 10) == WAIT_OBJECT_0)
b357df727b216b85d4517efecf466a7b14c2e80cvboxsync if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync LogFlowFunc(("DeviceIOControl(CtlMask - not) succeeded\n"));
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync LogFlowFunc(("DeviceIOControl(CtlMask) failed\n"));
a29027bb2378172c7c88610ad5311548b66f96f6vboxsync LogFlowFunc(("Finished VRDP change request thread\n"));