Commit 2c10f747 authored by Brendan Shanks's avatar Brendan Shanks Committed by Alexandre Julliard

winepulse: Set zero_bits correctly for large address aware applications on Wow64.

parent e0727a40
...@@ -119,6 +119,8 @@ static const REFERENCE_TIME DefaultPeriod = 100000; ...@@ -119,6 +119,8 @@ static const REFERENCE_TIME DefaultPeriod = 100000;
static pthread_mutex_t pulse_mutex; static pthread_mutex_t pulse_mutex;
static pthread_cond_t pulse_cond = PTHREAD_COND_INITIALIZER; static pthread_cond_t pulse_cond = PTHREAD_COND_INITIALIZER;
static ULONG_PTR zero_bits = 0;
static NTSTATUS pulse_not_implemented(void *args) static NTSTATUS pulse_not_implemented(void *args)
{ {
return STATUS_SUCCESS; return STATUS_SUCCESS;
...@@ -237,6 +239,16 @@ static NTSTATUS pulse_process_attach(void *args) ...@@ -237,6 +239,16 @@ static NTSTATUS pulse_process_attach(void *args)
if (pthread_mutex_init(&pulse_mutex, &attr) != 0) if (pthread_mutex_init(&pulse_mutex, &attr) != 0)
pthread_mutex_init(&pulse_mutex, NULL); pthread_mutex_init(&pulse_mutex, NULL);
#ifdef _WIN64
if (NtCurrentTeb()->WowTebOffset)
{
SYSTEM_BASIC_INFORMATION info;
NtQuerySystemInformation(SystemEmulationBasicInformation, &info, sizeof(info), NULL);
zero_bits = (ULONG_PTR)info.HighestUserAddress | 0x7fffffff;
}
#endif
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -1077,15 +1089,6 @@ static HRESULT pulse_stream_connect(struct pulse_stream *stream, const char *pul ...@@ -1077,15 +1089,6 @@ static HRESULT pulse_stream_connect(struct pulse_stream *stream, const char *pul
return S_OK; return S_OK;
} }
static ULONG_PTR zero_bits(void)
{
#ifdef _WIN64
return !NtCurrentTeb()->WowTebOffset ? 0 : 0x7fffffff;
#else
return 0;
#endif
}
static HRESULT get_device_period_helper(EDataFlow flow, const char *pulse_name, REFERENCE_TIME *def, REFERENCE_TIME *min) static HRESULT get_device_period_helper(EDataFlow flow, const char *pulse_name, REFERENCE_TIME *def, REFERENCE_TIME *min)
{ {
struct list *list = (flow == eRender) ? &g_phys_speakers : &g_phys_sources; struct list *list = (flow == eRender) ? &g_phys_speakers : &g_phys_sources;
...@@ -1183,7 +1186,7 @@ static NTSTATUS pulse_create_stream(void *args) ...@@ -1183,7 +1186,7 @@ static NTSTATUS pulse_create_stream(void *args)
size = stream->real_bufsize_bytes = size = stream->real_bufsize_bytes =
stream->bufsize_frames * 2 * pa_frame_size(&stream->ss); stream->bufsize_frames * 2 * pa_frame_size(&stream->ss);
if (NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->local_buffer, if (NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->local_buffer,
zero_bits(), &size, MEM_COMMIT, PAGE_READWRITE)) zero_bits, &size, MEM_COMMIT, PAGE_READWRITE))
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
} else { } else {
UINT32 i, capture_packets; UINT32 i, capture_packets;
...@@ -1197,7 +1200,7 @@ static NTSTATUS pulse_create_stream(void *args) ...@@ -1197,7 +1200,7 @@ static NTSTATUS pulse_create_stream(void *args)
size = stream->real_bufsize_bytes + capture_packets * sizeof(ACPacket); size = stream->real_bufsize_bytes + capture_packets * sizeof(ACPacket);
if (NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->local_buffer, if (NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->local_buffer,
zero_bits(), &size, MEM_COMMIT, PAGE_READWRITE)) zero_bits, &size, MEM_COMMIT, PAGE_READWRITE))
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
else { else {
ACPacket *cur_packet = (ACPacket*)((char*)stream->local_buffer + stream->real_bufsize_bytes); ACPacket *cur_packet = (ACPacket*)((char*)stream->local_buffer + stream->real_bufsize_bytes);
...@@ -1841,7 +1844,7 @@ static BOOL alloc_tmp_buffer(struct pulse_stream *stream, SIZE_T bytes) ...@@ -1841,7 +1844,7 @@ static BOOL alloc_tmp_buffer(struct pulse_stream *stream, SIZE_T bytes)
stream->tmp_buffer_bytes = 0; stream->tmp_buffer_bytes = 0;
} }
if (NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, if (NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer,
zero_bits(), &bytes, MEM_COMMIT, PAGE_READWRITE)) zero_bits, &bytes, MEM_COMMIT, PAGE_READWRITE))
return FALSE; return FALSE;
stream->tmp_buffer_bytes = bytes; stream->tmp_buffer_bytes = bytes;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment