VirtualBox

Changeset 96597 in vbox for trunk/src/VBox/Runtime/r3/win


Ignore:
Timestamp:
Sep 4, 2022 10:12:04 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
153474
Message:

IPRT: More correctly fake the extended GetVersionExW/RtlGetVersion output. Missed the dwOSVersionInfoSize for the GetVersion fallback case, which upset some code. Also, for NT4 we discarded the GetVersionExW output for the smaller structure because of a copy & paste error. bugref:10261

Location:
trunk/src/VBox/Runtime/r3/win
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/init-win.cpp

    r96573 r96597  
    324324    /*
    325325     * Use the NT version of RtlGetVersion (since w2k) so we don't get fooled
    326      * by compatability shims.
     326     * by the standard compatibility shims.  (Sandboxes may still fool us.)
     327     *
     328     * Note! This API was added in windows 2000 together with the extended
     329     *       version info structure (OSVERSIONINFOEXW), so there is no need
     330     *       to retry with the smaller version (OSVERSIONINFOW).
    327331     */
    328332    RT_ZERO(g_WinOsInfoEx);
     
    338342        /*
    339343         * Couldn't find it or it failed, try the windows version of the API.
    340          * The GetVersionExW API was added in NT 3.51.
     344         * The GetVersionExW API was added in NT 3.51, however only the small
     345         * structure version existed till windows 2000.  We'll try the larger
     346         * structure version first, anyway, just in case.
    341347         */
    342348        RT_ZERO(g_WinOsInfoEx);
     
    353359            RT_ZERO(g_WinOsInfoEx);
    354360            g_WinOsInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
    355             if (!pfnGetVersionExW || !pfnGetVersionExW((POSVERSIONINFOW)&g_WinOsInfoEx))
     361            if (!pfnGetVersionExW && pfnGetVersionExW((POSVERSIONINFOW)&g_WinOsInfoEx))
    356362                Assert(g_WinOsInfoEx.dwPlatformId != VER_PLATFORM_WIN32_NT || g_WinOsInfoEx.dwMajorVersion < 5);
    357363            else
     
    359365                /*
    360366                 * Okay, nothing worked, so use GetVersion.
     367                 *
    361368                 * This should only happen if we're on NT 3.1 or NT 3.50.
    362369                 * It should never happen for 64-bit builds.
     
    367374
    368375                /* Common fields: */
    369                 g_WinOsInfoEx.dwMajorVersion    = dwVersion & 0xff;
    370                 g_WinOsInfoEx.dwMinorVersion    = (dwVersion >> 8) & 0xff;
     376                g_WinOsInfoEx.dwMajorVersion        = dwVersion & 0xff;
     377                g_WinOsInfoEx.dwMinorVersion        = (dwVersion >> 8) & 0xff;
    371378                if (!(dwVersion & RT_BIT_32(31)))
    372                     g_WinOsInfoEx.dwBuildNumber = dwVersion >> 16;
     379                    g_WinOsInfoEx.dwBuildNumber     = dwVersion >> 16;
    373380                else
    374                     g_WinOsInfoEx.dwBuildNumber = 511;
    375                 g_WinOsInfoEx.dwPlatformId      = VER_PLATFORM_WIN32_NT;
    376                 g_WinOsInfoEx.wProductType      = VER_NT_WORKSTATION;
     381                    g_WinOsInfoEx.dwBuildNumber     = 511;
     382                g_WinOsInfoEx.dwPlatformId          = VER_PLATFORM_WIN32_NT;
    377383                /** @todo get CSD from registry. */
    378384#else
     
    381387#endif
    382388            }
     389
     390#ifdef RT_ARCH_X86
     391            /*
     392             * Fill in some of the extended info too.
     393             */
     394            g_WinOsInfoEx.dwOSVersionInfoSize       = sizeof(OSVERSIONINFOEXW); /* Pretend. */
     395            g_WinOsInfoEx.wProductType              = VER_NT_WORKSTATION;
     396            NT_PRODUCT_TYPE enmProdType = NtProductWinNt;
     397            if (RtlGetNtProductType(&enmProdType))
     398                g_WinOsInfoEx.wProductType = (BYTE)enmProdType;
     399            /** @todo parse the CSD string to figure that version. */
     400#endif
    383401        }
    384402    }
  • trunk/src/VBox/Runtime/r3/win/ntdll-mini-implib.def

    r96505 r96597  
    148148    RtlGetLastWin32Error                  ;;= _RtlGetLastWin32Error@0
    149149    RtlGetVersion                         ;;= _RtlGetVersion@4
     150    RtlGetNtProductType                   ;;= _RtlGetNtProductType@4
    150151    RtlInitializeSid                      ;;= _RtlInitializeSid@12
    151152    RtlNtStatusToDosError                 ;;= _RtlNtStatusToDosError@4
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