VirtualBox

Changeset 108071 in vbox


Ignore:
Timestamp:
Feb 5, 2025 2:14:02 PM (2 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167361
Message:

Windows driver installation: Added VBoxWinDrvRegQueryDWORD[W] to have a common base for querying registry values. Required as a prerequisite for unifying the InstallHelper.dll. bugref:10762

Location:
trunk/src/VBox
Files:
5 edited

Legend:

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

    r107901 r108071  
    697697}
    698698
     699/**
     700 * Queries a DWORD value from a Windows registry key, Unicode (wide char) version.
     701 *
     702 * @returns IPRT status code.
     703 * @retval  VERR_FILE_NOT_FOUND if the value has not been found.
     704 * @retval  VERR_WRONG_TYPE if the type (DWORD) of the value does not match.
     705 * @retval  VERR_MISMATCH if the type sizes do not match.
     706 * @param   hKey                    Registry handle of key to query.
     707 * @param   pwszName                Name of the value to query.
     708 * @param   pdwValue                Where to return the actual value on success.
     709 *
     710 * @note    Taken from IPRT's rtSystemWinRegistryQueryDWORDW.
     711 */
     712int VBoxWinDrvRegQueryDWORDW(HKEY hKey, LPCWSTR pwszName, DWORD *pdwValue)
     713{
     714    int rc = VINF_SUCCESS;
     715
     716    DWORD cbType = sizeof(DWORD);
     717    DWORD dwType = 0;
     718    DWORD dwValue;
     719    LONG lErr = RegQueryValueExW(hKey, pwszName, NULL, &dwType, (BYTE *)&dwValue, &cbType);
     720    if (lErr == ERROR_SUCCESS)
     721    {
     722        if (cbType == sizeof(DWORD))
     723        {
     724            if (dwType == REG_DWORD)
     725            {
     726                *pdwValue = dwValue;
     727            }
     728            else
     729                rc = VERR_WRONG_TYPE;
     730        }
     731        else
     732            rc = VERR_MISMATCH;
     733    }
     734    else
     735        rc = RTErrConvertFromWin32(lErr);
     736
     737    return rc;
     738}
     739
     740/**
     741 * Queries a DWORD value from a Windows registry key.
     742 *
     743 * @returns IPRT status code.
     744 * @retval  VERR_FILE_NOT_FOUND if the value has not been found.
     745 * @retval  VERR_WRONG_TYPE if the type (DWORD) of the value does not match.
     746 * @retval  VERR_MISMATCH if the type sizes do not match.
     747 * @param   hKey                    Registry handle of key to query.
     748 * @param   pszName                 Name of the value to query.
     749 * @param   pdwValue                Where to return the actual value on success.
     750 */
     751int VBoxWinDrvRegQueryDWORD(HKEY hKey, const char *pszName, DWORD *pdwValue)
     752{
     753    PRTUTF16 pwszName;
     754    int rc = RTStrToUtf16Ex(pszName, RTSTR_MAX, &pwszName, 0, NULL);
     755    if (RT_SUCCESS(rc))
     756    {
     757        rc = VBoxWinDrvRegQueryDWORDW(hKey, pwszName, pdwValue);
     758        RTUtf16Free(pwszName);
     759    }
     760
     761    return rc;
     762}
     763
  • trunk/src/VBox/GuestHost/installation/VBoxWinDrvCommon.h

    r107901 r108071  
    7575int VBoxWinDrvInstErrorFromWin32(unsigned uNativeCode);
    7676
     77int VBoxWinDrvRegQueryDWORDW(HKEY hKey, LPCWSTR pwszName, DWORD *pdwValue);
     78int VBoxWinDrvRegQueryDWORD(HKEY hKey, const char *pszName, DWORD *pdwValue);
     79
    7780#endif /* !VBOX_INCLUDED_SRC_installation_VBoxWinDrvCommon_h */
    7881
  • trunk/src/VBox/Installer/win/InstallHelper/Makefile.kmk

    r106321 r108071  
    5151        VBoxInstallHelper.rc \
    5252        VBoxCommon.cpp \
    53         $(PATH_ROOT)/src/VBox/GuestHost/Installation/VBoxWinDrvCommon.cpp \
    54         $(PATH_ROOT)/src/VBox/GuestHost/Installation/VBoxWinDrvInst.cpp \
    55         $(PATH_ROOT)/src/VBox/GuestHost/Installation/VBoxWinDrvStore.cpp
     53        $(PATH_ROOT)/src/VBox/GuestHost/installation/VBoxWinDrvCommon.cpp \
     54        $(PATH_ROOT)/src/VBox/GuestHost/installation/VBoxWinDrvInst.cpp \
     55        $(PATH_ROOT)/src/VBox/GuestHost/installation/VBoxWinDrvStore.cpp
     56VBoxInstallHelper_INCS    += \
     57        $(PATH_ROOT)/src/VBox/GuestHost/installation
    5658ifndef VBOX_OSE
    5759 VBoxInstallHelper_SOURCES += \
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxCommon.cpp

    r107950 r108071  
    3939#include <iprt/utf16.h>
    4040
     41#include <VBox/GuestHost/VBoxWinDrvInst.h>
     42#include <VBoxWinDrvCommon.h>
    4143#include "VBoxCommon.h"
    4244
     
    206208    return VBoxMsiSetProp(hMsi, pwszName, wszTemp);
    207209}
     210
     211/**
     212 * Queries a DWORD value from a Windows registry key, Unicode (wide char) version.
     213 *
     214 * @returns VBox status code.
     215 * @retval  VERR_FILE_NOT_FOUND if the value has not been found.
     216 * @retval  VERR_WRONG_TYPE if the type (DWORD) of the value does not match.
     217 * @retval  VERR_MISMATCH if the type sizes do not match.
     218 * @param   hMsi                MSI handle to use.
     219 * @param   hKey                Registry handle of key to query.
     220 * @param   pwszName            Name of the value to query.
     221 * @param   pdwValue            Where to return the actual value on success.
     222 */
     223int VBoxMsiRegQueryDWORDW(MSIHANDLE hMsi, HKEY hKey, LPCWSTR pwszName, DWORD *pdwValue)
     224{
     225    RT_NOREF(hMsi);
     226
     227    return VBoxWinDrvRegQueryDWORDW(hKey, pwszName, pdwValue);
     228}
     229
     230/**
     231 * Queries a DWORD value from a Windows registry key.
     232 *
     233 * @returns VBox status code.
     234 * @retval  VERR_FILE_NOT_FOUND if the value has not been found.
     235 * @retval  VERR_WRONG_TYPE if the type (DWORD) of the value does not match.
     236 * @retval  VERR_MISMATCH if the type sizes do not match.
     237 * @param   hKey                Registry handle of key to query.
     238 * @param   pszName             Name of the value to query.
     239 * @param   pdwValue            Where to return the actual value on success.
     240 */
     241int VBoxMsiRegQueryDWORD(MSIHANDLE hMsi, HKEY hKey, const char *pszName, DWORD *pdwValue)
     242{
     243    PRTUTF16 pwszName;
     244    int rc = RTStrToUtf16Ex(pszName, RTSTR_MAX, &pwszName, 0, NULL);
     245    if (RT_SUCCESS(rc))
     246    {
     247        rc = VBoxMsiRegQueryDWORDW(hMsi, hKey, pwszName, pdwValue);
     248        RTUtf16Free(pwszName);
     249    }
     250
     251    return rc;
     252}
     253
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxCommon.h

    r107948 r108071  
    4343int VBoxMsiSetPropUtf8(MSIHANDLE hMsi, const char *pszName, const char *pszValue);
    4444UINT VBoxMsiSetPropDWORD(MSIHANDLE hMsi, const WCHAR *pwszName, DWORD dwVal);
     45int VBoxMsiRegQueryDWORDW(MSIHANDLE hMsi, HKEY hKey, LPCWSTR pwszName, DWORD *pdwValue);
     46int VBoxMsiRegQueryDWORD(MSIHANDLE hMsi, HKEY hKey, const char *pszName, DWORD *pdwValue);
    4547
    4648#endif /* !VBOX_INCLUDED_SRC_InstallHelper_VBoxCommon_h */
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