Rebase against f266dc094a9b4fbe95792ed706891609901834e3.

This commit is contained in:
Alistair Leslie-Hughes
2023-05-24 12:06:20 +10:00
parent 3e3ebf5cfc
commit 6900845545
12 changed files with 115 additions and 114 deletions

View File

@@ -1,4 +1,4 @@
From 9262ac863f3c124e204a0fe96fbfc9ebefa2ee84 Mon Sep 17 00:00:00 2001
From da73611080701ad78b851b7d9e428744d1ce939d Mon Sep 17 00:00:00 2001
From: Paul Gofman <pgofman@codeweavers.com>
Date: Thu, 10 Nov 2022 18:48:14 -0600
Subject: [PATCH] ntdll: Pass allocation type to map_view().
@@ -9,7 +9,7 @@ Based on a patch by Nikolay Sivov.
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index a5c1c8214fa..e3df71a695c 100644
index e807754d16b..19584238d28 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -2011,8 +2011,9 @@ static NTSTATUS map_fixed_area( void *base, size_t size, unsigned int vprot )
@@ -32,7 +32,7 @@ index a5c1c8214fa..e3df71a695c 100644
}
/* now try to allocate the low 64K too */
@@ -2760,9 +2761,9 @@ static NTSTATUS virtual_map_image( HANDLE mapping, ACCESS_MASK access, void **ad
@@ -2767,9 +2768,9 @@ static NTSTATUS virtual_map_image( HANDLE mapping, ACCESS_MASK access, void **ad
if ((ULONG_PTR)base != image_info->base) base = NULL;
if ((char *)base >= (char *)address_space_start) /* make sure the DOS area remains free */
@@ -43,8 +43,8 @@ index a5c1c8214fa..e3df71a695c 100644
+ if (status) status = map_view( &view, NULL, size, alloc_type, vprot, limit, 0 );
if (status) goto done;
status = map_image_into_view( view, filename, unix_fd, base, image_info->header_size,
@@ -2885,7 +2886,7 @@ static unsigned int virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG_P
status = map_image_into_view( view, filename, unix_fd, base, image_info,
@@ -2893,7 +2894,7 @@ static unsigned int virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG_P
server_enter_uninterrupted_section( &virtual_mutex, &sigset );
@@ -53,7 +53,7 @@ index a5c1c8214fa..e3df71a695c 100644
if (res) goto done;
TRACE( "handle=%p size=%lx offset=%s\n", handle, size, wine_dbgstr_longlong(offset.QuadPart) );
@@ -3424,7 +3425,7 @@ NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, ULONG_PTR limit, SIZE_T
@@ -3463,7 +3464,7 @@ NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, ULONG_PTR limit, SIZE_T
server_enter_uninterrupted_section( &virtual_mutex, &sigset );
@@ -62,7 +62,7 @@ index a5c1c8214fa..e3df71a695c 100644
if (status != STATUS_SUCCESS) goto done;
#ifdef VALGRIND_STACK_REGISTER
@@ -4120,7 +4121,7 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
@@ -4159,7 +4160,7 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
if (vprot & VPROT_WRITECOPY) status = STATUS_INVALID_PAGE_PROTECTION;
else if (is_dos_memory) status = allocate_dos_memory( &view, vprot );

View File

@@ -1,4 +1,4 @@
From 73fa163482646dde03d10a2aaab1cb3df2d55225 Mon Sep 17 00:00:00 2001
From cfb6e0a17e03c42aa3483078390eb030edfeb271 Mon Sep 17 00:00:00 2001
From: Paul Gofman <pgofman@codeweavers.com>
Date: Thu, 10 Nov 2022 18:53:10 -0600
Subject: [PATCH] ntdll: Support MEM_RESERVE_PLACEHOLDER in
@@ -117,7 +117,7 @@ index 14eed7d8fe9..f7b321cc09f 100644
static void test_VirtualAllocFromApp(void)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c
index 549a2b12d5a..8b21e485736 100644
index 2c8b1614b84..604e234b100 100644
--- a/dlls/ntdll/tests/virtual.c
+++ b/dlls/ntdll/tests/virtual.c
@@ -334,15 +334,11 @@ static void test_NtAllocateVirtualMemoryEx(void)
@@ -256,10 +256,10 @@ index 549a2b12d5a..8b21e485736 100644
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE);
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
memset( &ext, 0, sizeof(ext) );
ext.Type = MemExtendedParameterAttributeFlags;
memset( ext, 0, sizeof(ext) );
ext[0].Type = MemExtendedParameterAttributeFlags;
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index e3df71a695c..77b0bc4c4c8 100644
index 19584238d28..feb93302af5 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -125,6 +125,8 @@ struct file_view
@@ -280,7 +280,7 @@ index e3df71a695c..77b0bc4c4c8 100644
else if (view->protect & SEC_IMAGE)
TRACE( " (image)\n" );
else if (view->protect & SEC_FILE)
@@ -4098,8 +4102,7 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
@@ -4137,8 +4141,7 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
/* Compute the alloc type flags */
@@ -290,7 +290,7 @@ index e3df71a695c..77b0bc4c4c8 100644
{
WARN("called with wrong alloc type flags (%08x) !\n", (int)type);
return STATUS_INVALID_PARAMETER;
@@ -4107,6 +4110,12 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
@@ -4146,6 +4149,12 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
if (!arm64ec_map && (attributes & MEM_EXTENDED_PARAMETER_EC_CODE)) return STATUS_INVALID_PARAMETER;
@@ -303,7 +303,7 @@ index e3df71a695c..77b0bc4c4c8 100644
/* Reserve the memory */
server_enter_uninterrupted_section( &virtual_mutex, &sigset );
@@ -4117,6 +4126,7 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
@@ -4156,6 +4165,7 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
{
if (type & MEM_COMMIT) vprot |= VPROT_COMMITTED;
if (type & MEM_WRITE_WATCH) vprot |= VPROT_WRITEWATCH;
@@ -311,7 +311,7 @@ index e3df71a695c..77b0bc4c4c8 100644
if (protect & PAGE_NOCACHE) vprot |= SEC_NOCACHE;
if (vprot & VPROT_WRITECOPY) status = STATUS_INVALID_PAGE_PROTECTION;
@@ -4136,6 +4146,7 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
@@ -4175,6 +4185,7 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
{
if (!(view = find_view( base, size ))) status = STATUS_NOT_MAPPED_VIEW;
else if (view->protect & SEC_FILE) status = STATUS_ALREADY_COMMITTED;
@@ -319,7 +319,7 @@ index e3df71a695c..77b0bc4c4c8 100644
else if (!(status = set_protection( view, base, size, protect )) && (view->protect & SEC_RESERVE))
{
SERVER_START_REQ( add_mapping_committed_range )
@@ -4171,6 +4182,7 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
@@ -4210,6 +4221,7 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR zero_bits,
SIZE_T *size_ptr, ULONG type, ULONG protect )
{
@@ -327,7 +327,7 @@ index e3df71a695c..77b0bc4c4c8 100644
ULONG_PTR limit;
TRACE("%p %p %08lx %x %08x\n", process, *ret, *size_ptr, (int)type, (int)protect );
@@ -4182,6 +4194,12 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR z
@@ -4221,6 +4233,12 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR z
if (!is_old_wow64() && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3;
#endif
@@ -340,7 +340,7 @@ index e3df71a695c..77b0bc4c4c8 100644
if (process != NtCurrentProcess())
{
apc_call_t call;
@@ -4284,6 +4302,8 @@ NTSTATUS WINAPI NtAllocateVirtualMemoryEx( HANDLE process, PVOID *ret, SIZE_T *s
@@ -4331,6 +4349,8 @@ NTSTATUS WINAPI NtAllocateVirtualMemoryEx( HANDLE process, PVOID *ret, SIZE_T *s
ULONG protect, MEM_EXTENDED_PARAMETER *parameters,
ULONG count )
{
@@ -349,8 +349,8 @@ index e3df71a695c..77b0bc4c4c8 100644
ULONG_PTR limit = 0;
ULONG_PTR align = 0;
ULONG attributes = 0;
@@ -4295,6 +4315,12 @@ NTSTATUS WINAPI NtAllocateVirtualMemoryEx( HANDLE process, PVOID *ret, SIZE_T *s
status = get_extended_params( parameters, count, &limit, &align, &attributes );
@@ -4343,6 +4363,12 @@ NTSTATUS WINAPI NtAllocateVirtualMemoryEx( HANDLE process, PVOID *ret, SIZE_T *s
status = get_extended_params( parameters, count, &limit, &align, &attributes, &machine );
if (status) return status;
+ if (type & ~type_mask)

View File

@@ -1,4 +1,4 @@
From dc171d61ceb1aae3102063208de1b47ce58139d3 Mon Sep 17 00:00:00 2001
From 0f2112fa71afccdebea36bdf357fd66a303ce870 Mon Sep 17 00:00:00 2001
From: Paul Gofman <pgofman@codeweavers.com>
Date: Wed, 9 Nov 2022 21:23:19 -0600
Subject: [PATCH] ntdll/tests: Add more tests for placeholders.
@@ -34,7 +34,7 @@ index b629b61ea5d..e5185a2587d 100644
UnmapViewOfFile(view1);
UnmapViewOfFile(view2);
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c
index 03b9106bc6b..3307c19bbea 100644
index 1718aaf30f9..45ba58868df 100644
--- a/dlls/ntdll/tests/virtual.c
+++ b/dlls/ntdll/tests/virtual.c
@@ -293,10 +293,14 @@ static void check_region_size_(void *p, SIZE_T s, unsigned int line)
@@ -42,7 +42,7 @@ index 03b9106bc6b..3307c19bbea 100644
static void test_NtAllocateVirtualMemoryEx(void)
{
+ MEMORY_BASIC_INFORMATION mbi;
MEM_EXTENDED_PARAMETER ext;
MEM_EXTENDED_PARAMETER ext[2];
+ void *addresses[16];
SIZE_T size, size2;
char *p, *p1, *p2;
@@ -266,8 +266,8 @@ index 03b9106bc6b..3307c19bbea 100644
+ ok(size2 == 0x8000, "Unexpected size %#Ix.\n", size2);
+ ok(p2 == p1 + size / 2, "Unexpected addr %p, expected %p.\n", p2, p1 + size / 2);
memset( &ext, 0, sizeof(ext) );
ext.Type = MemExtendedParameterAttributeFlags;
memset( ext, 0, sizeof(ext) );
ext[0].Type = MemExtendedParameterAttributeFlags;
--
2.40.1

View File

@@ -1,4 +1,4 @@
From e3fa80eae8154f4e621601d571306a96c71c285b Mon Sep 17 00:00:00 2001
From c1a82d397f9bf6ba20fe6966a5b1d2209c49d44b Mon Sep 17 00:00:00 2001
From: Paul Gofman <pgofman@codeweavers.com>
Date: Thu, 10 Nov 2022 19:02:50 -0600
Subject: [PATCH] ntdll: Support MEM_COALESCE_PLACEHOLDERS in
@@ -10,13 +10,13 @@ Subject: [PATCH] ntdll: Support MEM_COALESCE_PLACEHOLDERS in
2 files changed, 122 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c
index 3307c19bbea..c1e194f9e7d 100644
index 45ba58868df..f5f1964e516 100644
--- a/dlls/ntdll/tests/virtual.c
+++ b/dlls/ntdll/tests/virtual.c
@@ -295,9 +295,9 @@ static void test_NtAllocateVirtualMemoryEx(void)
{
MEMORY_BASIC_INFORMATION mbi;
MEM_EXTENDED_PARAMETER ext;
MEM_EXTENDED_PARAMETER ext[2];
+ char *p, *p1, *p2, *p3;
void *addresses[16];
SIZE_T size, size2;
@@ -114,7 +114,7 @@ index 3307c19bbea..c1e194f9e7d 100644
/* Split in two regions, specifying second half. */
addr1 = NULL;
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 07c24a31592..f7f5e44fb57 100644
index bdb213d968e..f5634e64021 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -114,6 +114,9 @@ struct file_view
@@ -180,7 +180,7 @@ index 07c24a31592..f7f5e44fb57 100644
/***********************************************************************
* allocate_dos_memory
*
@@ -4478,13 +4527,15 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
@@ -4526,13 +4575,15 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
else if (!(view = find_view( base, 0 ))) status = STATUS_MEMORY_NOT_ALLOCATED;
else if (!is_view_valloc( view )) status = STATUS_INVALID_PARAMETER;
else if (!size && base != view->base) status = STATUS_FREE_VM_NOT_AT_BASE;

View File

@@ -1,4 +1,4 @@
From cf1caf109030ac7b89dae57666ee084b23637a65 Mon Sep 17 00:00:00 2001
From 9628228a974df1aaa3649ee8b80361d4ede75b06 Mon Sep 17 00:00:00 2001
From: Paul Gofman <pgofman@codeweavers.com>
Date: Fri, 11 Nov 2022 12:41:31 -0600
Subject: [PATCH] ntdll: Factor out unmap_view_of_section() function.
@@ -8,11 +8,11 @@ Subject: [PATCH] ntdll: Factor out unmap_view_of_section() function.
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index f7f5e44fb57..71a5b294940 100644
index f5634e64021..fe2e81fbe95 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -5236,11 +5236,7 @@ NTSTATUS WINAPI NtMapViewOfSectionEx( HANDLE handle, HANDLE process, PVOID *addr
return virtual_map_section( handle, addr_ptr, limit, 0, offset_ptr, size_ptr, alloc_type, protect );
@@ -5288,11 +5288,7 @@ NTSTATUS WINAPI NtMapViewOfSectionEx( HANDLE handle, HANDLE process, PVOID *addr
alloc_type, protect, machine );
}
-/***********************************************************************
@@ -24,7 +24,7 @@ index f7f5e44fb57..71a5b294940 100644
{
struct file_view *view;
unsigned int status = STATUS_NOT_MAPPED_VIEW;
@@ -5297,6 +5293,15 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
@@ -5349,6 +5345,15 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
return status;
}
@@ -40,7 +40,7 @@ index f7f5e44fb57..71a5b294940 100644
/***********************************************************************
* NtUnmapViewOfSectionEx (NTDLL.@)
* ZwUnmapViewOfSectionEx (NTDLL.@)
@@ -5304,7 +5309,7 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
@@ -5356,7 +5361,7 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
NTSTATUS WINAPI NtUnmapViewOfSectionEx( HANDLE process, PVOID addr, ULONG flags )
{
if (flags) FIXME("Ignoring flags %#x.\n", (int)flags);

View File

@@ -1,4 +1,4 @@
From 0242eb04e638bde912dec2c7ee189be12ad24b47 Mon Sep 17 00:00:00 2001
From 5b6d1300eec9340cccf52cb7551878a82210c8fa Mon Sep 17 00:00:00 2001
From: Paul Gofman <pgofman@codeweavers.com>
Date: Fri, 11 Nov 2022 12:54:19 -0600
Subject: [PATCH] ntdll: Support MEM_PRESERVE_PLACEHOLDER in
@@ -114,10 +114,10 @@ index e5185a2587d..d70f947d6aa 100644
hmod = GetModuleHandleA("ntdll.dll");
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c
index 469c012190c..f481a1394b8 100644
index 5de4a7374bc..b3a8d79194f 100644
--- a/dlls/ntdll/unix/server.c
+++ b/dlls/ntdll/unix/server.c
@@ -638,7 +638,7 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result, BOO
@@ -624,7 +624,7 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result, BOO
result->type = call->type;
addr = wine_server_get_ptr( call->unmap_view.addr );
if ((ULONG_PTR)addr == call->unmap_view.addr)
@@ -127,11 +127,11 @@ index 469c012190c..f481a1394b8 100644
result->unmap_view.status = STATUS_INVALID_PARAMETER;
break;
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 71a5b294940..2e61e8ba22f 100644
index fe2e81fbe95..fc120eaafc0 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -5236,7 +5236,7 @@ NTSTATUS WINAPI NtMapViewOfSectionEx( HANDLE handle, HANDLE process, PVOID *addr
return virtual_map_section( handle, addr_ptr, limit, 0, offset_ptr, size_ptr, alloc_type, protect );
@@ -5288,7 +5288,7 @@ NTSTATUS WINAPI NtMapViewOfSectionEx( HANDLE handle, HANDLE process, PVOID *addr
alloc_type, protect, machine );
}
-NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr )
@@ -139,7 +139,7 @@ index 71a5b294940..2e61e8ba22f 100644
{
struct file_view *view;
unsigned int status = STATUS_NOT_MAPPED_VIEW;
@@ -5251,6 +5251,7 @@ NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr )
@@ -5303,6 +5303,7 @@ NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr )
call.unmap_view.type = APC_UNMAP_VIEW;
call.unmap_view.addr = wine_server_client_ptr( addr );
@@ -147,7 +147,7 @@ index 71a5b294940..2e61e8ba22f 100644
status = server_queue_process_apc( process, &call, &result );
if (status == STATUS_SUCCESS) status = result.unmap_view.status;
return status;
@@ -5259,6 +5260,11 @@ NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr )
@@ -5311,6 +5312,11 @@ NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr )
server_enter_uninterrupted_section( &virtual_mutex, &sigset );
if ((view = find_view( addr, 0 )) && !is_view_valloc( view ))
{
@@ -159,7 +159,7 @@ index 71a5b294940..2e61e8ba22f 100644
if (view->protect & VPROT_SYSTEM)
{
struct builtin_module *builtin;
@@ -5285,10 +5291,14 @@ NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr )
@@ -5337,10 +5343,14 @@ NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr )
if (!status)
{
if (view->protect & SEC_IMAGE) release_builtin_module( view->base );
@@ -175,7 +175,7 @@ index 71a5b294940..2e61e8ba22f 100644
server_leave_uninterrupted_section( &virtual_mutex, &sigset );
return status;
}
@@ -5299,7 +5309,7 @@ NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr )
@@ -5351,7 +5361,7 @@ NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr )
*/
NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
{
@@ -184,7 +184,7 @@ index 71a5b294940..2e61e8ba22f 100644
}
/***********************************************************************
@@ -5309,7 +5319,7 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
@@ -5361,7 +5371,7 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
NTSTATUS WINAPI NtUnmapViewOfSectionEx( HANDLE process, PVOID addr, ULONG flags )
{
if (flags) FIXME("Ignoring flags %#x.\n", (int)flags);
@@ -194,10 +194,10 @@ index 71a5b294940..2e61e8ba22f 100644
/******************************************************************************
diff --git a/server/protocol.def b/server/protocol.def
index 0515dcb2245..9c084fdfff7 100644
index 4c8de97041c..40125371249 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -615,6 +615,7 @@ typedef union
@@ -616,6 +616,7 @@ typedef union
enum apc_type type; /* APC_UNMAP_VIEW */
int __pad;
client_ptr_t addr; /* view address */