[PATCH v3] dsound: Make GlobalHandle() for the sound buffer failed.
Andrew Eikum
aeikum at codeweavers.com
Mon Mar 2 08:09:12 CST 2020
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
On Sat, Feb 29, 2020 at 09:27:15PM +0900, Akihiro Sagawa wrote:
> In v3, use VirtualAlloc/VirtualFree and revert dsound test for 32-bit.
> Andrew and Zebediah, thanks for reviewing and useful comments.
>
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48635
> Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
> ---
> dlls/dsound/buffer.c | 4 ++--
> dlls/dsound/tests/dsound.c | 7 +++++++
> 2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
> index 8d4a3b9..5f592a9 100644
> --- a/dlls/dsound/buffer.c
> +++ b/dlls/dsound/buffer.c
> @@ -1061,7 +1061,7 @@ HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *ds
> }
>
> /* Allocate system memory for buffer */
> - dsb->buffer->memory = HeapAlloc(GetProcessHeap(),0,dsb->buflen);
> + dsb->buffer->memory = VirtualAlloc(NULL,dsb->buflen,MEM_COMMIT,PAGE_READWRITE);
> if (!dsb->buffer->memory) {
> WARN("out of memory\n");
> IDirectSoundBuffer8_Release(&dsb->IDirectSoundBuffer8_iface);
> @@ -1137,7 +1137,7 @@ void secondarybuffer_destroy(IDirectSoundBufferImpl *This)
> This->buffer->ref--;
> list_remove(&This->entry);
> if (This->buffer->ref == 0) {
> - HeapFree(GetProcessHeap(), 0, This->buffer->memory);
> + VirtualFree(This->buffer->memory, 0, MEM_RELEASE);
> HeapFree(GetProcessHeap(), 0, This->buffer);
> }
>
> diff --git a/dlls/dsound/tests/dsound.c b/dlls/dsound/tests/dsound.c
> index 7fdac91..2bf87eb 100644
> --- a/dlls/dsound/tests/dsound.c
> +++ b/dlls/dsound/tests/dsound.c
> @@ -1157,6 +1157,13 @@ static HRESULT test_duplicate(LPGUID lpGuid)
> ok(rc==DS_OK && buf!=NULL,
> "IDirectSoundBuffer_Lock failed to lock the buffer %08x\n",rc);
> if (rc==DS_OK && buf!=NULL) {
> + if (sizeof(void*)==4) { /* crashes on 64-bit */
> + /* broken apps like Asuka 120% Return BURNING Fest,
> + pass the pointer to GlobalHandle. */
> + HGLOBAL hmem = GlobalHandle(buf);
> + ok(!hmem,"GlobalHandle should return NULL "
> + "for buffer %p, got %p\n",buf,hmem);
> + }
> ZeroMemory(buf,bufsize);
> rc=IDirectSoundBuffer_Unlock(original,buf,bufsize,
> NULL,0);
More information about the wine-devel
mailing list