Changeset 78937 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Jun 3, 2019 1:52:06 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 131059
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxTray
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp
r76553 r78937 16 16 */ 17 17 18 19 /********************************************************************************************************************************* 20 * Header Files * 21 *********************************************************************************************************************************/ 18 22 #include "VBoxTray.h" 19 23 #define _WIN32_WINNT 0x0601 … … 21 25 #include <iprt/errcore.h> 22 26 #include <iprt/assert.h> 27 #include <iprt/system.h> 23 28 24 29 #include <malloc.h> … … 644 649 { 645 650 DWORD err = NO_ERROR; 646 OSVERSIONINFO OSinfo; 647 OSinfo.dwOSVersionInfoSize = sizeof (OSinfo); 648 GetVersionEx (&OSinfo); 649 bool bSupported = true; 650 651 if (OSinfo.dwMajorVersion >= 6) 651 652 bool fSupported = true; 653 654 uint64_t const uNtVersion = RTSystemGetNtVersion(); 655 if (uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(6, 0, 0)) 652 656 { 653 657 LogFunc(("this is vista and up\n")); … … 657 661 *(uintptr_t *)&pIf->modeData.wddm.pfnChangeDisplaySettingsEx = (uintptr_t)GetProcAddress(hUser, "ChangeDisplaySettingsExA"); 658 662 LogFunc(("VBoxDisplayInit: pfnChangeDisplaySettingsEx = %p\n", pIf->modeData.wddm.pfnChangeDisplaySettingsEx)); 659 bSupported &= !!(pIf->modeData.wddm.pfnChangeDisplaySettingsEx);663 fSupported &= !!(pIf->modeData.wddm.pfnChangeDisplaySettingsEx); 660 664 661 665 *(uintptr_t *)&pIf->modeData.wddm.pfnEnumDisplayDevices = (uintptr_t)GetProcAddress(hUser, "EnumDisplayDevicesA"); 662 666 LogFunc(("VBoxDisplayInit: pfnEnumDisplayDevices = %p\n", pIf->modeData.wddm.pfnEnumDisplayDevices)); 663 bSupported &= !!(pIf->modeData.wddm.pfnEnumDisplayDevices); 667 fSupported &= !!(pIf->modeData.wddm.pfnEnumDisplayDevices); 668 664 669 /* for win 7 and above */ 665 if (OSinfo.dwMinorVersion >= 1)670 if (uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(6, 1, 0)) 666 671 { 667 672 *(uintptr_t *)&gCtx.pfnSetDisplayConfig = (uintptr_t)GetProcAddress(hUser, "SetDisplayConfig"); 668 673 LogFunc(("VBoxDisplayInit: pfnSetDisplayConfig = %p\n", gCtx.pfnSetDisplayConfig)); 669 bSupported &= !!(gCtx.pfnSetDisplayConfig);674 fSupported &= !!(gCtx.pfnSetDisplayConfig); 670 675 671 676 *(uintptr_t *)&gCtx.pfnQueryDisplayConfig = (uintptr_t)GetProcAddress(hUser, "QueryDisplayConfig"); 672 677 LogFunc(("VBoxDisplayInit: pfnQueryDisplayConfig = %p\n", gCtx.pfnQueryDisplayConfig)); 673 bSupported &= !!(gCtx.pfnQueryDisplayConfig);678 fSupported &= !!(gCtx.pfnQueryDisplayConfig); 674 679 675 680 *(uintptr_t *)&gCtx.pfnGetDisplayConfigBufferSizes = (uintptr_t)GetProcAddress(hUser, "GetDisplayConfigBufferSizes"); 676 681 LogFunc(("VBoxDisplayInit: pfnGetDisplayConfigBufferSizes = %p\n", gCtx.pfnGetDisplayConfigBufferSizes)); 677 bSupported &= !!(gCtx.pfnGetDisplayConfigBufferSizes);682 fSupported &= !!(gCtx.pfnGetDisplayConfigBufferSizes); 678 683 } 679 684 … … 2529 2534 DWORD err = NO_ERROR; 2530 2535 2531 OSVERSIONINFO OSinfo; 2532 OSinfo.dwOSVersionInfoSize = sizeof(OSinfo); 2533 GetVersionEx (&OSinfo); 2534 if (OSinfo.dwMajorVersion >= 5) 2536 uint64_t const uNtVersion = RTSystemGetNtVersion(); 2537 if (uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(5, 0, 0)) 2535 2538 { 2536 2539 HMODULE hUser = GetModuleHandle("user32.dll"); 2537 2540 if (NULL != hUser) 2538 2541 { 2539 bool bSupported = true;2540 2542 *(uintptr_t *)&pIf->modeData.xpdm.pfnChangeDisplaySettingsEx = (uintptr_t)GetProcAddress(hUser, "ChangeDisplaySettingsExA"); 2541 2543 LogFunc(("pfnChangeDisplaySettingsEx = %p\n", pIf->modeData.xpdm.pfnChangeDisplaySettingsEx)); 2542 bSupported &= !!(pIf->modeData.xpdm.pfnChangeDisplaySettingsEx); 2543 2544 if (!bSupported) 2544 bool const fSupported = RT_BOOL(pIf->modeData.xpdm.pfnChangeDisplaySettingsEx); 2545 if (!fSupported) 2545 2546 { 2546 2547 WARN_FUNC(("pfnChangeDisplaySettingsEx function pointer failed to initialize\n")); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
r76553 r78937 29 29 # include <iprt/asm.h> 30 30 #endif 31 #include <iprt/system.h> 31 32 32 33 #ifdef DEBUG /** @todo r=bird: these are all default values. sigh. */ … … 82 83 AssertPtr(pCtx); 83 84 84 OSVERSIONINFO OSinfo; /** @todo r=andy Use VBoxTray's g_dwMajorVersion? */85 OSinfo.dwOSVersionInfoSize = sizeof(OSinfo);86 GetVersionEx (&OSinfo);87 88 85 int rc; 89 86 HMODULE hUser = GetModuleHandle("user32.dll"); /** @todo r=andy Use RTLdrXXX and friends. */ … … 91 88 pCtx->pEnv = pEnv; 92 89 90 uint64_t const uNtVersion = RTSystemGetNtVersion(); 91 93 92 if (NULL == hUser) 94 93 { … … 96 95 rc = VERR_NOT_IMPLEMENTED; 97 96 } 98 else if ( OSinfo.dwMajorVersion >= 5)/* APIs available only on W2K and up. */97 else if (uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(5, 0, 0)) /* APIs available only on W2K and up. */ 99 98 { 100 99 /** @todo r=andy Use RTLdrXXX and friends. */ … … 107 106 108 107 #ifdef VBOX_WITH_WDDM 109 if ( OSinfo.dwMajorVersion >= 6)108 if (uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(6, 0, 0)) 110 109 { 111 110 /* This is Vista and up, check if we need to switch the display driver if to WDDM mode. */ … … 116 115 LogFlowFunc(("WDDM driver is installed, switching display driver if to WDDM mode\n")); 117 116 /* This is hacky, but the most easiest way. */ 118 VBOXDISPIF_MODE enmMode = (OSinfo.dwMajorVersion == 6 && OSinfo.dwMinorVersion == 0) ? VBOXDISPIF_MODE_WDDM : VBOXDISPIF_MODE_WDDM_W7; 117 VBOXDISPIF_MODE enmMode = uNtVersion < RTSYSTEM_MAKE_NT_VERSION(6, 1, 0) 118 ? VBOXDISPIF_MODE_WDDM : VBOXDISPIF_MODE_WDDM_W7; 119 119 DWORD dwErr = VBoxDispIfSwitchMode(const_cast<PVBOXDISPIF>(&pEnv->dispIf), enmMode, NULL /* old mode, we don't care about it */); 120 120 if (dwErr == NO_ERROR) … … 136 136 #endif 137 137 } 138 else if ( OSinfo.dwMajorVersion <= 4) /* Windows NT 4.0. */138 else if (uNtVersion < RTSYSTEM_MAKE_NT_VERSION(5, 0, 0)) /* Windows NT 4.0. */ 139 139 { 140 140 /* Nothing to do here yet. */ … … 280 280 deviceMode.dmPosition.y = 0; 281 281 deviceMode.dmBitsPerPel = 32; 282 OSVERSIONINFO OSinfo; 283 OSinfo.dwOSVersionInfoSize = sizeof (OSinfo); 284 GetVersionEx (&OSinfo); 285 286 if (OSinfo.dwMajorVersion < 6) 282 283 uint64_t const uNtVersion = RTSystemGetNtVersion(); 284 if (uNtVersion < RTSYSTEM_MAKE_NT_VERSION(6, 0, 0)) 287 285 /* dont any more flags here as, only DM_POISITON is used to enable the secondary display */ 288 286 deviceMode.dmFields = DM_POSITION; 289 287 else /* for win 7 and above */ 290 288 /* for vista and above DM_BITSPERPEL is necessary */ 291 deviceMode.dmFields = 289 deviceMode.dmFields = DM_BITSPERPEL | DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY | DM_POSITION; 292 290 293 291 dwStatus = pCtx->pfnChangeDisplaySettingsEx((LPSTR)displayDevice.DeviceName,&deviceMode, NULL, (CDS_UPDATEREGISTRY | CDS_NORESET), NULL); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHelpers.cpp
r76553 r78937 20 20 #include <iprt/string.h> 21 21 #include <iprt/alloca.h> 22 #include <iprt/system.h> 22 23 #include <VBox/Log.h> 23 24 #include <VBox/VBoxGuestLib.h> … … 290 291 /* Do we want to have */ 291 292 292 /* Get running OS version. */293 OSVERSIONINFO osInfo;294 osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);295 if (FALSE == GetVersionEx(&osInfo))296 return RTErrConvertFromWin32(GetLastError());297 298 293 /* Is the current OS supported (at least WinXP) for displaying 299 294 * our own icon and do we actually *want* to display our own stuff? */ 300 if ( osInfo.dwMajorVersion >= 5 295 uint64_t const uNtVersion = RTSystemGetNtVersion(); 296 if ( uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(5, 0, 0) 301 297 && (dwInfoFlags & NIIF_INFO)) 302 298 { … … 306 302 niData.dwInfoFlags = NIIF_USER; /* Use an own notification icon. */ 307 303 308 if ( osInfo.dwMajorVersion == 5 309 && osInfo.dwMinorVersion == 1) /* WinXP. */ 304 if (uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(5, 1, 0)) /* WinXP. */ 310 305 { 311 306 /* Use an own icon instead of the default one. */ 312 307 niData.hIcon = hIcon; 313 308 } 314 else if ( osInfo.dwMajorVersion == 6) /* Vista and up. */309 else if (uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(6, 0, 0)) /* Vista and up. */ 315 310 { 316 311 /* Use an own icon instead of the default one. */ -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxSeamless.cpp
r76553 r78937 21 21 #include <iprt/assert.h> 22 22 #include <iprt/ldr.h> 23 #include <iprt/system.h> 23 24 24 25 #include <VBoxDisplay.h> … … 69 70 pCtx->hModHook = NIL_RTLDRMOD; 70 71 71 OSVERSIONINFO OSinfo;72 OSinfo.dwOSVersionInfoSize = sizeof (OSinfo);73 GetVersionEx (&OSinfo);74 75 72 int rc; 76 73 77 74 /* We have to jump out here when using NT4, otherwise it complains about 78 75 a missing API function "UnhookWinEvent" used by the dynamically loaded VBoxHook.dll below */ 79 if (OSinfo.dwMajorVersion <= 4) /* Windows NT 4.0 or older */ 76 uint64_t const uNtVersion = RTSystemGetNtVersion(); 77 if (uNtVersion < RTSYSTEM_MAKE_NT_VERSION(5, 0, 0)) /* Windows NT 4.0 or older */ 80 78 { 81 79 Log(("VBoxTray: VBoxSeamlessInit: Windows NT 4.0 or older not supported!\n")); … … 214 212 char szWindowText[256]; 215 213 char szWindowClass[256]; 216 OSVERSIONINFO OSinfo;217 214 HWND hStart = NULL; 218 215 … … 223 220 GetClassName(hwnd, szWindowClass, sizeof(szWindowClass)); 224 221 225 OSinfo.dwOSVersionInfoSize = sizeof (OSinfo); 226 GetVersionEx (&OSinfo); 227 228 if (OSinfo.dwMajorVersion >= 6) 222 uint64_t const uNtVersion = RTSystemGetNtVersion(); 223 if (uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(6, 0, 0)) 229 224 { 230 225 hStart = ::FindWindowEx(GetDesktopWindow(), NULL, "Button", "Start"); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp
r78809 r78937 142 142 HWND g_hwndToolWindow; 143 143 NOTIFYICONDATA g_NotifyIconData; 144 DWORD g_dwMajorVersion;145 144 146 145 uint32_t g_fGuestDisplaysChanged = 0; … … 685 684 static int vboxTraySetupSeamless(void) 686 685 { 687 OSVERSIONINFO info;688 g_dwMajorVersion = 5; /* Default to Windows XP. */689 info.dwOSVersionInfoSize = sizeof(info);690 if (GetVersionEx(&info))691 {692 Log(("Windows version %ld.%ld\n", info.dwMajorVersion, info.dwMinorVersion));693 g_dwMajorVersion = info.dwMajorVersion;694 }695 696 686 /* We need to setup a security descriptor to allow other processes modify access to the seamless notification event semaphore. */ 697 687 SECURITY_ATTRIBUTES SecAttr; … … 713 703 { 714 704 /* For Vista and up we need to change the integrity of the security descriptor, too. */ 715 if (g_dwMajorVersion >= 6) 705 uint64_t const uNtVersion = RTSystemGetNtVersion(); 706 if (uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(6, 0, 0)) 716 707 { 717 708 BOOL (WINAPI * pfnConvertStringSecurityDescriptorToSecurityDescriptorA)(LPCSTR StringSecurityDescriptor, DWORD StringSDRevision, PSECURITY_DESCRIPTOR *SecurityDescriptor, PULONG SecurityDescriptorSize); … … 755 746 756 747 if ( dwErr == ERROR_SUCCESS 757 && g_dwMajorVersion >= 5) /* Only for W2K and up ... */748 && uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(5, 0, 0)) /* Only for W2K and up ... */ 758 749 { 759 750 g_hSeamlessWtNotifyEvent = CreateEvent(&SecAttr, FALSE, FALSE, VBOXHOOK_GLOBAL_WT_EVENT_NAME); … … 837 828 else 838 829 { 830 uint64_t const uNtVersion = RTSystemGetNtVersion(); 839 831 rc = vboxTrayCreateTrayIcon(); 840 832 if ( RT_SUCCESS(rc) 841 && g_dwMajorVersion >= 5) /* Only for W2K and up ... */833 && uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(5, 0, 0)) /* Only for W2K and up ... */ 842 834 { 843 835 /* We're ready to create the tooltip balloon. … … 998 990 if (RT_SUCCESS(rc)) 999 991 { 992 /* Log the major windows NT version: */ 993 uint64_t const uNtVersion = RTSystemGetNtVersion(); 994 LogRel(("Windows version %u.%u build %u (uNtVersion=%#RX64)\n", RTSYSTEM_NT_VERSION_GET_MAJOR(uNtVersion), 995 RTSYSTEM_NT_VERSION_GET_MINOR(uNtVersion), RTSYSTEM_NT_VERSION_GET_BUILD(uNtVersion), uNtVersion )); 996 1000 997 /* Save instance handle. */ 1001 998 g_hInstance = hInstance; … … 1465 1462 static int vboxDtInit() 1466 1463 { 1467 int rc = VINF_SUCCESS;1468 OSVERSIONINFO info;1469 g_dwMajorVersion = 5; /* Default to Windows XP. */1470 info.dwOSVersionInfoSize = sizeof(info);1471 if (GetVersionEx(&info))1472 {1473 LogRel(("Windows version %ld.%ld\n", info.dwMajorVersion, info.dwMinorVersion));1474 g_dwMajorVersion = info.dwMajorVersion;1475 }1476 1477 1464 RT_ZERO(gVBoxDt); 1478 1465 1466 int rc; 1479 1467 gVBoxDt.hNotifyEvent = CreateEvent(NULL, FALSE, FALSE, VBOXHOOK_GLOBAL_DT_EVENT_NAME); 1480 1468 if (gVBoxDt.hNotifyEvent != NULL) … … 1523 1511 BOOL fRc = FALSE; 1524 1512 /* For Vista and up we need to change the integrity of the security descriptor, too. */ 1525 if (g_dwMajorVersion >= 6) 1513 uint64_t const uNtVersion = RTSystemGetNtVersion(); 1514 if (uNtVersion >= RTSYSTEM_MAKE_NT_VERSION(6, 0, 0)) 1526 1515 { 1527 1516 HMODULE hModHook = (HMODULE)RTLdrGetNativeHandle(gVBoxDt.hLdrModHook); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.h
r78809 r78937 22 22 #endif 23 23 24 # define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap25 # define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap26 # define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap27 # define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap28 # define _interlockedbittestandset _interlockedbittestandset_StupidDDKVsCompilerCrap29 # define _interlockedbittestandreset _interlockedbittestandreset_StupidDDKVsCompilerCrap30 # define _interlockedbittestandset64 _interlockedbittestandset64_StupidDDKVsCompilerCrap31 # define _interlockedbittestandreset64 _interlockedbittestandreset64_StupidDDKVsCompilerCrap32 # pragma warning(disable : 4163)33 24 #include <iprt/win/windows.h> 34 # pragma warning(default : 4163)35 # undef _InterlockedExchange36 # undef _InterlockedExchangeAdd37 # undef _InterlockedCompareExchange38 # undef _InterlockedAddLargeStatistic39 # undef _interlockedbittestandset40 # undef _interlockedbittestandreset41 # undef _interlockedbittestandset6442 # undef _interlockedbittestandreset6443 25 44 26 #include <tchar.h> … … 189 171 } VBOXGLOBALMESSAGE, *PVBOXGLOBALMESSAGE; 190 172 173 extern HINSTANCE g_hInstance; 191 174 extern HWND g_hwndToolWindow; 192 extern HINSTANCE g_hInstance;193 175 extern uint32_t g_fGuestDisplaysChanged; 194 176
Note:
See TracChangeset
for help on using the changeset viewer.