[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    [PATCH v3] dsound: Make GlobalHandle() for the sound buffer failed.
From:       Akihiro Sagawa <sagawa.aki () gmail ! com>
Date:       2020-02-29 12:27:15
Message-ID: 20200229212446.700E.375B48EC () gmail ! com
[Download RAW message or body]

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@gmail.com>
---
 dlls/dsound/buffer.c       | 4 ++--
 dlls/dsound/tests/dsound.c | 7 +++++++
 2 files changed, 9 insertions(+), 2 deletions(-)


["v3-0001-dsound-Make-GlobalHandle-for-the-sound-buffer-fai.patch" (text/x-patch)]

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);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic