VirtualBox

Changeset 77150 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 4, 2019 1:48:58 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128623
Message:

Graphics/VideoMP: Fixed retrieving the product build version of VBoxQueryWinVersion() when being called the first time. Added a @todo.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPUtils.cpp

    r76553 r77150  
    4040
    4141/*Returns the windows version we're running on*/
     42/** @todo r=andy Use RTSystemQueryOSInfo() instead? This also does caching and stuff. */
    4243vboxWinVersion_t VBoxQueryWinVersion(uint32_t *pbuild)
    4344{
     45    static ULONG            s_pbuild     = 0;
     46    static vboxWinVersion_t s_WinVersion = WINVERSION_UNKNOWN;
     47
    4448    ULONG major, minor;
    45     static ULONG build = 0;
    4649    BOOLEAN checkedBuild;
    47     static vboxWinVersion_t s_WinVersion = WINVERSION_UNKNOWN;
    48 
    49     if (s_WinVersion != WINVERSION_UNKNOWN)
    50     {
    51         if (pbuild)
    52             *pbuild = build;
    53 
    54         return s_WinVersion;
    55     }
    56 
    57     checkedBuild = PsGetVersion(&major, &minor, &build, NULL);
    58     LOG(("running on version %d.%d, build %d(checked=%d)", major, minor, build, (int)checkedBuild));
    59 
    60     if (major > 6)
    61     {
    62         /* Everything newer than Windows 8.1, i.e. Windows 10 with major == 10. */
    63         s_WinVersion = WINVERSION_10;
    64     }
    65     else if (major == 6)
    66     {
    67         if (minor >= 4)
     50
     51    if (s_WinVersion == WINVERSION_UNKNOWN)
     52    {
     53        checkedBuild = PsGetVersion(&major, &minor, &s_pbuild, NULL);
     54        LOG(("running on version %d.%d, build %d(checked=%d)", major, minor, s_pbuild, (int)checkedBuild));
     55
     56        if (major > 6)
     57        {
     58            /* Everything newer than Windows 8.1, i.e. Windows 10 with major == 10. */
    6859            s_WinVersion = WINVERSION_10;
    69         else if (minor == 3)
    70             s_WinVersion = WINVERSION_81;
    71         else if (minor == 2)
    72             s_WinVersion = WINVERSION_8;
    73         else if (minor == 1)
    74             s_WinVersion = WINVERSION_7;
    75         else if (minor == 0)
    76             s_WinVersion = WINVERSION_VISTA; /* Or Windows Server 2008. */
    77     }
    78     else if (major == 5)
    79         s_WinVersion = (minor>=1) ? WINVERSION_XP: WINVERSION_2K;
    80     else if (major == 4)
    81         s_WinVersion = WINVERSION_NT4;
    82     else
    83         WARN(("NT4 required!"));
     60        }
     61        else if (major == 6)
     62        {
     63            if (minor >= 4)
     64                s_WinVersion = WINVERSION_10;
     65            else if (minor == 3)
     66                s_WinVersion = WINVERSION_81;
     67            else if (minor == 2)
     68                s_WinVersion = WINVERSION_8;
     69            else if (minor == 1)
     70                s_WinVersion = WINVERSION_7;
     71            else if (minor == 0)
     72                s_WinVersion = WINVERSION_VISTA; /* Or Windows Server 2008. */
     73        }
     74        else if (major == 5)
     75            s_WinVersion = (minor>=1) ? WINVERSION_XP: WINVERSION_2K;
     76        else if (major == 4)
     77            s_WinVersion = WINVERSION_NT4;
     78        else
     79            WARN(("NT4 required!"));
     80    }
     81
     82    if (pbuild)
     83        *pbuild = s_pbuild;
     84
    8485    return s_WinVersion;
    8586}
Note: See TracChangeset for help on using the changeset viewer.

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