Matteo Bruni (@Mystral) commented about dlls/dsound/capture.c:
*lplpvAudioPtr1 = This->device->buffer + dwReadCusor; - if ( (dwReadCusor + dwReadBytes) > This->device->buflen) { - *lpdwAudioBytes1 = This->device->buflen - dwReadCusor; - if (lplpvAudioPtr2) - *lplpvAudioPtr2 = This->device->buffer; - if (lpdwAudioBytes2) - *lpdwAudioBytes2 = dwReadBytes - *lpdwAudioBytes1; + if ( dwReadCusor > This->device->buflen || This->device->buflen - dwReadCusor < dwReadBytes) { + *lpdwAudioBytes1 = 0; + *lplpvAudioPtr1 = NULL; + if (lplpvAudioPtr2) + *lplpvAudioPtr2 = NULL; + if (lpdwAudioBytes2) + *lpdwAudioBytes2 = 0; + hres = DSERR_INVALIDPARAM; } else {
It doesn't look like we have tests confirming that `IDirectSoundCaptureBuffer::Lock()` never wraps around to the start of the buffer, returning valid data in the `lplpvAudioPtr2`, `lpdwAudioBytes2` out parameters (see e.g. https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ee418179...) for an explanation of how it would work). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10966#note_140985