[PATCH 1/2] mmdevapi: Truncate strings from PropertyStore's GetValue to 62 chars.
Andrew Eikum
aeikum at codeweavers.com
Mon May 23 11:18:46 CDT 2022
On Mon, May 23, 2022 at 06:50:16PM +0300, Gabriel Ivăncescu wrote:
> On 23/05/2022 18:03, Andrew Eikum wrote:
> > 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
> >
>
> Thanks. I tested it on Windows 7 VM. Unfortunately, it crashes in the same
> way on Windows if I make a device name longer than 63 chars (for some
> reason, 63 instead of 62, but might have been a lucky run?).
>
> So yes it's true that Windows doesn't do this, but it might also be that
> Windows doesn't have very long device names in the first place, so it's not
> a problem noticed "in the wild" there.
>
> I don't really like truncation either, but since it makes the game
> unplayable it's kind of tough decision. Maybe use a registry setting? But
> then most users wouldn't know to try it...
We could try to acquire a shorter name for the underlying device,
somehow, but I'm not sure what options PA and/or ALSA give us. Maybe
use PA_PROP_DEVICE_PRODUCT_NAME instead, for example.
Andrew
More information about the wine-devel
mailing list