Changeset 6360 in vbox
- Timestamp:
- Jan 15, 2008 5:37:15 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27282
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxService
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxDisplay.cpp
r5999 r6360 33 33 /* ChangeDisplaySettingsEx does not exist in NT. ResizeDisplayDevice uses the function. */ 34 34 LONG (WINAPI * pfnChangeDisplaySettingsEx)(LPCTSTR lpszDeviceName, LPDEVMODE lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam); 35 36 /* EnumDisplayDevices does not exist in NT. isVBoxDisplayDriverActive et al. are using these functions. */ 37 BOOL (WINAPI * pfnEnumDisplayDevices)(IN LPCSTR lpDevice, IN DWORD iDevNum, OUT PDISPLAY_DEVICEA lpDisplayDevice, IN DWORD dwFlags); 38 35 39 } VBOXDISPLAYCONTEXT; 36 40 … … 39 43 int VBoxDisplayInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread) 40 44 { 45 OSVERSIONINFO OSinfo; 46 OSinfo.dwOSVersionInfoSize = sizeof (OSinfo); 47 GetVersionEx (&OSinfo); 48 41 49 HMODULE hUser = GetModuleHandle("USER32"); 42 50 43 51 gCtx.pEnv = pEnv; 44 52 45 if (hUser) 53 if (NULL == hUser) 54 { 55 dprintf(("VBoxService: Could not get module handle of USER32.DLL!\n")); 56 return VERR_NOT_IMPLEMENTED; 57 } 58 else if (OSinfo.dwMajorVersion >= 5) /* APIs available only on W2K and up! */ 46 59 { 47 60 *(uintptr_t *)&gCtx.pfnChangeDisplaySettingsEx = (uintptr_t)GetProcAddress(hUser, "ChangeDisplaySettingsExA"); 48 dprintf(("VBoxService: pChangeDisplaySettingsEx = %p\n", gCtx.pfnChangeDisplaySettingsEx)); 49 } 61 dprintf(("VBoxService: pfnChangeDisplaySettingsEx = %p\n", gCtx.pfnChangeDisplaySettingsEx)); 62 63 *(uintptr_t *)&gCtx.pfnEnumDisplayDevices = (uintptr_t)GetProcAddress(hUser, "EnumDisplayDevicesA"); 64 dprintf(("VBoxService: pfnEnumDisplayDevices = %p\n", gCtx.pfnEnumDisplayDevices)); 65 } 66 else if (OSinfo.dwMajorVersion <= 4) /* Windows NT 4.0 */ 67 { 68 /* Nothing to do here yet */ 69 } 70 else /* Unsupported platform */ 71 { 72 dprintf(("VBoxService: Warning, display for platform not handled yet!\n")); 73 return VERR_NOT_IMPLEMENTED; 74 } 75 76 dprintf(("VBoxService: Display init successful.\n")); 50 77 51 78 *pfStartThread = true; … … 59 86 } 60 87 61 static bool isVBoxDisplayDriverActive ( void)88 static bool isVBoxDisplayDriverActive (VBOXDISPLAYCONTEXT *pCtx) 62 89 { 63 90 bool result = false; 64 91 65 DISPLAY_DEVICE dispDevice; 66 67 FillMemory(&dispDevice, sizeof(DISPLAY_DEVICE), 0); 68 69 dispDevice.cb = sizeof(DISPLAY_DEVICE); 70 71 INT devNum = 0; 72 73 while (EnumDisplayDevices(NULL, 74 devNum, 75 &dispDevice, 76 0)) 77 { 78 dprintf(("DevNum:%d\nName:%s\nString:%s\nID:%s\nKey:%s\nFlags=%08X\n\n", 79 devNum, 80 &dispDevice.DeviceName[0], 81 &dispDevice.DeviceString[0], 82 &dispDevice.DeviceID[0], 83 &dispDevice.DeviceKey[0], 84 dispDevice.StateFlags)); 85 86 if (dispDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) 87 { 88 dprintf(("Primary device.\n")); 89 90 if (strcmp(&dispDevice.DeviceString[0], "VirtualBox Graphics Adapter") == 0) 92 if( pCtx->pfnEnumDisplayDevices ) 93 { 94 INT devNum = 0; 95 DISPLAY_DEVICE dispDevice; 96 FillMemory(&dispDevice, sizeof(DISPLAY_DEVICE), 0); 97 dispDevice.cb = sizeof(DISPLAY_DEVICE); 98 99 dprintf(("Checking for active VBox display driver (W2K+)...\n")); 100 101 while (EnumDisplayDevices(NULL, 102 devNum, 103 &dispDevice, 104 0)) 105 { 106 dprintf(("DevNum:%d\nName:%s\nString:%s\nID:%s\nKey:%s\nFlags=%08X\n\n", 107 devNum, 108 &dispDevice.DeviceName[0], 109 &dispDevice.DeviceString[0], 110 &dispDevice.DeviceID[0], 111 &dispDevice.DeviceKey[0], 112 dispDevice.StateFlags)); 113 114 if (dispDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) 91 115 { 92 dprintf(("VBox display driver is active.\n")); 93 result = true; 116 dprintf(("Primary device.\n")); 117 118 if (strcmp(&dispDevice.DeviceString[0], "VirtualBox Graphics Adapter") == 0) 119 result = true; 120 121 break; 94 122 } 95 96 break; 97 } 98 99 FillMemory(&dispDevice, sizeof(DISPLAY_DEVICE), 0); 100 101 dispDevice.cb = sizeof(DISPLAY_DEVICE); 102 103 devNum++; 123 124 FillMemory(&dispDevice, sizeof(DISPLAY_DEVICE), 0); 125 126 dispDevice.cb = sizeof(DISPLAY_DEVICE); 127 128 devNum++; 129 } 130 } 131 else /* This must be NT 4 or something really old, so don't use EnumDisplayDevices() here ... */ 132 { 133 dprintf(("Checking for active VBox display driver (NT or older)...\n")); 134 135 DEVMODE tempDevMode; 136 ZeroMemory (&tempDevMode, sizeof (tempDevMode)); 137 tempDevMode.dmSize = sizeof(DEVMODE); 138 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &tempDevMode); /* Get current display device settings */ 139 140 /* Check for the short name, because all long stuff would be truncated */ 141 if (strcmp((char*)&tempDevMode.dmDeviceName[0], "VBoxDisp") == 0) 142 result = true; 104 143 } 105 144 … … 272 311 paDeviceModes[i].dmBitsPerPel = BitsPerPixel; 273 312 } 274 dprintf(("calling pfnChangeDisplaySettingsEx %x\n", gCtx.pfnChangeDisplaySettingsEx)); 313 314 dprintf(("calling pfnChangeDisplaySettingsEx %x\n", gCtx.pfnChangeDisplaySettingsEx)); 315 275 316 gCtx.pfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName, 276 &paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL); 317 &paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL); 318 277 319 dprintf(("ChangeDisplaySettings position err %d\n", GetLastError ())); 278 320 } … … 372 414 * Only try to change video mode if the active display driver is VBox additions. 373 415 */ 374 if (isVBoxDisplayDriverActive ( ))416 if (isVBoxDisplayDriverActive (pCtx)) 375 417 { 418 dprintf(("VBoxDisplayThread : Display driver is active!\n")); 419 376 420 if (pCtx->pfnChangeDisplaySettingsEx != 0) 377 421 { 422 dprintf(("VBoxDisplayThread : Detected W2K or later.")); 423 378 424 /* W2K or later. */ 379 425 if (!ResizeDisplayDevice(displayChangeRequest.display, … … 387 433 else 388 434 { 435 dprintf(("VBoxDisplayThread : Detected NT.\n")); 436 389 437 /* Single monitor NT. */ 390 438 DEVMODE devMode; … … 413 461 { 414 462 /* All zero values means a forced mode reset. Do nothing. */ 463 dprintf(("VBoxDisplayThread : Forced mode reset.\n")); 415 464 } 416 465 -
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxDisplay.h
r5999 r6360 23 23 void VBoxDisplayDestroy (const VBOXSERVICEENV *pEnv, void *pInstance); 24 24 25 static bool isVBoxDisplayDriverActive (void); 25 26 26 27 #endif /* __VBOXSERVICEDISPLAY__H */ -
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxSeamless.cpp
r5999 r6360 56 56 gCtx.pEnv = pEnv; 57 57 58 OSVERSIONINFO OSinfo; 59 OSinfo.dwOSVersionInfoSize = sizeof (OSinfo); 60 GetVersionEx (&OSinfo); 61 62 /* We have to jump out here when using NT4, otherwise it complains about 63 a missing API function "UnhookWinEvent" used by the dynamically loaded VBoxHook.dll below */ 64 if (OSinfo.dwMajorVersion <= 4) /* Windows NT 4.0 or older */ 65 { 66 dprintf(("VBoxSeamlessInit: Windows NT 4.0 or older not supported!")); 67 return VERR_NOT_SUPPORTED; 68 } 69 58 70 /* Will fail if SetWinEventHook is not present (version < NT4 SP6 apparently) */ 59 71 gCtx.hModule = LoadLibrary(VBOXHOOK_DLL_NAME); … … 72 84 &vmmreqGuestCaps, sizeof(vmmreqGuestCaps), &cbReturned, NULL)) 73 85 { 74 dprintf(("V MMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError()));86 dprintf(("VBoxSeamlessInit: VMMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError())); 75 87 return VERR_INVALID_PARAMETER; 76 88 } … … 82 94 else 83 95 { 84 dprintf(("VBoxSeamlessInit LoadLibrary failed with %d\n", GetLastError()));96 dprintf(("VBoxSeamlessInit: LoadLibrary failed with %d\n", GetLastError())); 85 97 return VERR_INVALID_PARAMETER; 86 98 } … … 405 417 } 406 418 407 -
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxService.cpp
r6169 r6360 30 30 31 31 #include "helpers.h" 32 33 32 #include <sddl.h> 34 33 … … 69 68 pReq->header.size += strlen(pReq->szString); 70 69 70 printf("%s\n", pReq->szString); 71 72 FILE* pFh = fopen("c:\\VBoxServiceDebug.txt", "at"); 73 74 /* Does maybe not work on Vista (write protection when starting without admin rights), 75 so do this check! */ 76 if (NULL != pFh) 77 { 78 fprintf(pFh, "%s", pReq->szString); 79 fclose(pFh); 80 } 81 71 82 DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_VMMREQUEST, pReq, pReq->header.size, 72 83 pReq, pReq->header.size, &cbReturned, NULL); … … 135 146 static int vboxStartServices (VBOXSERVICEENV *pEnv, VBOXSERVICEINFO *pTable) 136 147 { 148 dprintf(("VBoxService: Starting services...\n")); 149 137 150 pEnv->hStopEvent = CreateEvent(NULL, TRUE, FALSE, NULL); 138 151 … … 262 275 if (gVBoxDriver == INVALID_HANDLE_VALUE) 263 276 { 264 dprintf(("VBoxService: could not open VBox Guest Additions driver! rc = %d\n", GetLastError()));277 dprintf(("VBoxService: could not open VBox Guest Additions driver! Please install / start it first! rc = %d\n", GetLastError())); 265 278 status = ERROR_GEN_FAILURE; 266 279 } … … 315 328 if (gStopSem == NULL) 316 329 { 317 dprintf(("VBoxService: CreateEvent f ailed: rc = %d\n", GetLastError()));330 dprintf(("VBoxService: CreateEvent for Stopping failed: rc = %d\n", GetLastError())); 318 331 return; 319 332 } … … 377 390 } 378 391 379 ghSeamlessNotifyEvent = CreateEvent(&SecAttr, FALSE, FALSE, VBOXHOOK_GLOBAL_EVENT_NAME); 380 if (ghSeamlessNotifyEvent == NULL) 381 { 382 dprintf(("VBoxService: CreateEvent failed: rc = %d\n", GetLastError())); 383 return; 392 if (dwMajorVersion >= 5) /* Only for W2K and up ... */ 393 { 394 ghSeamlessNotifyEvent = CreateEvent(&SecAttr, FALSE, FALSE, VBOXHOOK_GLOBAL_EVENT_NAME); 395 if (ghSeamlessNotifyEvent == NULL) 396 { 397 dprintf(("VBoxService: CreateEvent for Seamless failed: rc = %d\n", GetLastError())); 398 return; 399 } 384 400 } 385 401 } … … 430 446 * Wait for the stop semaphore to be posted or a window event to arrive 431 447 */ 448 449 DWORD dwEventCount = 2; 432 450 HANDLE hWaitEvent[2] = {gStopSem, ghSeamlessNotifyEvent}; 451 452 if (0 == ghSeamlessNotifyEvent) /* If seamless mode is not active / supported, reduce event array count */ 453 dwEventCount = 1; 454 455 dprintf(("VBoxService: Number of events to wait in main loop: %ld\n", dwEventCount)); 456 433 457 while(true) 434 458 { 435 DWORD waitResult = MsgWaitForMultipleObjectsEx(2, hWaitEvent, 500, QS_ALLINPUT, 0); 436 if (waitResult == WAIT_OBJECT_0) 437 { 438 dprintf(("VBoxService: exit\n")); 459 DWORD waitResult = MsgWaitForMultipleObjectsEx(dwEventCount, hWaitEvent, 500, QS_ALLINPUT, 0); 460 waitResult = waitResult - WAIT_OBJECT_0; 461 462 dprintf(("VBoxService: Wait result = %ld.\n", waitResult)); 463 464 if (waitResult == 0) 465 { 466 dprintf(("VBoxService: Event 'Exit' triggered.\n")); 439 467 /* exit */ 440 468 break; 441 469 } 442 else 443 if (waitResult == WAIT_OBJECT_0+1) 444 { 470 else if ((waitResult == 1) && (ghSeamlessNotifyEvent!=0)) /* Only jump in, if seamless is active! */ 471 { 472 dprintf(("VBoxService: Event 'Seamless' triggered.\n")); 473 445 474 /* seamless window notification */ 446 475 VBoxSeamlessCheckWindows(); … … 504 533 dprintf(("VBoxService: WinMain\n")); 505 534 gInstance = hInstance; 506 VBoxServiceStart (); 535 VBoxServiceStart(); 536 507 537 return 0; 508 538 } … … 546 576 return 0; 547 577 } 548
Note:
See TracChangeset
for help on using the changeset viewer.