VirtualBox

Ignore:
Timestamp:
Jan 27, 2025 4:57:39 PM (2 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167195
Message:

Host installer/win: Added GetPlatformArchitecture() to the VBoxInstallHelper.dll. bugref:10849

Location:
trunk/src/VBox/Installer/win/InstallHelper
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp

    r106321 r107948  
    146146}
    147147
     148/**
     149 * Sets a MSI property.
     150 *
     151 * @returns UINT
     152 * @param   hMsi                MSI handle to use.
     153 * @param   pwszName            Name of property to set.
     154 * @param   pwszValue           Value to set.
     155 */
    148156UINT VBoxMsiSetProp(MSIHANDLE hMsi, const WCHAR *pwszName, const WCHAR *pwszValue)
    149157{
    150158    return MsiSetPropertyW(hMsi, pwszName, pwszValue);
    151159}
    152 #endif
    153 
     160#endif /* TESTCASE */
     161
     162/**
     163 * Sets a MSI property (in UTF-8).
     164 *
     165 * Convenience function for VBoxMsiSetProp().
     166 *
     167 * @returns VBox status code.
     168 * @param   hMsi                MSI handle to use.
     169 * @param   pszName             Name of property to set.
     170 * @param   pszValue            Value to set.
     171 */
     172int VBoxMsiSetPropUtf8(MSIHANDLE hMsi, const char *pszName, const char *pszValue)
     173{
     174    AssertPtrReturn(pszName, VERR_INVALID_POINTER);
     175    AssertPtrReturn(pszValue, VERR_INVALID_POINTER);
     176
     177    PRTUTF16 pwszName;
     178    int rc = RTStrToUtf16(pszName, &pwszName);
     179    if (RT_SUCCESS(rc))
     180    {
     181        PRTUTF16 pwszValue;
     182        rc = RTStrToUtf16(pszValue, &pwszValue);
     183        if (RT_SUCCESS(rc))
     184        {
     185            UINT const uRc = VBoxMsiSetProp(hMsi, pwszName, pwszValue);
     186            if (uRc != ERROR_SUCCESS)
     187                rc = RTErrConvertFromWin32(uRc);
     188            RTUtf16Free(pwszValue);
     189        }
     190
     191        RTUtf16Free(pwszName);
     192    }
     193
     194    return rc;
     195}
     196
     197/**
     198 * Sets a MSI property (DWORD).
     199 *
     200 * Convenience function for VBoxMsiSetProp().
     201 *
     202 * @returns UINT
     203 * @param   hMsi                MSI handle to use.
     204 * @param   pwszName            Name of property to set.
     205 * @param   dwVal               Value to set.
     206 */
    154207UINT VBoxMsiSetPropDWORD(MSIHANDLE hMsi, const WCHAR *pwszName, DWORD dwVal)
    155208{
     
    158211    return VBoxMsiSetProp(hMsi, pwszName, wszTemp);
    159212}
    160 
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxCommon.h

    r106321 r107948  
    4141int  VBoxMsiQueryPropInt32(MSIHANDLE hMsi, const char *pszName, DWORD *pdwValue);
    4242UINT VBoxMsiSetProp(MSIHANDLE hMsi, const WCHAR *pwszName, const WCHAR *pwszValue);
     43int VBoxMsiSetPropUtf8(MSIHANDLE hMsi, const char *pszName, const char *pszValue);
    4344UINT VBoxMsiSetPropDWORD(MSIHANDLE hMsi, const WCHAR *pwszName, DWORD dwVal);
    4445
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxInstallHelper.cpp

    r106839 r107948  
    6565#include <iprt/string.h> /* RT_ZERO */
    6666#include <iprt/stream.h>
     67#include <iprt/system.h>
    6768#include <iprt/thread.h>
    6869#include <iprt/utf16.h>
     
    15791580}
    15801581
     1582/**
     1583 * Returns the platform architecture as a string.
     1584 *
     1585 * Sets public property VBOX_PLATFORM_ARCH to "x86", "amd64" or "arm64" on success.
     1586 * Called from the MSI installer as custom action.
     1587 *
     1588 * @returns UINT as Windows error code.
     1589 * @retval  ERROR_INSTALL_PLATFORM_UNSUPPORTED if the platform is invalid or unsupported.
     1590 * @param   hModule             Windows installer module handle.
     1591 *
     1592 * @note    We don't use WIX' util.QueryNativeMachine, as it's apparently on available on Windows 10 >= 1709.
     1593 */
     1594UINT __stdcall GetPlatformArchitecture(MSIHANDLE hModule)
     1595{
     1596    const char *pszArch;
     1597
     1598RT_BREAKPOINT();
     1599
     1600    /* Only add supported platforms here. */
     1601    uint32_t const uNativeArch = RTSystemGetNativeArch();
     1602    switch (uNativeArch)
     1603    {
     1604        case RT_ARCH_VAL_X86:   pszArch = "x86";   break;
     1605        case RT_ARCH_VAL_AMD64: pszArch = "amd64"; break;
     1606        case RT_ARCH_VAL_ARM64: pszArch = "arm64"; break;
     1607        default:                pszArch = NULL;    break;
     1608    }
     1609
     1610    int rc;
     1611    if (pszArch)
     1612        rc = VBoxMsiSetPropUtf8(hModule, "VBOX_PLATFORM_ARCH", pszArch);
     1613    else
     1614        rc = VERR_NOT_SUPPORTED;
     1615
     1616   logStringF(hModule, "GetPlatformArchitecture: Detected '%s' (%Rrc)", pszArch ? pszArch : "<Unknown>", rc);
     1617
     1618    return RT_SUCCESS(rc) ? ERROR_SUCCESS : ERROR_INSTALL_PLATFORM_UNSUPPORTED;
     1619}
     1620
    15811621#if defined(VBOX_WITH_NETFLT) || defined(VBOX_WITH_NETADP)
    15821622
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxInstallHelper.def

    r106321 r107948  
    3434    IsPythonInstalled
    3535    IsWindows10
     36    GetPlatformArchitecture
    3637    ArePythonAPIDepsInstalled
    3738    InstallPythonAPI
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