Created
May 28, 2021 00:53
-
-
Save gardotd426/85eb1e07ee1a942226f0b907af72081f to your computer and use it in GitHub Desktop.
Fixed LAA-unix-staging.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 6a1159fd49718165c61100ea70b0054d5a484ea6 Mon Sep 17 00:00:00 2001 | |
From: Steven Noonan <[email protected]> | |
Date: Wed, 17 Oct 2018 04:13:37 -0700 | |
Subject: [PATCH] ntdll/loader: add support for overriding | |
IMAGE_FILE_LARGE_ADDRESS_AWARE | |
Signed-off-by: Steven Noonan <[email protected]> | |
--- | |
dlls/kernel32/heap.c | 9 ++++++++- | |
dlls/ntdll/ntdll.spec | 1 + | |
dlls/ntdll/unix/server.c | 3 ++- | |
dlls/ntdll/unix/unix_private.h | 2 ++ | |
dlls/ntdll/unix/virtual.c | 13 +++++++++++++ | |
5 files changed, 26 insertions(+), 2 deletions(-) | |
diff --git a/dlls/kernel32/heap.c b/dlls/kernel32/heap.c | |
index b7bd6f5f91d..fef060e9c22 100644 | |
--- a/dlls/kernel32/heap.c | |
+++ b/dlls/kernel32/heap.c | |
@@ -44,6 +44,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(globalmem); | |
static HANDLE systemHeap; /* globally shared heap */ | |
+extern BOOL CDECL __wine_needs_override_large_address_aware(void); | |
+ | |
/*********************************************************************** | |
* HEAP_CreateSystemHeap | |
@@ -544,6 +546,10 @@ VOID WINAPI GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer ) | |
#ifndef _WIN64 | |
IMAGE_NT_HEADERS *nt = RtlImageNtHeader( GetModuleHandleW(0) ); | |
#endif | |
+ static int force_large_address_aware = -1; | |
+ | |
+ if (force_large_address_aware == -1) | |
+ force_large_address_aware = __wine_needs_override_large_address_aware(); | |
/* Because GlobalMemoryStatus is identical to GlobalMemoryStatusEX save | |
for one extra field in the struct, and the lack of a bug, we simply | |
@@ -584,7 +590,8 @@ VOID WINAPI GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer ) | |
/* values are limited to 2Gb unless the app has the IMAGE_FILE_LARGE_ADDRESS_AWARE flag */ | |
/* page file sizes are not limited (Adobe Illustrator 8 depends on this) */ | |
- if (!(nt->FileHeader.Characteristics & IMAGE_FILE_LARGE_ADDRESS_AWARE)) | |
+ if (!(nt->FileHeader.Characteristics & IMAGE_FILE_LARGE_ADDRESS_AWARE) && | |
+ !force_large_address_aware) | |
{ | |
if (lpBuffer->dwTotalPhys > MAXLONG) lpBuffer->dwTotalPhys = MAXLONG; | |
if (lpBuffer->dwAvailPhys > MAXLONG) lpBuffer->dwAvailPhys = MAXLONG; | |
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec | |
index ca427c46c04..10327373959 100644 | |
--- a/dlls/ntdll/ntdll.spec | |
+++ b/dlls/ntdll/ntdll.spec | |
@@ -1625,6 +1625,9 @@ | |
@ cdecl -norelay __wine_dbg_output(str) | |
@ cdecl -norelay __wine_dbg_strdup(str) | |
+# Virtual memory | |
+@ cdecl -syscall __wine_needs_override_large_address_aware() | |
+ | |
# Version | |
@ cdecl wine_get_version() | |
@ cdecl wine_get_build_id() | |
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c | |
index 7236f0acb83..e34abd88093 100644 | |
--- a/dlls/ntdll/unix/server.c | |
+++ b/dlls/ntdll/unix/server.c | |
@@ -1471,8 +1471,8 @@ void server_init_process_done(void) | |
#ifdef __APPLE__ | |
send_server_task_port(); | |
#endif | |
- if (main_image_info.ImageCharacteristics & IMAGE_FILE_LARGE_ADDRESS_AWARE) | |
- virtual_set_large_address_space(); | |
+ if (main_image_info.ImageCharacteristics & IMAGE_FILE_LARGE_ADDRESS_AWARE | |
+ || __wine_needs_override_large_address_aware()) virtual_set_large_address_space(); | |
/* Install signal handlers; this cannot be done earlier, since we cannot | |
* send exceptions to the debugger before the create process event that | |
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h | |
index c3ad0a41098..e0326f88a21 100644 | |
--- a/dlls/ntdll/unix/unix_private.h | |
+++ b/dlls/ntdll/unix/unix_private.h | |
@@ -470,4 +470,6 @@ static inline int ntdll_wcsnicmp( const WCHAR *str1, const WCHAR *str2, int n ) | |
#define towupper(c) ntdll_towupper(c) | |
#define towlower(c) ntdll_towlower(c) | |
+BOOL CDECL __wine_needs_override_large_address_aware(void); | |
+ | |
#endif /* __NTDLL_UNIX_PRIVATE_H */ | |
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c | |
index 1337e2de861..200a777eb5c 100644 | |
--- a/dlls/ntdll/unix/virtual.c | |
+++ b/dlls/ntdll/unix/virtual.c | |
@@ -3420,6 +3420,19 @@ void CDECL virtual_release_address_space(void) | |
server_leave_uninterrupted_section( &virtual_mutex, &sigset ); | |
} | |
+BOOL CDECL __wine_needs_override_large_address_aware(void) | |
+{ | |
+ static int needs_override = -1; | |
+ | |
+ if (needs_override == -1) | |
+ { | |
+ const char *str = getenv( "WINE_LARGE_ADDRESS_AWARE" ); | |
+ | |
+ needs_override = !str || atoi(str) == 1; | |
+ } | |
+ return needs_override; | |
+} | |
+ | |
/*********************************************************************** | |
* virtual_set_large_address_space | |
-- | |
2.26.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment