VirtualBox

Changeset 108071 in vbox for trunk/src/VBox/GuestHost


Ignore:
Timestamp:
Feb 5, 2025 2:14:02 PM (3 months 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/GuestHost/installation
Files:
2 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
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