From 7709f6b37ccff8e2598ae26558feca4ad88ec34c Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Thu, 7 Sep 2017 20:12:14 +0200 Subject: [PATCH] Rebase against b32c3243782477f7cc6dc5a189a3e4a5dacce1c8. --- ...on-to-create-new-tokens-for-elevatio.patch | 26 +- .../advapi32-Token_Integrity_Level/definition | 1 - ...-8bpp-gray-bitmaps-for-bitmap-target.patch | 77 ----- ...buffer-size-passed-to-CreateAlphaTex.patch | 28 -- ...e-Use-8bpp-bitmaps-in-grayscale-mode.patch | 312 ------------------ ...8bpp-text-bitmaps-for-grayscale-mode.patch | 28 -- ...0001-ntdll-Fix-holes-in-ELF-mappings.patch | 14 +- ...ory-limitation-to-32GB-on-64-bit-by-.patch | 157 --------- patches/ntdll-Grow_Virtual_Heap/definition | 1 - ...-Improve-heap-allocation-performance.patch | 56 ++-- patches/ntdll-Heap_Improvements/definition | 1 - ...ive-symlinks-before-returning-sectio.patch | 18 +- ...ead-to-update-user_shared_data-time-.patch | 18 +- ...andle-PAGE_WRITECOPY-protection.-try.patch | 26 +- patches/patchinstall.sh | 50 +-- ...-Implement-virtual_map_shared_memory.patch | 23 +- ...e_uninterrupted_-read-write-_memory-.patch | 18 +- 17 files changed, 103 insertions(+), 751 deletions(-) delete mode 100644 patches/dwrite-8bpp_Grayscale_Mode/0001-dwrite-Handle-8bpp-gray-bitmaps-for-bitmap-target.patch delete mode 100644 patches/dwrite-8bpp_Grayscale_Mode/0002-dwrite-Validate-buffer-size-passed-to-CreateAlphaTex.patch delete mode 100644 patches/dwrite-8bpp_Grayscale_Mode/0003-dwrite-Use-8bpp-bitmaps-in-grayscale-mode.patch delete mode 100644 patches/dwrite-8bpp_Grayscale_Mode/0004-d2d1-Use-8bpp-text-bitmaps-for-grayscale-mode.patch delete mode 100644 patches/ntdll-Grow_Virtual_Heap/0001-ntdll-Remove-memory-limitation-to-32GB-on-64-bit-by-.patch delete mode 100644 patches/ntdll-Grow_Virtual_Heap/definition diff --git a/patches/advapi32-Token_Integrity_Level/0006-ntdll-Add-function-to-create-new-tokens-for-elevatio.patch b/patches/advapi32-Token_Integrity_Level/0006-ntdll-Add-function-to-create-new-tokens-for-elevatio.patch index 10393ac9..28f8a785 100644 --- a/patches/advapi32-Token_Integrity_Level/0006-ntdll-Add-function-to-create-new-tokens-for-elevatio.patch +++ b/patches/advapi32-Token_Integrity_Level/0006-ntdll-Add-function-to-create-new-tokens-for-elevatio.patch @@ -1,4 +1,4 @@ -From fcceb1b0f1aee4ca4fe7362a4e87c4c94456f2ec Mon Sep 17 00:00:00 2001 +From 0d98f9a1ea69511f6bb2901e71c72ac715bffd27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sat, 5 Aug 2017 01:45:29 +0200 Subject: ntdll: Add function to create new tokens for elevation purposes. @@ -13,10 +13,10 @@ Subject: ntdll: Add function to create new tokens for elevation purposes. 6 files changed, 117 insertions(+) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec -index 275fda57970..8f5357b944c 100644 +index 30dfa60b1a0..69bfe923234 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec -@@ -1487,6 +1487,9 @@ +@@ -1480,6 +1480,9 @@ @ cdecl wine_server_send_fd(long) @ cdecl __wine_make_process_system() @@ -27,11 +27,11 @@ index 275fda57970..8f5357b944c 100644 @ cdecl wine_get_version() NTDLL_wine_get_version @ cdecl wine_get_patches() NTDLL_wine_get_patches diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index c6c60090d10..e64cb9e75a3 100644 +index c97b1e1f73f..030704e1727 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h -@@ -82,6 +82,9 @@ extern void fill_cpu_info(void) DECLSPEC_HIDDEN; - extern void *grow_virtual_heap( HANDLE handle, SIZE_T *size ) DECLSPEC_HIDDEN; +@@ -77,6 +77,9 @@ extern void virtual_init_threading(void) DECLSPEC_HIDDEN; + extern void fill_cpu_info(void) DECLSPEC_HIDDEN; extern void heap_set_debug_flags( HANDLE handle ) DECLSPEC_HIDDEN; +/* token */ @@ -41,7 +41,7 @@ index c6c60090d10..e64cb9e75a3 100644 extern timeout_t server_start_time DECLSPEC_HIDDEN; extern unsigned int server_cpus DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c -index f2eb09c142f..ba4613e87b3 100644 +index f615ce2fea7..77048003ace 100644 --- a/dlls/ntdll/process.c +++ b/dlls/ntdll/process.c @@ -99,6 +99,24 @@ HANDLE CDECL __wine_make_process_system(void) @@ -70,10 +70,10 @@ index f2eb09c142f..ba4613e87b3 100644 #define UNIMPLEMENTED_INFO_CLASS(c) \ diff --git a/server/protocol.def b/server/protocol.def -index ac2e2242511..300f23fb9b6 100644 +index b5b2650c8ed..9140feee717 100644 --- a/server/protocol.def +++ b/server/protocol.def -@@ -3688,6 +3688,14 @@ struct handle_info +@@ -3615,6 +3615,14 @@ struct handle_info @END @@ -101,7 +101,7 @@ index 6c337143c3d..21e90ccf23f 100644 /* token functions */ diff --git a/server/token.c b/server/token.c -index e61fe97bfa0..c9d36a5b4f3 100644 +index 3301283ee25..7abd92386ea 100644 --- a/server/token.c +++ b/server/token.c @@ -71,6 +71,7 @@ static const SID anonymous_logon_sid = { SID_REVISION, 1, { SECURITY_NT_AUTHORIT @@ -120,7 +120,7 @@ index e61fe97bfa0..c9d36a5b4f3 100644 static luid_t prev_luid_value = { 1000, 0 }; -@@ -924,6 +926,64 @@ struct token *token_create_admin( void ) +@@ -915,6 +917,64 @@ struct token *token_create_admin( void ) return token; } @@ -185,7 +185,7 @@ index e61fe97bfa0..c9d36a5b4f3 100644 static struct privilege *token_find_privilege( struct token *token, const LUID *luid, int enabled_only ) { struct privilege *privilege; -@@ -1738,3 +1798,27 @@ DECL_HANDLER(set_token_default_dacl) +@@ -1729,3 +1789,27 @@ DECL_HANDLER(set_token_default_dacl) release_object( token ); } } @@ -214,5 +214,5 @@ index e61fe97bfa0..c9d36a5b4f3 100644 + } +} -- -2.13.1 +2.14.1 diff --git a/patches/advapi32-Token_Integrity_Level/definition b/patches/advapi32-Token_Integrity_Level/definition index 26358d61..4ea715ed 100644 --- a/patches/advapi32-Token_Integrity_Level/definition +++ b/patches/advapi32-Token_Integrity_Level/definition @@ -5,7 +5,6 @@ Depends: advapi32-GetExplicitEntriesFromAclW Depends: kernel32-COMSPEC Depends: kernel32-UmsStubs Depends: ntdll-APC_Start_Process -Depends: ntdll-Grow_Virtual_Heap Depends: ntdll-TokenLogonSid Depends: ntdll-RunlevelInformationInActivationContext Depends: server-CreateProcess_ACLs diff --git a/patches/dwrite-8bpp_Grayscale_Mode/0001-dwrite-Handle-8bpp-gray-bitmaps-for-bitmap-target.patch b/patches/dwrite-8bpp_Grayscale_Mode/0001-dwrite-Handle-8bpp-gray-bitmaps-for-bitmap-target.patch deleted file mode 100644 index 0fc9ea65..00000000 --- a/patches/dwrite-8bpp_Grayscale_Mode/0001-dwrite-Handle-8bpp-gray-bitmaps-for-bitmap-target.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 8156e6f36bc04da891cd2541d8ad6a65a89738ce Mon Sep 17 00:00:00 2001 -From: Nikolay Sivov -Date: Tue, 5 Sep 2017 13:35:27 +0300 -Subject: dwrite: Handle 8bpp gray bitmaps for bitmap target. - -Signed-off-by: Nikolay Sivov -Signed-off-by: Alexandre Julliard ---- - dlls/dwrite/gdiinterop.c | 38 ++++++++++++++++++++++++-------------- - 1 file changed, 24 insertions(+), 14 deletions(-) - -diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c -index 5425b5c4aec..2e1811bd66d 100644 ---- a/dlls/dwrite/gdiinterop.c -+++ b/dlls/dwrite/gdiinterop.c -@@ -256,6 +256,25 @@ static inline DWORD *get_pixel_ptr_32(struct dib_data *dib, int x, int y) - return (DWORD *)((BYTE*)dib->ptr + y * dib->stride + x * 4); - } - -+static inline BYTE blend_color(BYTE dst, BYTE src, BYTE alpha) -+{ -+ return (src * alpha + dst * (255 - alpha) + 127) / 255; -+} -+ -+static inline DWORD blend_subpixel(BYTE r, BYTE g, BYTE b, DWORD text, const BYTE *alpha) -+{ -+ return blend_color(r, text >> 16, alpha[0]) << 16 | -+ blend_color(g, text >> 8, alpha[1]) << 8 | -+ blend_color(b, text, alpha[2]); -+} -+ -+static inline DWORD blend_pixel(BYTE r, BYTE g, BYTE b, DWORD text, BYTE alpha) -+{ -+ return blend_color(r, text >> 16, alpha) << 16 | -+ blend_color(g, text >> 8, alpha) << 8 | -+ blend_color(b, text, alpha); -+} -+ - static void blit_8(struct dib_data *dib, const BYTE *src, const RECT *rect, DWORD text_pixel) - { - DWORD *dst_ptr = get_pixel_ptr_32(dib, rect->left, rect->top); -@@ -263,8 +282,11 @@ static void blit_8(struct dib_data *dib, const BYTE *src, const RECT *rect, DWOR - - for (y = rect->top; y < rect->bottom; y++) { - for (x = 0; x < src_width; x++) { -- if (src[x] < DWRITE_ALPHA_MAX) continue; -- dst_ptr[x] = text_pixel; -+ if (src[x]) continue; -+ if (src[x] == DWRITE_ALPHA_MAX) -+ dst_ptr[x] = text_pixel; -+ else -+ dst_ptr[x] = blend_pixel(dst_ptr[x] >> 16, dst_ptr[x] >> 8, dst_ptr[x], text_pixel, src[x]); - } - - src += src_width; -@@ -272,18 +294,6 @@ static void blit_8(struct dib_data *dib, const BYTE *src, const RECT *rect, DWOR - } - } - --static inline BYTE blend_color(BYTE dst, BYTE src, BYTE alpha) --{ -- return (src * alpha + dst * (255 - alpha) + 127) / 255; --} -- --static inline DWORD blend_subpixel(BYTE r, BYTE g, BYTE b, DWORD text, const BYTE *alpha) --{ -- return blend_color(r, text >> 16, alpha[0]) << 16 | -- blend_color(g, text >> 8, alpha[1]) << 8 | -- blend_color(b, text, alpha[2]); --} -- - static void blit_subpixel_888(struct dib_data *dib, int dib_width, const BYTE *src, - const RECT *rect, DWORD text_pixel) - { --- -2.14.1 - diff --git a/patches/dwrite-8bpp_Grayscale_Mode/0002-dwrite-Validate-buffer-size-passed-to-CreateAlphaTex.patch b/patches/dwrite-8bpp_Grayscale_Mode/0002-dwrite-Validate-buffer-size-passed-to-CreateAlphaTex.patch deleted file mode 100644 index d89f9543..00000000 --- a/patches/dwrite-8bpp_Grayscale_Mode/0002-dwrite-Validate-buffer-size-passed-to-CreateAlphaTex.patch +++ /dev/null @@ -1,28 +0,0 @@ -From f4a73bdd781cfbfb371f07c0b37cde10a5ad0c17 Mon Sep 17 00:00:00 2001 -From: Nikolay Sivov -Date: Tue, 5 Sep 2017 13:35:28 +0300 -Subject: dwrite: Validate buffer size passed to CreateAlphaTexture() against - analysis texture type. - -Signed-off-by: Nikolay Sivov -Signed-off-by: Alexandre Julliard ---- - dlls/dwrite/font.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c -index 0b4717331cf..c15c941cc14 100644 ---- a/dlls/dwrite/font.c -+++ b/dlls/dwrite/font.c -@@ -5092,7 +5092,7 @@ static HRESULT WINAPI glyphrunanalysis_CreateAlphaTexture(IDWriteGlyphRunAnalysi - - /* make sure buffer is large enough for requested texture type */ - required = (bounds->right - bounds->left) * (bounds->bottom - bounds->top); -- if (type == DWRITE_TEXTURE_CLEARTYPE_3x1) -+ if (This->texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1) - required *= 3; - - if (size < required) --- -2.14.1 - diff --git a/patches/dwrite-8bpp_Grayscale_Mode/0003-dwrite-Use-8bpp-bitmaps-in-grayscale-mode.patch b/patches/dwrite-8bpp_Grayscale_Mode/0003-dwrite-Use-8bpp-bitmaps-in-grayscale-mode.patch deleted file mode 100644 index 9bd8fd56..00000000 --- a/patches/dwrite-8bpp_Grayscale_Mode/0003-dwrite-Use-8bpp-bitmaps-in-grayscale-mode.patch +++ /dev/null @@ -1,312 +0,0 @@ -From ed60832c952c8dbcae96d24a28f23d57df76daed Mon Sep 17 00:00:00 2001 -From: Nikolay Sivov -Date: Tue, 5 Sep 2017 13:35:29 +0300 -Subject: dwrite: Use 8bpp bitmaps in grayscale mode. - -Problem analyzed by Kimmo Myllyvirta. - -Signed-off-by: Nikolay Sivov -Signed-off-by: Alexandre Julliard ---- - dlls/dwrite/dwrite_private.h | 2 +- - dlls/dwrite/font.c | 37 +++++++----- - dlls/dwrite/freetype.c | 6 +- - dlls/dwrite/tests/font.c | 134 ++++++++++++++++++++++++++++++++++++++----- - 4 files changed, 148 insertions(+), 31 deletions(-) - -diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h -index 288da2cb43b..d12118c2580 100644 ---- a/dlls/dwrite/dwrite_private.h -+++ b/dlls/dwrite/dwrite_private.h -@@ -273,11 +273,11 @@ struct dwrite_glyphbitmap { - DWORD simulations; - FLOAT emsize; - BOOL nohint; -+ BOOL aliased; - UINT16 index; - INT pitch; - RECT bbox; - BYTE *buf; -- DWRITE_TEXTURE_TYPE type; - DWRITE_MATRIX *m; - }; - -diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c -index c15c941cc14..5ca4c8a5f96 100644 ---- a/dlls/dwrite/font.c -+++ b/dlls/dwrite/font.c -@@ -4872,10 +4872,9 @@ static BOOL is_natural_rendering_mode(DWRITE_RENDERING_MODE1 mode) - } - } - --static UINT32 get_glyph_bitmap_pitch(DWRITE_TEXTURE_TYPE type, INT width) -+static UINT32 get_glyph_bitmap_pitch(DWRITE_RENDERING_MODE1 rendering_mode, INT width) - { -- return type == DWRITE_TEXTURE_CLEARTYPE_3x1 ? (width + 3) / 4 * 4 : -- ((width + 31) >> 5) << 2; -+ return rendering_mode == DWRITE_RENDERING_MODE1_ALIASED ? ((width + 31) >> 5) << 2 : (width + 3) / 4 * 4; - } - - static void glyphrunanalysis_get_texturebounds(struct dwrite_glyphrunanalysis *analysis, RECT *bounds) -@@ -4912,7 +4911,7 @@ static void glyphrunanalysis_get_texturebounds(struct dwrite_glyphrunanalysis *a - glyph_bitmap.index = analysis->run.glyphIndices[i]; - freetype_get_glyph_bbox(&glyph_bitmap); - -- bitmap_size = get_glyph_bitmap_pitch(analysis->texture_type, bbox->right - bbox->left) * -+ bitmap_size = get_glyph_bitmap_pitch(analysis->rendering_mode, bbox->right - bbox->left) * - (bbox->bottom - bbox->top); - if (bitmap_size > analysis->max_glyph_bitmap_size) - analysis->max_glyph_bitmap_size = bitmap_size; -@@ -4995,7 +4994,7 @@ static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis) - glyph_bitmap.simulations = IDWriteFontFace4_GetSimulations(fontface); - glyph_bitmap.emsize = analysis->run.fontEmSize; - glyph_bitmap.nohint = is_natural_rendering_mode(analysis->rendering_mode); -- glyph_bitmap.type = analysis->texture_type; -+ glyph_bitmap.aliased = analysis->rendering_mode == DWRITE_RENDERING_MODE1_ALIASED; - if (analysis->flags & RUNANALYSIS_USE_TRANSFORM) - glyph_bitmap.m = &analysis->m; - if (!(glyph_bitmap.buf = heap_alloc(analysis->max_glyph_bitmap_size))) { -@@ -5019,7 +5018,7 @@ static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis) - width = bbox->right - bbox->left; - height = bbox->bottom - bbox->top; - -- glyph_bitmap.pitch = get_glyph_bitmap_pitch(analysis->texture_type, width); -+ glyph_bitmap.pitch = get_glyph_bitmap_pitch(analysis->rendering_mode, width); - memset(src, 0, height * glyph_bitmap.pitch); - is_1bpp = freetype_get_glyph_bitmap(&glyph_bitmap); - -@@ -5044,18 +5043,27 @@ static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis) - for (x = 0; x < width; x++) - if (src[x / 8] & masks[x % 8]) - dst[x] = DWRITE_ALPHA_MAX; -- src += get_dib_stride(width, 1); -+ src += glyph_bitmap.pitch; - dst += analysis->bounds.right - analysis->bounds.left; - } - } - } - else { -- /* at this point it's DWRITE_TEXTURE_CLEARTYPE_3x1 with 8bpp src bitmap */ -- for (y = 0; y < height; y++) { -- for (x = 0; x < width; x++) -- dst[3*x] = dst[3*x+1] = dst[3*x+2] = src[x] | dst[3*x]; -- src += glyph_bitmap.pitch; -- dst += (analysis->bounds.right - analysis->bounds.left) * 3; -+ if (analysis->texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1) { -+ for (y = 0; y < height; y++) { -+ for (x = 0; x < width; x++) -+ dst[3*x] = dst[3*x+1] = dst[3*x+2] = src[x] | dst[3*x]; -+ src += glyph_bitmap.pitch; -+ dst += (analysis->bounds.right - analysis->bounds.left) * 3; -+ } -+ } -+ else { -+ for (y = 0; y < height; y++) { -+ for (x = 0; x < width; x++) -+ dst[x] |= src[x]; -+ src += glyph_bitmap.pitch; -+ dst += analysis->bounds.right - analysis->bounds.left; -+ } - } - } - } -@@ -5223,7 +5231,8 @@ HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc *desc, IDWrit - analysis->ref = 1; - analysis->rendering_mode = desc->rendering_mode; - -- if (desc->rendering_mode == DWRITE_RENDERING_MODE1_ALIASED) -+ if (desc->rendering_mode == DWRITE_RENDERING_MODE1_ALIASED -+ || desc->aa_mode == DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE) - analysis->texture_type = DWRITE_TEXTURE_ALIASED_1x1; - else - analysis->texture_type = DWRITE_TEXTURE_CLEARTYPE_3x1; -diff --git a/dlls/dwrite/freetype.c b/dlls/dwrite/freetype.c -index 571fa24c336..ffdd8a8f1e8 100644 ---- a/dlls/dwrite/freetype.c -+++ b/dlls/dwrite/freetype.c -@@ -860,10 +860,10 @@ BOOL freetype_get_glyph_bitmap(struct dwrite_glyphbitmap *bitmap) - else - glyph_copy = NULL; - -- if (bitmap->type == DWRITE_TEXTURE_CLEARTYPE_3x1) -- ret = freetype_get_aa_glyph_bitmap(bitmap, glyph); -- else -+ if (bitmap->aliased) - ret = freetype_get_aliased_glyph_bitmap(bitmap, glyph); -+ else -+ ret = freetype_get_aa_glyph_bitmap(bitmap, glyph); - - if (glyph_copy) - pFT_Done_Glyph(glyph_copy); -diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c -index 54dcc75c81f..813ce22abf3 100644 ---- a/dlls/dwrite/tests/font.c -+++ b/dlls/dwrite/tests/font.c -@@ -4732,6 +4732,7 @@ static void test_CreateGlyphRunAnalysis(void) - - IDWriteGlyphRunAnalysis *analysis, *analysis2; - IDWriteRenderingParams *params; -+ IDWriteFactory3 *factory3; - IDWriteFactory2 *factory2; - IDWriteFactory *factory; - DWRITE_GLYPH_RUN run; -@@ -4745,6 +4746,8 @@ static void test_CreateGlyphRunAnalysis(void) - DWRITE_GLYPH_METRICS metrics; - DWRITE_FONT_METRICS fm; - DWRITE_MATRIX m; -+ ULONG size; -+ BYTE *bits; - ULONG ref; - int i; - -@@ -5057,29 +5060,134 @@ static void test_CreateGlyphRunAnalysis(void) - 0.0f, 0.0f, &analysis); - ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); - -- /* Natural mode, grayscale antialiased. */ -+ /* Win8 does not accept default grid fitting mode. */ - hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_NATURAL, - DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DEFAULT, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE, - 0.0f, 0.0f, &analysis); -- ok(hr == S_OK || broken(hr == E_INVALIDARG) /* Win8 */, "Failed to create glyph run analysis, hr %#x.\n", hr); -+ ok(hr == S_OK || broken(hr == E_INVALIDARG) /* Win8 */, "Failed to create analysis, hr %#x.\n", hr); -+ if (hr == S_OK) -+ IDWriteGlyphRunAnalysis_Release(analysis); - -- if (hr == S_OK) { -- hr = IDWriteFactory_CreateCustomRenderingParams(factory, 0.1f, 0.0f, 1.0f, DWRITE_PIXEL_GEOMETRY_FLAT, -- DWRITE_RENDERING_MODE_NATURAL, ¶ms); -- ok(hr == S_OK, "Failed to create custom parameters, hr %#x.\n", hr); -+ /* Natural mode, grayscale antialiased. */ -+ hr = IDWriteFactory2_CreateGlyphRunAnalysis(factory2, &run, NULL, DWRITE_RENDERING_MODE_NATURAL, -+ DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DISABLED, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE, -+ 0.0f, 0.0f, &analysis); -+ ok(hr == S_OK, "Failed to create analysis, hr %#x.\n", hr); - -- hr = IDWriteGlyphRunAnalysis_GetAlphaBlendParams(analysis, params, &gamma, &contrast, &cleartype_level); -- ok(hr == S_OK, "Failed to get alpha blend params, hr %#x.\n", hr); -- todo_wine -- ok(cleartype_level == 0.0f, "Unexpected cleartype level %f.\n", cleartype_level); -+ SetRect(&rect, 0, 1, 0, 1); -+ hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect); -+ ok(hr == S_OK, "Failed to get texture bounds, hr %#x.\n", hr); -+ ok(IsRectEmpty(&rect), "Expected empty bbox.\n"); - -- IDWriteRenderingParams_Release(params); -- IDWriteGlyphRunAnalysis_Release(analysis); -- } -+ SetRectEmpty(&rect); -+ hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect); -+ ok(hr == S_OK, "Failed to get texture bounds, hr %#x.\n", hr); -+ ok(!IsRectEmpty(&rect), "Unexpected empty bbox.\n"); -+ -+ size = (rect.right - rect.left) * (rect.bottom - rect.top); -+ bits = HeapAlloc(GetProcessHeap(), 0, size); -+ -+ hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect, bits, size); -+ ok(hr == S_OK, "Failed to get alpha texture, hr %#x.\n", hr); -+ -+ hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect, bits, size - 1); -+ ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#x.\n", hr); -+ -+ hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect, bits, size); -+ ok(hr == DWRITE_E_UNSUPPORTEDOPERATION, "Unexpected hr %#x.\n", hr); -+ -+ hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect, bits, size - 1); -+ todo_wine -+ ok(hr == DWRITE_E_UNSUPPORTEDOPERATION, "Unexpected hr %#x.\n", hr); -+ -+ HeapFree(GetProcessHeap(), 0, bits); -+ -+ hr = IDWriteFactory_CreateCustomRenderingParams(factory, 0.1f, 0.0f, 1.0f, DWRITE_PIXEL_GEOMETRY_FLAT, -+ DWRITE_RENDERING_MODE_NATURAL, ¶ms); -+ ok(hr == S_OK, "Failed to create custom parameters, hr %#x.\n", hr); -+ -+ hr = IDWriteGlyphRunAnalysis_GetAlphaBlendParams(analysis, params, &gamma, &contrast, &cleartype_level); -+ ok(hr == S_OK, "Failed to get alpha blend params, hr %#x.\n", hr); -+ todo_wine -+ ok(cleartype_level == 0.0f, "Unexpected cleartype level %f.\n", cleartype_level); -+ -+ IDWriteRenderingParams_Release(params); -+ IDWriteGlyphRunAnalysis_Release(analysis); - - IDWriteFactory2_Release(factory2); - } - -+ if (IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory3, (void **)&factory3) == S_OK) { -+ -+ /* Invalid antialias mode. */ -+ hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_ALIASED, -+ DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DEFAULT, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE + 1, -+ 0.0f, 0.0f, &analysis); -+ ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); -+ -+ /* Invalid grid fit mode. */ -+ hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_ALIASED, -+ DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_ENABLED + 1, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE, -+ 0.0f, 0.0f, &analysis); -+ ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); -+ -+ /* Invalid rendering mode. */ -+ hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_OUTLINE, -+ DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_ENABLED, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE, -+ 0.0f, 0.0f, &analysis); -+ ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); -+ -+ /* Invalid measuring mode. */ -+ hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_ALIASED, -+ DWRITE_MEASURING_MODE_GDI_NATURAL + 1, DWRITE_GRID_FIT_MODE_ENABLED, -+ DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE, 0.0f, 0.0f, &analysis); -+ ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); -+ -+ hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_NATURAL, -+ DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DEFAULT, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE, -+ 0.0f, 0.0f, &analysis); -+ ok(hr == S_OK, "Failed to create analysis, hr %#x.\n", hr); -+ IDWriteGlyphRunAnalysis_Release(analysis); -+ -+ /* Natural mode, grayscale antialiased. */ -+ hr = IDWriteFactory3_CreateGlyphRunAnalysis(factory3, &run, NULL, DWRITE_RENDERING_MODE1_NATURAL, -+ DWRITE_MEASURING_MODE_NATURAL, DWRITE_GRID_FIT_MODE_DISABLED, DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE, -+ 0.0f, 0.0f, &analysis); -+ ok(hr == S_OK, "Failed to create analysis, hr %#x.\n", hr); -+ -+ SetRect(&rect, 0, 1, 0, 1); -+ hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect); -+ ok(hr == S_OK, "Failed to get texture bounds, hr %#x.\n", hr); -+ ok(IsRectEmpty(&rect), "Expected empty bbox.\n"); -+ -+ SetRectEmpty(&rect); -+ hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect); -+ ok(hr == S_OK, "Failed to get texture bounds, hr %#x.\n", hr); -+ ok(!IsRectEmpty(&rect), "Unexpected empty bbox.\n"); -+ -+ size = (rect.right - rect.left) * (rect.bottom - rect.top); -+ bits = HeapAlloc(GetProcessHeap(), 0, size); -+ -+ hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect, bits, size); -+ ok(hr == S_OK, "Failed to get alpha texture, hr %#x.\n", hr); -+ -+ hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect, bits, size - 1); -+ ok(hr == E_NOT_SUFFICIENT_BUFFER, "Unexpected hr %#x.\n", hr); -+ -+ hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect, bits, size); -+ ok(hr == DWRITE_E_UNSUPPORTEDOPERATION, "Unexpected hr %#x.\n", hr); -+ -+ hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis, DWRITE_TEXTURE_CLEARTYPE_3x1, &rect, bits, size - 1); -+ todo_wine -+ ok(hr == DWRITE_E_UNSUPPORTEDOPERATION, "Unexpected hr %#x.\n", hr); -+ -+ HeapFree(GetProcessHeap(), 0, bits); -+ -+ IDWriteGlyphRunAnalysis_Release(analysis); -+ -+ IDWriteFactory3_Release(factory3); -+ } -+ - IDWriteFontFace_Release(face); - ref = IDWriteFactory_Release(factory); - ok(ref == 0, "factory not released, %u\n", ref); --- -2.14.1 - diff --git a/patches/dwrite-8bpp_Grayscale_Mode/0004-d2d1-Use-8bpp-text-bitmaps-for-grayscale-mode.patch b/patches/dwrite-8bpp_Grayscale_Mode/0004-d2d1-Use-8bpp-text-bitmaps-for-grayscale-mode.patch deleted file mode 100644 index 127803da..00000000 --- a/patches/dwrite-8bpp_Grayscale_Mode/0004-d2d1-Use-8bpp-text-bitmaps-for-grayscale-mode.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 733892bb06a198dcdc045afc5db7cfb6e1ce4d79 Mon Sep 17 00:00:00 2001 -From: Nikolay Sivov -Date: Tue, 5 Sep 2017 13:35:30 +0300 -Subject: d2d1: Use 8bpp text bitmaps for grayscale mode. - -Signed-off-by: Nikolay Sivov -Signed-off-by: Henri Verbeet -Signed-off-by: Alexandre Julliard ---- - dlls/d2d1/render_target.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/dlls/d2d1/render_target.c b/dlls/d2d1/render_target.c -index f37565d4ee7..02f926fc42b 100644 ---- a/dlls/d2d1/render_target.c -+++ b/dlls/d2d1/render_target.c -@@ -1141,7 +1141,7 @@ static void d2d_rt_draw_glyph_run_bitmap(struct d2d_d3d_render_target *render_ta - return; - } - -- if (rendering_mode == DWRITE_RENDERING_MODE_ALIASED) -+ if (rendering_mode == DWRITE_RENDERING_MODE_ALIASED || antialias_mode == DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE) - texture_type = DWRITE_TEXTURE_ALIASED_1x1; - else - texture_type = DWRITE_TEXTURE_CLEARTYPE_3x1; --- -2.14.1 - diff --git a/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch b/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch index 1d28417e..818be333 100644 --- a/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch +++ b/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch @@ -1,4 +1,4 @@ -From 75af51bc0f3d02eeb1d4e243190db9a4813cb11f Mon Sep 17 00:00:00 2001 +From 62e317a96953781723231782f4d5b2392b347fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 1 Jun 2017 06:04:53 +0200 Subject: ntdll: Fix holes in ELF mappings. (v2) @@ -10,11 +10,11 @@ Based on a patch by Andrew Wesie. 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 1fa9fd925a1..56a384448c4 100644 +index 25946c22c97..2305bfb47f3 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c -@@ -1670,6 +1670,20 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) - if (VIRTUAL_GetUnixProt( get_page_vprot( view, page )) & PROT_READ) ret = STATUS_SUCCESS; +@@ -1720,6 +1720,20 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) + if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_READ) ret = STATUS_SUCCESS; else update_shared_data = FALSE; } + else if (!err && (view->protect & VPROT_SYSTEM) && (VIRTUAL_GetUnixProt( vprot ) & PROT_READ)) @@ -23,17 +23,17 @@ index 1fa9fd925a1..56a384448c4 100644 + unsigned char vec; + + if (!VIRTUAL_SetProt( view, page, page_size, vprot )) -+ set_page_vprot_bits( view, page, page_size, 0, VPROT_READ | VPROT_EXEC ); ++ set_page_vprot_bits( page, page_size, 0, VPROT_READ | VPROT_EXEC ); + else if (!mincore( page, page_size, &vec ) && (vec & 1)) + ret = STATUS_SUCCESS; + else if (wine_anon_mmap( page, page_size, unix_prot, MAP_FIXED ) != page) -+ set_page_vprot_bits( view, page, page_size, 0, VPROT_READ | VPROT_EXEC ); ++ set_page_vprot_bits( page, page_size, 0, VPROT_READ | VPROT_EXEC ); + else + ret = STATUS_SUCCESS; + } if (!on_signal_stack && (vprot & VPROT_GUARD)) { - set_page_vprot_bits( view, page, page_size, 0, VPROT_GUARD ); + set_page_vprot_bits( page, page_size, 0, VPROT_GUARD ); diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c index e35a7b694cb..e7af5bc61cc 100644 --- a/dlls/psapi/tests/psapi_main.c diff --git a/patches/ntdll-Grow_Virtual_Heap/0001-ntdll-Remove-memory-limitation-to-32GB-on-64-bit-by-.patch b/patches/ntdll-Grow_Virtual_Heap/0001-ntdll-Remove-memory-limitation-to-32GB-on-64-bit-by-.patch deleted file mode 100644 index de37288f..00000000 --- a/patches/ntdll-Grow_Virtual_Heap/0001-ntdll-Remove-memory-limitation-to-32GB-on-64-bit-by-.patch +++ /dev/null @@ -1,157 +0,0 @@ -From 9b16ad9a6bfe64270aa8747c6f701264840eec04 Mon Sep 17 00:00:00 2001 -From: Sebastian Lackner -Date: Sun, 15 Jan 2017 17:48:58 +0100 -Subject: ntdll: Remove memory limitation to 32GB on 64-bit by growing heap - dynamically. (v2) - ---- - dlls/ntdll/heap.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ - dlls/ntdll/ntdll_misc.h | 3 +++ - dlls/ntdll/virtual.c | 28 +++++++++++++++++++++++++--- - 3 files changed, 77 insertions(+), 3 deletions(-) - -diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c -index f928ebff500..e4517c0b69b 100644 ---- a/dlls/ntdll/heap.c -+++ b/dlls/ntdll/heap.c -@@ -27,6 +27,9 @@ - #include - #include - #include -+#ifdef HAVE_SYS_MMAN_H -+# include -+#endif - #ifdef HAVE_VALGRIND_MEMCHECK_H - #include - #else -@@ -40,6 +43,7 @@ - #include "winnt.h" - #include "winternl.h" - #include "ntdll_misc.h" -+#include "wine/library.h" - #include "wine/list.h" - #include "wine/debug.h" - #include "wine/server.h" -@@ -658,6 +662,9 @@ static void HEAP_MakeInUseBlockFree( SUBHEAP *subheap, ARENA_INUSE *pArena ) - if ((char *)pFree + size < (char *)subheap->base + subheap->size) - return; /* Not the last block, so nothing more to do */ - -+ if (!(subheap->heap->flags & HEAP_GROWABLE) && (subheap != &subheap->heap->subheap)) -+ return; /* virtual heap, never attempt to release or decommit memory */ -+ - /* Free the whole sub-heap if it's empty and not the original one */ - - if (((char *)pFree == (char *)subheap->base + subheap->headerSize) && -@@ -1048,6 +1055,48 @@ static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, SIZE_T size, - } - - -+/* similar to HEAP_FindFreeBlock, but for the virtual heap */ -+void *grow_virtual_heap( HANDLE handle, SIZE_T *size ) -+{ -+ HEAP *heap = HEAP_GetPtr( handle ); -+ SIZE_T rounded_size, total_size; -+ SUBHEAP *subheap; -+ void *address; -+ -+ assert( !(heap->flags & HEAP_GROWABLE) ); -+ -+ /* compute rounded size, see RtlAllocateHeap */ -+ rounded_size = ROUND_SIZE( *size ) + HEAP_TAIL_EXTRA_SIZE( heap->flags ); -+ if (rounded_size < *size) return NULL; -+ if (rounded_size < HEAP_MIN_DATA_SIZE) rounded_size = HEAP_MIN_DATA_SIZE; -+ -+ /* compute total size, see HEAP_FindFreeBlock */ -+ total_size = rounded_size + ROUND_SIZE(sizeof(SUBHEAP)) + sizeof(ARENA_INUSE) + sizeof(ARENA_FREE); -+ if (total_size < rounded_size) return NULL; -+ -+ *size = (max( heap->grow_size, total_size ) + page_size - 1) & ~(page_size - 1); -+ if ((address = wine_anon_mmap( NULL, *size, PROT_READ|PROT_WRITE, 0 )) != (void *)-1) -+ { -+ if (heap->grow_size < 128 * 1024 * 1024) heap->grow_size *= 2; -+ } -+ else while (address != (void *)-1) /* shrink the grow size again if we are running out of space */ -+ { -+ if (heap->grow_size <= total_size || heap->grow_size <= 4 * 1024 * 1024) return NULL; -+ heap->grow_size /= 2; -+ *size = (max( heap->grow_size, total_size ) + page_size - 1) & ~(page_size - 1); -+ address = wine_anon_mmap( NULL, *size, PROT_READ|PROT_WRITE, 0 ); -+ } -+ -+ subheap = HEAP_CreateSubHeap( heap, address, heap->flags, *size, *size ); -+ assert( subheap != NULL ); -+ -+ TRACE("created new sub-heap %p of %08lx bytes for heap %p\n", -+ subheap, subheap->size, heap ); -+ -+ return address; -+} -+ -+ - /*********************************************************************** - * HEAP_IsValidArenaPtr - * -diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index 5e4c39e8bd6..ecd839b0436 100644 ---- a/dlls/ntdll/ntdll_misc.h -+++ b/dlls/ntdll/ntdll_misc.h -@@ -75,6 +75,9 @@ extern void actctx_init(void) DECLSPEC_HIDDEN; - extern void virtual_init(void) DECLSPEC_HIDDEN; - extern void virtual_init_threading(void) DECLSPEC_HIDDEN; - extern void fill_cpu_info(void) DECLSPEC_HIDDEN; -+ -+/* heap routines */ -+extern void *grow_virtual_heap( HANDLE handle, SIZE_T *size ) DECLSPEC_HIDDEN; - extern void heap_set_debug_flags( HANDLE handle ) DECLSPEC_HIDDEN; - - /* server support */ -diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index e826fa03c0c..a6a6f5c3823 100644 ---- a/dlls/ntdll/virtual.c -+++ b/dlls/ntdll/virtual.c -@@ -454,6 +454,7 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz - { - struct file_view *view; - struct list *ptr; -+ SIZE_T view_size = sizeof(*view) + (size >> page_shift) - 1; - int unix_prot = VIRTUAL_GetUnixProt( vprot ); - - assert( !((UINT_PTR)base & page_mask) ); -@@ -461,10 +462,31 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz - - /* Create the view structure */ - -- if (!(view = RtlAllocateHeap( virtual_heap, 0, sizeof(*view) + (size >> page_shift) - 1 ))) -+ if (!(view = RtlAllocateHeap( virtual_heap, 0, view_size ))) - { -- FIXME( "out of memory in virtual heap for %p-%p\n", base, (char *)base + size ); -- return STATUS_NO_MEMORY; -+ SIZE_T heap_size = max( view_size, VIRTUAL_HEAP_SIZE ); -+ struct file_view *heap_view; -+ void *heap_base; -+ -+ if (!(heap_base = grow_virtual_heap( virtual_heap, &heap_size ))) -+ { -+ FIXME( "failed to grow virtual heap for %p-%p\n", base, (char *)base + size ); -+ return STATUS_NO_MEMORY; -+ } -+ -+ /* FIXME: The grown heap is guaranteed to be large to handle allocation -+ * of size 'view_size', but we also have to add a second view for the -+ * newly reserved area. If this fails we can no longer track all memory -+ * areas. On the other hand, first calling create_view and then -+ * RtlAllocateHeap would be even worse, and could end in an endless loop. */ -+ view = RtlAllocateHeap( virtual_heap, 0, view_size ); -+ create_view( &heap_view, heap_base, heap_size, VPROT_COMMITTED | VPROT_READ | VPROT_WRITE ); -+ -+ if (!view) -+ { -+ FIXME( "out of memory in virtual heap for %p-%p\n", base, (char *)base + size ); -+ return STATUS_NO_MEMORY; -+ } - } - - view->base = base; --- -2.11.0 - diff --git a/patches/ntdll-Grow_Virtual_Heap/definition b/patches/ntdll-Grow_Virtual_Heap/definition deleted file mode 100644 index 49d1b722..00000000 --- a/patches/ntdll-Grow_Virtual_Heap/definition +++ /dev/null @@ -1 +0,0 @@ -Fixes: [39885] Remove memory limitation to 32GB on 64-bit by growing heap dynamically diff --git a/patches/ntdll-Heap_Improvements/0002-ntdll-Improve-heap-allocation-performance.patch b/patches/ntdll-Heap_Improvements/0002-ntdll-Improve-heap-allocation-performance.patch index c7432cc5..d1af3195 100644 --- a/patches/ntdll-Heap_Improvements/0002-ntdll-Improve-heap-allocation-performance.patch +++ b/patches/ntdll-Heap_Improvements/0002-ntdll-Improve-heap-allocation-performance.patch @@ -1,4 +1,4 @@ -From ced9d6d9ab67f54a59ee6a6726e002e50d91c38c Mon Sep 17 00:00:00 2001 +From aeb5877ee941be158b6850b7c88f26eb5fa4d5b4 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 22 Jul 2017 07:21:45 +0200 Subject: ntdll: Improve heap allocation performance. (v2) @@ -9,10 +9,10 @@ Subject: ntdll: Improve heap allocation performance. (v2) 2 files changed, 234 insertions(+), 87 deletions(-) diff --git a/configure.ac b/configure.ac -index 533f1e49342..560a58d6977 100644 +index bf73b651c50..e71e3bf1224 100644 --- a/configure.ac +++ b/configure.ac -@@ -2650,6 +2650,15 @@ then +@@ -2657,6 +2657,15 @@ then AC_DEFINE(HAVE___BUILTIN_CLZ, 1, [Define to 1 if you have the `__builtin_clz' built-in function.]) fi @@ -29,7 +29,7 @@ index 533f1e49342..560a58d6977 100644 AC_CACHE_CHECK([for __builtin_popcount], ac_cv_have___builtin_popcount, AC_LINK_IFELSE([AC_LANG_PROGRAM(,[[return __builtin_popcount(1)]])], diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c -index 64236204477..f4ddd7bd68a 100644 +index dc45a688925..effda46d0bf 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -3,6 +3,7 @@ @@ -40,15 +40,15 @@ index 64236204477..f4ddd7bd68a 100644 * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public -@@ -45,6 +46,7 @@ +@@ -41,6 +42,7 @@ + #include "winternl.h" #include "ntdll_misc.h" - #include "wine/library.h" #include "wine/list.h" +#include "wine/rbtree.h" #include "wine/debug.h" #include "wine/server.h" -@@ -66,7 +68,11 @@ typedef struct tagARENA_FREE +@@ -62,7 +64,11 @@ typedef struct tagARENA_FREE { DWORD size; /* Block size; must be the first field */ DWORD magic; /* Magic number */ @@ -61,7 +61,7 @@ index 64236204477..f4ddd7bd68a 100644 } ARENA_FREE; typedef struct -@@ -79,9 +85,11 @@ typedef struct +@@ -75,9 +81,11 @@ typedef struct DWORD magic; /* these must remain at the end of the structure */ } ARENA_LARGE; @@ -76,7 +76,7 @@ index 64236204477..f4ddd7bd68a 100644 #define ARENA_LARGE_SIZE 0xfedcba90 /* magic value for 'size' field in large blocks */ /* Value for arena 'magic' field */ -@@ -99,6 +107,8 @@ typedef struct +@@ -95,6 +103,8 @@ typedef struct #define LARGE_ALIGNMENT 16 /* large blocks have stricter alignment */ #define ARENA_OFFSET (ALIGNMENT - sizeof(ARENA_INUSE)) @@ -85,7 +85,7 @@ index 64236204477..f4ddd7bd68a 100644 C_ASSERT( sizeof(ARENA_LARGE) % LARGE_ALIGNMENT == 0 ); #define ROUND_SIZE(size) ((((size) + ALIGNMENT - 1) & ~(ALIGNMENT-1)) + ARENA_OFFSET) -@@ -107,8 +117,7 @@ C_ASSERT( sizeof(ARENA_LARGE) % LARGE_ALIGNMENT == 0 ); +@@ -103,8 +113,7 @@ C_ASSERT( sizeof(ARENA_LARGE) % LARGE_ALIGNMENT == 0 ); #define NOISY 0 /* Report all errors */ /* minimum data size (without arenas) of an allocated block */ @@ -95,7 +95,7 @@ index 64236204477..f4ddd7bd68a 100644 /* minimum size that must remain to shrink an allocated block */ #define HEAP_MIN_SHRINK_SIZE (HEAP_MIN_DATA_SIZE+sizeof(ARENA_FREE)) /* minimum size to start allocating large blocks */ -@@ -116,19 +125,14 @@ C_ASSERT( sizeof(ARENA_LARGE) % LARGE_ALIGNMENT == 0 ); +@@ -112,19 +121,14 @@ C_ASSERT( sizeof(ARENA_LARGE) % LARGE_ALIGNMENT == 0 ); /* extra size to add at the end of block for tail checking */ #define HEAP_TAIL_EXTRA_SIZE(flags) \ ((flags & HEAP_TAIL_CHECKING_ENABLED) || RUNNING_ON_VALGRIND ? ALIGNMENT : 0) @@ -123,7 +123,7 @@ index 64236204477..f4ddd7bd68a 100644 struct tagHEAP; -@@ -161,9 +165,17 @@ typedef struct tagHEAP +@@ -157,9 +161,17 @@ typedef struct tagHEAP DWORD pending_pos; /* Position in pending free requests ring */ ARENA_INUSE **pending_free; /* Ring buffer for pending free requests */ RTL_CRITICAL_SECTION critSection; /* Critical section for serialization */ @@ -142,7 +142,7 @@ index 64236204477..f4ddd7bd68a 100644 #define HEAP_MAGIC ((DWORD)('H' | ('E'<<8) | ('A'<<16) | ('P'<<24))) #define HEAP_DEF_SIZE 0x110000 /* Default heap size = 1Mb + 64Kb */ -@@ -180,6 +192,30 @@ static HEAP *processHeap; /* main process heap */ +@@ -176,6 +188,30 @@ static HEAP *processHeap; /* main process heap */ static BOOL HEAP_IsRealArena( HEAP *heapPtr, DWORD flags, LPCVOID block, BOOL quiet ); @@ -173,7 +173,7 @@ index 64236204477..f4ddd7bd68a 100644 /* mark a block of memory as free for debugging purposes */ static inline void mark_block_free( void *ptr, SIZE_T size, DWORD flags ) { -@@ -301,17 +337,6 @@ static void subheap_notify_free_all(SUBHEAP const *subheap) +@@ -297,17 +333,6 @@ static void subheap_notify_free_all(SUBHEAP const *subheap) #endif } @@ -191,7 +191,7 @@ index 64236204477..f4ddd7bd68a 100644 /* get the memory protection type to use for a given heap */ static inline ULONG get_protection_type( DWORD flags ) { -@@ -339,12 +364,31 @@ static void HEAP_Dump( HEAP *heap ) +@@ -335,12 +360,31 @@ static void HEAP_Dump( HEAP *heap ) DPRINTF( "Next: %p Sub-heaps:", LIST_ENTRY( heap->entry.next, HEAP, entry ) ); LIST_FOR_EACH_ENTRY( subheap, &heap->subheap_list, SUBHEAP, entry ) DPRINTF( " %p", subheap ); @@ -228,7 +228,7 @@ index 64236204477..f4ddd7bd68a 100644 LIST_FOR_EACH_ENTRY( subheap, &heap->subheap_list, SUBHEAP, entry ) { -@@ -359,11 +403,32 @@ static void HEAP_Dump( HEAP *heap ) +@@ -355,11 +399,32 @@ static void HEAP_Dump( HEAP *heap ) if (*(DWORD *)ptr & ARENA_FLAG_FREE) { ARENA_FREE *pArena = (ARENA_FREE *)ptr; @@ -266,7 +266,7 @@ index 64236204477..f4ddd7bd68a 100644 ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK); arenaSize += sizeof(ARENA_FREE); freeSize += pArena->size & ARENA_SIZE_MASK; -@@ -471,20 +536,19 @@ static HEAP *HEAP_GetPtr( +@@ -467,20 +532,19 @@ static HEAP *HEAP_GetPtr( */ static inline void HEAP_InsertFreeBlock( HEAP *heap, ARENA_FREE *pArena, BOOL last ) { @@ -295,7 +295,7 @@ index 64236204477..f4ddd7bd68a 100644 } -@@ -495,7 +559,19 @@ static inline void HEAP_InsertFreeBlock( HEAP *heap, ARENA_FREE *pArena, BOOL la +@@ -491,7 +555,19 @@ static inline void HEAP_InsertFreeBlock( HEAP *heap, ARENA_FREE *pArena, BOOL la */ static inline void HEAP_DeleteFreeBlock( HEAP *heap, ARENA_FREE *pArena ) { @@ -316,7 +316,7 @@ index 64236204477..f4ddd7bd68a 100644 } -@@ -878,6 +954,15 @@ static BOOL validate_large_arena( HEAP *heap, const ARENA_LARGE *arena, BOOL qui +@@ -871,6 +947,15 @@ static BOOL validate_large_arena( HEAP *heap, const ARENA_LARGE *arena, BOOL qui } @@ -332,7 +332,7 @@ index 64236204477..f4ddd7bd68a 100644 /*********************************************************************** * HEAP_CreateSubHeap */ -@@ -885,7 +970,6 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags, +@@ -878,7 +963,6 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags, SIZE_T commitSize, SIZE_T totalSize ) { SUBHEAP *subheap; @@ -340,7 +340,7 @@ index 64236204477..f4ddd7bd68a 100644 unsigned int i; if (!address) -@@ -946,17 +1030,21 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags, +@@ -939,17 +1023,21 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags, subheap->headerSize = ROUND_SIZE( sizeof(HEAP) ); list_add_head( &heap->subheap_list, &subheap->entry ); @@ -372,7 +372,7 @@ index 64236204477..f4ddd7bd68a 100644 /* Initialize critical section */ -@@ -999,6 +1087,34 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags, +@@ -992,6 +1080,34 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags, } @@ -407,7 +407,7 @@ index 64236204477..f4ddd7bd68a 100644 /*********************************************************************** * HEAP_FindFreeBlock * -@@ -1008,26 +1124,39 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags, +@@ -1001,26 +1117,39 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags, static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, SIZE_T size, SUBHEAP **ppSubHeap ) { @@ -459,7 +459,7 @@ index 64236204477..f4ddd7bd68a 100644 } /* If no block was found, attempt to grow the heap */ -@@ -1115,13 +1244,10 @@ void *grow_virtual_heap( HANDLE handle, SIZE_T *size ) +@@ -1066,13 +1195,10 @@ static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, SIZE_T size, */ static BOOL HEAP_IsValidArenaPtr( const HEAP *heap, const ARENA_FREE *ptr ) { @@ -473,7 +473,7 @@ index 64236204477..f4ddd7bd68a 100644 return FALSE; } -@@ -1133,7 +1259,7 @@ static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena ) +@@ -1084,7 +1210,7 @@ static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena ) { DWORD flags = subheap->heap->flags; SIZE_T size; @@ -482,7 +482,7 @@ index 64236204477..f4ddd7bd68a 100644 char *heapEnd = (char *)subheap->base + subheap->size; /* Check for unaligned pointers */ -@@ -1150,7 +1276,8 @@ static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena ) +@@ -1101,7 +1227,8 @@ static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena ) return FALSE; } /* Check size flags */ @@ -492,7 +492,7 @@ index 64236204477..f4ddd7bd68a 100644 (pArena->size & ARENA_FLAG_PREV_FREE)) { ERR("Heap %p: bad flags %08x for free arena %p\n", -@@ -1164,34 +1291,45 @@ static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena ) +@@ -1115,34 +1242,45 @@ static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena ) ERR("Heap %p: bad size %08lx for free arena %p\n", subheap->heap, size, pArena ); return FALSE; } @@ -547,5 +547,5 @@ index 64236204477..f4ddd7bd68a 100644 subheap->heap, prev, pArena ); return FALSE; -- -2.13.1 +2.14.1 diff --git a/patches/ntdll-Heap_Improvements/definition b/patches/ntdll-Heap_Improvements/definition index 26a829c0..f49134b2 100644 --- a/patches/ntdll-Heap_Improvements/definition +++ b/patches/ntdll-Heap_Improvements/definition @@ -1,2 +1 @@ Fixes: [43224] Improvement for heap allocation performance -Depends: ntdll-Grow_Virtual_Heap diff --git a/patches/ntdll-NtQueryVirtualMemory/0008-ntdll-Resolve-drive-symlinks-before-returning-sectio.patch b/patches/ntdll-NtQueryVirtualMemory/0008-ntdll-Resolve-drive-symlinks-before-returning-sectio.patch index 4551a77c..fdad87b4 100644 --- a/patches/ntdll-NtQueryVirtualMemory/0008-ntdll-Resolve-drive-symlinks-before-returning-sectio.patch +++ b/patches/ntdll-NtQueryVirtualMemory/0008-ntdll-Resolve-drive-symlinks-before-returning-sectio.patch @@ -1,4 +1,4 @@ -From 2ea8d5c16d9ab714f8cecde6cd6b2ff51738535a Mon Sep 17 00:00:00 2001 +From 6933f5fa85dac92bc6aa20946c42fb55d1465485 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 28 May 2017 11:17:26 +0200 Subject: ntdll: Resolve drive symlinks before returning section name. @@ -24,7 +24,7 @@ index 97b42398bb0..c0b2a1ea83e 100644 OBJECT_ATTRIBUTES attr; UNICODE_STRING targetW; diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index 0e7749af4c3..e56a781fc29 100644 +index a4daeed3adf..3f4142ee1c5 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -161,6 +161,7 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S @@ -36,7 +36,7 @@ index 0e7749af4c3..e56a781fc29 100644 extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECLSPEC_HIDDEN; extern NTSTATUS virtual_create_builtin_view( void *base ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 80700437a45..1f3be783fb3 100644 +index b42da879a4b..59239b986c9 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -53,6 +53,7 @@ @@ -47,16 +47,16 @@ index 80700437a45..1f3be783fb3 100644 #include "wine/list.h" #include "wine/debug.h" #include "ntdll_misc.h" -@@ -146,6 +147,8 @@ static const BOOL is_win64 = (sizeof(void *) > sizeof(int)); - - #define VIRTUAL_HEAP_SIZE (sizeof(void*)*1024*1024) +@@ -154,6 +155,8 @@ static BYTE **pages_vprot; + static BYTE *pages_vprot; + #endif +#define MAX_DIR_ENTRY_LEN 255 /* max length of a directory entry in chars */ + static HANDLE virtual_heap; static void *preload_reserve_start; static void *preload_reserve_end; -@@ -2409,12 +2412,15 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, +@@ -2589,12 +2592,15 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, MEMORY_SECTION_NAME *info, SIZE_T len, SIZE_T *res_len ) { @@ -73,7 +73,7 @@ index 80700437a45..1f3be783fb3 100644 if (!addr || !info || !res_len) return STATUS_INVALID_PARAMETER; -@@ -2464,14 +2470,34 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, +@@ -2644,14 +2650,34 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, } found: @@ -159,5 +159,5 @@ index 0751bb24fb8..dd592a9ab21 100644 SetLastError(0xdeadbeef); -- -2.12.2 +2.14.1 diff --git a/patches/ntdll-User_Shared_Data/0003-ntdll-Create-thread-to-update-user_shared_data-time-.patch b/patches/ntdll-User_Shared_Data/0003-ntdll-Create-thread-to-update-user_shared_data-time-.patch index cbb5d935..b6928755 100644 --- a/patches/ntdll-User_Shared_Data/0003-ntdll-Create-thread-to-update-user_shared_data-time-.patch +++ b/patches/ntdll-User_Shared_Data/0003-ntdll-Create-thread-to-update-user_shared_data-time-.patch @@ -1,4 +1,4 @@ -From 72c26c780e40e1c08de072b724e3c4912f539927 Mon Sep 17 00:00:00 2001 +From fd6f4d21e1f1aa87ae2c82edc38c6286e8af7a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Fri, 5 May 2017 05:40:50 +0200 Subject: ntdll: Create thread to update user_shared_data time values when @@ -208,10 +208,10 @@ index 0cebc2a8daf..9064e1559a9 100644 /* allocate and initialize the PEB */ diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index ea4834f6abd..caf26ade02d 100644 +index 9f1b6da0c5e..25946c22c97 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c -@@ -1619,6 +1619,7 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) +@@ -1691,6 +1691,7 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) struct file_view *view; NTSTATUS ret = STATUS_ACCESS_VIOLATION; sigset_t sigset; @@ -219,26 +219,26 @@ index ea4834f6abd..caf26ade02d 100644 server_enter_uninterrupted_section( &csVirtual, &sigset ); if ((view = VIRTUAL_FindView( addr, 0 ))) -@@ -1635,6 +1636,18 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) +@@ -1707,6 +1708,18 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) /* ignore fault if page is writable now */ - if (VIRTUAL_GetUnixProt( get_page_vprot( view, page )) & PROT_WRITE) ret = STATUS_SUCCESS; + if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_WRITE) ret = STATUS_SUCCESS; } + else if (!err && page == user_shared_data_external) + { + if (!(vprot & VPROT_READ)) + { -+ set_page_vprot_bits( view, page, page_size, VPROT_READ | VPROT_WRITE, 0 ); ++ set_page_vprot_bits( page, page_size, VPROT_READ | VPROT_WRITE, 0 ); + mprotect_range( view, page, page_size, 0, 0 ); + update_shared_data = TRUE; + } + /* ignore fault if page is readable now */ -+ if (VIRTUAL_GetUnixProt( get_page_vprot( view, page )) & PROT_READ) ret = STATUS_SUCCESS; ++ if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_READ) ret = STATUS_SUCCESS; + else update_shared_data = FALSE; + } if (!on_signal_stack && (vprot & VPROT_GUARD)) { - set_page_vprot_bits( view, page, page_size, 0, VPROT_GUARD ); -@@ -1643,6 +1656,10 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) + set_page_vprot_bits( page, page_size, 0, VPROT_GUARD ); +@@ -1715,6 +1728,10 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) } } server_leave_uninterrupted_section( &csVirtual, &sigset ); diff --git a/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch b/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch index 3b86231e..4c76adb4 100644 --- a/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch +++ b/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch @@ -1,4 +1,4 @@ -From a50d535e6d20143d4a8346e8377ee401d9b5ca9a Mon Sep 17 00:00:00 2001 +From 49bf588587cbda92fe79073c08379604f40cc677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sat, 4 Oct 2014 03:22:09 +0200 Subject: ntdll: Properly handle PAGE_WRITECOPY protection. (try 5) @@ -9,10 +9,10 @@ For now, only enable it when a special environment variable is set. 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 2d12a125a3e..84a7fecb5da 100644 +index c9a5945efbf..c17b359fc7c 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c -@@ -206,6 +206,21 @@ static const char *VIRTUAL_GetProtStr( BYTE prot ) +@@ -265,6 +265,21 @@ static const char *VIRTUAL_GetProtStr( BYTE prot ) return buffer; } @@ -34,7 +34,7 @@ index 2d12a125a3e..84a7fecb5da 100644 /*********************************************************************** * VIRTUAL_GetUnixProt -@@ -219,8 +234,19 @@ static int VIRTUAL_GetUnixProt( BYTE vprot ) +@@ -278,8 +293,19 @@ static int VIRTUAL_GetUnixProt( BYTE vprot ) { if (vprot & VPROT_READ) prot |= PROT_READ; if (vprot & VPROT_WRITE) prot |= PROT_WRITE | PROT_READ; @@ -55,28 +55,28 @@ index 2d12a125a3e..84a7fecb5da 100644 if (vprot & VPROT_WRITEWATCH) prot &= ~PROT_WRITE; } if (!prot) prot = PROT_NONE; -@@ -1625,13 +1651,18 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) +@@ -1697,13 +1723,18 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) { void *page = ROUND_ADDR( addr, page_mask ); - BYTE vprot = get_page_vprot( view, page ); + BYTE vprot = get_page_vprot( page ); - if ((err & EXCEPTION_WRITE_FAULT) && (view->protect & VPROT_WRITEWATCH)) + if (err & EXCEPTION_WRITE_FAULT) { - if (vprot & VPROT_WRITEWATCH) + if ((view->protect & VPROT_WRITEWATCH) && (vprot & VPROT_WRITEWATCH)) { - set_page_vprot_bits( view, page, page_size, 0, VPROT_WRITEWATCH ); + set_page_vprot_bits( page, page_size, 0, VPROT_WRITEWATCH ); mprotect_range( view, page, page_size, 0, 0 ); } + if (vprot & VPROT_WRITECOPY) + { -+ set_page_vprot_bits( view, page, page_size, VPROT_WRITE, VPROT_WRITECOPY ); ++ set_page_vprot_bits( page, page_size, VPROT_WRITE, VPROT_WRITECOPY ); + mprotect_range( view, page, page_size, 0, 0 ); + } /* ignore fault if page is writable now */ - if (VIRTUAL_GetUnixProt( get_page_vprot( view, page )) & PROT_WRITE) ret = STATUS_SUCCESS; + if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_WRITE) ret = STATUS_SUCCESS; } -@@ -1841,14 +1872,16 @@ SIZE_T CDECL wine_uninterrupted_write_memory( void *addr, const void *buffer, SI +@@ -1913,14 +1944,16 @@ SIZE_T CDECL wine_uninterrupted_write_memory( void *addr, const void *buffer, SI * exception. Similar to virtual_handle_fault. */ if (!(VIRTUAL_GetUnixProt( vprot ) & PROT_WRITE)) { @@ -86,16 +86,16 @@ index 2d12a125a3e..84a7fecb5da 100644 - if (vprot & VPROT_WRITEWATCH) + if ((view->protect & VPROT_WRITEWATCH) && (vprot & VPROT_WRITEWATCH)) { - set_page_vprot_bits( view, page, page_size, 0, VPROT_WRITEWATCH ); + set_page_vprot_bits( page, page_size, 0, VPROT_WRITEWATCH ); mprotect_range( view, page, page_size, 0, 0 ); } + if (vprot & VPROT_WRITECOPY) + { -+ set_page_vprot_bits( view, page, page_size, VPROT_WRITE, VPROT_WRITECOPY ); ++ set_page_vprot_bits( page, page_size, VPROT_WRITE, VPROT_WRITECOPY ); + mprotect_range( view, page, page_size, 0, 0 ); + } /* ignore fault if page is writable now */ - if (!(VIRTUAL_GetUnixProt( get_page_vprot( view, page )) & PROT_WRITE)) + if (!(VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_WRITE)) break; -- 2.14.1 diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index a06581f6..198473d4 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -52,7 +52,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "eb5c1872540a71ebef4703387c11c414516233f4" + echo "b32c3243782477f7cc6dc5a189a3e4a5dacce1c8" } # Show version information @@ -249,7 +249,6 @@ patch_enable_all () enable_ntdll_FileFsVolumeInformation="$1" enable_ntdll_FileNameInformation="$1" enable_ntdll_Fix_Alignment="$1" - enable_ntdll_Grow_Virtual_Heap="$1" enable_ntdll_HashLinks="$1" enable_ntdll_Heap_Improvements="$1" enable_ntdll_Hide_Wine_Exports="$1" @@ -1027,9 +1026,6 @@ patch_enable () ntdll-Fix_Alignment) enable_ntdll_Fix_Alignment="$2" ;; - ntdll-Grow_Virtual_Heap) - enable_ntdll_Grow_Virtual_Heap="$2" - ;; ntdll-HashLinks) enable_ntdll_HashLinks="$2" ;; @@ -2649,13 +2645,6 @@ if test "$enable_ntdll_NtQueryEaFile" -eq 1; then enable_kernel32_SetFileCompletionNotificationModes=1 fi -if test "$enable_ntdll_Heap_Improvements" -eq 1; then - if test "$enable_ntdll_Grow_Virtual_Heap" -gt 1; then - abort "Patchset ntdll-Grow_Virtual_Heap disabled, but ntdll-Heap_Improvements depends on that." - fi - enable_ntdll_Grow_Virtual_Heap=1 -fi - if test "$enable_ntdll_HashLinks" -eq 1; then if test "$enable_ntdll_CLI_Images" -gt 1; then abort "Patchset ntdll-CLI_Images disabled, but ntdll-HashLinks depends on that." @@ -2898,9 +2887,6 @@ if test "$enable_advapi32_Token_Integrity_Level" -eq 1; then if test "$enable_ntdll_APC_Start_Process" -gt 1; then abort "Patchset ntdll-APC_Start_Process disabled, but advapi32-Token_Integrity_Level depends on that." fi - if test "$enable_ntdll_Grow_Virtual_Heap" -gt 1; then - abort "Patchset ntdll-Grow_Virtual_Heap disabled, but advapi32-Token_Integrity_Level depends on that." - fi if test "$enable_ntdll_RunlevelInformationInActivationContext" -gt 1; then abort "Patchset ntdll-RunlevelInformationInActivationContext disabled, but advapi32-Token_Integrity_Level depends on that." fi @@ -2919,7 +2905,6 @@ if test "$enable_advapi32_Token_Integrity_Level" -eq 1; then enable_kernel32_COMSPEC=1 enable_kernel32_UmsStubs=1 enable_ntdll_APC_Start_Process=1 - enable_ntdll_Grow_Virtual_Heap=1 enable_ntdll_RunlevelInformationInActivationContext=1 enable_ntdll_TokenLogonSid=1 enable_server_CreateProcess_ACLs=1 @@ -3280,21 +3265,6 @@ if test "$enable_ntdll_APC_Start_Process" -eq 1; then ) >> "$patchlist" fi -# Patchset ntdll-Grow_Virtual_Heap -# | -# | This patchset fixes the following Wine bugs: -# | * [#39885] Remove memory limitation to 32GB on 64-bit by growing heap dynamically -# | -# | Modified files: -# | * dlls/ntdll/heap.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/virtual.c -# | -if test "$enable_ntdll_Grow_Virtual_Heap" -eq 1; then - patch_apply ntdll-Grow_Virtual_Heap/0001-ntdll-Remove-memory-limitation-to-32GB-on-64-bit-by-.patch - ( - printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Remove memory limitation to 32GB on 64-bit by growing heap dynamically.", 2 },'; - ) >> "$patchlist" -fi - # Patchset ntdll-RunlevelInformationInActivationContext # | # | Modified files: @@ -3327,8 +3297,8 @@ fi # | # | This patchset has the following (direct or indirect) dependencies: # | * Staging, advapi32-CreateRestrictedToken, advapi32-GetExplicitEntriesFromAclW, kernel32-COMSPEC, kernel32-UmsStubs, -# | ntdll-APC_Start_Process, ntdll-Grow_Virtual_Heap, ntdll-RunlevelInformationInActivationContext, ntdll-TokenLogonSid, -# | server-CreateProcess_ACLs, server-Misc_ACL +# | ntdll-APC_Start_Process, ntdll-RunlevelInformationInActivationContext, ntdll-TokenLogonSid, server-CreateProcess_ACLs, +# | server-Misc_ACL # | # | This patchset fixes the following Wine bugs: # | * [#40613] Basic implementation for token integrity levels and UAC handling @@ -4713,20 +4683,11 @@ fi # | * [#43319] Use 8bpp bitmaps in grayscale mode # | # | Modified files: -# | * dlls/d2d1/render_target.c, dlls/dwrite/dwrite_private.h, dlls/dwrite/font.c, dlls/dwrite/freetype.c, -# | dlls/dwrite/gdiinterop.c, dlls/dwrite/tests/font.c +# | * dlls/dwrite/gdiinterop.c # | if test "$enable_dwrite_8bpp_Grayscale_Mode" -eq 1; then - patch_apply dwrite-8bpp_Grayscale_Mode/0001-dwrite-Handle-8bpp-gray-bitmaps-for-bitmap-target.patch - patch_apply dwrite-8bpp_Grayscale_Mode/0002-dwrite-Validate-buffer-size-passed-to-CreateAlphaTex.patch - patch_apply dwrite-8bpp_Grayscale_Mode/0003-dwrite-Use-8bpp-bitmaps-in-grayscale-mode.patch - patch_apply dwrite-8bpp_Grayscale_Mode/0004-d2d1-Use-8bpp-text-bitmaps-for-grayscale-mode.patch patch_apply dwrite-8bpp_Grayscale_Mode/0005-dwrite-Fix-8bpp-bitmap-copy.patch ( - printf '%s\n' '+ { "Nikolay Sivov", "dwrite: Handle 8bpp gray bitmaps for bitmap target.", 1 },'; - printf '%s\n' '+ { "Nikolay Sivov", "dwrite: Validate buffer size passed to CreateAlphaTexture() against analysis texture type.", 1 },'; - printf '%s\n' '+ { "Nikolay Sivov", "dwrite: Use 8bpp bitmaps in grayscale mode.", 1 },'; - printf '%s\n' '+ { "Nikolay Sivov", "d2d1: Use 8bpp text bitmaps for grayscale mode.", 1 },'; printf '%s\n' '+ { "Nikolay Sivov", "dwrite: Fix 8bpp bitmap copy.", 1 },'; ) >> "$patchlist" fi @@ -6431,9 +6392,6 @@ fi # Patchset ntdll-Heap_Improvements # | -# | This patchset has the following (direct or indirect) dependencies: -# | * ntdll-Grow_Virtual_Heap -# | # | This patchset fixes the following Wine bugs: # | * [#43224] Improvement for heap allocation performance # | diff --git a/patches/server-Shared_Memory/0001-ntdll-Implement-virtual_map_shared_memory.patch b/patches/server-Shared_Memory/0001-ntdll-Implement-virtual_map_shared_memory.patch index 5ed0461c..110bdc2e 100644 --- a/patches/server-Shared_Memory/0001-ntdll-Implement-virtual_map_shared_memory.patch +++ b/patches/server-Shared_Memory/0001-ntdll-Implement-virtual_map_shared_memory.patch @@ -1,4 +1,4 @@ -From 16bdcfee73240d725727f595f08e851b719e16c5 Mon Sep 17 00:00:00 2001 +From d1632e12696bc193aa988df005f63014d319c3af Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Wed, 18 Mar 2015 23:03:01 +0100 Subject: ntdll: Implement virtual_map_shared_memory. @@ -6,14 +6,14 @@ Subject: ntdll: Implement virtual_map_shared_memory. Preparation for shared memory wineserver communication. --- dlls/ntdll/ntdll_misc.h | 1 + - dlls/ntdll/virtual.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 53 insertions(+) + dlls/ntdll/virtual.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 52 insertions(+) diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index cbd19db..7eded42 100644 +index c97b1e1f73f..9a5578c946d 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h -@@ -166,6 +166,7 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S +@@ -164,6 +164,7 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECLSPEC_HIDDEN; extern NTSTATUS virtual_create_builtin_view( void *base ) DECLSPEC_HIDDEN; extern NTSTATUS virtual_alloc_thread_stack( TEB *teb, SIZE_T reserve_size, SIZE_T commit_size ) DECLSPEC_HIDDEN; @@ -22,13 +22,14 @@ index cbd19db..7eded42 100644 extern BOOL virtual_handle_stack_fault( void *addr ) DECLSPEC_HIDDEN; extern BOOL virtual_is_valid_code_address( const void *addr, SIZE_T size ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 4d4bc3b..8b422f4 100644 +index 9f1b6da0c5e..4f816b2b1ca 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c -@@ -2729,6 +2729,58 @@ done: +@@ -2899,6 +2899,57 @@ done: + } - /*********************************************************************** ++/*********************************************************************** + * virtual_map_shared_memory + */ +NTSTATUS virtual_map_shared_memory( int fd, PVOID *addr_ptr, ULONG zero_bits, @@ -64,7 +65,6 @@ index 4d4bc3b..8b422f4 100644 + + if (mmap( view->base, size, prot, MAP_FIXED | MAP_SHARED, fd, 0 ) != (void *)-1) + { -+ memset( view->prot, vprot, size >> page_shift ); + *addr_ptr = view->base; + *size_ptr = size; + } @@ -80,10 +80,9 @@ index 4d4bc3b..8b422f4 100644 +} + + -+/*********************************************************************** + /*********************************************************************** * NtUnmapViewOfSection (NTDLL.@) * ZwUnmapViewOfSection (NTDLL.@) - */ -- -2.6.1 +2.14.1 diff --git a/patches/ws2_32-WriteWatches/0001-ntdll-Expose-wine_uninterrupted_-read-write-_memory-.patch b/patches/ws2_32-WriteWatches/0001-ntdll-Expose-wine_uninterrupted_-read-write-_memory-.patch index 9158e347..1b48489b 100644 --- a/patches/ws2_32-WriteWatches/0001-ntdll-Expose-wine_uninterrupted_-read-write-_memory-.patch +++ b/patches/ws2_32-WriteWatches/0001-ntdll-Expose-wine_uninterrupted_-read-write-_memory-.patch @@ -1,4 +1,4 @@ -From 49b080a1497ac9817b6fb26fdc45b5c567b5048d Mon Sep 17 00:00:00 2001 +From 7e530d8dbeddd226975a3d2c156a6bf4385f4fe2 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 3 Jan 2015 20:07:08 +0100 Subject: ntdll: Expose wine_uninterrupted_[read|write]_memory as exports. @@ -27,10 +27,10 @@ index 68d7f22b192..77c4a589e15 100644 @ cdecl wine_nt_to_unix_file_name(ptr ptr long long) @ cdecl wine_unix_to_nt_file_name(ptr ptr) diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index 48acbbfbe85..b8bbefc8a9c 100644 +index c97b1e1f73f..7a8b046ba7a 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h -@@ -172,8 +172,6 @@ extern BOOL virtual_is_valid_code_address( const void *addr, SIZE_T size ) DECLS +@@ -170,8 +170,6 @@ extern BOOL virtual_is_valid_code_address( const void *addr, SIZE_T size ) DECLS extern NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) DECLSPEC_HIDDEN; extern BOOL virtual_check_buffer_for_read( const void *ptr, SIZE_T size ) DECLSPEC_HIDDEN; extern BOOL virtual_check_buffer_for_write( void *ptr, SIZE_T size ) DECLSPEC_HIDDEN; @@ -75,10 +75,10 @@ index f33c43f1782..03b0f2dcdf6 100644 { context->Ecx = stack[0]; diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 40dd3d16b4b..d9d96f7b7ec 100644 +index 9f1b6da0c5e..c9a5945efbf 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c -@@ -1769,13 +1769,14 @@ BOOL virtual_check_buffer_for_write( void *ptr, SIZE_T size ) +@@ -1838,13 +1838,14 @@ BOOL virtual_check_buffer_for_write( void *ptr, SIZE_T size ) /*********************************************************************** @@ -96,8 +96,8 @@ index 40dd3d16b4b..d9d96f7b7ec 100644 { struct file_view *view; sigset_t sigset; -@@ -1793,10 +1794,14 @@ SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T - while (bytes_read < size && (VIRTUAL_GetUnixProt( get_page_vprot( view, page )) & PROT_READ)) +@@ -1862,10 +1863,14 @@ SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T + while (bytes_read < size && (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_READ)) { SIZE_T block_size = min( size, page_size - ((UINT_PTR)addr & page_mask) ); - memcpy( buffer, addr, block_size ); @@ -114,7 +114,7 @@ index 40dd3d16b4b..d9d96f7b7ec 100644 bytes_read += block_size; page += page_size; } -@@ -1808,13 +1813,14 @@ SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T +@@ -1877,13 +1882,14 @@ SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T /*********************************************************************** @@ -132,7 +132,7 @@ index 40dd3d16b4b..d9d96f7b7ec 100644 { struct file_view *view; sigset_t sigset; -@@ -1852,10 +1858,14 @@ SIZE_T virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_ +@@ -1921,10 +1927,14 @@ SIZE_T virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_ } block_size = min( size, page_size - ((UINT_PTR)addr & page_mask) );