VirtualBox

Ignore:
Timestamp:
Jun 3, 2019 1:52:06 PM (6 years ago)
Author:
vboxsync
Message:

VBoxTray: Use RTSystemGetNtVersion() rather than GetVersion or GetVersionEx for determining the actual windows version. Some cleanups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp

    r78809 r78937  
    142142HWND                  g_hwndToolWindow;
    143143NOTIFYICONDATA        g_NotifyIconData;
    144 DWORD                 g_dwMajorVersion;
    145144
    146145uint32_t              g_fGuestDisplaysChanged = 0;
     
    685684static int vboxTraySetupSeamless(void)
    686685{
    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 
    696686    /* We need to setup a security descriptor to allow other processes modify access to the seamless notification event semaphore. */
    697687    SECURITY_ATTRIBUTES     SecAttr;
     
    713703    {
    714704        /* 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))
    716707        {
    717708            BOOL (WINAPI * pfnConvertStringSecurityDescriptorToSecurityDescriptorA)(LPCSTR StringSecurityDescriptor, DWORD StringSDRevision, PSECURITY_DESCRIPTOR  *SecurityDescriptor, PULONG  SecurityDescriptorSize);
     
    755746
    756747        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 ... */
    758749        {
    759750            g_hSeamlessWtNotifyEvent = CreateEvent(&SecAttr, FALSE, FALSE, VBOXHOOK_GLOBAL_WT_EVENT_NAME);
     
    837828        else
    838829        {
     830            uint64_t const uNtVersion = RTSystemGetNtVersion();
    839831            rc = vboxTrayCreateTrayIcon();
    840832            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 ... */
    842834            {
    843835                /* We're ready to create the tooltip balloon.
     
    998990        if (RT_SUCCESS(rc))
    999991        {
     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
    1000997            /* Save instance handle. */
    1001998            g_hInstance = hInstance;
     
    14651462static int vboxDtInit()
    14661463{
    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 
    14771464    RT_ZERO(gVBoxDt);
    14781465
     1466    int rc;
    14791467    gVBoxDt.hNotifyEvent = CreateEvent(NULL, FALSE, FALSE, VBOXHOOK_GLOBAL_DT_EVENT_NAME);
    14801468    if (gVBoxDt.hNotifyEvent != NULL)
     
    15231511                    BOOL fRc = FALSE;
    15241512                    /* 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))
    15261515                    {
    15271516                        HMODULE hModHook = (HMODULE)RTLdrGetNativeHandle(gVBoxDt.hLdrModHook);
Note: See TracChangeset for help on using the changeset viewer.

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