VirtualBox

Changeset 93335 in vbox for trunk


Ignore:
Timestamp:
Jan 18, 2022 11:40:20 PM (3 years ago)
Author:
vboxsync
Message:

Installer/win/InstallHelper: Documented some oddities of getPythonPathEx, a couple of @todo that should be addressed.

File:
1 edited

Legend:

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

    r93334 r93335  
    223223 * @param   ppszPath            Where to store the allocated Python path on success.
    224224 *                              Must be free'd by the caller using RTStrFree().
     225 * @remarks r=bird: This may return VINF_SUCCESS and *ppszPath = NULL if there
     226 *          are no keys under "SOFTWARE\\Python\\PythonCore" or none of them
     227 *          has an "InstallPath" key.  It seems to work out fine, though, as
     228 *          we'll just use python.exe w/o a full path.
     229 *
     230 * @todo    r=bird: On a more serious note, caller ASSUMES the returned path
     231 *          ends with a slash as it just appends the "python.exe" string to it.
    225232 */
    226233static int getPythonPathEx(MSIHANDLE hModule, HKEY hKeyRoot, char **ppszPath)
     
    233240    char *pszPythonPath = NULL;
    234241
    235     RTUTF16 wszKey [RTPATH_MAX] = { 0 };
    236     RTUTF16 wszKey2[RTPATH_MAX] = { 0 };
    237     RTUTF16 wszVal [RTPATH_MAX] = { 0 };
    238 
    239242    int rc = VINF_SUCCESS;
    240243
     
    243246    for (int i = 0;; ++i)
    244247    {
    245         DWORD dwKey     = sizeof(wszKey);
    246         DWORD dwKeyType = REG_SZ;
    247 
     248        RTUTF16 wszKey[RTPATH_MAX];
     249        DWORD   dwKey     = sizeof(wszKey);
     250        DWORD   dwKeyType = REG_SZ;
     251
     252        /** @todo r=bird: Break on ERROR_NO_MORE_ITEMS, skip to the next one on
     253         *        errors. */
    248254        dwErr = RegEnumKeyExW(hkPythonCore, i, wszKey, &dwKey, NULL, NULL, NULL, NULL);
    249255        if (dwErr != ERROR_SUCCESS || dwKey <= 0)
     
    251257        AssertBreakStmt(dwKey <= sizeof(wszKey), VERR_BUFFER_OVERFLOW);
    252258
     259        /** @todo r=bird: Waste of space + effort, just append "\\InstallPath" to
     260         *        wszKey, reserving sufficent room for it above. */
     261        RTUTF16 wszKey2[RTPATH_MAX];
    253262        if (RTUtf16Printf(wszKey2, sizeof(wszKey2), "%ls\\InstallPath", wszKey) <= 0)
    254263        {
     
    256265            break;
    257266        }
    258 
    259         dwKey = sizeof(wszKey2); /* Re-initialize length. */
    260267
    261268        HKEY hkPythonInstPath = NULL;
     
    264271            continue;
    265272
    266         dwErr = RegQueryValueExW(hkPythonInstPath, L"", NULL, &dwKeyType, (LPBYTE)wszVal, &dwKey);
     273        RTUTF16 wszVal[RTPATH_MAX] = { 0 };
     274        DWORD   cbValue = sizeof(wszVal) - sizeof(RTUTF16);
     275        dwErr = RegQueryValueExW(hkPythonInstPath, L"", NULL, &dwKeyType, (LPBYTE)wszVal, &cbValue);
    267276        if (dwErr == ERROR_SUCCESS)
    268277            logStringF(hModule, "getPythonPath: Path \"%ls\" found.", wszVal);
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