[PATCH 4/6] winecoreaudio: Limit Wow64 buffer allocations to 32-bit addresses.
Huw Davies
huw at codeweavers.com
Mon Apr 25 01:58:36 CDT 2022
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
dlls/winecoreaudio.drv/coreaudio.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c
index 955b7d2afaf..463a330eeda 100644
--- a/dlls/winecoreaudio.drv/coreaudio.c
+++ b/dlls/winecoreaudio.drv/coreaudio.c
@@ -615,6 +615,15 @@ static HRESULT ca_setup_audiounit(EDataFlow dataflow, AudioComponentInstance uni
return S_OK;
}
+static ULONG_PTR zero_bits(void)
+{
+#ifdef _WIN64
+ return !NtCurrentTeb()->WowTebOffset ? 0 : 0x7fffffff;
+#else
+ return 0;
+#endif
+}
+
static NTSTATUS create_stream(void *args)
{
struct create_stream_params *params = args;
@@ -685,8 +694,8 @@ static NTSTATUS create_stream(void *args)
}
size = stream->bufsize_frames * stream->fmt->nBlockAlign;
- if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->local_buffer, 0, &size,
- MEM_COMMIT, PAGE_READWRITE)){
+ if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->local_buffer, zero_bits(),
+ &size, MEM_COMMIT, PAGE_READWRITE)){
params->result = E_OUTOFMEMORY;
goto end;
}
@@ -1371,7 +1380,7 @@ static NTSTATUS get_render_buffer(void *args)
stream->tmp_buffer = NULL;
}
size = params->frames * stream->fmt->nBlockAlign;
- if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, 0,
+ if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, zero_bits(),
&size, MEM_COMMIT, PAGE_READWRITE)){
stream->tmp_buffer_frames = 0;
params->result = E_OUTOFMEMORY;
@@ -1469,7 +1478,7 @@ static NTSTATUS get_capture_buffer(void *args)
chunk_bytes = chunk_frames * stream->fmt->nBlockAlign;
if(!stream->tmp_buffer){
size = stream->period_frames * stream->fmt->nBlockAlign;
- NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, 0,
+ NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, zero_bits(),
&size, MEM_COMMIT, PAGE_READWRITE);
}
*params->data = stream->tmp_buffer;
--
2.23.0
More information about the wine-devel
mailing list