VirtualBox

Ticket #14040: VBoxNetCfg-Win10.patch

File VBoxNetCfg-Win10.patch, 1.7 KB (added by Jiri Hruska, 9 years ago)

Fix suggestion (WTFPL license)

  • VBoxNetCfg.cpp

     
    29612961        if (hkey == INVALID_HANDLE_VALUE)
    29622962            SetErrBreak(("SetupDiOpenDevRegKey failed (0x%08X)", GetLastError()));
    29632963
    2964         cbSize = sizeof(pWCfgGuidString);
     2964        /*
     2965         * Since Windows 10 it apparently takes some time before the necessary
     2966         * value "NetCfgInstanceId" appears in the registry. Retry silently for
     2967         * a while and fail only if it really does not show up.
     2968         */
    29652969        DWORD ret;
    2966         ret = RegQueryValueExW (hkey, L"NetCfgInstanceId", NULL,
    2967                                &dwValueType, (LPBYTE) pWCfgGuidString, &cbSize);
     2970        int retry = 0;
     2971        for (;;)
     2972        {
     2973            cbSize = sizeof(pWCfgGuidString);
     2974            ret = RegQueryValueExW (hkey, L"NetCfgInstanceId", NULL,
     2975                                   &dwValueType, (LPBYTE) pWCfgGuidString, &cbSize);
     2976            if (ret != ERROR_FILE_NOT_FOUND || ++retry > 3 * 4)
     2977                break;
     2978            Sleep(250);
     2979        }
     2980        if (ret != ERROR_SUCCESS)
     2981            SetErrBreak(("RegQueryValueEx(NetCfgInstanceId) failed (0x%08X)", ret));
    29682982
    29692983        RegCloseKey (hkey);
    29702984
     
    30073021    if (hDeviceInfo != INVALID_HANDLE_VALUE)
    30083022    {
    30093023        /* an error has occurred, but the device is registered, we must remove it */
    3010         if (ret != 0 && registered)
     3024        if (FAILED(hrc) && registered)
    30113025            SetupDiCallClassInstaller(DIF_REMOVE, hDeviceInfo, &DeviceInfoData);
    30123026
    30133027        found = SetupDiDeleteDeviceInfo(hDeviceInfo, &DeviceInfoData);

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy