From 279eca11f110626cce233b7ecaa5c7cdb376c1c0 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 8 Sep 2017 00:29:26 +0200 Subject: [PATCH] Rebase against d003ed3b1743985282c8c8e9c597d77c4b47bb15. --- ...ive-symlinks-before-returning-sectio.patch | 16 ++-- ...andle-PAGE_WRITECOPY-protection.-try.patch | 65 ++++++++------- ...-conditions-with-write-watches-in-Nt.patch | 20 ++--- patches/patchinstall.sh | 6 +- ...plement-IWICBitmapDecoder-CopyPalett.patch | 31 ------- ...x-IWICBitmapEncoder-SetPalette-for-a.patch | 41 ---------- ...e_uninterrupted_-read-write-_memory-.patch | 81 +++++++++---------- ...e-conditions-of-async-WSARecv-operat.patch | 10 +-- 8 files changed, 98 insertions(+), 172 deletions(-) delete mode 100644 patches/windowscodecs-Palette_Images/0001-windowscodecs-Implement-IWICBitmapDecoder-CopyPalett.patch delete mode 100644 patches/windowscodecs-Palette_Images/0003-windowscodecs-Fix-IWICBitmapEncoder-SetPalette-for-a.patch 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 fdad87b4..d613afab 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 6933f5fa85dac92bc6aa20946c42fb55d1465485 Mon Sep 17 00:00:00 2001 +From 68b5e9a9e9a4552c5bc04250d40d20fced0430a6 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 a4daeed3adf..3f4142ee1c5 100644 +index ecee4a193d9..e8586486a58 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 a4daeed3adf..3f4142ee1c5 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 b42da879a4b..59239b986c9 100644 +index 005e9b150d3..deff0da4549 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -53,6 +53,7 @@ @@ -47,16 +47,16 @@ index b42da879a4b..59239b986c9 100644 #include "wine/list.h" #include "wine/debug.h" #include "ntdll_misc.h" -@@ -154,6 +155,8 @@ static BYTE **pages_vprot; +@@ -152,6 +153,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 struct file_view *view_block_start, *view_block_end, *next_free_view; + static const size_t view_block_size = 0x100000; static void *preload_reserve_start; - static void *preload_reserve_end; -@@ -2589,12 +2592,15 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, +@@ -2595,12 +2598,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 b42da879a4b..59239b986c9 100644 if (!addr || !info || !res_len) return STATUS_INVALID_PARAMETER; -@@ -2644,14 +2650,34 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, +@@ -2650,14 +2656,34 @@ static NTSTATUS get_section_name( HANDLE process, LPCVOID addr, } found: 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 4c76adb4..831f7d02 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,18 +1,18 @@ -From 49bf588587cbda92fe79073c08379604f40cc677 Mon Sep 17 00:00:00 2001 +From c43f021985b9bd0d2ac1ba0e8145b8eddb665506 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) For now, only enable it when a special environment variable is set. --- - dlls/ntdll/virtual.c | 47 ++++++++++++++++++++++++++++++++++++++++------- - 1 file changed, 40 insertions(+), 7 deletions(-) + dlls/ntdll/virtual.c | 51 ++++++++++++++++++++++++++++++++++++++++++++------- + 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index c9a5945efbf..c17b359fc7c 100644 +index cb3b9aad385..7365c3ad487 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c -@@ -265,6 +265,21 @@ static const char *VIRTUAL_GetProtStr( BYTE prot ) +@@ -264,6 +264,21 @@ static const char *VIRTUAL_GetProtStr( BYTE prot ) return buffer; } @@ -34,7 +34,7 @@ index c9a5945efbf..c17b359fc7c 100644 /*********************************************************************** * VIRTUAL_GetUnixProt -@@ -278,8 +293,19 @@ static int VIRTUAL_GetUnixProt( BYTE vprot ) +@@ -277,8 +292,19 @@ static int VIRTUAL_GetUnixProt( BYTE vprot ) { if (vprot & VPROT_READ) prot |= PROT_READ; if (vprot & VPROT_WRITE) prot |= PROT_WRITE | PROT_READ; @@ -55,7 +55,7 @@ index c9a5945efbf..c17b359fc7c 100644 if (vprot & VPROT_WRITEWATCH) prot &= ~PROT_WRITE; } if (!prot) prot = PROT_NONE; -@@ -1697,13 +1723,18 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) +@@ -1721,13 +1747,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( page ); @@ -76,27 +76,36 @@ index c9a5945efbf..c17b359fc7c 100644 /* ignore fault if page is writable now */ if (VIRTUAL_GetUnixProt( get_page_vprot( page )) & PROT_WRITE) ret = STATUS_SUCCESS; } -@@ -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)) - { -- if (!(view->protect & VPROT_WRITEWATCH)) -- break; -- -- if (vprot & VPROT_WRITEWATCH) -+ if ((view->protect & VPROT_WRITEWATCH) && (vprot & 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( 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( page )) & PROT_WRITE)) - break; +@@ -1918,6 +1949,7 @@ NTSTATUS CDECL wine_uninterrupted_write_memory( void *addr, const void *buffer, + struct file_view *view; + sigset_t sigset; + NTSTATUS ret = STATUS_ACCESS_VIOLATION; ++ BOOL writecopy = FALSE; + + if (!size) return STATUS_SUCCESS; + +@@ -1929,12 +1961,17 @@ NTSTATUS CDECL wine_uninterrupted_write_memory( void *addr, const void *buffer, + + for (i = 0; i < total; i += page_size) + { +- int prot = VIRTUAL_GetUnixProt( get_page_vprot( page + i ) & ~VPROT_WRITEWATCH ); +- if (!(prot & PROT_WRITE)) goto done; ++ BYTE vprot = get_page_vprot( page + i ) & ~VPROT_WRITEWATCH; ++ if (vprot & VPROT_WRITECOPY) ++ { ++ vprot = (vprot & ~VPROT_WRITECOPY) | VPROT_WRITE; ++ writecopy = TRUE; ++ } ++ if (!(VIRTUAL_GetUnixProt( vprot ) & PROT_WRITE)) goto done; + } +- if (view->protect & VPROT_WRITEWATCH) /* enable write access by clearing write watches */ ++ if ((view->protect & VPROT_WRITEWATCH) || writecopy) /* enable write access by clearing write watches */ + { +- set_page_vprot_bits( addr, size, 0, VPROT_WRITEWATCH ); ++ set_page_vprot_bits( addr, size, VPROT_WRITE, VPROT_WRITECOPY | VPROT_WRITEWATCH ); + mprotect_range( view, addr, size, 0, 0 ); + } + if (buffer) memcpy( addr, buffer, size ); -- 2.14.1 diff --git a/patches/ntdll-WriteWatches/0001-ntdll-Avoid-race-conditions-with-write-watches-in-Nt.patch b/patches/ntdll-WriteWatches/0001-ntdll-Avoid-race-conditions-with-write-watches-in-Nt.patch index 5a378fd5..899a68f9 100644 --- a/patches/ntdll-WriteWatches/0001-ntdll-Avoid-race-conditions-with-write-watches-in-Nt.patch +++ b/patches/ntdll-WriteWatches/0001-ntdll-Avoid-race-conditions-with-write-watches-in-Nt.patch @@ -1,4 +1,4 @@ -From d587367c1f1e2dbe9b284b32027db068691838eb Mon Sep 17 00:00:00 2001 +From c6dc4f67d20bd4deb3c8655da9dae191af34135a Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Tue, 10 Feb 2015 06:36:52 +0100 Subject: ntdll: Avoid race-conditions with write watches in NtReadFile. @@ -10,10 +10,10 @@ Rebased against kernel32-NamedPipe patchset by Sebastian Lackner buffer[fileio->already], NULL, -+ fileio->count - fileio->already ) >= (fileio->count - fileio->already)) ? ++ fileio->count - fileio->already ) == STATUS_SUCCESS) ? + STATUS_PENDING : STATUS_ACCESS_VIOLATION; else /* check to see if the transfer is complete */ status = FILE_GetNtStatus(); } -@@ -875,6 +879,13 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent, +@@ -871,6 +875,13 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent, /* async I/O doesn't make sense on regular files */ while ((result = pread( unix_handle, buffer, length, offset->QuadPart )) == -1) { @@ -63,13 +63,13 @@ index c153e7bb5c..34fd08fb0b 100644 if (errno != EINTR) { status = FILE_GetNtStatus(); -@@ -949,6 +960,13 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent, +@@ -945,6 +956,13 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent, else if (errno != EAGAIN) { if (errno == EINTR) continue; + if (errno == EFAULT) + { -+ if (wine_uninterrupted_write_memory( (char *)buffer + total, NULL, length - total ) >= (length - total)) ++ if (wine_uninterrupted_write_memory( (char *)buffer + total, NULL, length - total ) == STATUS_SUCCESS) + continue; + else + errno = EFAULT; @@ -78,5 +78,5 @@ index c153e7bb5c..34fd08fb0b 100644 goto done; } -- -2.11.0 +2.14.1 diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 198473d4..d193f735 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -52,7 +52,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "b32c3243782477f7cc6dc5a189a3e4a5dacce1c8" + echo "d003ed3b1743985282c8c8e9c597d77c4b47bb15" } # Show version information @@ -9127,8 +9127,6 @@ fi # | dlls/windowscodecs/tests/converter.c, dlls/windowscodecs/tests/pngformat.c, dlls/windowscodecs/tiffformat.c # | if test "$enable_windowscodecs_Palette_Images" -eq 1; then - patch_apply windowscodecs-Palette_Images/0001-windowscodecs-Implement-IWICBitmapDecoder-CopyPalett.patch - patch_apply windowscodecs-Palette_Images/0003-windowscodecs-Fix-IWICBitmapEncoder-SetPalette-for-a.patch patch_apply windowscodecs-Palette_Images/0004-windowscodecs-Decode-PNG-images-with-a-tRNS-chunk-in.patch patch_apply windowscodecs-Palette_Images/0005-windowscodecs-Add-support-for-palette-image-formats-.patch patch_apply windowscodecs-Palette_Images/0006-windowscodecs-Fix-IWICBitmapEncoder-SetPalette-for-a.patch @@ -9149,8 +9147,6 @@ if test "$enable_windowscodecs_Palette_Images" -eq 1; then patch_apply windowscodecs-Palette_Images/0021-windowscodecs-PNG-decoder-should-return-WINCODEC_ERR.patch patch_apply windowscodecs-Palette_Images/0022-windowscodecs-PNG-decoder-should-use-indexed-formats.patch ( - printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapDecoder::CopyPalette in PNG decoder.", 1 },'; - printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Fix IWICBitmapEncoder::SetPalette for a not initialized case in PNG encoder.", 1 },'; printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Decode PNG images with a tRNS chunk in their native formats.", 1 },'; printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Add support for palette image formats to PNG encoder.", 1 },'; printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Fix IWICBitmapEncoder::SetPalette for a not initialized case in BMP encoder.", 1 },'; diff --git a/patches/windowscodecs-Palette_Images/0001-windowscodecs-Implement-IWICBitmapDecoder-CopyPalett.patch b/patches/windowscodecs-Palette_Images/0001-windowscodecs-Implement-IWICBitmapDecoder-CopyPalett.patch deleted file mode 100644 index 172c917a..00000000 --- a/patches/windowscodecs-Palette_Images/0001-windowscodecs-Implement-IWICBitmapDecoder-CopyPalett.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 3ed4435cbd9872e7cfc9122874839e3656b007a6 Mon Sep 17 00:00:00 2001 -From: Dmitry Timoshkov -Date: Tue, 20 Sep 2016 14:09:22 +0800 -Subject: windowscodecs: Implement IWICBitmapDecoder::CopyPalette in PNG - decoder. - ---- - dlls/windowscodecs/pngformat.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c -index bb2aef9..623577e 100644 ---- a/dlls/windowscodecs/pngformat.c -+++ b/dlls/windowscodecs/pngformat.c -@@ -855,10 +855,10 @@ static HRESULT WINAPI PngDecoder_GetDecoderInfo(IWICBitmapDecoder *iface, - } - - static HRESULT WINAPI PngDecoder_CopyPalette(IWICBitmapDecoder *iface, -- IWICPalette *pIPalette) -+ IWICPalette *palette) - { -- FIXME("(%p,%p): stub\n", iface, pIPalette); -- return E_NOTIMPL; -+ TRACE("(%p,%p)\n", iface, palette); -+ return WINCODEC_ERR_PALETTEUNAVAILABLE; - } - - static HRESULT WINAPI PngDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface, --- -2.9.0 - diff --git a/patches/windowscodecs-Palette_Images/0003-windowscodecs-Fix-IWICBitmapEncoder-SetPalette-for-a.patch b/patches/windowscodecs-Palette_Images/0003-windowscodecs-Fix-IWICBitmapEncoder-SetPalette-for-a.patch deleted file mode 100644 index c48f7866..00000000 --- a/patches/windowscodecs-Palette_Images/0003-windowscodecs-Fix-IWICBitmapEncoder-SetPalette-for-a.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 21789956f3eab8c48e1291437a9edef7ab4de638 Mon Sep 17 00:00:00 2001 -From: Dmitry Timoshkov -Date: Tue, 20 Sep 2016 14:15:41 +0800 -Subject: windowscodecs: Fix IWICBitmapEncoder::SetPalette for a not - initialized case in PNG encoder. - ---- - dlls/windowscodecs/pngformat.c | 16 +++++++++++++--- - 1 file changed, 13 insertions(+), 3 deletions(-) - -diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c -index 1fda2b7..fa54a23 100644 ---- a/dlls/windowscodecs/pngformat.c -+++ b/dlls/windowscodecs/pngformat.c -@@ -1919,10 +1919,20 @@ static HRESULT WINAPI PngEncoder_SetColorContexts(IWICBitmapEncoder *iface, - return E_NOTIMPL; - } - --static HRESULT WINAPI PngEncoder_SetPalette(IWICBitmapEncoder *iface, IWICPalette *pIPalette) -+static HRESULT WINAPI PngEncoder_SetPalette(IWICBitmapEncoder *iface, IWICPalette *palette) - { -- TRACE("(%p,%p)\n", iface, pIPalette); -- return WINCODEC_ERR_UNSUPPORTEDOPERATION; -+ PngEncoder *This = impl_from_IWICBitmapEncoder(iface); -+ HRESULT hr; -+ -+ TRACE("(%p,%p)\n", iface, palette); -+ -+ EnterCriticalSection(&This->lock); -+ -+ hr = This->stream ? WINCODEC_ERR_UNSUPPORTEDOPERATION : WINCODEC_ERR_NOTINITIALIZED; -+ -+ LeaveCriticalSection(&This->lock); -+ -+ return hr; - } - - static HRESULT WINAPI PngEncoder_SetThumbnail(IWICBitmapEncoder *iface, IWICBitmapSource *pIThumbnail) --- -2.9.0 - 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 1b48489b..8e4cd610 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 7e530d8dbeddd226975a3d2c156a6bf4385f4fe2 Mon Sep 17 00:00:00 2001 +From 6d426bf5815052c59127d85383a82e080a00f21b 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. @@ -6,16 +6,16 @@ Subject: ntdll: Expose wine_uninterrupted_[read|write]_memory as exports. --- dlls/ntdll/ntdll.spec | 4 ++++ dlls/ntdll/ntdll_misc.h | 2 -- - dlls/ntdll/signal_i386.c | 10 +++++----- - dlls/ntdll/virtual.c | 34 ++++++++++++++++++++++------------ + dlls/ntdll/signal_i386.c | 12 ++++++------ + dlls/ntdll/virtual.c | 26 ++++++++++++++++---------- include/winternl.h | 3 +++ - 5 files changed, 34 insertions(+), 19 deletions(-) + 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec -index 68d7f22b192..77c4a589e15 100644 +index 69bfe923234..5d5fa5b5c4e 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec -@@ -1491,6 +1491,10 @@ +@@ -1495,6 +1495,10 @@ # signal handling @ cdecl __wine_set_signal_handler(long ptr) @@ -27,23 +27,23 @@ 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 c97b1e1f73f..7a8b046ba7a 100644 +index 3358119657d..af142a31c70 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h -@@ -170,8 +170,6 @@ extern BOOL virtual_is_valid_code_address( const void *addr, SIZE_T size ) DECLS +@@ -173,8 +173,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; -extern SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T size ) DECLSPEC_HIDDEN; --extern SIZE_T virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_T size ) DECLSPEC_HIDDEN; +-extern NTSTATUS virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_T size ) DECLSPEC_HIDDEN; extern void VIRTUAL_SetForceExec( BOOL enable ) DECLSPEC_HIDDEN; extern void virtual_release_address_space(void) DECLSPEC_HIDDEN; extern void virtual_set_large_address_space(void) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c -index f33c43f1782..03b0f2dcdf6 100644 +index ab8d1144472..94b06214568 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c -@@ -1802,13 +1802,13 @@ static BOOL check_atl_thunk( EXCEPTION_RECORD *rec, CONTEXT *context ) +@@ -1802,14 +1802,14 @@ static BOOL check_atl_thunk( EXCEPTION_RECORD *rec, CONTEXT *context ) union atl_thunk thunk_copy; SIZE_T thunk_len; @@ -54,11 +54,13 @@ index f33c43f1782..03b0f2dcdf6 100644 if (thunk_len >= sizeof(thunk_copy.t1) && thunk_copy.t1.movl == 0x042444c7 && thunk_copy.t1.jmp == 0xe9) { -- if (virtual_uninterrupted_write_memory( (DWORD *)context->Esp + 1, -+ if (wine_uninterrupted_write_memory( (DWORD *)context->Esp + 1, - &thunk_copy.t1.this, sizeof(DWORD) ) == sizeof(DWORD)) +- if (!virtual_uninterrupted_write_memory( (DWORD *)context->Esp + 1, +- &thunk_copy.t1.this, sizeof(DWORD) )) ++ if (!wine_uninterrupted_write_memory( (DWORD *)context->Esp + 1, ++ &thunk_copy.t1.this, sizeof(DWORD) )) { context->Eip = (DWORD_PTR)(&thunk->t1.func + 1) + thunk_copy.t1.func; + TRACE( "emulating ATL thunk type 1 at %p, func=%08x arg=%08x\n", @@ -1852,11 +1852,11 @@ static BOOL check_atl_thunk( EXCEPTION_RECORD *rec, CONTEXT *context ) thunk_copy.t5.inst2 == 0x0460) { @@ -69,16 +71,16 @@ index f33c43f1782..03b0f2dcdf6 100644 - virtual_uninterrupted_read_memory( (DWORD *)stack[1] + 1, + wine_uninterrupted_read_memory( (DWORD *)stack[1] + 1, &func, sizeof(DWORD) ) == sizeof(DWORD) && -- virtual_uninterrupted_write_memory( (DWORD *)context->Esp + 1, -+ wine_uninterrupted_write_memory( (DWORD *)context->Esp + 1, - &stack[0], sizeof(stack[0]) ) == sizeof(stack[0])) +- !virtual_uninterrupted_write_memory( (DWORD *)context->Esp + 1, &stack[0], sizeof(stack[0]) )) ++ !wine_uninterrupted_write_memory( (DWORD *)context->Esp + 1, &stack[0], sizeof(stack[0]) )) { context->Ecx = stack[0]; + context->Eax = stack[1]; diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c -index 9f1b6da0c5e..c9a5945efbf 100644 +index a73041706f7..cb3b9aad385 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c -@@ -1838,13 +1838,14 @@ BOOL virtual_check_buffer_for_write( void *ptr, SIZE_T size ) +@@ -1862,13 +1862,14 @@ BOOL virtual_check_buffer_for_write( void *ptr, SIZE_T size ) /*********************************************************************** @@ -96,7 +98,7 @@ index 9f1b6da0c5e..c9a5945efbf 100644 { struct file_view *view; sigset_t sigset; -@@ -1862,10 +1863,14 @@ SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T +@@ -1886,10 +1887,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) ); @@ -114,12 +116,12 @@ index 9f1b6da0c5e..c9a5945efbf 100644 bytes_read += block_size; page += page_size; } -@@ -1877,13 +1882,14 @@ SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T +@@ -1901,13 +1906,14 @@ SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T /*********************************************************************** - * virtual_uninterrupted_write_memory -+ * wine_uninterrupted_write_memory (NTDLL.@) ++ * wine_uninterrupted_write_memory * * Similar to NtWriteVirtualMemory, but without wineserver calls. Moreover * permissions are checked before accessing each page, to ensure that no @@ -127,39 +129,30 @@ index 9f1b6da0c5e..c9a5945efbf 100644 + * exceptions can happen. When a NULL pointer is passed as buffer the + * permissions are only checked and no actual memcpy is performed. */ --SIZE_T virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_T size ) -+SIZE_T CDECL wine_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_T size ) +-NTSTATUS virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_T size ) ++NTSTATUS CDECL wine_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_T size ) { struct file_view *view; sigset_t sigset; -@@ -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) ); -- memcpy( addr, buffer, block_size ); - -- addr = (void *)((char *)addr + block_size); -- buffer = (const void *)((const char *)buffer + block_size); -+ if (buffer) -+ { -+ memcpy( addr, buffer, block_size ); -+ buffer = (const void *)((const char *)buffer + block_size); -+ } -+ -+ addr = (void *)((char *)addr + block_size); - bytes_written += block_size; - } +@@ -1931,7 +1937,7 @@ NTSTATUS virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZ + set_page_vprot_bits( addr, size, 0, VPROT_WRITEWATCH ); + mprotect_range( view, addr, size, 0, 0 ); } +- memcpy( addr, buffer, size ); ++ if (buffer) memcpy( addr, buffer, size ); + ret = STATUS_SUCCESS; + } + done: diff --git a/include/winternl.h b/include/winternl.h -index df20da58c3c..5c697dd45cd 100644 +index 3d60baa1f98..3ff6c38d6dc 100644 --- a/include/winternl.h +++ b/include/winternl.h -@@ -2789,6 +2789,9 @@ NTSYSAPI NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, +@@ -2790,6 +2790,9 @@ NTSYSAPI NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, UINT disposition, BOOLEAN check_case ); NTSYSAPI NTSTATUS CDECL wine_unix_to_nt_file_name( const ANSI_STRING *name, UNICODE_STRING *nt ); +NTSYSAPI SIZE_T CDECL wine_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T size ); -+NTSYSAPI SIZE_T CDECL wine_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_T size ); ++NTSYSAPI NTSTATUS CDECL wine_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_T size ); + /*********************************************************************** diff --git a/patches/ws2_32-WriteWatches/0002-ws2_32-Avoid-race-conditions-of-async-WSARecv-operat.patch b/patches/ws2_32-WriteWatches/0002-ws2_32-Avoid-race-conditions-of-async-WSARecv-operat.patch index 39434603..43f1afce 100644 --- a/patches/ws2_32-WriteWatches/0002-ws2_32-Avoid-race-conditions-of-async-WSARecv-operat.patch +++ b/patches/ws2_32-WriteWatches/0002-ws2_32-Avoid-race-conditions-of-async-WSARecv-operat.patch @@ -1,4 +1,4 @@ -From 252e65f38146194200160b94bf2b4c1963980a07 Mon Sep 17 00:00:00 2001 +From 1f6c4cab7763e40ed66d3d9336e47be045a4abb1 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 21 Nov 2014 12:22:46 +0100 Subject: ws2_32: Avoid race-conditions of async WSARecv() operations with @@ -41,10 +41,10 @@ that data is immediately available. 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c -index d13fbf4da4..a532c2591d 100644 +index 681f340bc6d..ac356035cc6 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c -@@ -2332,7 +2332,20 @@ static int WS2_recv( int fd, struct ws2_async *wsa, int flags ) +@@ -2358,7 +2358,20 @@ static int WS2_recv( int fd, struct ws2_async *wsa, int flags ) while ((n = recvmsg(fd, &hdr, flags)) == -1) { @@ -55,7 +55,7 @@ index d13fbf4da4..a532c2591d 100644 + for (i = wsa->first_iovec; i < wsa->n_iovecs; i++) + { + struct iovec *iov = &wsa->iovec[i]; -+ if (wine_uninterrupted_write_memory( iov->iov_base, NULL, iov->iov_len ) < iov->iov_len) ++ if (wine_uninterrupted_write_memory( iov->iov_base, NULL, iov->iov_len ) != STATUS_SUCCESS) + { + errno = EFAULT; + return -1; @@ -67,5 +67,5 @@ index d13fbf4da4..a532c2591d 100644 } -- -2.11.0 +2.14.1