VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp@ 68367

Last change on this file since 68367 was 68367, checked in by vboxsync, 8 years ago

VboxTray: Code cleanup in VBoxDisplay service, bugref:8444

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 44.0 KB
Line 
1/* $Id: VBoxDisplay.cpp 68367 2017-08-10 12:53:22Z vboxsync $ */
2/** @file
3 * VBoxSeamless - Display notifications.
4 */
5
6/*
7 * Copyright (C) 2006-2016 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17#include "VBoxTray.h"
18#include "VBoxHelpers.h"
19#include "VBoxSeamless.h"
20
21#include <malloc.h>
22
23#include <iprt/assert.h>
24#ifdef VBOX_WITH_WDDM
25# include <iprt/asm.h>
26#endif
27
28#ifdef DEBUG
29# define LOG_ENABLED
30# define LOG_GROUP LOG_GROUP_DEFAULT
31#endif
32#include <VBox/log.h>
33#include <VBox/VMMDev.h>
34
35#include <VBoxDisplay.h>
36#include <VBoxHook.h>
37
38
39
40typedef struct _VBOXDISPLAYCONTEXT
41{
42 const VBOXSERVICEENV *pEnv;
43 BOOL fAnyX;
44 /** ChangeDisplaySettingsEx does not exist in NT. ResizeDisplayDevice uses the function. */
45 LONG (WINAPI * pfnChangeDisplaySettingsEx)(LPCTSTR lpszDeviceName, LPDEVMODE lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam);
46 /** EnumDisplayDevices does not exist in NT. isVBoxDisplayDriverActive et al. are using these functions. */
47 BOOL (WINAPI * pfnEnumDisplayDevices)(IN LPCSTR lpDevice, IN DWORD iDevNum, OUT PDISPLAY_DEVICEA lpDisplayDevice, IN DWORD dwFlags);
48 /** Display driver interface, XPDM - WDDM abstraction see VBOXDISPIF** definitions above */
49 VBOXDISPIF dispIf;
50} VBOXDISPLAYCONTEXT, *PVBOXDISPLAYCONTEXT;
51
52static VBOXDISPLAYCONTEXT g_Ctx = { 0 };
53
54typedef enum
55{
56 VBOXDISPLAY_DRIVER_TYPE_UNKNOWN = 0,
57 VBOXDISPLAY_DRIVER_TYPE_XPDM = 1,
58 VBOXDISPLAY_DRIVER_TYPE_WDDM = 2
59} VBOXDISPLAY_DRIVER_TYPE;
60
61static VBOXDISPLAY_DRIVER_TYPE getVBoxDisplayDriverType (VBOXDISPLAYCONTEXT *pCtx);
62
63static DECLCALLBACK(int) VBoxDisplayInit(const PVBOXSERVICEENV pEnv, void **ppInstance)
64{
65 LogFlowFuncEnter();
66
67 PVBOXDISPLAYCONTEXT pCtx = &g_Ctx; /** @todo r=andy Use instance data via service lookup (add void *pInstance). */
68 AssertPtr(pCtx);
69
70 OSVERSIONINFO OSinfo; /** @todo r=andy Use VBoxTray's g_dwMajorVersion? */
71 OSinfo.dwOSVersionInfoSize = sizeof(OSinfo);
72 GetVersionEx (&OSinfo);
73
74 int rc;
75 HMODULE hUser = GetModuleHandle("user32.dll"); /** @todo r=andy Use RTLdrXXX and friends. */
76
77 pCtx->pEnv = pEnv;
78
79 if (NULL == hUser)
80 {
81 LogFlowFunc(("Could not get module handle of USER32.DLL!\n"));
82 rc = VERR_NOT_IMPLEMENTED;
83 }
84 else if (OSinfo.dwMajorVersion >= 5) /* APIs available only on W2K and up. */
85 {
86 /** @todo r=andy Use RTLdrXXX and friends. */
87 /** @todo r=andy No unicode version available? */
88 *(uintptr_t *)&pCtx->pfnChangeDisplaySettingsEx = (uintptr_t)GetProcAddress(hUser, "ChangeDisplaySettingsExA");
89 LogFlowFunc(("pfnChangeDisplaySettingsEx = %p\n", pCtx->pfnChangeDisplaySettingsEx));
90
91 *(uintptr_t *)&pCtx->pfnEnumDisplayDevices = (uintptr_t)GetProcAddress(hUser, "EnumDisplayDevicesA");
92 LogFlowFunc(("pfnEnumDisplayDevices = %p\n", pCtx->pfnEnumDisplayDevices));
93
94#ifdef VBOX_WITH_WDDM
95 if (OSinfo.dwMajorVersion >= 6)
96 {
97 /* This is Vista and up, check if we need to switch the display driver if to WDDM mode. */
98 LogFlowFunc(("this is Windows Vista and up\n"));
99 VBOXDISPLAY_DRIVER_TYPE enmType = getVBoxDisplayDriverType(pCtx);
100 if (enmType == VBOXDISPLAY_DRIVER_TYPE_WDDM)
101 {
102 LogFlowFunc(("WDDM driver is installed, switching display driver if to WDDM mode\n"));
103 /* This is hacky, but the most easiest way. */
104 VBOXDISPIF_MODE enmMode = (OSinfo.dwMajorVersion == 6 && OSinfo.dwMinorVersion == 0) ? VBOXDISPIF_MODE_WDDM : VBOXDISPIF_MODE_WDDM_W7;
105 DWORD dwErr = VBoxDispIfSwitchMode(const_cast<PVBOXDISPIF>(&pEnv->dispIf), enmMode, NULL /* old mode, we don't care about it */);
106 if (dwErr == NO_ERROR)
107 {
108 LogFlowFunc(("DispIf successfully switched to WDDM mode\n"));
109 rc = VINF_SUCCESS;
110 }
111 else
112 {
113 LogFlowFunc(("Failed to switch DispIf to WDDM mode, error (%d)\n", dwErr));
114 rc = RTErrConvertFromWin32(dwErr);
115 }
116 }
117 else
118 rc = VINF_SUCCESS;
119 }
120 else
121 rc = VINF_SUCCESS;
122#endif
123 }
124 else if (OSinfo.dwMajorVersion <= 4) /* Windows NT 4.0. */
125 {
126 /* Nothing to do here yet. */
127 /** @todo r=andy Has this been tested? */
128 rc = VINF_SUCCESS;
129 }
130 else /* Unsupported platform. */
131 {
132 LogFlowFunc(("Warning: Display for platform not handled yet!\n"));
133 rc = VERR_NOT_IMPLEMENTED;
134 }
135
136 if (RT_SUCCESS(rc))
137 {
138 VBOXDISPIFESCAPE_ISANYX IsAnyX = { 0 };
139 IsAnyX.EscapeHdr.escapeCode = VBOXESC_ISANYX;
140 DWORD err = VBoxDispIfEscapeInOut(&pEnv->dispIf, &IsAnyX.EscapeHdr, sizeof(uint32_t));
141 if (err == NO_ERROR)
142 pCtx->fAnyX = !!IsAnyX.u32IsAnyX;
143 else
144 pCtx->fAnyX = TRUE;
145
146 *ppInstance = pCtx;
147 }
148
149 LogFlowFuncLeaveRC(rc);
150 return rc;
151}
152
153static DECLCALLBACK(void) VBoxDisplayDestroy(void *pInstance)
154{
155 RT_NOREF(pInstance);
156 return;
157}
158
159static VBOXDISPLAY_DRIVER_TYPE getVBoxDisplayDriverType(PVBOXDISPLAYCONTEXT pCtx)
160{
161 VBOXDISPLAY_DRIVER_TYPE enmType = VBOXDISPLAY_DRIVER_TYPE_UNKNOWN;
162
163 if (pCtx->pfnEnumDisplayDevices)
164 {
165 INT devNum = 0;
166 DISPLAY_DEVICE dispDevice;
167 FillMemory(&dispDevice, sizeof(DISPLAY_DEVICE), 0);
168 dispDevice.cb = sizeof(DISPLAY_DEVICE);
169
170 LogFlowFunc(("getVBoxDisplayDriverType: Checking for active VBox display driver (W2K+) ...\n"));
171
172 while (EnumDisplayDevices(NULL,
173 devNum,
174 &dispDevice,
175 0))
176 {
177 LogFlowFunc(("getVBoxDisplayDriverType: DevNum:%d\nName:%s\nString:%s\nID:%s\nKey:%s\nFlags=%08X\n\n",
178 devNum,
179 &dispDevice.DeviceName[0],
180 &dispDevice.DeviceString[0],
181 &dispDevice.DeviceID[0],
182 &dispDevice.DeviceKey[0],
183 dispDevice.StateFlags));
184
185 if (dispDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
186 {
187 LogFlowFunc(("getVBoxDisplayDriverType: Primary device\n"));
188
189 /* WDDM driver can now have multiple incarnations,
190 * if the driver name contains VirtualBox, and does NOT match the XPDM name,
191 * assume it to be WDDM */
192 if (strcmp(&dispDevice.DeviceString[0], "VirtualBox Graphics Adapter") == 0)
193 enmType = VBOXDISPLAY_DRIVER_TYPE_XPDM;
194 else if (strstr(&dispDevice.DeviceString[0], "VirtualBox"))
195 enmType = VBOXDISPLAY_DRIVER_TYPE_WDDM;
196
197 break;
198 }
199
200 FillMemory(&dispDevice, sizeof(DISPLAY_DEVICE), 0);
201
202 dispDevice.cb = sizeof(DISPLAY_DEVICE);
203
204 devNum++;
205 }
206 }
207 else /* This must be NT 4 or something really old, so don't use EnumDisplayDevices() here ... */
208 {
209 LogFlowFunc(("getVBoxDisplayDriverType: Checking for active VBox display driver (NT or older) ...\n"));
210
211 DEVMODE tempDevMode;
212 ZeroMemory (&tempDevMode, sizeof (tempDevMode));
213 tempDevMode.dmSize = sizeof(DEVMODE);
214 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &tempDevMode); /* Get current display device settings */
215
216 /* Check for the short name, because all long stuff would be truncated */
217 if (strcmp((char*)&tempDevMode.dmDeviceName[0], "VBoxDisp") == 0)
218 enmType = VBOXDISPLAY_DRIVER_TYPE_XPDM;
219 }
220
221 return enmType;
222}
223
224/** @todo r=andy The "display", "seamless" (and VBoxCaps facility in VBoxTray.cpp indirectly) is using this.
225 * Add a PVBOXDISPLAYCONTEXT here for properly getting the display (XPDM/WDDM) abstraction interfaces. */
226DWORD EnableAndResizeDispDev(DEVMODE *paDeviceModes, DISPLAY_DEVICE *paDisplayDevices,
227 DWORD totalDispNum, UINT Id, DWORD aWidth, DWORD aHeight,
228 DWORD aBitsPerPixel, LONG aPosX, LONG aPosY, BOOL fEnabled, BOOL fExtDispSup)
229{
230 DISPLAY_DEVICE displayDeviceTmp;
231 DISPLAY_DEVICE displayDevice;
232 DEVMODE deviceMode;
233 DWORD dwStatus = DISP_CHANGE_SUCCESSFUL;
234 DWORD iter ;
235
236 PVBOXDISPLAYCONTEXT pCtx = &g_Ctx; /* See todo above. */
237
238 deviceMode = paDeviceModes[Id];
239 displayDevice = paDisplayDevices[Id];
240
241 for (iter = 0; iter < totalDispNum; iter++)
242 {
243 if (iter != 0 && iter != Id && !(paDisplayDevices[iter].StateFlags & DISPLAY_DEVICE_ACTIVE))
244 {
245 LogRel(("Display: Initially disabling monitor with ID=%ld; total monitor count is %ld\n", iter, totalDispNum));
246 DEVMODE deviceModeTmp;
247 ZeroMemory(&deviceModeTmp, sizeof(DEVMODE));
248 deviceModeTmp.dmSize = sizeof(DEVMODE);
249 deviceModeTmp.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_POSITION
250 | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS ;
251 displayDeviceTmp = paDisplayDevices[iter];
252 pCtx->pfnChangeDisplaySettingsEx(displayDeviceTmp.DeviceName, &deviceModeTmp, NULL,
253 (CDS_UPDATEREGISTRY | CDS_NORESET), NULL);
254 }
255 }
256
257 if (fExtDispSup) /* Extended Display Support possible*/
258 {
259 if (fEnabled)
260 {
261 /* Special case for enabling the secondary monitor. */
262 if(!(displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE))
263 {
264 LogRel(("Display [ID=%ld, name='%s']: Is a secondary monitor and disabled -- enabling it\n", Id, displayDevice.DeviceName));
265 deviceMode.dmPosition.x = paDeviceModes[0].dmPelsWidth;
266 deviceMode.dmPosition.y = 0;
267 deviceMode.dmBitsPerPel = 32;
268 OSVERSIONINFO OSinfo;
269 OSinfo.dwOSVersionInfoSize = sizeof (OSinfo);
270 GetVersionEx (&OSinfo);
271
272 if (OSinfo.dwMajorVersion < 6)
273 /* dont any more flags here as, only DM_POISITON is used to enable the secondary display */
274 deviceMode.dmFields = DM_POSITION;
275 else /* for win 7 and above */
276 /* for vista and above DM_BITSPERPEL is necessary */
277 deviceMode.dmFields = DM_BITSPERPEL | DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY | DM_POSITION;
278
279 dwStatus = pCtx->pfnChangeDisplaySettingsEx((LPSTR)displayDevice.DeviceName,&deviceMode, NULL, (CDS_UPDATEREGISTRY | CDS_NORESET), NULL);
280 /* A second call to ChangeDisplaySettings updates the monitor.*/
281 pCtx->pfnChangeDisplaySettingsEx(NULL, NULL, NULL,0, NULL);
282 }
283 else /* secondary monitor already enabled. Request to change the resolution or position. */
284 {
285 if (aWidth !=0 && aHeight != 0)
286 {
287 LogRel(("Display [ID=%ld, name='%s']: Changing resolution to %ldx%ld\n", Id, displayDevice.DeviceName, aWidth, aHeight));
288 deviceMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL
289 | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS;
290 deviceMode.dmPelsWidth = aWidth;
291 deviceMode.dmPelsHeight = aHeight;
292 deviceMode.dmBitsPerPel = aBitsPerPixel;
293 }
294 if (aPosX != 0 || aPosY != 0)
295 {
296 LogRel(("Display [ID=%ld, name='%s']: Changing position to %ld,%ld\n", Id, displayDevice.DeviceName, aPosX, aPosY));
297 deviceMode.dmFields |= DM_POSITION;
298 deviceMode.dmPosition.x = aPosX;
299 deviceMode.dmPosition.y = aPosY;
300 }
301 dwStatus = pCtx->pfnChangeDisplaySettingsEx((LPSTR)displayDevice.DeviceName,
302 &deviceMode, NULL, CDS_NORESET|CDS_UPDATEREGISTRY, NULL);
303 /* A second call to ChangeDisplaySettings updates the monitor. */
304 pCtx->pfnChangeDisplaySettingsEx(NULL, NULL, NULL,0, NULL);
305 }
306 }
307 else /* Request is there to disable the monitor with ID = Id*/
308 {
309 LogRel(("Display [ID=%ld, name='%s']: Disalbing\n", Id, displayDevice.DeviceName));
310
311 DEVMODE deviceModeTmp;
312 ZeroMemory(&deviceModeTmp, sizeof(DEVMODE));
313 deviceModeTmp.dmSize = sizeof(DEVMODE);
314 deviceModeTmp.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_POSITION
315 | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS ;
316 displayDeviceTmp = paDisplayDevices[Id];
317 dwStatus = pCtx->pfnChangeDisplaySettingsEx(displayDeviceTmp.DeviceName, &deviceModeTmp, NULL,
318 (CDS_UPDATEREGISTRY | CDS_NORESET), NULL);
319 pCtx->pfnChangeDisplaySettingsEx(NULL, NULL, NULL,0, NULL);
320 }
321 }
322 return dwStatus;
323}
324
325DWORD VBoxDisplayGetCount(void)
326{
327 DISPLAY_DEVICE DisplayDevice;
328
329 ZeroMemory(&DisplayDevice, sizeof(DISPLAY_DEVICE));
330 DisplayDevice.cb = sizeof(DISPLAY_DEVICE);
331
332 /* Find out how many display devices the system has */
333 DWORD NumDevices = 0;
334 DWORD i = 0;
335 while (EnumDisplayDevices (NULL, i, &DisplayDevice, 0))
336 {
337 LogFlowFunc(("ResizeDisplayDevice: [%d] %s\n", i, DisplayDevice.DeviceName));
338
339 if (DisplayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
340 {
341 LogFlowFunc(("ResizeDisplayDevice: Found primary device. err %d\n", GetLastError ()));
342 NumDevices++;
343 }
344 else if (!(DisplayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))
345 {
346
347 LogFlowFunc(("ResizeDisplayDevice: Found secondary device. err %d\n", GetLastError ()));
348 NumDevices++;
349 }
350
351 ZeroMemory(&DisplayDevice, sizeof(DisplayDevice));
352 DisplayDevice.cb = sizeof(DisplayDevice);
353 i++;
354 }
355
356 return NumDevices;
357}
358
359DWORD VBoxDisplayGetConfig(const DWORD NumDevices, DWORD *pDevPrimaryNum, DWORD *pNumDevices,
360 DISPLAY_DEVICE *paDisplayDevices, DEVMODE *paDeviceModes)
361{
362 /* Fetch information about current devices and modes. */
363 DWORD DevNum = 0;
364 DWORD DevPrimaryNum = 0;
365
366 DISPLAY_DEVICE DisplayDevice;
367
368 ZeroMemory(&DisplayDevice, sizeof(DISPLAY_DEVICE));
369 DisplayDevice.cb = sizeof(DISPLAY_DEVICE);
370
371 DWORD i = 0;
372 while (EnumDisplayDevices (NULL, i, &DisplayDevice, 0))
373 {
374 LogFlowFunc(("ResizeDisplayDevice: [%d(%d)] %s\n", i, DevNum, DisplayDevice.DeviceName));
375
376 BOOL bFetchDevice = FALSE;
377
378 if (DisplayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
379 {
380 LogFlowFunc(("ResizeDisplayDevice: Found primary device. err %d\n", GetLastError ()));
381 DevPrimaryNum = DevNum;
382 bFetchDevice = TRUE;
383 }
384 else if (!(DisplayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))
385 {
386
387 LogFlowFunc(("ResizeDisplayDevice: Found secondary device. err %d\n", GetLastError ()));
388 bFetchDevice = TRUE;
389 }
390
391 if (bFetchDevice)
392 {
393 if (DevNum >= NumDevices)
394 {
395 LogFlowFunc(("ResizeDisplayDevice: %d >= %d\n", NumDevices, DevNum));
396 return ERROR_BUFFER_OVERFLOW;
397 }
398
399 paDisplayDevices[DevNum] = DisplayDevice;
400
401 /* First try to get the video mode stored in registry (ENUM_REGISTRY_SETTINGS).
402 * A secondary display could be not active at the moment and would not have
403 * a current video mode (ENUM_CURRENT_SETTINGS).
404 */
405 ZeroMemory(&paDeviceModes[DevNum], sizeof(DEVMODE));
406 paDeviceModes[DevNum].dmSize = sizeof(DEVMODE);
407 if (!EnumDisplaySettings((LPSTR)DisplayDevice.DeviceName,
408 ENUM_REGISTRY_SETTINGS, &paDeviceModes[DevNum]))
409 {
410 LogFlowFunc(("ResizeDisplayDevice: EnumDisplaySettings error %d\n", GetLastError ()));
411 }
412
413 if ( paDeviceModes[DevNum].dmPelsWidth == 0
414 || paDeviceModes[DevNum].dmPelsHeight == 0)
415 {
416 /* No ENUM_REGISTRY_SETTINGS yet. Seen on Vista after installation.
417 * Get the current video mode then.
418 */
419 ZeroMemory(&paDeviceModes[DevNum], sizeof(DEVMODE));
420 paDeviceModes[DevNum].dmSize = sizeof(DEVMODE);
421 if (!EnumDisplaySettings((LPSTR)DisplayDevice.DeviceName,
422 ENUM_CURRENT_SETTINGS, &paDeviceModes[DevNum]))
423 {
424 /* ENUM_CURRENT_SETTINGS returns FALSE when the display is not active:
425 * for example a disabled secondary display.
426 * Do not return here, ignore the error and set the display info to 0x0x0.
427 */
428 LogFlowFunc(("ResizeDisplayDevice: EnumDisplaySettings(ENUM_CURRENT_SETTINGS) error %d\n", GetLastError ()));
429 }
430 }
431
432
433 DevNum++;
434 }
435
436 ZeroMemory(&DisplayDevice, sizeof(DISPLAY_DEVICE));
437 DisplayDevice.cb = sizeof(DISPLAY_DEVICE);
438 i++;
439 }
440
441 *pNumDevices = DevNum;
442 *pDevPrimaryNum = DevPrimaryNum;
443
444 return NO_ERROR;
445}
446
447/* Returns TRUE to try again. */
448/** @todo r=andy Why not using the VMMDevDisplayChangeRequestEx structure for all those parameters here? */
449static BOOL ResizeDisplayDevice(PVBOXDISPLAYCONTEXT pCtx,
450 UINT Id, DWORD Width, DWORD Height, DWORD BitsPerPixel,
451 BOOL fEnabled, LONG dwNewPosX, LONG dwNewPosY, bool fChangeOrigin,
452 BOOL fExtDispSup)
453{
454 BOOL fDispAlreadyEnabled = false; /* check whether the monitor with ID is already enabled. */
455 BOOL fModeReset = (Width == 0 && Height == 0 && BitsPerPixel == 0 &&
456 dwNewPosX == 0 && dwNewPosY == 0 && !fChangeOrigin);
457 DWORD dmFields = 0;
458
459 LogFlowFunc(("[%d] %dx%d at %d,%d fChangeOrigin %d fEnabled %d fExtDisSup %d\n",
460 Id, Width, Height, dwNewPosX, dwNewPosY, fChangeOrigin, fEnabled, fExtDispSup));
461
462 if (!pCtx->fAnyX)
463 Width &= 0xFFF8;
464
465 VBoxDispIfCancelPendingResize(&pCtx->pEnv->dispIf);
466
467 DWORD NumDevices = VBoxDisplayGetCount();
468
469 if (NumDevices == 0 || Id >= NumDevices)
470 {
471 LogFlowFunc(("ResizeDisplayDevice: Requested identifier %d is invalid. err %d\n", Id, GetLastError ()));
472 return FALSE;
473 }
474
475 LogFlowFunc(("ResizeDisplayDevice: Found total %d devices. err %d\n", NumDevices, GetLastError ()));
476
477 DISPLAY_DEVICE *paDisplayDevices = (DISPLAY_DEVICE *)alloca (sizeof (DISPLAY_DEVICE) * NumDevices);
478 DEVMODE *paDeviceModes = (DEVMODE *)alloca (sizeof (DEVMODE) * NumDevices);
479 RECTL *paRects = (RECTL *)alloca (sizeof (RECTL) * NumDevices);
480 DWORD DevNum = 0;
481 DWORD DevPrimaryNum = 0;
482 DWORD dwStatus = VBoxDisplayGetConfig(NumDevices, &DevPrimaryNum, &DevNum, paDisplayDevices, paDeviceModes);
483 if (dwStatus != NO_ERROR)
484 {
485 LogFlowFunc(("ResizeDisplayDevice: VBoxGetDisplayConfig failed, %d\n", dwStatus));
486 return dwStatus;
487 }
488
489 if (NumDevices != DevNum)
490 LogFlowFunc(("ResizeDisplayDevice: NumDevices(%d) != DevNum(%d)\n", NumDevices, DevNum));
491
492 DWORD i = 0;
493
494 for (i = 0; i < DevNum; ++i)
495 {
496 if (fExtDispSup)
497 {
498 LogRel(("Extended Display Support.\n"));
499 LogFlowFunc(("[%d] %dx%dx%d at %d,%d, dmFields 0x%x\n",
500 i,
501 paDeviceModes[i].dmPelsWidth,
502 paDeviceModes[i].dmPelsHeight,
503 paDeviceModes[i].dmBitsPerPel,
504 paDeviceModes[i].dmPosition.x,
505 paDeviceModes[i].dmPosition.y,
506 paDeviceModes[i].dmFields));
507 }
508 else
509 {
510 LogRel(("NO Ext Display Support \n"));
511 }
512
513 paRects[i].left = paDeviceModes[i].dmPosition.x;
514 paRects[i].top = paDeviceModes[i].dmPosition.y;
515 paRects[i].right = paDeviceModes[i].dmPosition.x + paDeviceModes[i].dmPelsWidth;
516 paRects[i].bottom = paDeviceModes[i].dmPosition.y + paDeviceModes[i].dmPelsHeight;
517 }
518
519 /* Keep a record if the display with ID is already active or not. */
520 if (paDisplayDevices[Id].StateFlags & DISPLAY_DEVICE_ACTIVE)
521 {
522 LogRel(("Display with ID=%d already enabled\n", Id));
523 fDispAlreadyEnabled = TRUE;
524 }
525
526 /* Width, height equal to 0 means that this value must be not changed.
527 * Update input parameters if necessary.
528 * Note: BitsPerPixel is taken into account later, when new rectangles
529 * are assigned to displays.
530 */
531 if (Width == 0)
532 Width = paRects[Id].right - paRects[Id].left;
533 else
534 dmFields |= DM_PELSWIDTH;
535
536 if (Height == 0)
537 Height = paRects[Id].bottom - paRects[Id].top;
538 else
539 dmFields |= DM_PELSHEIGHT;
540
541 if (BitsPerPixel == 0)
542 BitsPerPixel = paDeviceModes[Id].dmBitsPerPel;
543 else
544 dmFields |= DM_BITSPERPEL;
545
546 if (!fChangeOrigin)
547 {
548 /* Use existing position. */
549 dwNewPosX = paRects[Id].left;
550 dwNewPosY = paRects[Id].top;
551 LogFlowFunc(("existing dwNewPosX %d, dwNewPosY %d\n", dwNewPosX, dwNewPosY));
552 }
553
554 /* Always update the position.
555 * It is either explicitly requested or must be set to the existing position.
556 */
557 dmFields |= DM_POSITION;
558
559 /* Check whether a mode reset or a change is requested.
560 * Rectangle position is recalculated only if fEnabled is 1.
561 * For non extended supported modes (old Host VMs), fEnabled
562 * is always 1.
563 */
564 /* Handled the case where previouseresolution of secondary monitor
565 * was for eg. 1024*768*32 and monitor was in disabled state.
566 * User gives the command
567 * setvideomode 1024 768 32 1 yes.
568 * Now in this case the resolution request is same as previous one but
569 * monitor is going from disabled to enabled state so the below condition
570 * shour return false
571 * The below condition will only return true , if no mode reset has
572 * been requested AND fEnabled is 1 and fDispAlreadyEnabled is also 1 AND
573 * all rect conditions are true. Thus in this case nothing has to be done.
574 */
575 if ( !fModeReset && (!fEnabled == !fDispAlreadyEnabled)
576 && paRects[Id].left == dwNewPosX
577 && paRects[Id].top == dwNewPosY
578 && paRects[Id].right - paRects[Id].left == (LONG)Width
579 && paRects[Id].bottom - paRects[Id].top == (LONG)Height
580 && paDeviceModes[Id].dmBitsPerPel == BitsPerPixel)
581 {
582 LogRel(("Already at desired resolution. No Change.\n"));
583 return FALSE;
584 }
585
586 hlpResizeRect(paRects, NumDevices, DevPrimaryNum, Id,
587 fEnabled ? Width : 0, fEnabled ? Height : 0, dwNewPosX, dwNewPosY);
588#ifdef Log
589 for (i = 0; i < NumDevices; i++)
590 {
591 LogFlowFunc(("ResizeDisplayDevice: [%d]: %d,%d %dx%d\n",
592 i, paRects[i].left, paRects[i].top,
593 paRects[i].right - paRects[i].left,
594 paRects[i].bottom - paRects[i].top));
595 }
596#endif /* Log */
597
598#ifdef VBOX_WITH_WDDM
599 VBOXDISPLAY_DRIVER_TYPE enmDriverType = getVBoxDisplayDriverType (pCtx);
600 if (enmDriverType == VBOXDISPLAY_DRIVER_TYPE_WDDM)
601 {
602 /* Assign the new rectangles to displays. */
603 for (i = 0; i < NumDevices; i++)
604 {
605 paDeviceModes[i].dmPosition.x = paRects[i].left;
606 paDeviceModes[i].dmPosition.y = paRects[i].top;
607 paDeviceModes[i].dmPelsWidth = paRects[i].right - paRects[i].left;
608 paDeviceModes[i].dmPelsHeight = paRects[i].bottom - paRects[i].top;
609
610 if (i == Id)
611 paDeviceModes[i].dmBitsPerPel = BitsPerPixel;
612
613 paDeviceModes[i].dmFields |= dmFields;
614
615 /* On Vista one must specify DM_BITSPERPEL.
616 * Note that the current mode dmBitsPerPel is already in the DEVMODE structure.
617 */
618 if (!(paDeviceModes[i].dmFields & DM_BITSPERPEL))
619 {
620 LogFlowFunc(("no DM_BITSPERPEL\n"));
621 paDeviceModes[i].dmFields |= DM_BITSPERPEL;
622 paDeviceModes[i].dmBitsPerPel = 32;
623 }
624
625 LogFlowFunc(("ResizeDisplayDevice: pfnChangeDisplaySettingsEx %x: %dx%dx%d at %d,%d fields 0x%X\n",
626 pCtx->pfnChangeDisplaySettingsEx,
627 paDeviceModes[i].dmPelsWidth,
628 paDeviceModes[i].dmPelsHeight,
629 paDeviceModes[i].dmBitsPerPel,
630 paDeviceModes[i].dmPosition.x,
631 paDeviceModes[i].dmPosition.y,
632 paDeviceModes[i].dmFields));
633 }
634
635 LogFlowFunc(("Request to resize the displa\n"));
636 DWORD err = VBoxDispIfResizeModes(&pCtx->pEnv->dispIf, Id, fEnabled, fExtDispSup, paDisplayDevices, paDeviceModes, DevNum);
637 if (err != ERROR_RETRY)
638 {
639 if (err == NO_ERROR)
640 LogFlowFunc(("VBoxDispIfResizeModes succeeded\n"));
641 else
642 LogFlowFunc(("Failure VBoxDispIfResizeModes (%d)\n", err));
643 return FALSE;
644 }
645
646 LogFlowFunc(("ResizeDisplayDevice: RETRY requested\n"));
647 return TRUE;
648 }
649#endif
650 /* Without this, Windows will not ask the miniport for its
651 * mode table but uses an internal cache instead.
652 */
653 for (i = 0; i < NumDevices; i++)
654 {
655 DEVMODE tempDevMode;
656 ZeroMemory (&tempDevMode, sizeof (tempDevMode));
657 tempDevMode.dmSize = sizeof(DEVMODE);
658 EnumDisplaySettings((LPSTR)paDisplayDevices[i].DeviceName, 0xffffff, &tempDevMode);
659 LogFlowFunc(("ResizeDisplayDevice: EnumDisplaySettings last error %d\n", GetLastError ()));
660 }
661
662 /* Assign the new rectangles to displays. */
663 for (i = 0; i < NumDevices; i++)
664 {
665 paDeviceModes[i].dmPosition.x = paRects[i].left;
666 paDeviceModes[i].dmPosition.y = paRects[i].top;
667 paDeviceModes[i].dmPelsWidth = paRects[i].right - paRects[i].left;
668 paDeviceModes[i].dmPelsHeight = paRects[i].bottom - paRects[i].top;
669
670 /* On Vista one must specify DM_BITSPERPEL.
671 * Note that the current mode dmBitsPerPel is already in the DEVMODE structure.
672 */
673 paDeviceModes[i].dmFields = DM_POSITION | DM_PELSHEIGHT | DM_PELSWIDTH | DM_BITSPERPEL;
674
675 if ( i == Id
676 && BitsPerPixel != 0)
677 {
678 /* Change dmBitsPerPel if requested. */
679 paDeviceModes[i].dmBitsPerPel = BitsPerPixel;
680 }
681
682 LogFlowFunc(("ResizeDisplayDevice: pfnChangeDisplaySettingsEx Current MonitorId=%d: %dx%dx%d at %d,%d\n",
683 i,
684 paDeviceModes[i].dmPelsWidth,
685 paDeviceModes[i].dmPelsHeight,
686 paDeviceModes[i].dmBitsPerPel,
687 paDeviceModes[i].dmPosition.x,
688 paDeviceModes[i].dmPosition.y));
689
690 LONG status = pCtx->pfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName,
691 &paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL);
692 LogFlowFunc(("ResizeDisplayDevice: ChangeDisplaySettingsEx position status %d, err %d\n", status, GetLastError()));
693 NOREF(status);
694 }
695
696 LogFlowFunc(("Enable And Resize Device. Id = %d, Width=%d Height=%d, \
697 dwNewPosX = %d, dwNewPosY = %d fEnabled=%d & fExtDispSupport = %d \n",
698 Id, Width, Height, dwNewPosX, dwNewPosY, fEnabled, fExtDispSup));
699 dwStatus = EnableAndResizeDispDev(paDeviceModes, paDisplayDevices, DevNum, Id, Width, Height, BitsPerPixel,
700 dwNewPosX, dwNewPosY, fEnabled, fExtDispSup);
701 if (dwStatus == DISP_CHANGE_SUCCESSFUL || dwStatus == DISP_CHANGE_BADMODE)
702 {
703 /* Successfully set new video mode or our driver can not set
704 * the requested mode. Stop trying.
705 */
706 return FALSE;
707 }
708 /* Retry the request. */
709 return TRUE;
710}
711
712/**
713 * Thread function to wait for and process display change
714 * requests
715 */
716DECLCALLBACK(int) VBoxDisplayWorker(void *pInstance, bool volatile *pfShutdown)
717{
718 AssertPtr(pInstance);
719 LogFlowFunc(("pInstance=%p\n", pInstance));
720
721 /*
722 * Tell the control thread that it can continue
723 * spawning services.
724 */
725 RTThreadUserSignal(RTThreadSelf());
726
727 PVBOXDISPLAYCONTEXT pCtx = (PVBOXDISPLAYCONTEXT)pInstance;
728
729 HANDLE gVBoxDriver = pCtx->pEnv->hDriver;
730 VBoxGuestFilterMaskInfo maskInfo;
731 DWORD cbReturned;
732
733 maskInfo.u32OrMask = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED;
734 maskInfo.u32NotMask = 0;
735 if (!DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
736 {
737 DWORD dwErr = GetLastError();
738 LogFlowFunc(("DeviceIOControl(CtlMask - or) failed with %ld, exiting\n", dwErr));
739 return RTErrConvertFromWin32(dwErr);
740 }
741
742 PostMessage(g_hwndToolWindow, WM_VBOX_GRAPHICS_SUPPORTED, 0, 0);
743
744 VBoxDispIfResizeStarted(&pCtx->pEnv->dispIf);
745
746 int rc = VINF_SUCCESS;
747
748 for (;;)
749 {
750 BOOL fExtDispSup = TRUE;
751 /* Wait for a display change event. */
752 VBoxGuestWaitEventInfo waitEvent;
753 waitEvent.u32TimeoutIn = 1000;
754 waitEvent.u32EventMaskIn = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED;
755 if (DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent), &waitEvent, sizeof(waitEvent), &cbReturned, NULL))
756 {
757 /*LogFlowFunc(("DeviceIOControl succeeded\n"));*/
758
759 if (NULL == pCtx) {
760 LogFlowFunc(("Invalid context detected!\n"));
761 break;
762 }
763
764 if (NULL == pCtx->pEnv) {
765 LogFlowFunc(("Invalid context environment detected!\n"));
766 break;
767 }
768
769 /* are we supposed to stop? */
770 if (*pfShutdown)
771 break;
772
773 /* did we get the right event? */
774 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)
775 {
776 LogFlowFunc(("going to get display change information\n"));
777 BOOL fDisplayChangeQueried;
778
779
780 /* We got at least one event. Read the requested resolution
781 * and try to set it until success. New events will not be seen
782 * but a new resolution will be read in this poll loop.
783 */
784 /* Try if extended mode display information is available from the host. */
785 VMMDevDisplayChangeRequestEx displayChangeRequest = {0};
786 fExtDispSup = TRUE;
787 displayChangeRequest.header.size = sizeof(VMMDevDisplayChangeRequestEx);
788 displayChangeRequest.header.version = VMMDEV_REQUEST_HEADER_VERSION;
789 displayChangeRequest.header.requestType = VMMDevReq_GetDisplayChangeRequestEx;
790 displayChangeRequest.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
791 fDisplayChangeQueried = DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_VMMREQUEST(sizeof(VMMDevDisplayChangeRequestEx)), &displayChangeRequest, sizeof(VMMDevDisplayChangeRequestEx),
792 &displayChangeRequest, sizeof(VMMDevDisplayChangeRequestEx), &cbReturned, NULL);
793
794 if (!fDisplayChangeQueried)
795 {
796 LogFlowFunc(("Extended Display Not Supported. Trying VMMDevDisplayChangeRequest2\n"));
797 fExtDispSup = FALSE; /* Extended display Change request is not supported */
798
799 displayChangeRequest.header.size = sizeof(VMMDevDisplayChangeRequest2);
800 displayChangeRequest.header.version = VMMDEV_REQUEST_HEADER_VERSION;
801 displayChangeRequest.header.requestType = VMMDevReq_GetDisplayChangeRequest2;
802 displayChangeRequest.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
803 fDisplayChangeQueried = DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_VMMREQUEST(sizeof(VMMDevDisplayChangeRequest2)), &displayChangeRequest, sizeof(VMMDevDisplayChangeRequest2),
804 &displayChangeRequest, sizeof(VMMDevDisplayChangeRequest2), &cbReturned, NULL);
805 displayChangeRequest.cxOrigin = 0;
806 displayChangeRequest.cyOrigin = 0;
807 displayChangeRequest.fChangeOrigin = 0;
808 displayChangeRequest.fEnabled = 1; /* Always Enabled for old VMs on Host.*/
809 }
810
811 if (!fDisplayChangeQueried)
812 {
813 LogFlowFunc(("Extended Display Not Supported. Trying VMMDevDisplayChangeRequest\n"));
814 fExtDispSup = FALSE; /*Extended display Change request is not supported */
815 /* Try the old version of the request for old VBox hosts. */
816 displayChangeRequest.header.size = sizeof(VMMDevDisplayChangeRequest);
817 displayChangeRequest.header.version = VMMDEV_REQUEST_HEADER_VERSION;
818 displayChangeRequest.header.requestType = VMMDevReq_GetDisplayChangeRequest;
819 displayChangeRequest.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
820 fDisplayChangeQueried = DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_VMMREQUEST(sizeof(VMMDevDisplayChangeRequest)), &displayChangeRequest, sizeof(VMMDevDisplayChangeRequest),
821 &displayChangeRequest, sizeof(VMMDevDisplayChangeRequest), &cbReturned, NULL);
822 displayChangeRequest.display = 0;
823 displayChangeRequest.cxOrigin = 0;
824 displayChangeRequest.cyOrigin = 0;
825 displayChangeRequest.fChangeOrigin = 0;
826 displayChangeRequest.fEnabled = 1; /* Always Enabled for old VMs on Host.*/
827 }
828
829 if (fDisplayChangeQueried)
830 {
831 /* Try to set the requested video mode. Repeat until it is successful or is rejected by the driver. */
832 for (;;)
833 {
834 LogFlowFunc(("VMMDevReq_GetDisplayChangeRequest2: %dx%dx%d at %d\n", displayChangeRequest.xres, displayChangeRequest.yres, displayChangeRequest.bpp, displayChangeRequest.display));
835
836 /* Only try to change video mode if the active display driver is VBox additions. */
837
838 VBOXDISPLAY_DRIVER_TYPE enmDriverType = getVBoxDisplayDriverType (pCtx);
839
840 if (enmDriverType == VBOXDISPLAY_DRIVER_TYPE_UNKNOWN)
841 {
842 LogFlowFunc(("vboxDisplayDriver is not active\n"));
843 break;
844 }
845
846 if (pCtx->pfnChangeDisplaySettingsEx != 0)
847 {
848 LogFlowFunc(("Detected W2K or later\n"));
849 /* W2K or later. */
850 LogFlowFunc(("DisplayChangeReqEx parameters aDisplay=%d x xRes=%d x yRes=%d x bpp=%d x SecondayMonEnb=%d x NewOriginX=%d x NewOriginY=%d x ChangeOrigin=%d\n",
851 displayChangeRequest.display,
852 displayChangeRequest.xres,
853 displayChangeRequest.yres,
854 displayChangeRequest.bpp,
855 displayChangeRequest.fEnabled,
856 displayChangeRequest.cxOrigin,
857 displayChangeRequest.cyOrigin,
858 displayChangeRequest.fChangeOrigin));
859 if (!ResizeDisplayDevice(pCtx,
860 displayChangeRequest.display,
861 displayChangeRequest.xres,
862 displayChangeRequest.yres,
863 displayChangeRequest.bpp,
864 displayChangeRequest.fEnabled,
865 displayChangeRequest.cxOrigin,
866 displayChangeRequest.cyOrigin,
867 displayChangeRequest.fChangeOrigin,
868 fExtDispSup
869 ))
870 {
871 LogFlowFunc(("ResizeDipspalyDevice return 0\n"));
872 break;
873 }
874
875 }
876 else
877 {
878 LogFlowFunc(("Detected NT\n"));
879
880 /* Single monitor NT. */
881 DEVMODE devMode;
882 RT_ZERO(devMode);
883 devMode.dmSize = sizeof(DEVMODE);
884
885 /* get the current screen setup */
886 if (EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &devMode))
887 {
888 LogFlowFunc(("Current mode: %d x %d x %d at %d,%d\n",
889 devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel, devMode.dmPosition.x, devMode.dmPosition.y));
890
891 /* Check whether a mode reset or a change is requested. */
892 if (displayChangeRequest.xres || displayChangeRequest.yres || displayChangeRequest.bpp)
893 {
894 /* A change is requested.
895 * Set values which are not to be changed to the current values.
896 */
897 if (!displayChangeRequest.xres)
898 displayChangeRequest.xres = devMode.dmPelsWidth;
899 if (!displayChangeRequest.yres)
900 displayChangeRequest.yres = devMode.dmPelsHeight;
901 if (!displayChangeRequest.bpp)
902 displayChangeRequest.bpp = devMode.dmBitsPerPel;
903 }
904 else
905 {
906 /* All zero values means a forced mode reset. Do nothing. */
907 LogFlowFunc(("Forced mode reset\n"));
908 }
909
910 /* Verify that the mode is indeed changed. */
911 if ( devMode.dmPelsWidth == displayChangeRequest.xres
912 && devMode.dmPelsHeight == displayChangeRequest.yres
913 && devMode.dmBitsPerPel == displayChangeRequest.bpp)
914 {
915 LogFlowFunc(("already at desired resolution\n"));
916 break;
917 }
918
919 // without this, Windows will not ask the miniport for its
920 // mode table but uses an internal cache instead
921 DEVMODE tempDevMode = {0};
922 tempDevMode.dmSize = sizeof(DEVMODE);
923 EnumDisplaySettings(NULL, 0xffffff, &tempDevMode);
924
925 /* adjust the values that are supposed to change */
926 if (displayChangeRequest.xres)
927 devMode.dmPelsWidth = displayChangeRequest.xres;
928 if (displayChangeRequest.yres)
929 devMode.dmPelsHeight = displayChangeRequest.yres;
930 if (displayChangeRequest.bpp)
931 devMode.dmBitsPerPel = displayChangeRequest.bpp;
932
933 LogFlowFunc(("setting new mode %d x %d, %d BPP\n",
934 devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel));
935
936 /* set the new mode */
937 LONG status = ChangeDisplaySettings(&devMode, CDS_UPDATEREGISTRY);
938 if (status != DISP_CHANGE_SUCCESSFUL)
939 {
940 LogFlowFunc(("error from ChangeDisplaySettings: %d\n", status));
941
942 if (status == DISP_CHANGE_BADMODE)
943 {
944 /* Our driver can not set the requested mode. Stop trying. */
945 break;
946 }
947 }
948 else
949 {
950 /* Successfully set new video mode. */
951 break;
952 }
953 }
954 else
955 {
956 LogFlowFunc(("error from EnumDisplaySettings: %d\n", GetLastError ()));
957 break;
958 }
959 }
960
961 /* Retry the change a bit later. */
962 RTThreadSleep(1000);
963 }
964 }
965 else
966 {
967 /* sleep a bit to not eat too much CPU while retrying */
968 RTThreadSleep(50);
969 }
970 }
971
972 /* are we supposed to stop? */
973 if (*pfShutdown)
974 break;
975
976 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED)
977 hlpReloadCursor();
978 }
979 else
980 {
981 // Checking once a second whether or not WM_DISPLAYCHANGED happened.
982 if (ASMAtomicXchgU32(&g_fGuestDisplaysChanged, 0))
983 {
984 // XPDM driver has VBoxDispDrvNotify to receive such a notifications
985 if (pCtx->pEnv->dispIf.enmMode >= VBOXDISPIF_MODE_WDDM)
986 {
987 VBOXDISPIFESCAPE EscapeHdr = { 0 };
988 EscapeHdr.escapeCode = VBOXESC_GUEST_DISPLAYCHANGED;
989
990 DWORD err = VBoxDispIfEscapeInOut(&pCtx->pEnv->dispIf, &EscapeHdr, 0);
991 LogFlowFunc(("VBoxDispIfEscapeInOut returned %d\n", err)); NOREF(err);
992 }
993 }
994 /* sleep a bit to not eat too much CPU in case the above call always fails */
995 RTThreadSleep(10);
996
997 if (*pfShutdown)
998 break;
999 }
1000 }
1001
1002 /*
1003 * Remove event filter and graphics capability report.
1004 */
1005 maskInfo.u32OrMask = 0;
1006 maskInfo.u32NotMask = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED;
1007 if (!DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
1008 LogFlowFunc(("DeviceIOControl(CtlMask - not) failed\n"));
1009 PostMessage(g_hwndToolWindow, WM_VBOX_GRAPHICS_UNSUPPORTED, 0, 0);
1010
1011 LogFlowFuncLeaveRC(rc);
1012 return rc;
1013}
1014
1015/**
1016 * The service description.
1017 */
1018VBOXSERVICEDESC g_SvcDescDisplay =
1019{
1020 /* pszName. */
1021 "display",
1022 /* pszDescription. */
1023 "Display Notifications",
1024 /* methods */
1025 VBoxDisplayInit,
1026 VBoxDisplayWorker,
1027 NULL /* pfnStop */,
1028 VBoxDisplayDestroy
1029};
1030
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette