You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-04-13 14:42:51 -07:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f8cc3baab3 | ||
|
7665942477 | ||
|
0cd181d0ce | ||
|
a580edefe1 | ||
|
fe6cfefe64 | ||
|
6900845545 | ||
|
3e3ebf5cfc | ||
|
f48794a9ce | ||
|
27397d1764 |
@@ -1,4 +1,4 @@
|
||||
From f4e3bbf1a91a5a99d703d3fee9a81a5c5089ab79 Mon Sep 17 00:00:00 2001
|
||||
From 5bc649eecc617214650f5af105f3ae6b6fae5a11 Mon Sep 17 00:00:00 2001
|
||||
From: Mark Harmstone <mark@harmstone.com>
|
||||
Date: Fri, 27 Mar 2015 20:48:19 +0000
|
||||
Subject: [PATCH] dsound: Support getting and setting EAX buffer properties.
|
||||
@@ -11,12 +11,12 @@ Subject: [PATCH] dsound: Support getting and setting EAX buffer properties.
|
||||
4 files changed, 72 insertions(+)
|
||||
|
||||
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
|
||||
index b7a0fb26c4b..0aff7c96842 100644
|
||||
index 5c8c495bfe4..ede6d9f1ba1 100644
|
||||
--- a/dlls/dsound/buffer.c
|
||||
+++ b/dlls/dsound/buffer.c
|
||||
@@ -1127,6 +1127,8 @@ HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *ds
|
||||
return DSERR_OUTOFMEMORY;
|
||||
}
|
||||
@@ -1107,6 +1107,8 @@ HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *ds
|
||||
dsb->sec_mixpos = 0;
|
||||
dsb->state = STATE_STOPPED;
|
||||
|
||||
+ dsb->eax.reverb_mix = EAX_REVERBMIX_USEDISTANCE;
|
||||
+
|
||||
@@ -39,7 +39,7 @@ index c90d82d9a3f..2ee83b94ff9 100644
|
||||
}
|
||||
#endif
|
||||
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
|
||||
index a11379f0f88..9b537ad80a5 100644
|
||||
index 021844c414d..7a89b047b42 100644
|
||||
--- a/dlls/dsound/dsound_private.h
|
||||
+++ b/dlls/dsound/dsound_private.h
|
||||
@@ -177,6 +177,8 @@ struct IDirectSoundBufferImpl
|
||||
@@ -52,7 +52,7 @@ index a11379f0f88..9b537ad80a5 100644
|
||||
};
|
||||
|
||||
diff --git a/dlls/dsound/eax.c b/dlls/dsound/eax.c
|
||||
index cdd03becbee..3931681d295 100644
|
||||
index 13471aec3a9..03b6e0a9813 100644
|
||||
--- a/dlls/dsound/eax.c
|
||||
+++ b/dlls/dsound/eax.c
|
||||
@@ -178,6 +178,38 @@ HRESULT WINAPI EAX_Get(IDirectSoundBufferImpl *buf, REFGUID guidPropSet,
|
||||
@@ -134,5 +134,5 @@ index cdd03becbee..3931681d295 100644
|
||||
}
|
||||
|
||||
--
|
||||
2.33.0
|
||||
2.40.1
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
From 42c58e406220e9351337b079ae44364fbc39365d Mon Sep 17 00:00:00 2001
|
||||
From e484e3dc512eacc9708c245a9e64372428bc1875 Mon Sep 17 00:00:00 2001
|
||||
From: Mark Harmstone <mark@harmstone.com>
|
||||
Date: Fri, 27 Mar 2015 20:58:37 +0000
|
||||
Subject: [PATCH] dsound: Add EAX init and free stubs.
|
||||
@@ -10,11 +10,11 @@ Subject: [PATCH] dsound: Add EAX init and free stubs.
|
||||
3 files changed, 33 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
|
||||
index 22b23c9f877..72e96765883 100644
|
||||
index ede6d9f1ba1..309d632397a 100644
|
||||
--- a/dlls/dsound/buffer.c
|
||||
+++ b/dlls/dsound/buffer.c
|
||||
@@ -1152,6 +1152,8 @@ HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *ds
|
||||
DSOUND_RecalcVolPan(&(dsb->volpan));
|
||||
@@ -1145,6 +1145,8 @@ HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *ds
|
||||
}
|
||||
|
||||
InitializeSRWLock(&dsb->lock);
|
||||
+ if (dsb->device->eax.using_eax)
|
||||
@@ -22,7 +22,7 @@ index 22b23c9f877..72e96765883 100644
|
||||
|
||||
/* register buffer */
|
||||
err = DirectSoundDevice_AddBuffer(device, dsb);
|
||||
@@ -1193,6 +1195,8 @@ void secondarybuffer_destroy(IDirectSoundBufferImpl *This)
|
||||
@@ -1186,6 +1188,8 @@ void secondarybuffer_destroy(IDirectSoundBufferImpl *This)
|
||||
free(This->filters);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ index 22b23c9f877..72e96765883 100644
|
||||
|
||||
free(This);
|
||||
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
|
||||
index 09566b28a12..703b5da8225 100644
|
||||
index 7a89b047b42..c5e84f07763 100644
|
||||
--- a/dlls/dsound/dsound_private.h
|
||||
+++ b/dlls/dsound/dsound_private.h
|
||||
@@ -240,6 +240,8 @@ HRESULT WINAPI EAX_Get(IDirectSoundBufferImpl *buf, REFGUID guidPropSet,
|
||||
@@ -97,5 +97,5 @@ index 03b6e0a9813..91438efc335 100644
|
||||
|
||||
HRESULT WINAPI EAX_Get(IDirectSoundBufferImpl *buf, REFGUID guidPropSet,
|
||||
--
|
||||
2.39.2
|
||||
2.40.1
|
||||
|
||||
|
@@ -1 +1,2 @@
|
||||
Fixes: Improve performance of bilinear bitmap scaling
|
||||
Disabled: True
|
||||
|
@@ -1,4 +1,4 @@
|
||||
From 5814a4b9c7d4dec027b0c2dd29822664aa56ada1 Mon Sep 17 00:00:00 2001
|
||||
From 5a81a28605ec0b32b020c84032e3f4a35d0e4768 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Gofman <pgofman@codeweavers.com>
|
||||
Date: Tue, 14 Jan 2020 21:39:23 +0300
|
||||
Subject: [PATCH] ntdll: Increase step after failed map attempt in
|
||||
@@ -9,10 +9,10 @@ Subject: [PATCH] ntdll: Increase step after failed map attempt in
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
|
||||
index 84a4e331ad7..a63882023e6 100644
|
||||
index 2e61e8ba22f..039007f6a9b 100644
|
||||
--- a/dlls/ntdll/unix/virtual.c
|
||||
+++ b/dlls/ntdll/unix/virtual.c
|
||||
@@ -1327,6 +1327,7 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step,
|
||||
@@ -1336,6 +1336,7 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step,
|
||||
step == 0)
|
||||
break;
|
||||
start = (char *)start + step;
|
||||
@@ -21,5 +21,5 @@ index 84a4e331ad7..a63882023e6 100644
|
||||
|
||||
return NULL;
|
||||
--
|
||||
2.38.1
|
||||
2.40.1
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
From b1e6d32e7dc3bac93419f3a573f509ee6e1177b2 Mon Sep 17 00:00:00 2001
|
||||
From b7c39298824976bbbc8788b60aa4195f3815d3b9 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Gofman <pgofman@codeweavers.com>
|
||||
Date: Thu, 23 Jul 2020 18:40:39 +0300
|
||||
Subject: [PATCH] ntdll: Increase free ranges view block size on 64 bit.
|
||||
@@ -8,10 +8,10 @@ Subject: [PATCH] ntdll: Increase free ranges view block size on 64 bit.
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
|
||||
index a63882023e6..83909f57d4a 100644
|
||||
index 039007f6a9b..82a0a91cf14 100644
|
||||
--- a/dlls/ntdll/unix/virtual.c
|
||||
+++ b/dlls/ntdll/unix/virtual.c
|
||||
@@ -205,7 +205,11 @@ static BYTE *pages_vprot;
|
||||
@@ -212,7 +212,11 @@ static BYTE *pages_vprot;
|
||||
#endif
|
||||
|
||||
static struct file_view *view_block_start, *view_block_end, *next_free_view;
|
||||
@@ -24,5 +24,5 @@ index a63882023e6..83909f57d4a 100644
|
||||
static void *preload_reserve_end;
|
||||
static BOOL force_exec_prot; /* whether to force PROT_EXEC on all PROT_READ mmaps */
|
||||
--
|
||||
2.38.1
|
||||
2.40.1
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
From c3252fd68ecdcc0186b4d284df1b36ea11ca7d7f Mon Sep 17 00:00:00 2001
|
||||
From 5be3a73fdd9728f6280a2c0b790166c94309bf73 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Gofman <pgofman@codeweavers.com>
|
||||
Date: Mon, 25 Nov 2019 12:19:20 +0300
|
||||
Subject: [PATCH] ntdll: Force virtual memory allocation order.
|
||||
@@ -16,10 +16,10 @@ Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46568
|
||||
1 file changed, 227 insertions(+), 223 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
|
||||
index 83909f57d4a..4bce8f2f806 100644
|
||||
index 13aa67c2d82..fd5bb86e6de 100644
|
||||
--- a/dlls/ntdll/unix/virtual.c
|
||||
+++ b/dlls/ntdll/unix/virtual.c
|
||||
@@ -1266,44 +1266,15 @@ static struct file_view *find_view_range( const void *addr, size_t size )
|
||||
@@ -1275,44 +1275,15 @@ static struct file_view *find_view_range( const void *addr, size_t size )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ index 83909f57d4a..4bce8f2f806 100644
|
||||
|
||||
/***********************************************************************
|
||||
* try_map_free_area
|
||||
@@ -1337,110 +1308,6 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step,
|
||||
@@ -1346,110 +1317,6 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ index 83909f57d4a..4bce8f2f806 100644
|
||||
/***********************************************************************
|
||||
* add_reserved_area
|
||||
*
|
||||
@@ -1608,8 +1475,7 @@ static void free_view( struct file_view *view )
|
||||
@@ -1617,8 +1484,7 @@ static void free_view( struct file_view *view )
|
||||
*/
|
||||
static void unregister_view( struct file_view *view )
|
||||
{
|
||||
@@ -193,7 +193,7 @@ index 83909f57d4a..4bce8f2f806 100644
|
||||
wine_rb_remove( &views_tree, &view->entry );
|
||||
}
|
||||
|
||||
@@ -1636,8 +1502,7 @@ static void delete_view( struct file_view *view ) /* [in] View */
|
||||
@@ -1646,8 +1512,7 @@ static void delete_view( struct file_view *view ) /* [in] View */
|
||||
static void register_view( struct file_view *view )
|
||||
{
|
||||
wine_rb_put( &views_tree, view->base, &view->entry );
|
||||
@@ -203,7 +203,7 @@ index 83909f57d4a..4bce8f2f806 100644
|
||||
}
|
||||
|
||||
|
||||
@@ -1906,55 +1771,229 @@ static inline void *unmap_extra_space( void *ptr, size_t total_size, size_t want
|
||||
@@ -1916,55 +1781,229 @@ static inline void *unmap_extra_space( void *ptr, size_t total_size, size_t want
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -241,7 +241,10 @@ index 83909f57d4a..4bce8f2f806 100644
|
||||
+
|
||||
+ if (area->map_area_end <= (char *)start)
|
||||
+ return 0;
|
||||
+
|
||||
|
||||
- if (start < address_space_start) start = address_space_start;
|
||||
- if (is_beyond_limit( start, size, alloc->limit )) end = alloc->limit;
|
||||
- if (start >= end) return 0;
|
||||
+ if ((ULONG_PTR)area->map_area_end < area->size)
|
||||
+ return 1;
|
||||
+
|
||||
@@ -255,10 +258,7 @@ index 83909f57d4a..4bce8f2f806 100644
|
||||
+ alloc_start, area->size, area->unix_prot )))
|
||||
+ return 1;
|
||||
+ }
|
||||
|
||||
- if (start < address_space_start) start = address_space_start;
|
||||
- if (is_beyond_limit( start, size, alloc->limit )) end = alloc->limit;
|
||||
- if (start >= end) return 0;
|
||||
+
|
||||
+ if (intersect_end - intersect_start >= area->size)
|
||||
+ {
|
||||
+ alloc_start = ROUND_ADDR( intersect_end - area->size, align_mask );
|
||||
@@ -467,7 +467,7 @@ index 83909f57d4a..4bce8f2f806 100644
|
||||
/***********************************************************************
|
||||
* map_fixed_area
|
||||
*
|
||||
@@ -2019,6 +2058,8 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
|
||||
@@ -2029,6 +2068,8 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
|
||||
void *ptr;
|
||||
NTSTATUS status;
|
||||
|
||||
@@ -475,9 +475,9 @@ index 83909f57d4a..4bce8f2f806 100644
|
||||
+
|
||||
if (alloc_type & MEM_REPLACE_PLACEHOLDER)
|
||||
{
|
||||
if ((*view_ret = find_view( base, 0 )))
|
||||
@@ -2044,6 +2085,8 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
struct file_view *view;
|
||||
@@ -2046,6 +2087,8 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
+ if (!align_mask) align_mask = granularity_mask;
|
||||
@@ -485,7 +485,7 @@ index 83909f57d4a..4bce8f2f806 100644
|
||||
if (base)
|
||||
{
|
||||
if (is_beyond_limit( base, size, address_space_limit ))
|
||||
@@ -2052,52 +2095,10 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
|
||||
@@ -2056,52 +2099,10 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
|
||||
if (status != STATUS_SUCCESS) return status;
|
||||
ptr = base;
|
||||
}
|
||||
@@ -540,7 +540,7 @@ index 83909f57d4a..4bce8f2f806 100644
|
||||
status = create_view( view_ret, ptr, size, vprot );
|
||||
if (status != STATUS_SUCCESS) unmap_area( ptr, size );
|
||||
return status;
|
||||
@@ -2758,6 +2759,7 @@ static NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG_PTR z
|
||||
@@ -3050,6 +3051,7 @@ static unsigned int virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG_P
|
||||
done:
|
||||
server_leave_uninterrupted_section( &virtual_mutex, &sigset );
|
||||
if (needs_close) close( unix_handle );
|
||||
@@ -548,7 +548,7 @@ index 83909f57d4a..4bce8f2f806 100644
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -2826,6 +2828,7 @@ void virtual_init(void)
|
||||
@@ -3118,6 +3120,7 @@ void virtual_init(void)
|
||||
if (preload_reserve_start)
|
||||
address_space_start = min( address_space_start, preload_reserve_start );
|
||||
}
|
||||
@@ -556,7 +556,7 @@ index 83909f57d4a..4bce8f2f806 100644
|
||||
}
|
||||
|
||||
/* try to find space in a reserved area for the views and pages protection table */
|
||||
@@ -5579,6 +5582,7 @@ NTSTATUS WINAPI NtWow64AllocateVirtualMemory64( HANDLE process, ULONG64 *ret, UL
|
||||
@@ -5842,6 +5845,7 @@ NTSTATUS WINAPI NtWow64AllocateVirtualMemory64( HANDLE process, ULONG64 *ret, UL
|
||||
*ret = (ULONG_PTR)base;
|
||||
*size_ptr = size;
|
||||
}
|
||||
@@ -565,5 +565,5 @@ index 83909f57d4a..4bce8f2f806 100644
|
||||
}
|
||||
|
||||
--
|
||||
2.38.1
|
||||
2.40.1
|
||||
|
||||
|
@@ -1,25 +1,35 @@
|
||||
From d29a79d8cca2220c838fbbea6ea81b9f73070ba5 Mon Sep 17 00:00:00 2001
|
||||
From bd1c2ee8168bc923e3040af04ea3bebc8c021ea5 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Gofman <pgofman@codeweavers.com>
|
||||
Date: Tue, 2 Jun 2020 21:06:33 +0300
|
||||
Subject: [PATCH] ntdll: Exclude natively mapped areas from free areas list.
|
||||
|
||||
---
|
||||
dlls/ntdll/unix/virtual.c | 118 ++++++++++++++++++++++++++++++++------
|
||||
1 file changed, 100 insertions(+), 18 deletions(-)
|
||||
dlls/ntdll/unix/virtual.c | 126 ++++++++++++++++++++++++++++++++------
|
||||
1 file changed, 107 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
|
||||
index 4bce8f2f806..3c1bf6edc30 100644
|
||||
index b189ded181b..00569e5e24c 100644
|
||||
--- a/dlls/ntdll/unix/virtual.c
|
||||
+++ b/dlls/ntdll/unix/virtual.c
|
||||
@@ -125,6 +125,7 @@ struct file_view
|
||||
@@ -130,6 +130,7 @@ C_ASSERT( offsetof( struct file_view, entry ) == 0 );
|
||||
#define VPROT_SYSTEM 0x0200 /* system view (underlying mmap not under our control) */
|
||||
#define VPROT_PLACEHOLDER 0x0400
|
||||
#define VPROT_FROMPLACEHOLDER 0x0800
|
||||
#define VPROT_PLACEHOLDER 0x0400
|
||||
#define VPROT_FREE_PLACEHOLDER 0x0800
|
||||
+#define VPROT_NATIVE 0x1000
|
||||
|
||||
/* Conversion from VPROT_* to Win32 flags */
|
||||
static const BYTE VIRTUAL_Win32Flags[16] =
|
||||
@@ -1119,7 +1120,9 @@ static void dump_view( struct file_view *view )
|
||||
@@ -184,6 +185,9 @@ static void *working_set_limit = (void *)0x7fff0000;
|
||||
|
||||
static UINT64 *arm64ec_map;
|
||||
|
||||
+static const ptrdiff_t max_try_map_step = 0x40000000;
|
||||
+static BOOL increase_try_map_step = TRUE;
|
||||
+
|
||||
struct _KUSER_SHARED_DATA *user_shared_data = (void *)0x7ffe0000;
|
||||
|
||||
/* TEB allocation blocks */
|
||||
@@ -1164,7 +1168,9 @@ static void dump_view( struct file_view *view )
|
||||
BYTE prot = get_page_vprot( addr );
|
||||
|
||||
TRACE( "View: %p - %p", addr, addr + view->size - 1 );
|
||||
@@ -28,9 +38,9 @@ index 4bce8f2f806..3c1bf6edc30 100644
|
||||
+ TRACE(" (native)\n");
|
||||
+ else if (view->protect & VPROT_SYSTEM)
|
||||
TRACE( " (builtin image)\n" );
|
||||
else if (view->protect & VPROT_PLACEHOLDER)
|
||||
else if (view->protect & VPROT_FREE_PLACEHOLDER)
|
||||
TRACE( " (placeholder)\n" );
|
||||
@@ -1274,6 +1277,8 @@ struct alloc_area
|
||||
@@ -1283,6 +1289,8 @@ struct alloc_area
|
||||
int unix_prot;
|
||||
BOOL top_down;
|
||||
UINT_PTR align_mask;
|
||||
@@ -39,7 +49,7 @@ index 4bce8f2f806..3c1bf6edc30 100644
|
||||
};
|
||||
|
||||
/***********************************************************************
|
||||
@@ -1282,21 +1287,28 @@ struct alloc_area
|
||||
@@ -1291,27 +1299,35 @@ struct alloc_area
|
||||
* Try mmaping some expected free memory region, eventually stepping and
|
||||
* retrying inside it, and return where it actually succeeded, or NULL.
|
||||
*/
|
||||
@@ -73,7 +83,15 @@ index 4bce8f2f806..3c1bf6edc30 100644
|
||||
if ((step > 0 && (char *)end - (char *)start < step) ||
|
||||
(step < 0 && (char *)start - (char *)base < -step) ||
|
||||
step == 0)
|
||||
@@ -1797,9 +1809,9 @@ static int alloc_area_in_reserved_or_between_callback( void *start, SIZE_T size,
|
||||
break;
|
||||
start = (char *)start + step;
|
||||
- step *= 2;
|
||||
+ if (increase_try_map_step && llabs(step) < max_try_map_step)
|
||||
+ step *= 2;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -1807,9 +1823,9 @@ static int alloc_area_in_reserved_or_between_callback( void *start, SIZE_T size,
|
||||
assert(intersect_start <= intersect_end);
|
||||
if (area->map_area_end - intersect_end >= area->size)
|
||||
{
|
||||
@@ -86,7 +104,7 @@ index 4bce8f2f806..3c1bf6edc30 100644
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1838,8 +1850,8 @@ static int alloc_area_in_reserved_or_between_callback( void *start, SIZE_T size,
|
||||
@@ -1848,8 +1864,8 @@ static int alloc_area_in_reserved_or_between_callback( void *start, SIZE_T size,
|
||||
if (intersect_start - area->map_area_start >= area->size)
|
||||
{
|
||||
alloc_start = ROUND_ADDR( area->map_area_start + align_mask, align_mask );
|
||||
@@ -97,7 +115,7 @@ index 4bce8f2f806..3c1bf6edc30 100644
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1900,8 +1912,7 @@ static void *alloc_free_area_in_range( struct alloc_area *area, char *base, char
|
||||
@@ -1910,8 +1926,7 @@ static void *alloc_free_area_in_range( struct alloc_area *area, char *base, char
|
||||
if (start >= area->map_area_end || start < area->map_area_start)
|
||||
return NULL;
|
||||
|
||||
@@ -107,7 +125,7 @@ index 4bce8f2f806..3c1bf6edc30 100644
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1911,8 +1922,7 @@ static void *alloc_free_area_in_range( struct alloc_area *area, char *base, char
|
||||
@@ -1921,8 +1936,7 @@ static void *alloc_free_area_in_range( struct alloc_area *area, char *base, char
|
||||
|| area->map_area_end - start < area->size)
|
||||
return NULL;
|
||||
|
||||
@@ -117,15 +135,15 @@ index 4bce8f2f806..3c1bf6edc30 100644
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1922,6 +1932,7 @@ static void *alloc_free_area( void *limit, size_t size, BOOL top_down, int unix_
|
||||
char *reserve_start, *reserve_end;
|
||||
@@ -1933,6 +1947,7 @@ static void *alloc_free_area( void *limit, size_t size, BOOL top_down, int unix_
|
||||
struct alloc_area area;
|
||||
char *base, *end;
|
||||
+ NTSTATUS status;
|
||||
int ranges_inc;
|
||||
+ UINT status;
|
||||
|
||||
TRACE("limit %p, size %p, top_down %#x.\n", limit, (void *)size, top_down);
|
||||
@@ -1991,7 +2002,58 @@ static void *alloc_free_area( void *limit, size_t size, BOOL top_down, int unix_
|
||||
|
||||
@@ -2001,7 +2016,58 @@ static void *alloc_free_area( void *limit, size_t size, BOOL top_down, int unix_
|
||||
if ((area.result = alloc_free_area_in_range( &area, base, end )))
|
||||
break;
|
||||
}
|
||||
@@ -177,7 +195,7 @@ index 4bce8f2f806..3c1bf6edc30 100644
|
||||
+ }
|
||||
+ if ((status = create_view( &next, native_mapped_start, native_mapped_end - native_mapped_start,
|
||||
+ VPROT_SYSTEM | VPROT_NATIVE )))
|
||||
+ ERR("Could not cretae view for natively mapped area, status %#x.\n", status);
|
||||
+ ERR("Could not create view for natively mapped area, status %#x.\n", status);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -185,7 +203,7 @@ index 4bce8f2f806..3c1bf6edc30 100644
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
@@ -2045,6 +2107,17 @@ static NTSTATUS map_fixed_area( void *base, size_t size, unsigned int vprot )
|
||||
@@ -2055,6 +2121,17 @@ static NTSTATUS map_fixed_area( void *base, size_t size, unsigned int vprot )
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -203,20 +221,22 @@ index 4bce8f2f806..3c1bf6edc30 100644
|
||||
/***********************************************************************
|
||||
* map_view
|
||||
*
|
||||
@@ -2097,7 +2170,11 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
|
||||
@@ -2114,7 +2191,13 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
|
||||
}
|
||||
else if (!(ptr = alloc_free_area( (void *)limit, size, top_down, get_unix_prot( vprot ), align_mask )))
|
||||
{
|
||||
- return STATUS_NO_MEMORY;
|
||||
+ WARN("Allocation failed, clearing native views.\n");
|
||||
+ WARN( "Allocation failed, clearing native views.\n" );
|
||||
+
|
||||
+ clear_native_views();
|
||||
+ if (!(ptr = alloc_free_area( (void *)limit, size, top_down, get_unix_prot( vprot ), align_mask )))
|
||||
+ return STATUS_NO_MEMORY;
|
||||
+ if (!is_win64) increase_try_map_step = FALSE;
|
||||
+ ptr = alloc_free_area( (void *)limit, size, top_down, get_unix_prot( vprot ), align_mask );
|
||||
+ if (!is_win64) increase_try_map_step = TRUE;
|
||||
+ if (!ptr) return STATUS_NO_MEMORY;
|
||||
}
|
||||
status = create_view( view_ret, ptr, size, vprot );
|
||||
if (status != STATUS_SUCCESS) unmap_area( ptr, size );
|
||||
@@ -3835,7 +3912,12 @@ void virtual_set_force_exec( BOOL enable )
|
||||
@@ -4106,7 +4189,12 @@ void virtual_set_force_exec( BOOL enable )
|
||||
WINE_RB_FOR_EACH_ENTRY( view, &views_tree, struct file_view, entry )
|
||||
{
|
||||
/* file mappings are always accessible */
|
||||
@@ -231,5 +251,5 @@ index 4bce8f2f806..3c1bf6edc30 100644
|
||||
mprotect_range( view->base, view->size, commit, 0 );
|
||||
}
|
||||
--
|
||||
2.38.1
|
||||
2.40.1
|
||||
|
||||
|
@@ -1,4 +1,3 @@
|
||||
Fixes: [48175] AION (64 bit) - crashes in crysystem.dll.CryFree() due to high memory pointers allocated
|
||||
Fixes: [46568] 64-bit msxml6.dll from Microsoft Core XML Services 6.0 redist package fails to load (Wine doesn't respect 44-bit user-mode VA limitation from Windows < 8.1)
|
||||
Depends: ntdll-Placeholders
|
||||
Disabled: True
|
||||
|
@@ -1,58 +0,0 @@
|
||||
From ebca5e5a6d9e498ca1f7c0f823e40c25be547500 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Gofman <pgofman@codeweavers.com>
|
||||
Date: Thu, 10 Nov 2022 18:40:18 -0600
|
||||
Subject: [PATCH] ntdll: Handle NULL process handle in MapViewOfFile3().
|
||||
|
||||
Based on a patch by Nikolay Sivov.
|
||||
---
|
||||
dlls/kernelbase/memory.c | 2 ++
|
||||
dlls/ntdll/tests/virtual.c | 13 +++++++++++++
|
||||
2 files changed, 15 insertions(+)
|
||||
|
||||
diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c
|
||||
index 4188eebf181..19381e00b31 100644
|
||||
--- a/dlls/kernelbase/memory.c
|
||||
+++ b/dlls/kernelbase/memory.c
|
||||
@@ -265,6 +265,8 @@ LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFile3( HANDLE handle, HANDLE process, P
|
||||
LARGE_INTEGER off;
|
||||
void *addr;
|
||||
|
||||
+ if (!process) process = GetCurrentProcess();
|
||||
+
|
||||
addr = baseaddr;
|
||||
off.QuadPart = offset;
|
||||
if (!set_ntstatus( NtMapViewOfSectionEx( handle, process, &addr, &off, &size, alloc_type, protection,
|
||||
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c
|
||||
index ffa462f579f..559ba484d60 100644
|
||||
--- a/dlls/ntdll/tests/virtual.c
|
||||
+++ b/dlls/ntdll/tests/virtual.c
|
||||
@@ -1131,6 +1131,13 @@ static void test_NtMapViewOfSection(void)
|
||||
process = create_target_process("sleep");
|
||||
ok(process != NULL, "Can't start process\n");
|
||||
|
||||
+ ptr = NULL;
|
||||
+ size = 0;
|
||||
+ offset.QuadPart = 0;
|
||||
+ status = NtMapViewOfSection(mapping, NULL, &ptr, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE);
|
||||
+ ok(status == STATUS_INVALID_HANDLE, "NtMapViewOfSection returned %08lx\n", status);
|
||||
+ ok(!((ULONG_PTR)ptr & 0xffff), "returned memory %p is not aligned to 64k\n", ptr);
|
||||
+
|
||||
ptr = NULL;
|
||||
size = 0;
|
||||
offset.QuadPart = 0;
|
||||
@@ -1404,6 +1411,12 @@ static void test_NtMapViewOfSectionEx(void)
|
||||
process = create_target_process("sleep");
|
||||
ok(process != NULL, "Can't start process\n");
|
||||
|
||||
+ ptr = NULL;
|
||||
+ size = 0;
|
||||
+ offset.QuadPart = 0;
|
||||
+ status = pNtMapViewOfSectionEx(mapping, NULL, &ptr, &offset, &size, 0, PAGE_READWRITE, NULL, 0);
|
||||
+ ok(status == STATUS_INVALID_HANDLE, "Unexpected status %08lx\n", status);
|
||||
+
|
||||
ptr = NULL;
|
||||
size = 0x1000;
|
||||
offset.QuadPart = 0;
|
||||
--
|
||||
2.40.1
|
||||
|
@@ -0,0 +1,205 @@
|
||||
From 03f652283badc478f715d50d63de4cb9064ef7f1 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
|
||||
NtFreeVirtualMemory().
|
||||
|
||||
---
|
||||
dlls/ntdll/tests/virtual.c | 72 ++++++++++++++++++++++++++++++++++++--
|
||||
dlls/ntdll/unix/virtual.c | 55 ++++++++++++++++++++++++++++-
|
||||
2 files changed, 124 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c
|
||||
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[2];
|
||||
+ char *p, *p1, *p2, *p3;
|
||||
void *addresses[16];
|
||||
SIZE_T size, size2;
|
||||
- char *p, *p1, *p2;
|
||||
ULONG granularity;
|
||||
NTSTATUS status;
|
||||
ULONG_PTR count;
|
||||
@@ -510,6 +510,7 @@ static void test_NtAllocateVirtualMemoryEx(void)
|
||||
|
||||
p1 = addr1;
|
||||
p2 = p1 + size / 4;
|
||||
+ p3 = p2 + size / 4;
|
||||
size2 = size / 4;
|
||||
status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
@@ -517,12 +518,79 @@ static void test_NtAllocateVirtualMemoryEx(void)
|
||||
ok(size2 == 0x4000, "Unexpected size %#Ix.\n", size2);
|
||||
ok(p1 == addr1, "Unexpected addr %p, expected %p.\n", p1, addr1);
|
||||
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ check_region_size(p1, p2 - p1);
|
||||
+ check_region_size(p2, p3 - p2);
|
||||
+ check_region_size(p3, size - (p3 - p1));
|
||||
+
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_INVALID_PARAMETER_4, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size2 = size + 0x1000;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size2 = size - 0x1000;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ p1 = (char *)addr1 + 0x1000;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+ p1 = addr1;
|
||||
+
|
||||
+ size2 = 0;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_INVALID_PARAMETER_3, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_RELEASE);
|
||||
+ ok(status == STATUS_UNABLE_TO_FREE_VM, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ ok(size == 0x10000, "Unexpected size %#Ix.\n", size);
|
||||
+ ok(p1 == addr1, "Unexpected addr %p, expected %p.\n", p1, addr1);
|
||||
+ check_region_size(p1, size);
|
||||
+
|
||||
+ size2 = size / 4;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ ok(size2 == 0x4000, "Unexpected size %#Ix.\n", size2);
|
||||
+ ok(p1 == addr1, "Unexpected addr %p, expected %p.\n", p1, addr1);
|
||||
check_region_size(p1, size / 4);
|
||||
check_region_size(p2, size - size / 4);
|
||||
- status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE);
|
||||
+
|
||||
+ size2 = size - size / 4;
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), (void **)&p2, &size2, MEM_RESERVE | MEM_REPLACE_PLACEHOLDER,
|
||||
+ PAGE_READWRITE, NULL, 0);
|
||||
ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size2 = size - size / 4;
|
||||
status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE);
|
||||
ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ ok(size2 == 0xc000, "Unexpected size %#Ix.\n", size2);
|
||||
+ ok(p2 == p1 + size / 4, "Unexpected addr %p, expected %p.\n", p2, p1 + size / 4);
|
||||
+
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size2 = size / 4;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ ok(size2 == 0x4000, "Unexpected size %#Ix.\n", size2);
|
||||
+ ok(p1 == addr1, "Unexpected addr %p, expected %p.\n", p1, addr1);
|
||||
+
|
||||
+ size2 = 0;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p3, &size2, MEM_RELEASE);
|
||||
+ ok(status == STATUS_MEMORY_NOT_ALLOCATED, "Unexpected status %08lx.\n", status);
|
||||
|
||||
/* Split in two regions, specifying second half. */
|
||||
addr1 = NULL;
|
||||
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
|
||||
index f68c5ec84d6..26d4edb019a 100644
|
||||
--- a/dlls/ntdll/unix/virtual.c
|
||||
+++ b/dlls/ntdll/unix/virtual.c
|
||||
@@ -114,6 +114,9 @@ struct file_view
|
||||
unsigned int protect; /* protection for all pages at allocation time and SEC_* flags */
|
||||
};
|
||||
|
||||
+/* Assert this so RB_ENTRY_VALUE() result can be checked for NULL. */
|
||||
+C_ASSERT( offsetof( struct file_view, entry ) == 0 );
|
||||
+
|
||||
/* per-page protection flags */
|
||||
#define VPROT_READ 0x01
|
||||
#define VPROT_WRITE 0x02
|
||||
@@ -2335,6 +2338,52 @@ static NTSTATUS free_pages( struct file_view *view, char *base, size_t size )
|
||||
}
|
||||
|
||||
|
||||
+/***********************************************************************
|
||||
+ * coalesce_placeholders
|
||||
+ *
|
||||
+ * Coalesce placeholder views.
|
||||
+ * virtual_mutex must be held by caller.
|
||||
+ */
|
||||
+static NTSTATUS coalesce_placeholders( struct file_view *view, char *base, size_t size, ULONG type )
|
||||
+{
|
||||
+ struct file_view *curr_view, *next_view;
|
||||
+ unsigned int i, view_count = 0;
|
||||
+ size_t views_size = 0;
|
||||
+
|
||||
+ if (type != (MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS)) return STATUS_INVALID_PARAMETER_4;
|
||||
+ if (!size) return STATUS_INVALID_PARAMETER_3;
|
||||
+ if (base != view->base) return STATUS_CONFLICTING_ADDRESSES;
|
||||
+
|
||||
+ curr_view = view;
|
||||
+ while (curr_view->protect & VPROT_FREE_PLACEHOLDER)
|
||||
+ {
|
||||
+ ++view_count;
|
||||
+ views_size += curr_view->size;
|
||||
+ if (views_size >= size) break;
|
||||
+ if (!(next_view = RB_ENTRY_VALUE( rb_next( &curr_view->entry ), struct file_view, entry ))) break;
|
||||
+ if ((char *)curr_view->base + curr_view->size != next_view->base) break;
|
||||
+ curr_view = next_view;
|
||||
+ }
|
||||
+
|
||||
+ if (view_count < 2 || size != views_size) return STATUS_CONFLICTING_ADDRESSES;
|
||||
+
|
||||
+ for (i = 1; i < view_count; ++i)
|
||||
+ {
|
||||
+ curr_view = RB_ENTRY_VALUE( rb_next( &view->entry ), struct file_view, entry );
|
||||
+ unregister_view( curr_view );
|
||||
+ free_view( curr_view );
|
||||
+ }
|
||||
+
|
||||
+ unregister_view( view );
|
||||
+ view->size = views_size;
|
||||
+ register_view( view );
|
||||
+
|
||||
+ VIRTUAL_DEBUG_DUMP_VIEW( view );
|
||||
+
|
||||
+ return STATUS_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+
|
||||
/***********************************************************************
|
||||
* allocate_dos_memory
|
||||
*
|
||||
@@ -4509,7 +4558,8 @@ 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;
|
||||
- else if ((char *)view->base + view->size - base < size) status = STATUS_UNABLE_TO_FREE_VM;
|
||||
+ else if ((char *)view->base + view->size - base < size && !(type & MEM_COALESCE_PLACEHOLDERS))
|
||||
+ status = STATUS_UNABLE_TO_FREE_VM;
|
||||
else switch (type)
|
||||
{
|
||||
case MEM_DECOMMIT:
|
||||
@@ -4522,6 +4572,9 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
|
||||
case MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER:
|
||||
status = free_pages_preserve_placeholder( view, base, size );
|
||||
break;
|
||||
+ case MEM_COALESCE_PLACEHOLDERS:
|
||||
+ status = coalesce_placeholders( view, base, size, type );
|
||||
+ break;
|
||||
default:
|
||||
status = STATUS_INVALID_PARAMETER;
|
||||
break;
|
||||
--
|
||||
2.40.1
|
||||
|
@@ -1,4 +1,4 @@
|
||||
From 41d2b081fcdf72704cfc9a7a0e0f53215074346c 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 ed6d9be8b6f..320596c740e 100644
|
||||
index f5634e64021..fe2e81fbe95 100644
|
||||
--- a/dlls/ntdll/unix/virtual.c
|
||||
+++ b/dlls/ntdll/unix/virtual.c
|
||||
@@ -5208,11 +5208,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 ed6d9be8b6f..320596c740e 100644
|
||||
{
|
||||
struct file_view *view;
|
||||
unsigned int status = STATUS_NOT_MAPPED_VIEW;
|
||||
@@ -5269,6 +5265,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 ed6d9be8b6f..320596c740e 100644
|
||||
/***********************************************************************
|
||||
* NtUnmapViewOfSectionEx (NTDLL.@)
|
||||
* ZwUnmapViewOfSectionEx (NTDLL.@)
|
||||
@@ -5276,7 +5281,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);
|
@@ -1,119 +0,0 @@
|
||||
From 5275b219783f0a85e3fad17ac0f999c98d4b7b1c Mon Sep 17 00:00:00 2001
|
||||
From: Paul Gofman <pgofman@codeweavers.com>
|
||||
Date: Thu, 10 Nov 2022 18:43:05 -0600
|
||||
Subject: [PATCH] ntdll: Support MEM_PRESERVE_PLACEHOLDER in
|
||||
NtFreeVirtualMemory().
|
||||
|
||||
Based on a patch by Nikolay Sivov.
|
||||
---
|
||||
dlls/ntdll/unix/virtual.c | 46 +++++++++++++++++++++++++++++++++------
|
||||
1 file changed, 39 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
|
||||
index 7142d2adf79..85c4ab878b3 100644
|
||||
--- a/dlls/ntdll/unix/virtual.c
|
||||
+++ b/dlls/ntdll/unix/virtual.c
|
||||
@@ -123,6 +123,7 @@ struct file_view
|
||||
#define VPROT_WRITTEN 0x80
|
||||
/* per-mapping protection flags */
|
||||
#define VPROT_SYSTEM 0x0200 /* system view (underlying mmap not under our control) */
|
||||
+#define VPROT_PLACEHOLDER 0x0400
|
||||
|
||||
/* Conversion from VPROT_* to Win32 flags */
|
||||
static const BYTE VIRTUAL_Win32Flags[16] =
|
||||
@@ -1115,6 +1116,8 @@ static void dump_view( struct file_view *view )
|
||||
TRACE( "View: %p - %p", addr, addr + view->size - 1 );
|
||||
if (view->protect & VPROT_SYSTEM)
|
||||
TRACE( " (builtin image)\n" );
|
||||
+ else if (view->protect & VPROT_PLACEHOLDER)
|
||||
+ TRACE( " (placeholder)\n" );
|
||||
else if (view->protect & SEC_IMAGE)
|
||||
TRACE( " (image)\n" );
|
||||
else if (view->protect & SEC_FILE)
|
||||
@@ -4180,7 +4183,7 @@ 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 (type == MEM_RELEASE)
|
||||
+ else if (type == MEM_RELEASE || (type == (MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER)))
|
||||
{
|
||||
/* Free the pages */
|
||||
|
||||
@@ -4190,14 +4193,15 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
|
||||
{
|
||||
if (!size) size = view->size;
|
||||
|
||||
- if (size == view->size)
|
||||
+ if (type == MEM_RELEASE && size == view->size)
|
||||
{
|
||||
assert( base == view->base );
|
||||
delete_view( view );
|
||||
}
|
||||
else
|
||||
{
|
||||
- struct file_view *new_view = NULL;
|
||||
+ struct file_view *new_view = NULL, *preserve_view = NULL;
|
||||
+ int preserve_whole;
|
||||
|
||||
if (view->base != base && base + size != (char *)view->base + view->size
|
||||
&& !(new_view = alloc_view()))
|
||||
@@ -4205,7 +4209,8 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
|
||||
ERR( "out of memory for %p-%p\n", base, (char *)base + size );
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
- unregister_view( view );
|
||||
+ preserve_whole = (size == view->size);
|
||||
+ if (!preserve_whole) unregister_view( view );
|
||||
|
||||
if (new_view)
|
||||
{
|
||||
@@ -4220,7 +4225,7 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
|
||||
VIRTUAL_DEBUG_DUMP_VIEW( view );
|
||||
VIRTUAL_DEBUG_DUMP_VIEW( new_view );
|
||||
}
|
||||
- else
|
||||
+ else if (!preserve_whole)
|
||||
{
|
||||
if (view->base == base)
|
||||
{
|
||||
@@ -4235,8 +4240,35 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
|
||||
VIRTUAL_DEBUG_DUMP_VIEW( view );
|
||||
}
|
||||
|
||||
- set_page_vprot( base, size, 0 );
|
||||
- unmap_area( base, size );
|
||||
+ if (type & MEM_PRESERVE_PLACEHOLDER)
|
||||
+ {
|
||||
+ if (preserve_whole)
|
||||
+ {
|
||||
+ view->protect = VPROT_PLACEHOLDER;
|
||||
+ preserve_view = view;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ if (!(preserve_view = alloc_view()))
|
||||
+ {
|
||||
+ ERR( "out of memory for %p-%p\n", base, (char *)base + size );
|
||||
+ return STATUS_NO_MEMORY;
|
||||
+ }
|
||||
+ preserve_view->base = base;
|
||||
+ preserve_view->size = size;
|
||||
+ preserve_view->protect = VPROT_PLACEHOLDER;
|
||||
+ register_view( preserve_view );
|
||||
+ }
|
||||
+ set_page_vprot( base, size, 0 );
|
||||
+ if (anon_mmap_fixed(base, size, 0, 0) != base)
|
||||
+ ERR("anon_mmap_fixed failed, err %s.\n", strerror(errno));
|
||||
+ VIRTUAL_DEBUG_DUMP_VIEW( preserve_view );
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ set_page_vprot( base, size, 0 );
|
||||
+ unmap_area( base, size );
|
||||
+ }
|
||||
}
|
||||
*addr_ptr = base;
|
||||
*size_ptr = size;
|
||||
--
|
||||
2.38.1
|
||||
|
@@ -1,46 +0,0 @@
|
||||
From 81be823356cc1752e878a0c26529d8a579d96a54 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().
|
||||
|
||||
Based on a patch by Nikolay Sivov.
|
||||
---
|
||||
dlls/ntdll/unix/virtual.c | 7 ++++---
|
||||
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
|
||||
index 418ad19d990..71cf44bec39 100644
|
||||
--- a/dlls/ntdll/unix/virtual.c
|
||||
+++ b/dlls/ntdll/unix/virtual.c
|
||||
@@ -2012,8 +2012,9 @@ static NTSTATUS map_fixed_area( void *base, size_t size, unsigned int vprot )
|
||||
* virtual_mutex must be held by caller.
|
||||
*/
|
||||
static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
|
||||
- int top_down, unsigned int vprot, ULONG_PTR limit, size_t align_mask )
|
||||
+ unsigned int alloc_type, unsigned int vprot, ULONG_PTR limit, size_t align_mask )
|
||||
{
|
||||
+ int top_down = alloc_type & MEM_TOP_DOWN;
|
||||
void *ptr;
|
||||
NTSTATUS status;
|
||||
|
||||
@@ -2230,7 +2231,7 @@ static NTSTATUS allocate_dos_memory( struct file_view **view, unsigned int vprot
|
||||
if (mmap_is_in_reserved_area( low_64k, dosmem_size - 0x10000 ) != 1)
|
||||
{
|
||||
addr = anon_mmap_tryfixed( low_64k, dosmem_size - 0x10000, unix_prot, 0 );
|
||||
- if (addr == MAP_FAILED) return map_view( view, NULL, dosmem_size, FALSE, vprot, 0, 0 );
|
||||
+ if (addr == MAP_FAILED) return map_view( view, NULL, dosmem_size, 0, vprot, 0, 0 );
|
||||
}
|
||||
|
||||
/* now try to allocate the low 64K too */
|
||||
@@ -3371,7 +3372,7 @@ NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, ULONG_PTR limit, SIZE_T
|
||||
|
||||
server_enter_uninterrupted_section( &virtual_mutex, &sigset );
|
||||
|
||||
- status = map_view( &view, NULL, size, FALSE, VPROT_READ | VPROT_WRITE | VPROT_COMMITTED, limit, 0 );
|
||||
+ status = map_view( &view, NULL, size, 0, VPROT_READ | VPROT_WRITE | VPROT_COMMITTED, limit, 0 );
|
||||
if (status != STATUS_SUCCESS) goto done;
|
||||
|
||||
#ifdef VALGRIND_STACK_REGISTER
|
||||
--
|
||||
2.40.1
|
||||
|
@@ -1,4 +1,4 @@
|
||||
From af7dcbb2688ca53aa22421b30f02e2b7b08601ca 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
|
||||
@@ -7,12 +7,12 @@ Subject: [PATCH] ntdll: Support MEM_PRESERVE_PLACEHOLDER in
|
||||
---
|
||||
dlls/kernelbase/tests/process.c | 53 +++++++++++++++++++++++++++++++--
|
||||
dlls/ntdll/unix/server.c | 2 +-
|
||||
dlls/ntdll/unix/virtual.c | 25 +++++++++++++---
|
||||
dlls/ntdll/unix/virtual.c | 18 ++++++++---
|
||||
server/protocol.def | 1 +
|
||||
4 files changed, 73 insertions(+), 8 deletions(-)
|
||||
4 files changed, 66 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/dlls/kernelbase/tests/process.c b/dlls/kernelbase/tests/process.c
|
||||
index 03f76a1b73a..448369a3743 100644
|
||||
index e5185a2587d..d70f947d6aa 100644
|
||||
--- a/dlls/kernelbase/tests/process.c
|
||||
+++ b/dlls/kernelbase/tests/process.c
|
||||
@@ -41,6 +41,7 @@ static PVOID (WINAPI *pVirtualAllocFromApp)(PVOID, SIZE_T, DWORD, DWORD);
|
||||
@@ -37,7 +37,7 @@ index 03f76a1b73a..448369a3743 100644
|
||||
/* Placeholder splitting functionality */
|
||||
placeholder1 = pVirtualAlloc2(NULL, NULL, 2 * size, MEM_RESERVE_PLACEHOLDER | MEM_RESERVE, PAGE_NOACCESS, NULL, 0);
|
||||
ok(!!placeholder1, "Failed to create a placeholder range.\n");
|
||||
@@ -199,11 +207,20 @@ static void test_VirtualAlloc2(void)
|
||||
@@ -198,11 +206,20 @@ static void test_VirtualAlloc2(void)
|
||||
section = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, size, NULL);
|
||||
ok(!!section, "Failed to create a section.\n");
|
||||
|
||||
@@ -60,7 +60,7 @@ index 03f76a1b73a..448369a3743 100644
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
VirtualQuery(placeholder1, &info, sizeof(info));
|
||||
@@ -220,7 +237,34 @@ static void test_VirtualAlloc2(void)
|
||||
@@ -219,7 +236,34 @@ static void test_VirtualAlloc2(void)
|
||||
ok(info.RegionSize == size, "Unexpected size.\n");
|
||||
|
||||
CloseHandle(section);
|
||||
@@ -96,7 +96,7 @@ index 03f76a1b73a..448369a3743 100644
|
||||
UnmapViewOfFile(view2);
|
||||
|
||||
VirtualFree(placeholder1, 0, MEM_RELEASE);
|
||||
@@ -250,6 +294,8 @@ static void test_VirtualAlloc2(void)
|
||||
@@ -249,6 +293,8 @@ static void test_VirtualAlloc2(void)
|
||||
|
||||
p1 = p;
|
||||
p2 = p + size / 2;
|
||||
@@ -105,7 +105,7 @@ index 03f76a1b73a..448369a3743 100644
|
||||
ret = VirtualFree(p1, size / 2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
ok(ret, "Failed to split a placeholder.\n");
|
||||
check_region_size(p1, size / 2);
|
||||
@@ -462,6 +508,7 @@ static void init_funcs(void)
|
||||
@@ -461,6 +507,7 @@ static void init_funcs(void)
|
||||
X(VirtualAlloc2);
|
||||
X(VirtualAlloc2FromApp);
|
||||
X(VirtualAllocFromApp);
|
||||
@@ -114,10 +114,10 @@ index 03f76a1b73a..448369a3743 100644
|
||||
hmod = GetModuleHandleA("ntdll.dll");
|
||||
|
||||
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c
|
||||
index c143560e360..40efda551e0 100644
|
||||
index 5de4a7374bc..b3a8d79194f 100644
|
||||
--- a/dlls/ntdll/unix/server.c
|
||||
+++ b/dlls/ntdll/unix/server.c
|
||||
@@ -618,7 +618,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 c143560e360..40efda551e0 100644
|
||||
result->unmap_view.status = STATUS_INVALID_PARAMETER;
|
||||
break;
|
||||
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
|
||||
index 320596c740e..493f6b80419 100644
|
||||
index fe2e81fbe95..fc120eaafc0 100644
|
||||
--- a/dlls/ntdll/unix/virtual.c
|
||||
+++ b/dlls/ntdll/unix/virtual.c
|
||||
@@ -5208,7 +5208,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 320596c740e..493f6b80419 100644
|
||||
{
|
||||
struct file_view *view;
|
||||
unsigned int status = STATUS_NOT_MAPPED_VIEW;
|
||||
@@ -5223,6 +5223,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,11 +147,11 @@ index 320596c740e..493f6b80419 100644
|
||||
status = server_queue_process_apc( process, &call, &result );
|
||||
if (status == STATUS_SUCCESS) status = result.unmap_view.status;
|
||||
return status;
|
||||
@@ -5231,6 +5232,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 ))
|
||||
{
|
||||
+ if (flags & MEM_PRESERVE_PLACEHOLDER && !(view->protect & VPROT_FROMPLACEHOLDER))
|
||||
+ if (flags & MEM_PRESERVE_PLACEHOLDER && !(view->protect & VPROT_PLACEHOLDER))
|
||||
+ {
|
||||
+ status = STATUS_CONFLICTING_ADDRESSES;
|
||||
+ goto done;
|
||||
@@ -159,22 +159,15 @@ index 320596c740e..493f6b80419 100644
|
||||
if (view->protect & VPROT_SYSTEM)
|
||||
{
|
||||
struct builtin_module *builtin;
|
||||
@@ -5257,10 +5263,21 @@ 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 );
|
||||
- delete_view( view );
|
||||
+ if (flags & MEM_PRESERVE_PLACEHOLDER)
|
||||
+ {
|
||||
+ view->protect = VPROT_PLACEHOLDER;
|
||||
+ set_page_vprot( view->base, view->size, 0 );
|
||||
+ if (anon_mmap_fixed(view->base, view->size, 0, 0) != view->base)
|
||||
+ ERR("anon_mmap_fixed failed, err %s.\n", strerror(errno));
|
||||
+ }
|
||||
+ remove_pages_from_view( view, view->base, view->size );
|
||||
+ else
|
||||
+ {
|
||||
+ delete_view( view );
|
||||
+ }
|
||||
}
|
||||
else FIXME( "failed to unmap %p %x\n", view->base, status );
|
||||
}
|
||||
@@ -182,7 +175,7 @@ index 320596c740e..493f6b80419 100644
|
||||
server_leave_uninterrupted_section( &virtual_mutex, &sigset );
|
||||
return status;
|
||||
}
|
||||
@@ -5271,7 +5288,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 )
|
||||
{
|
||||
@@ -191,7 +184,7 @@ index 320596c740e..493f6b80419 100644
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
@@ -5281,7 +5298,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);
|
||||
@@ -201,10 +194,10 @@ index 320596c740e..493f6b80419 100644
|
||||
|
||||
/******************************************************************************
|
||||
diff --git a/server/protocol.def b/server/protocol.def
|
||||
index 8f5202792b4..10729e3ff64 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 */
|
@@ -1,100 +0,0 @@
|
||||
From ed0aa7cbd5dcaad27598466c273ed4fb96c71a60 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
|
||||
NtAllocateVirtualMemoryEx().
|
||||
|
||||
Based on a patch by Nikolay Sivov.
|
||||
---
|
||||
dlls/ntdll/unix/virtual.c | 26 ++++++++++++++++++++++++--
|
||||
1 file changed, 24 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
|
||||
index 71cf44bec39..d0f1a1d37b1 100644
|
||||
--- a/dlls/ntdll/unix/virtual.c
|
||||
+++ b/dlls/ntdll/unix/virtual.c
|
||||
@@ -4045,8 +4045,7 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
|
||||
|
||||
/* Compute the alloc type flags */
|
||||
|
||||
- if (!(type & (MEM_COMMIT | MEM_RESERVE | MEM_RESET)) ||
|
||||
- (type & ~(MEM_COMMIT | MEM_RESERVE | MEM_TOP_DOWN | MEM_WRITE_WATCH | MEM_RESET)))
|
||||
+ if (!(type & (MEM_COMMIT | MEM_RESERVE | MEM_RESET)))
|
||||
{
|
||||
WARN("called with wrong alloc type flags (%08x) !\n", (int)type);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
@@ -4054,6 +4053,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;
|
||||
|
||||
+ if (type & MEM_RESERVE_PLACEHOLDER && (protect != PAGE_NOACCESS))
|
||||
+ {
|
||||
+ WARN("Wrong protect %#x for placeholder.\n", protect);
|
||||
+ return STATUS_INVALID_PARAMETER;
|
||||
+ }
|
||||
+
|
||||
/* Reserve the memory */
|
||||
|
||||
server_enter_uninterrupted_section( &virtual_mutex, &sigset );
|
||||
@@ -4064,6 +4069,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;
|
||||
+ if (type & MEM_RESERVE_PLACEHOLDER) vprot |= VPROT_PLACEHOLDER;
|
||||
if (protect & PAGE_NOCACHE) vprot |= SEC_NOCACHE;
|
||||
|
||||
if (vprot & VPROT_WRITECOPY) status = STATUS_INVALID_PAGE_PROTECTION;
|
||||
@@ -4083,6 +4089,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;
|
||||
+ else if (view->protect & VPROT_PLACEHOLDER) status = STATUS_CONFLICTING_ADDRESSES;
|
||||
else if (!(status = set_protection( view, base, size, protect )) && (view->protect & SEC_RESERVE))
|
||||
{
|
||||
SERVER_START_REQ( add_mapping_committed_range )
|
||||
@@ -4118,6 +4125,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 )
|
||||
{
|
||||
+ static const ULONG type_mask = MEM_COMMIT | MEM_RESERVE | MEM_TOP_DOWN | MEM_WRITE_WATCH | MEM_RESET;
|
||||
ULONG_PTR limit;
|
||||
|
||||
TRACE("%p %p %08lx %x %08x\n", process, *ret, *size_ptr, (int)type, (int)protect );
|
||||
@@ -4129,6 +4137,12 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR z
|
||||
if (!is_old_wow64() && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3;
|
||||
#endif
|
||||
|
||||
+ if (type & ~type_mask)
|
||||
+ {
|
||||
+ WARN("Called with wrong alloc type flags %08x.\n", type);
|
||||
+ return STATUS_INVALID_PARAMETER;
|
||||
+ }
|
||||
+
|
||||
if (process != NtCurrentProcess())
|
||||
{
|
||||
apc_call_t call;
|
||||
@@ -4231,6 +4245,8 @@ NTSTATUS WINAPI NtAllocateVirtualMemoryEx( HANDLE process, PVOID *ret, SIZE_T *s
|
||||
ULONG protect, MEM_EXTENDED_PARAMETER *parameters,
|
||||
ULONG count )
|
||||
{
|
||||
+ static const ULONG type_mask = MEM_COMMIT | MEM_RESERVE | MEM_TOP_DOWN | MEM_WRITE_WATCH
|
||||
+ | MEM_RESET | MEM_RESERVE_PLACEHOLDER;
|
||||
ULONG_PTR limit = 0;
|
||||
ULONG_PTR align = 0;
|
||||
ULONG attributes = 0;
|
||||
@@ -4239,6 +4255,12 @@ NTSTATUS WINAPI NtAllocateVirtualMemoryEx( HANDLE process, PVOID *ret, SIZE_T *s
|
||||
TRACE( "%p %p %08lx %x %08x %p %u\n",
|
||||
process, *ret, *size_ptr, (int)type, (int)protect, parameters, (int)count );
|
||||
|
||||
+ if (type & ~type_mask)
|
||||
+ {
|
||||
+ WARN("Called with wrong alloc type flags %08x.\n", type);
|
||||
+ return STATUS_INVALID_PARAMETER;
|
||||
+ }
|
||||
+
|
||||
status = get_extended_params( parameters, count, &limit, &align, &attributes );
|
||||
if (status) return status;
|
||||
|
||||
--
|
||||
2.40.1
|
||||
|
@@ -1,107 +0,0 @@
|
||||
From 34562a9ed59356de31669c76bdf87886ee9febe4 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Gofman <pgofman@codeweavers.com>
|
||||
Date: Thu, 10 Nov 2022 18:58:26 -0600
|
||||
Subject: [PATCH] ntdll: Support MEM_REPLACE_PLACEHOLDER in
|
||||
NtAllocateVirtualMemoryEx().
|
||||
|
||||
---
|
||||
dlls/ntdll/unix/virtual.c | 41 +++++++++++++++++++++++++++++++++++----
|
||||
1 file changed, 37 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
|
||||
index dd146126361..0f2818f563d 100644
|
||||
--- a/dlls/ntdll/unix/virtual.c
|
||||
+++ b/dlls/ntdll/unix/virtual.c
|
||||
@@ -126,6 +126,7 @@ struct file_view
|
||||
/* per-mapping protection flags */
|
||||
#define VPROT_SYSTEM 0x0200 /* system view (underlying mmap not under our control) */
|
||||
#define VPROT_PLACEHOLDER 0x0400
|
||||
+#define VPROT_FROMPLACEHOLDER 0x0800
|
||||
|
||||
/* Conversion from VPROT_* to Win32 flags */
|
||||
static const BYTE VIRTUAL_Win32Flags[16] =
|
||||
@@ -2044,6 +2045,31 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
|
||||
void *ptr;
|
||||
NTSTATUS status;
|
||||
|
||||
+ if (alloc_type & MEM_REPLACE_PLACEHOLDER)
|
||||
+ {
|
||||
+ if ((*view_ret = find_view( base, 0 )))
|
||||
+ {
|
||||
+ TRACE( "found view %p, size %p, protect %#x.\n",
|
||||
+ (*view_ret)->base, (void *)(*view_ret)->size, (*view_ret)->protect );
|
||||
+ if ((*view_ret)->base != base || (*view_ret)->size != size)
|
||||
+ return STATUS_CONFLICTING_ADDRESSES;
|
||||
+ if (!((*view_ret)->protect & VPROT_PLACEHOLDER))
|
||||
+ {
|
||||
+ TRACE("Wrong protect %#x for MEM_REPLACE_PLACEHOLDER.\n", (*view_ret)->protect);
|
||||
+ return STATUS_INVALID_PARAMETER;
|
||||
+ }
|
||||
+ (*view_ret)->protect = vprot | VPROT_FROMPLACEHOLDER;
|
||||
+
|
||||
+ if (!set_vprot( *view_ret, base, size, vprot | VPROT_COMMITTED ))
|
||||
+ ERR("set_protection failed.\n");
|
||||
+ if (vprot & VPROT_WRITEWATCH)
|
||||
+ reset_write_watches( base, size );
|
||||
+ return STATUS_SUCCESS;
|
||||
+ }
|
||||
+ TRACE("MEM_REPLACE_PLACEHOLDER view not found.\n");
|
||||
+ return STATUS_INVALID_PARAMETER;
|
||||
+ }
|
||||
+
|
||||
if (base)
|
||||
{
|
||||
if (is_beyond_limit( base, size, address_space_limit ))
|
||||
@@ -4048,7 +4074,7 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
|
||||
|
||||
if (*ret)
|
||||
{
|
||||
- if (type & MEM_RESERVE) /* Round down to 64k boundary */
|
||||
+ if (type & MEM_RESERVE && !(type & MEM_REPLACE_PLACEHOLDER)) /* Round down to 64k boundary */
|
||||
base = ROUND_ADDR( *ret, granularity_mask );
|
||||
else
|
||||
base = ROUND_ADDR( *ret, page_mask );
|
||||
@@ -4072,7 +4098,8 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
|
||||
|
||||
/* Compute the alloc type flags */
|
||||
|
||||
- if (!(type & (MEM_COMMIT | MEM_RESERVE | MEM_RESET)))
|
||||
+ if (!(type & (MEM_COMMIT | MEM_RESERVE | MEM_RESET))
|
||||
+ || (type & MEM_REPLACE_PLACEHOLDER && !(type & MEM_RESERVE)))
|
||||
{
|
||||
WARN("called with wrong alloc type flags (%08x) !\n", (int)type);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
@@ -4101,7 +4128,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 );
|
||||
- else status = map_view( &view, base, size, type & MEM_TOP_DOWN, vprot, limit,
|
||||
+ else status = map_view( &view, base, size, type & (MEM_TOP_DOWN | MEM_REPLACE_PLACEHOLDER), vprot, limit,
|
||||
align ? align - 1 : granularity_mask );
|
||||
|
||||
if (status == STATUS_SUCCESS) base = view->base;
|
||||
@@ -4213,7 +4240,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemoryEx( HANDLE process, PVOID *ret, SIZE_T *s
|
||||
ULONG count )
|
||||
{
|
||||
static const ULONG type_mask = MEM_COMMIT | MEM_RESERVE | MEM_TOP_DOWN | MEM_WRITE_WATCH
|
||||
- | MEM_RESET | MEM_RESERVE_PLACEHOLDER;
|
||||
+ | MEM_RESET | MEM_RESERVE_PLACEHOLDER | MEM_REPLACE_PLACEHOLDER;
|
||||
ULONG_PTR limit = 0;
|
||||
ULONG_PTR align = 0;
|
||||
ULONG attributes = 0;
|
||||
@@ -4371,6 +4398,12 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
|
||||
|
||||
if (size && (char *)view->base + view->size - base < size) status = STATUS_UNABLE_TO_FREE_VM;
|
||||
else if (!size && base != view->base) status = STATUS_FREE_VM_NOT_AT_BASE;
|
||||
+ else if (type == (MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER) && !size) status = STATUS_INVALID_PARAMETER_3;
|
||||
+ else if (type == (MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER) && !((view->protect & VPROT_FROMPLACEHOLDER)
|
||||
+ || (view->protect & VPROT_PLACEHOLDER && size != view->size)))
|
||||
+ {
|
||||
+ status = STATUS_CONFLICTING_ADDRESSES;
|
||||
+ }
|
||||
else
|
||||
{
|
||||
if (!size) size = view->size;
|
||||
--
|
||||
2.40.1
|
||||
|
@@ -1,27 +0,0 @@
|
||||
From 96519657b5925777d613f6a6c0e93bc4d85897b9 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Gofman <pgofman@codeweavers.com>
|
||||
Date: Thu, 10 Nov 2022 19:01:50 -0600
|
||||
Subject: [PATCH] ntdll: Support MEM_REPLACE_PLACEHOLDER in
|
||||
virtual_map_section().
|
||||
|
||||
Based on a patch by Nikolay Sivov.
|
||||
---
|
||||
dlls/ntdll/unix/virtual.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
|
||||
index a36d2c47269..7f57b436b55 100644
|
||||
--- a/dlls/ntdll/unix/virtual.c
|
||||
+++ b/dlls/ntdll/unix/virtual.c
|
||||
@@ -2857,7 +2857,7 @@ static unsigned int virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG_P
|
||||
|
||||
server_enter_uninterrupted_section( &virtual_mutex, &sigset );
|
||||
|
||||
- res = map_view( &view, base, size, alloc_type & MEM_TOP_DOWN, vprot, limit, 0 );
|
||||
+ res = map_view( &view, base, size, alloc_type & (MEM_TOP_DOWN | MEM_REPLACE_PLACEHOLDER), vprot, limit, 0 );
|
||||
if (res) goto done;
|
||||
|
||||
TRACE( "handle=%p size=%lx offset=%s\n", handle, size, wine_dbgstr_longlong(offset.QuadPart) );
|
||||
--
|
||||
2.40.1
|
||||
|
@@ -1,314 +0,0 @@
|
||||
From 2248dedbf01f0abeb4290d79c13c3b967010ba97 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.
|
||||
|
||||
---
|
||||
dlls/kernelbase/tests/process.c | 15 ++-
|
||||
dlls/ntdll/tests/virtual.c | 217 +++++++++++++++++++++++---------
|
||||
2 files changed, 171 insertions(+), 61 deletions(-)
|
||||
|
||||
diff --git a/dlls/kernelbase/tests/process.c b/dlls/kernelbase/tests/process.c
|
||||
index b8c3bbb7276..03f76a1b73a 100644
|
||||
--- a/dlls/kernelbase/tests/process.c
|
||||
+++ b/dlls/kernelbase/tests/process.c
|
||||
@@ -168,7 +168,6 @@ static void test_VirtualAlloc2(void)
|
||||
|
||||
/* Placeholder splitting functionality */
|
||||
placeholder1 = pVirtualAlloc2(NULL, NULL, 2 * size, MEM_RESERVE_PLACEHOLDER | MEM_RESERVE, PAGE_NOACCESS, NULL, 0);
|
||||
- todo_wine
|
||||
ok(!!placeholder1, "Failed to create a placeholder range.\n");
|
||||
if (!placeholder1) return;
|
||||
|
||||
@@ -206,6 +205,20 @@ static void test_VirtualAlloc2(void)
|
||||
view2 = pMapViewOfFile3(section, NULL, placeholder2, 0, size, MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, NULL, 0);
|
||||
ok(!!view2, "Failed to map a section.\n");
|
||||
|
||||
+ memset(&info, 0, sizeof(info));
|
||||
+ VirtualQuery(placeholder1, &info, sizeof(info));
|
||||
+ ok(info.AllocationProtect == PAGE_READWRITE, "Unexpected protection %#lx.\n", info.AllocationProtect);
|
||||
+ ok(info.State == MEM_COMMIT, "Unexpected state %#lx.\n", info.State);
|
||||
+ ok(info.Type == MEM_MAPPED, "Unexpected type %#lx.\n", info.Type);
|
||||
+ ok(info.RegionSize == size, "Unexpected size.\n");
|
||||
+
|
||||
+ memset(&info, 0, sizeof(info));
|
||||
+ VirtualQuery(placeholder2, &info, sizeof(info));
|
||||
+ ok(info.AllocationProtect == PAGE_READWRITE, "Unexpected protection %#lx.\n", info.AllocationProtect);
|
||||
+ ok(info.State == MEM_COMMIT, "Unexpected state %#lx.\n", info.State);
|
||||
+ ok(info.Type == MEM_MAPPED, "Unexpected type %#lx.\n", info.Type);
|
||||
+ ok(info.RegionSize == size, "Unexpected size.\n");
|
||||
+
|
||||
CloseHandle(section);
|
||||
UnmapViewOfFile(view1);
|
||||
UnmapViewOfFile(view2);
|
||||
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c
|
||||
index 335ba118fb9..3000ae68620 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)
|
||||
|
||||
static void test_NtAllocateVirtualMemoryEx(void)
|
||||
{
|
||||
+ MEMORY_BASIC_INFORMATION mbi;
|
||||
+ void *addresses[16];
|
||||
MEM_EXTENDED_PARAMETER ext;
|
||||
SIZE_T size, size2;
|
||||
char *p, *p1, *p2;
|
||||
+ ULONG granularity;
|
||||
NTSTATUS status;
|
||||
+ ULONG_PTR count;
|
||||
void *addr1;
|
||||
|
||||
if (!pNtAllocateVirtualMemoryEx)
|
||||
@@ -332,48 +336,148 @@ static void test_NtAllocateVirtualMemoryEx(void)
|
||||
status = NtAllocateVirtualMemory(NtCurrentProcess(), &addr1, 0, &size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, PAGE_NOACCESS);
|
||||
ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
|
||||
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
|
||||
+ PAGE_READWRITE, NULL, 0);
|
||||
+ ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
|
||||
PAGE_NOACCESS, NULL, 0);
|
||||
todo_wine
|
||||
ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
|
||||
- if (addr1)
|
||||
- {
|
||||
- size = 0;
|
||||
- status = NtFreeVirtualMemory(NtCurrentProcess(), &addr1, &size, MEM_RELEASE);
|
||||
- ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
- }
|
||||
+ size = 0x10000;
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_COMMIT | MEM_REPLACE_PLACEHOLDER,
|
||||
+ PAGE_READWRITE, NULL, 0);
|
||||
+ ok(!status, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ memset(addr1, 0xcc, size);
|
||||
+
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&addr1, &size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
+ ok(!status, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size = 0x10000;
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_COMMIT | MEM_REPLACE_PLACEHOLDER,
|
||||
+ PAGE_READONLY, NULL, 0);
|
||||
+ ok(!status, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ ok(!*(unsigned int *)addr1, "Got %#x.\n", *(unsigned int *)addr1);
|
||||
+
|
||||
+ status = NtQueryVirtualMemory( NtCurrentProcess(), addr1, MemoryBasicInformation, &mbi, sizeof(mbi), &size );
|
||||
+ ok(!status, "Unexpected status %08lx.\n", status);
|
||||
+ ok(mbi.AllocationProtect == PAGE_READONLY, "Unexpected protection %#lx.\n", mbi.AllocationProtect);
|
||||
+ ok(mbi.State == MEM_COMMIT, "Unexpected state %#lx.\n", mbi.State);
|
||||
+ ok(mbi.Type == MEM_PRIVATE, "Unexpected type %#lx.\n", mbi.Type);
|
||||
+ ok(mbi.RegionSize == 0x10000, "Unexpected size.\n");
|
||||
+
|
||||
+ size = 0x10000;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&addr1, &size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
+ ok(!status, "Unexpected status %08lx.\n", status);
|
||||
|
||||
- /* Placeholder region splitting. */
|
||||
+ status = NtQueryVirtualMemory( NtCurrentProcess(), addr1, MemoryBasicInformation, &mbi, sizeof(mbi), &size );
|
||||
+ ok(!status, "Unexpected status %08lx.\n", status);
|
||||
+ ok(mbi.AllocationProtect == PAGE_NOACCESS, "Unexpected protection %#lx.\n", mbi.AllocationProtect);
|
||||
+ ok(mbi.State == MEM_RESERVE, "Unexpected state %#lx.\n", mbi.State);
|
||||
+ ok(mbi.Type == MEM_PRIVATE, "Unexpected type %#lx.\n", mbi.Type);
|
||||
+ ok(mbi.RegionSize == 0x10000, "Unexpected size.\n");
|
||||
+
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
|
||||
+ PAGE_NOACCESS, NULL, 0);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE,
|
||||
+ PAGE_NOACCESS, NULL, 0);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size = 0x1000;
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_REPLACE_PLACEHOLDER,
|
||||
+ PAGE_NOACCESS, NULL, 0);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size = 0x10000;
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_COMMIT, PAGE_READWRITE, NULL, 0);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size = 0x10000;
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, NULL, 0);
|
||||
+ ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size = 0x10000;
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_COMMIT | MEM_REPLACE_PLACEHOLDER,
|
||||
+ PAGE_READWRITE, NULL, 0);
|
||||
+ ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size = 0x10000;
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size,
|
||||
+ MEM_WRITE_WATCH | MEM_RESERVE | MEM_REPLACE_PLACEHOLDER,
|
||||
+ PAGE_READONLY, NULL, 0);
|
||||
+ ok(!status, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size = 0x10000;
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_COMMIT, PAGE_READWRITE, NULL, 0);
|
||||
+ ok(!status, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ status = NtQueryVirtualMemory( NtCurrentProcess(), addr1, MemoryBasicInformation, &mbi, sizeof(mbi), &size );
|
||||
+ ok(!status, "Unexpected status %08lx.\n", status);
|
||||
+ ok(mbi.AllocationProtect == PAGE_READONLY, "Unexpected protection %#lx.\n", mbi.AllocationProtect);
|
||||
+ ok(mbi.State == MEM_COMMIT, "Unexpected state %#lx.\n", mbi.State);
|
||||
+ ok(mbi.Type == MEM_PRIVATE, "Unexpected type %#lx.\n", mbi.Type);
|
||||
+ ok(mbi.RegionSize == 0x10000, "Unexpected size.\n");
|
||||
+
|
||||
+ size = 0x10000;
|
||||
+ count = ARRAY_SIZE(addresses);
|
||||
+ status = NtGetWriteWatch( NtCurrentProcess(), WRITE_WATCH_FLAG_RESET, addr1, size,
|
||||
+ addresses, &count, &granularity );
|
||||
+ ok(!status, "Unexpected status %08lx.\n", status);
|
||||
+ ok(!count, "Unexpected count %u.\n", (unsigned int)count);
|
||||
+ trace("addr1 %p, addresses[0] %p.\n", addr1, addresses[0]);
|
||||
+ *((char *)addr1 + 0x1000) = 1;
|
||||
+ count = ARRAY_SIZE(addresses);
|
||||
+ status = NtGetWriteWatch( NtCurrentProcess(), WRITE_WATCH_FLAG_RESET, addr1, size,
|
||||
+ addresses, &count, &granularity );
|
||||
+ ok(!status, "Unexpected status %08lx.\n", status);
|
||||
+ ok(count == 1, "Unexpected count %u.\n", (unsigned int)count);
|
||||
+ ok(addresses[0] == (char *)addr1 + 0x1000, "Unexpected address %p.\n", addresses[0]);
|
||||
+
|
||||
+ size = 0;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), &addr1, &size, MEM_RELEASE);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ /* Placeholder region splitting. */
|
||||
+ addr1 = NULL;
|
||||
+ size = 0x10000;
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE,
|
||||
+ PAGE_NOACCESS, NULL, 0);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ p = addr1;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p, &size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p, &size, MEM_RELEASE);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
|
||||
/* Split in three regions. */
|
||||
addr1 = NULL;
|
||||
size = 0x10000;
|
||||
status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
|
||||
PAGE_NOACCESS, NULL, 0);
|
||||
- todo_wine
|
||||
ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
|
||||
- if (status == STATUS_SUCCESS)
|
||||
- {
|
||||
- p = addr1;
|
||||
- p1 = p + size / 2;
|
||||
- p2 = p1 + size / 4;
|
||||
- size2 = size / 4;
|
||||
- status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
- ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
-
|
||||
- check_region_size(p, size / 2);
|
||||
- check_region_size(p1, size / 4);
|
||||
- check_region_size(p2, size - size / 2 - size / 4);
|
||||
-
|
||||
- status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p, &size2, MEM_RELEASE);
|
||||
- ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
- status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE);
|
||||
- ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
- status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE);
|
||||
- ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
- }
|
||||
+ p = addr1;
|
||||
+ p1 = p + size / 2;
|
||||
+ p2 = p1 + size / 4;
|
||||
+ size2 = size / 4;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ check_region_size(p, size / 2);
|
||||
+ check_region_size(p1, size / 4);
|
||||
+ check_region_size(p2, size - size / 2 - size / 4);
|
||||
+
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p, &size2, MEM_RELEASE);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
|
||||
/* Split in two regions, specifying lower part. */
|
||||
addr1 = NULL;
|
||||
@@ -383,22 +487,19 @@ static void test_NtAllocateVirtualMemoryEx(void)
|
||||
todo_wine
|
||||
ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
|
||||
- if (status == STATUS_SUCCESS)
|
||||
- {
|
||||
- p1 = addr1;
|
||||
- p2 = p1 + size / 4;
|
||||
- size2 = size / 4;
|
||||
- status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
- ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
- ok(p1 == addr1, "Unexpected address.\n");
|
||||
-
|
||||
- check_region_size(p1, size / 4);
|
||||
- check_region_size(p2, size - size / 4);
|
||||
- status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE);
|
||||
- ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
- status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE);
|
||||
- ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
- }
|
||||
+ p1 = addr1;
|
||||
+ p2 = p1 + size / 4;
|
||||
+ size2 = size / 4;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ ok(p1 == addr1, "Unexpected address.\n");
|
||||
+
|
||||
+ check_region_size(p1, size / 4);
|
||||
+ check_region_size(p2, size - size / 4);
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
|
||||
/* Split in two regions, specifying second half. */
|
||||
addr1 = NULL;
|
||||
@@ -407,23 +508,19 @@ static void test_NtAllocateVirtualMemoryEx(void)
|
||||
PAGE_NOACCESS, NULL, 0);
|
||||
todo_wine
|
||||
ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ p1 = addr1;
|
||||
+ p2 = p1 + size / 2;
|
||||
|
||||
- if (status == STATUS_SUCCESS)
|
||||
- {
|
||||
- p1 = addr1;
|
||||
- p2 = p1 + size / 2;
|
||||
-
|
||||
- size2 = size / 2;
|
||||
- status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
- ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
- ok(p2 == p1 + size / 2, "Unexpected address.\n");
|
||||
- check_region_size(p1, size / 2);
|
||||
- check_region_size(p2, size / 2);
|
||||
- status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE);
|
||||
- ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
- status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE);
|
||||
- ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
- }
|
||||
+ size2 = size / 2;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ ok(p2 == p1 + size / 2, "Unexpected address.\n");
|
||||
+ check_region_size(p1, size / 2);
|
||||
+ check_region_size(p2, size / 2);
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ 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;
|
||||
--
|
||||
2.40.1
|
||||
|
@@ -1,117 +0,0 @@
|
||||
From b7bd1f2c2c63573e47b07f178711586a1f37d765 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
|
||||
NtFreeVirtualMemory().
|
||||
|
||||
---
|
||||
dlls/ntdll/tests/virtual.c | 53 +++++++++++++++++++++++++++++++++++++-
|
||||
dlls/ntdll/unix/virtual.c | 24 +++++++++++++++++
|
||||
2 files changed, 76 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c
|
||||
index b41f42ac9d1..11ccca2ffb4 100644
|
||||
--- a/dlls/ntdll/tests/virtual.c
|
||||
+++ b/dlls/ntdll/tests/virtual.c
|
||||
@@ -499,11 +499,62 @@ static void test_NtAllocateVirtualMemoryEx(void)
|
||||
|
||||
check_region_size(p1, size / 4);
|
||||
check_region_size(p2, size - size / 4);
|
||||
- status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE);
|
||||
+
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_INVALID_PARAMETER_4, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size2 = size + 0x1000;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size2 = size - 0x1000;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ p1 = (char *)addr1 + 0x1000;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+ p1 = addr1;
|
||||
+
|
||||
+ size2 = 0;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_INVALID_PARAMETER_3, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_RELEASE);
|
||||
+ ok(status == STATUS_UNABLE_TO_FREE_VM, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ check_region_size(p1, size);
|
||||
+
|
||||
+ size2 = size / 4;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+ check_region_size(p1, size / 4);
|
||||
+ check_region_size(p2, size - size / 4);
|
||||
+
|
||||
+ size2 = size - size / 4;
|
||||
+ status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), (void **)&p2, &size2, MEM_RESERVE | MEM_REPLACE_PLACEHOLDER,
|
||||
+ PAGE_READWRITE, NULL, 0);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size2 = size - size / 4;
|
||||
status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE);
|
||||
ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS);
|
||||
+ ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
+ size2 = size / 4;
|
||||
+ status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE);
|
||||
+ ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
|
||||
+
|
||||
/* Split in two regions, specifying second half. */
|
||||
addr1 = NULL;
|
||||
size = 0x10000;
|
||||
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
|
||||
index 60203bd4380..226c99c5512 100644
|
||||
--- a/dlls/ntdll/unix/virtual.c
|
||||
+++ b/dlls/ntdll/unix/virtual.c
|
||||
@@ -4339,6 +4339,30 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
|
||||
*size_ptr = size;
|
||||
}
|
||||
}
|
||||
+ else if (type & MEM_COALESCE_PLACEHOLDERS)
|
||||
+ {
|
||||
+ struct file_view *next_view = RB_ENTRY_VALUE( rb_next( &view->entry ), struct file_view, entry );
|
||||
+
|
||||
+ if (type != (MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS)) status = STATUS_INVALID_PARAMETER_4;
|
||||
+ else if (!size) status = STATUS_INVALID_PARAMETER_3;
|
||||
+ else if (!next_view || (char *)view->base + view->size != next_view->base
|
||||
+ || base != view->base || size != view->size + next_view->size
|
||||
+ || !(view->protect & VPROT_PLACEHOLDER) || !(next_view->protect & VPROT_PLACEHOLDER))
|
||||
+ {
|
||||
+ status = STATUS_CONFLICTING_ADDRESSES;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ unregister_view( view );
|
||||
+ unregister_view( next_view );
|
||||
+
|
||||
+ view->size += next_view->size;
|
||||
+ free_view( next_view );
|
||||
+
|
||||
+ register_view( view );
|
||||
+ VIRTUAL_DEBUG_DUMP_VIEW( view );
|
||||
+ }
|
||||
+ }
|
||||
else
|
||||
{
|
||||
WARN("called with wrong free type flags (%08x) !\n", (int)type);
|
||||
--
|
||||
2.38.1
|
||||
|
@@ -2,4 +2,3 @@
|
||||
# and "Halo Infinite". Neither have been tested with upstream Wine. Added to
|
||||
# wine-staging primarly because ntdll-ForceBottomUpAlloc touches the same area.
|
||||
Depends: ntdll-WRITECOPY
|
||||
Disabled: True
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user