[PATCH 1/2] mmdevapi: Truncate strings from PropertyStore's GetValue to 62 chars.

Andrew Eikum aeikum at codeweavers.com
Mon May 23 10:03:45 CDT 2022


On Fri, May 20, 2022 at 08:40:18PM +0300, Gabriel Ivăncescu wrote:
> @@ -1397,7 +1399,16 @@ static HRESULT WINAPI MMDevPropStore_GetValue(IPropertyStore *iface, REFPROPERTY
>          return S_OK;
>      }
>  
> -    return MMDevice_GetPropValue(&This->parent->devguid, This->parent->flow, key, pv);
> +    hres = MMDevice_GetPropValue(&This->parent->devguid, This->parent->flow, key, pv);
> +    if (FAILED(hres))
> +        return hres;
> +
> +    /* Some broken apps and libs (e.g. Split/Second with fmodex)
> +       can't deal with strings longer than 62 characters + NUL. */
> +    if (pv->vt == VT_LPWSTR && wcslen(pv->pwszVal) > 62)
> +        pv->pwszVal[62] = '\0';
> +

I think we'd only want to do this for certain keys, not every returned
string. But, Windows doesn't do this. You can edit the registry and
put whatever you want into the device name, and it'll be returned
unmodified:

    [HKLM\Software\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\<device_guid>\Properties]
    "{b3f8fa53-0004-438e-9003-51a46e139bfc},6"="A Very Long String...."

I don't immediately have the ability to check if the game crashes on
Windows if I set the string very long, but that's what I would check
next.

Andrew



More information about the wine-devel mailing list