VirtualBox

Changeset 108081 in vbox


Ignore:
Timestamp:
Feb 5, 2025 5:28:52 PM (2 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167375
Message:

Windows driver installation: Added installer shim detection by comparing the OS versions found by the API vs. the one found in the registry. Use the one in the registry by default if they differ. bugref:10762

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/installation/VBoxWinDrvInst.cpp

    r107994 r108081  
    19651965        pCtx->pvUser     = pvUser;
    19661966
     1967        /* 1. Detect the Windows version using API calls. */
    19671968        pCtx->uOsVer     = RTSystemGetNtVersion(); /* Might be overwritten later via VBoxWinDrvInstSetOsVersion(). */
     1969
     1970        /* 2. Detect the Windows from the registry. */
     1971        HKEY hKey;
     1972        LSTATUS lrc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey);
     1973        if (lrc == ERROR_SUCCESS)
     1974        {
     1975            DWORD dwMaj;
     1976            rc = VBoxWinDrvRegQueryDWORD(hKey, "CurrentMajorVersionNumber", &dwMaj);
     1977            if (RT_SUCCESS(rc))
     1978            {
     1979                DWORD dwMin;
     1980                rc = VBoxWinDrvRegQueryDWORD(hKey, "CurrentMinorVersionNumber", &dwMin);
     1981                if (RT_SUCCESS(rc))
     1982                {
     1983                    uint64_t const uRegOsVer = RTSYSTEM_MAKE_NT_VERSION(dwMaj, dwMin, 0 /* Build, ignored */);
     1984
     1985                    /* When running this code in context of an MSI installer, the MSI engine might shim the Windows
     1986                     * version which is being reported via API calls. So compare the both OS versions
     1987                     * and prefer the one being reported via the registry if they don't match.
     1988                     *
     1989                     * The OS version to use still can be later tweaked using VBoxWinDrvInstSetOsVersion(). */
     1990                    if (   (pCtx->uOsVer != uRegOsVer)
     1991                        && RTSYSTEM_NT_VERSION_GET_MAJOR(uRegOsVer) > 4 /* XP+ */)
     1992                    {
     1993                        vboxWinDrvInstLogWarn(pCtx, "Detected Windows version (%u.%u) does not match the one stored in the registry (%u.%u)",
     1994                                              RTSYSTEM_NT_VERSION_GET_MAJOR(pCtx->uOsVer),
     1995                                              RTSYSTEM_NT_VERSION_GET_MINOR(pCtx->uOsVer),
     1996                                              RTSYSTEM_NT_VERSION_GET_MAJOR(uRegOsVer),
     1997                                              RTSYSTEM_NT_VERSION_GET_MINOR(uRegOsVer));
     1998
     1999                        /* Override the OS version from the API with the one found in the registry. */
     2000                        VBoxWinDrvInstSetOsVersion(pCtx, uRegOsVer);
     2001                    }
     2002                }
     2003            }
     2004
     2005            RegCloseKey(hKey);
     2006        }
     2007        /* else not fatal. */
    19682008
    19692009        vboxWinDrvInstLogInfo(pCtx, VBOX_PRODUCT " Version " VBOX_VERSION_STRING " - r%s", RTBldCfgRevisionStr());
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