VirtualBox

Changeset 95037 in vbox


Ignore:
Timestamp:
May 18, 2022 2:23:26 PM (3 years ago)
Author:
vboxsync
Message:

Windows host installer: More fun for Windows 10 detection, as the former way often did not work and thus wrong / missing certificates were being installed (running .msi directly vs. .exe installer). We now use a custom action via VBoxInstallHelper.dll, which in turn queries the registry for the (hopefully) correct build number. Note that we cannot use any of the RtlGetVersion() / GetVersion[Ex]W() APIs here, as the Windows Installer service seems to shims those, sigh. bugref:8691

Location:
trunk/src/VBox/Installer/win
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/win/CommonProperties.wxi

    r95033 r95037  
    1717         xmlns:difxapp="http://schemas.microsoft.com/wix/DifxAppExtension">
    1818
    19   <!-- MSI is soo messed up wrt NT versioning on Windows 10.  msiexec runs in
    20        Windows 8.1 compatibility mode, so everything returns 6.3 as the
    21        version.  This unfortunately include all system DLLs.  Fortunately,
    22        the build number is left as-is, so we ASSUME build numbers above 10000
    23        means its Windows 10.
    24        Note! "HKLM\Software\Microsoft\Windows NT\CurrentVersion\CurrentBuild" could
    25              probably be read here as well (CurrentVersion is "6.3" of course). -->
    26   <Property Id="VBOX_IS_WINDOWS_10" >
    27     <DirectorySearch Id="DirSearchForWindows10NtDll" Path="[SystemFolder]" >
    28       <FileSearch Name="kernelbase.dll" MinVersion="6.3.10000.000" />
    29     </DirectorySearch>
    30   </Property>
    31 
    3219</Include>
    3320
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxInstallHelper.cpp

    r93343 r95037  
    431431
    432432    VBoxSetMsiProp(hModule, L"VBOX_PYTHON_DEPS_INSTALLED", dwErr == ERROR_SUCCESS ? L"1" : L"0");
     433    return ERROR_SUCCESS; /* Never return failure. */
     434}
     435
     436/**
     437 * Checks if the running OS is (at least) Windows 10 (e.g. >= build 10000).
     438 *
     439 * Called from the MSI installer as custom action.
     440 *
     441 * @returns Always ERROR_SUCCESS.
     442 *          Sets public property VBOX_IS_WINDOWS_10 to "" (empty / false) or "1" (success).
     443 *
     444 * @param   hModule             Windows installer module handle.
     445 */
     446UINT __stdcall IsWindows10(MSIHANDLE hModule)
     447{
     448    /*
     449     * Note: We cannot use RtlGetVersion() / GetVersionExW() here, as the Windows Installer service
     450     *       all shims this, unfortunately. So we have to go another route by querying the major version
     451     *       number from the registry.
     452     */
     453    HKEY hKeyCurVer = NULL;
     454    LSTATUS dwErr = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKeyCurVer);
     455    if (dwErr == ERROR_SUCCESS)
     456    {
     457        DWORD dwVal = 0;
     458        DWORD cbVal = sizeof(dwVal);
     459        DWORD dwValueType = REG_DWORD;
     460        dwErr = RegQueryValueExW(hKeyCurVer, L"CurrentMajorVersionNumber", NULL, &dwValueType, (LPBYTE)&dwVal, &cbVal);
     461        if (dwErr == ERROR_SUCCESS)
     462        {
     463            logStringF(hModule, L"IsWindows10/CurrentMajorVersionNumber: %ld", dwVal);
     464
     465            VBoxSetMsiProp(hModule, L"VBOX_IS_WINDOWS_10", dwVal >= 10 ? L"1" : L"");
     466        }
     467        else
     468            logStringF(hModule, L"IsWindows10/RegOpenKeyExW: Error reading CurrentMajorVersionNumber (%ld)", dwErr);
     469
     470        RegCloseKey(hKeyCurVer);
     471    }
     472    else
     473        logStringF(hModule, L"IsWindows10/RegOpenKeyExW: Error opening CurrentVersion key (%ld)", dwErr);
     474
    433475    return ERROR_SUCCESS; /* Never return failure. */
    434476}
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxInstallHelper.def

    r93242 r95037  
    2121    CheckSerial
    2222    IsPythonInstalled
     23    IsWindows10
    2324    ArePythonAPIDepsInstalled
    2425    InstallPythonAPI
  • trunk/src/VBox/Installer/win/UserInterface.wxi

    r94380 r95037  
    12001200            <Custom Action="ca_OriginalTargetDir" After="FileCost"><![CDATA[(NOT INSTALLDIR) AND (NOT EXISTINGINSTALLDIR)]]></Custom>
    12011201            <Custom Action="ca_DefaultTargetDir" After="FileCost"><![CDATA[NOT Installed AND (NOT INSTALLDIR) AND EXISTINGINSTALLDIR]]></Custom>
     1202            <Custom Action="ca_IsWindows10" After="CostFinalize" />
    12021203
    12031204<?if $(env.VBOX_WITH_PYTHON) = "yes" ?>
  • trunk/src/VBox/Installer/win/VBoxMergeAppCA.wxi

    r82970 r95037  
    1717         xmlns:difxapp="http://schemas.microsoft.com/wix/DifxAppExtension">
    1818
     19    <CustomAction Id="ca_IsWindows10" BinaryKey="VBoxInstallHelper"
     20                  DllEntry="IsWindows10" Execute="immediate" Return="ignore" Impersonate="no" />
     21
    1922</Include>
  • trunk/src/VBox/Installer/win/VBoxMergeAppSeq.wxi

    r82970 r95037  
    1717         xmlns:difxapp="http://schemas.microsoft.com/wix/DifxAppExtension">
    1818
     19    <Custom Action="ca_IsWindows10"  After="FileCost">1</Custom>
     20
    1921</Include>
    2022
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