Commit 726472fe authored by Brendan Shanks's avatar Brendan Shanks Committed by Alexandre Julliard

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

parent d5373ef6
...@@ -112,7 +112,7 @@ static DC_ATTR *alloc_dc_attr(void) ...@@ -112,7 +112,7 @@ static DC_ATTR *alloc_dc_attr(void)
{ {
SIZE_T size = system_info.AllocationGranularity; SIZE_T size = system_info.AllocationGranularity;
bucket->entries = NULL; bucket->entries = NULL;
if (!NtAllocateVirtualMemory( GetCurrentProcess(), (void **)&bucket->entries, zero_bits(), if (!NtAllocateVirtualMemory( GetCurrentProcess(), (void **)&bucket->entries, zero_bits,
&size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE )) &size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE ))
{ {
bucket->next_free = NULL; bucket->next_free = NULL;
......
...@@ -1549,7 +1549,7 @@ HBITMAP WINAPI NtGdiCreateDIBSection( HDC hdc, HANDLE section, DWORD offset, con ...@@ -1549,7 +1549,7 @@ HBITMAP WINAPI NtGdiCreateDIBSection( HDC hdc, HANDLE section, DWORD offset, con
{ {
SIZE_T size = bmp->dib.dsBmih.biSizeImage; SIZE_T size = bmp->dib.dsBmih.biSizeImage;
offset = 0; offset = 0;
if (NtAllocateVirtualMemory( GetCurrentProcess(), &bmp->dib.dsBm.bmBits, zero_bits(), if (NtAllocateVirtualMemory( GetCurrentProcess(), &bmp->dib.dsBm.bmBits, zero_bits,
&size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE )) &size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE ))
goto error; goto error;
} }
......
...@@ -566,7 +566,7 @@ static void init_gdi_shared(void) ...@@ -566,7 +566,7 @@ static void init_gdi_shared(void)
{ {
SIZE_T size = sizeof(*gdi_shared); SIZE_T size = sizeof(*gdi_shared);
if (NtAllocateVirtualMemory( GetCurrentProcess(), (void **)&gdi_shared, zero_bits(), if (NtAllocateVirtualMemory( GetCurrentProcess(), (void **)&gdi_shared, zero_bits,
&size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE )) &size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE ))
return; return;
next_unused = gdi_shared->Handles + FIRST_GDI_HANDLE; next_unused = gdi_shared->Handles + FIRST_GDI_HANDLE;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "ntuser.h" #include "ntuser.h"
#include "wine/unixlib.h" #include "wine/unixlib.h"
ULONG_PTR zero_bits = 0;
static void * const syscalls[] = static void * const syscalls[] =
{ {
...@@ -450,6 +451,16 @@ static SYSTEM_SERVICE_TABLE syscall_table = ...@@ -450,6 +451,16 @@ static SYSTEM_SERVICE_TABLE syscall_table =
static NTSTATUS init( void *dispatcher ) static NTSTATUS init( void *dispatcher )
{ {
#ifdef _WIN64
if (NtCurrentTeb()->WowTebOffset)
{
SYSTEM_BASIC_INFORMATION info;
NtQuerySystemInformation(SystemEmulationBasicInformation, &info, sizeof(info), NULL);
zero_bits = (ULONG_PTR)info.HighestUserAddress | 0x7fffffff;
}
#endif
return ntdll_init_syscalls( 1, &syscall_table, dispatcher ); return ntdll_init_syscalls( 1, &syscall_table, dispatcher );
} }
......
...@@ -271,6 +271,8 @@ extern HKEY hkcu_key DECLSPEC_HIDDEN; ...@@ -271,6 +271,8 @@ extern HKEY hkcu_key DECLSPEC_HIDDEN;
extern const struct user_driver_funcs *user_driver DECLSPEC_HIDDEN; extern const struct user_driver_funcs *user_driver DECLSPEC_HIDDEN;
extern ULONG_PTR zero_bits DECLSPEC_HIDDEN;
static inline BOOL set_ntstatus( NTSTATUS status ) static inline BOOL set_ntstatus( NTSTATUS status )
{ {
if (status) RtlSetLastWin32Error( RtlNtStatusToDosError( status )); if (status) RtlSetLastWin32Error( RtlNtStatusToDosError( status ));
...@@ -330,15 +332,6 @@ static inline BOOL is_win9x(void) ...@@ -330,15 +332,6 @@ static inline BOOL is_win9x(void)
return NtCurrentTeb()->Peb->OSPlatformId == VER_PLATFORM_WIN32s; return NtCurrentTeb()->Peb->OSPlatformId == VER_PLATFORM_WIN32s;
} }
static inline ULONG_PTR zero_bits(void)
{
#ifdef _WIN64
return !NtCurrentTeb()->WowTebOffset ? 0 : 0x7fffffff;
#else
return 0;
#endif
}
static inline const char *debugstr_us( const UNICODE_STRING *us ) static inline const char *debugstr_us( const UNICODE_STRING *us )
{ {
if (!us) return "<null>"; if (!us) return "<null>";
......
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