winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
May 2023
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
775 discussions
Start a n
N
ew thread
Rémi Bernon : server: Move set_cursor desktop local variable to wider scope.
by Alexandre Julliard
30 May '23
30 May '23
Module: wine Branch: master Commit: 26c6386de90b93503231dcf44dc4efee28bbd736 URL:
https://gitlab.winehq.org/wine/wine/-/commit/26c6386de90b93503231dcf44dc4ef…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Mon Jan 25 15:05:19 2021 +0100 server: Move set_cursor desktop local variable to wider scope. --- server/queue.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/server/queue.c b/server/queue.c index 586f0c99696..22842ff286f 100644 --- a/server/queue.c +++ b/server/queue.c @@ -3264,14 +3264,16 @@ DECL_HANDLER(set_cursor) { struct msg_queue *queue = get_current_queue(); struct thread_input *input; + struct desktop *desktop; if (!queue) return; input = queue->input; + desktop = input->desktop; reply->prev_handle = input->cursor; reply->prev_count = input->cursor_count; - reply->prev_x = input->desktop->cursor.x; - reply->prev_y = input->desktop->cursor.y; + reply->prev_x = desktop->cursor.x; + reply->prev_y = desktop->cursor.y; if (req->flags & SET_CURSOR_HANDLE) { @@ -3287,20 +3289,14 @@ DECL_HANDLER(set_cursor) queue->cursor_count += req->show_count; input->cursor_count += req->show_count; } - if (req->flags & SET_CURSOR_POS) - { - set_cursor_pos( input->desktop, req->x, req->y ); - } - if (req->flags & (SET_CURSOR_CLIP | SET_CURSOR_NOCLIP)) - { - struct desktop *desktop = input->desktop; - set_clip_rectangle( desktop, (req->flags & SET_CURSOR_NOCLIP) ? NULL : &req->clip, 0 ); - } + if (req->flags & SET_CURSOR_POS) set_cursor_pos( desktop, req->x, req->y ); + if (req->flags & SET_CURSOR_CLIP) set_clip_rectangle( desktop, &req->clip, 0 ); + if (req->flags & SET_CURSOR_NOCLIP) set_clip_rectangle( desktop, NULL, 0 ); - reply->new_x = input->desktop->cursor.x; - reply->new_y = input->desktop->cursor.y; - reply->new_clip = input->desktop->cursor.clip; - reply->last_change = input->desktop->cursor.last_change; + reply->new_x = desktop->cursor.x; + reply->new_y = desktop->cursor.y; + reply->new_clip = desktop->cursor.clip; + reply->last_change = desktop->cursor.last_change; } /* Get the history of the 64 last cursor positions */
1
0
0
0
Rémi Bernon : server: Assume the internal clip message to be WM_WINE_CLIPCURSOR.
by Alexandre Julliard
30 May '23
30 May '23
Module: wine Branch: master Commit: 61dbfea452c0efc676d521ab5374abda108f4f1e URL:
https://gitlab.winehq.org/wine/wine/-/commit/61dbfea452c0efc676d521ab5374ab…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue May 16 17:35:19 2023 +0200 server: Assume the internal clip message to be WM_WINE_CLIPCURSOR. --- dlls/win32u/cursoricon.c | 1 - include/wine/server_protocol.h | 4 +--- server/protocol.def | 1 - server/queue.c | 9 ++------- server/request.h | 3 +-- server/trace.c | 1 - server/user.h | 1 - 7 files changed, 4 insertions(+), 16 deletions(-) diff --git a/dlls/win32u/cursoricon.c b/dlls/win32u/cursoricon.c index bf4b1c3ac23..584a2cffca7 100644 --- a/dlls/win32u/cursoricon.c +++ b/dlls/win32u/cursoricon.c @@ -174,7 +174,6 @@ BOOL WINAPI NtUserClipCursor( const RECT *rect ) SERVER_START_REQ( set_cursor ) { - req->clip_msg = WM_WINE_CLIPCURSOR; if (rect) { req->flags = SET_CURSOR_CLIP; diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index de56b8420d5..881b6022086 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -5334,8 +5334,6 @@ struct set_cursor_request int x; int y; rectangle_t clip; - unsigned int clip_msg; - char __pad_52[4]; }; struct set_cursor_reply { @@ -6415,7 +6413,7 @@ union generic_reply /* ### protocol_version begin ### */ -#define SERVER_PROTOCOL_VERSION 771 +#define SERVER_PROTOCOL_VERSION 772 /* ### protocol_version end ### */ diff --git a/server/protocol.def b/server/protocol.def index a1d066b0918..49fe8012606 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -3700,7 +3700,6 @@ struct handle_info int x; /* cursor position */ int y; rectangle_t clip; /* cursor clip rectangle */ - unsigned int clip_msg; /* message to post on cursor clip changes */ @REPLY user_handle_t prev_handle; /* previous handle */ int prev_count; /* previous show count */ diff --git a/server/queue.c b/server/queue.c index 7320dddc6b7..586f0c99696 100644 --- a/server/queue.c +++ b/server/queue.c @@ -34,6 +34,7 @@ #include "wingdi.h" #include "winuser.h" #include "winternl.h" +#include "ntuser.h" #include "handle.h" #include "file.h" @@ -467,8 +468,7 @@ static void set_clip_rectangle( struct desktop *desktop, const rectangle_t *rect } else desktop->cursor.clip = top_rect; - if (desktop->cursor.clip_msg && send_clip_msg) - post_desktop_message( desktop, desktop->cursor.clip_msg, rect != NULL, 0 ); + if (send_clip_msg) post_desktop_message( desktop, WM_WINE_CLIPCURSOR, rect != NULL, 0 ); /* warp the mouse to be inside the clip rect */ x = max( min( desktop->cursor.x, desktop->cursor.clip.right - 1 ), desktop->cursor.clip.left ); @@ -3294,11 +3294,6 @@ DECL_HANDLER(set_cursor) if (req->flags & (SET_CURSOR_CLIP | SET_CURSOR_NOCLIP)) { struct desktop *desktop = input->desktop; - - /* only the desktop owner can set the message */ - if (req->clip_msg && get_top_window_owner(desktop) == current->process) - desktop->cursor.clip_msg = req->clip_msg; - set_clip_rectangle( desktop, (req->flags & SET_CURSOR_NOCLIP) ? NULL : &req->clip, 0 ); } diff --git a/server/request.h b/server/request.h index c7288255aa3..07a5546d008 100644 --- a/server/request.h +++ b/server/request.h @@ -2225,8 +2225,7 @@ C_ASSERT( FIELD_OFFSET(struct set_cursor_request, show_count) == 20 ); C_ASSERT( FIELD_OFFSET(struct set_cursor_request, x) == 24 ); C_ASSERT( FIELD_OFFSET(struct set_cursor_request, y) == 28 ); C_ASSERT( FIELD_OFFSET(struct set_cursor_request, clip) == 32 ); -C_ASSERT( FIELD_OFFSET(struct set_cursor_request, clip_msg) == 48 ); -C_ASSERT( sizeof(struct set_cursor_request) == 56 ); +C_ASSERT( sizeof(struct set_cursor_request) == 48 ); C_ASSERT( FIELD_OFFSET(struct set_cursor_reply, prev_handle) == 8 ); C_ASSERT( FIELD_OFFSET(struct set_cursor_reply, prev_count) == 12 ); C_ASSERT( FIELD_OFFSET(struct set_cursor_reply, prev_x) == 16 ); diff --git a/server/trace.c b/server/trace.c index 007c0b578f5..2950edac3e5 100644 --- a/server/trace.c +++ b/server/trace.c @@ -4407,7 +4407,6 @@ static void dump_set_cursor_request( const struct set_cursor_request *req ) fprintf( stderr, ", x=%d", req->x ); fprintf( stderr, ", y=%d", req->y ); dump_rectangle( ", clip=", &req->clip ); - fprintf( stderr, ", clip_msg=%08x", req->clip_msg ); } static void dump_set_cursor_reply( const struct set_cursor_reply *req ) diff --git a/server/user.h b/server/user.h index 280da454d07..530e91c0c09 100644 --- a/server/user.h +++ b/server/user.h @@ -57,7 +57,6 @@ struct global_cursor int x; /* cursor position */ int y; rectangle_t clip; /* cursor clip rectangle */ - unsigned int clip_msg; /* message to post for cursor clip changes */ unsigned int last_change; /* time of last position change */ user_handle_t win; /* window that contains the cursor */ };
1
0
0
0
Alistair Leslie-Hughes : include: Use STDMETHOD when returning HRESULT.
by Alexandre Julliard
30 May '23
30 May '23
Module: wine Branch: master Commit: d476a4cad7c2ba8d2198184875d1eed8454e76d7 URL:
https://gitlab.winehq.org/wine/wine/-/commit/d476a4cad7c2ba8d2198184875d1ee…
Author: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com> Date: Fri May 26 18:04:57 2023 +1000 include: Use STDMETHOD when returning HRESULT. --- include/xact.h | 2 +- include/xact3.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/xact.h b/include/xact.h index 03a354e69a9..c6b34cc2c05 100644 --- a/include/xact.h +++ b/include/xact.h @@ -708,7 +708,7 @@ DECLARE_INTERFACE(IXACTWaveBank) #define INTERFACE IXACTEngine DECLARE_INTERFACE_(IXACTEngine,IUnknown) { - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID iid, void **out) PURE; + STDMETHOD(QueryInterface)(THIS_ REFIID iid, void **out) PURE; STDMETHOD_(ULONG,AddRef)(THIS) PURE; STDMETHOD_(ULONG,Release)(THIS) PURE; STDMETHOD(GetRendererCount)(THIS_ XACTINDEX *count) PURE; diff --git a/include/xact3.h b/include/xact3.h index 99fd8dcea5b..939a80e2af5 100644 --- a/include/xact3.h +++ b/include/xact3.h @@ -664,7 +664,7 @@ DECLARE_INTERFACE(IXACT3WaveBank) DECLARE_INTERFACE_(IXACT3Engine,IUnknown) { /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; STDMETHOD_(ULONG,AddRef)(THIS) PURE; STDMETHOD_(ULONG,Release)(THIS) PURE; /*** IXACT3Engine methods ***/
1
0
0
0
Alistair Leslie-Hughes : xactengine: Correct interfaces for IXACT3Cue.
by Alexandre Julliard
30 May '23
30 May '23
Module: wine Branch: master Commit: cd8c46f9e434254b7585a75fb6ff0df9622551b8 URL:
https://gitlab.winehq.org/wine/wine/-/commit/cd8c46f9e434254b7585a75fb6ff0d…
Author: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com> Date: Fri May 26 18:04:57 2023 +1000 xactengine: Correct interfaces for IXACT3Cue. --- dlls/xactengine3_7/xact_dll.c | 4 ++-- include/xact3.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/xactengine3_7/xact_dll.c b/dlls/xactengine3_7/xact_dll.c index b0f8ec13ac4..cb6b76cbf30 100644 --- a/dlls/xactengine3_7/xact_dll.c +++ b/dlls/xactengine3_7/xact_dll.c @@ -316,7 +316,7 @@ static HRESULT WINAPI IXACT3CueImpl_GetProperties(IXACT3Cue *iface, } #endif -#if XACT3_VER >= 0x0300 +#if XACT3_VER >= 0x0305 static HRESULT WINAPI IXACT3CueImpl_SetOutputVoices(IXACT3Cue *iface, const XAUDIO2_VOICE_SENDS *pSendList) { @@ -356,7 +356,7 @@ static const IXACT3CueVtbl XACT3Cue_Vtbl = #if XACT3_VER >= 0x0205 IXACT3CueImpl_GetProperties, #endif -#if XACT3_VER >= 0x0300 +#if XACT3_VER >= 0x0305 IXACT3CueImpl_SetOutputVoices, IXACT3CueImpl_SetOutputVoiceMatrix #endif diff --git a/include/xact3.h b/include/xact3.h index a1df1a51330..99fd8dcea5b 100644 --- a/include/xact3.h +++ b/include/xact3.h @@ -487,8 +487,10 @@ DECLARE_INTERFACE(IXACT3Cue) STDMETHOD(GetVariable)(THIS_ XACTVARIABLEINDEX nIndex, XACTVARIABLEVALUE *nValue) PURE; STDMETHOD(Pause)(THIS_ BOOL fPause) PURE; STDMETHOD(GetProperties)(THIS_ LPXACT_CUE_INSTANCE_PROPERTIES *ppProperties) PURE; +#if XACT3_VER >= 0x0305 STDMETHOD(SetOutputVoices)(THIS_ const XAUDIO2_VOICE_SENDS *pSendList) PURE; STDMETHOD(SetOutputVoiceMatrix)(THIS_ IXAudio2Voice *pDestinationVoice, UINT32 SourceChannels, UINT32 DestinationChannels, const float *pLevelMatrix) PURE; +#endif }; #undef INTERFACE
1
0
0
0
Paul Gofman : ntdll: Support MEM_PRESERVE_PLACEHOLDER in NtUnmapViewOfSectionEx().
by Alexandre Julliard
30 May '23
30 May '23
Module: wine Branch: master Commit: fce615a2c3da4d408d61ddca6e6b34c606fc2171 URL:
https://gitlab.winehq.org/wine/wine/-/commit/fce615a2c3da4d408d61ddca6e6b34…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Fri Nov 11 12:54:19 2022 -0600 ntdll: Support MEM_PRESERVE_PLACEHOLDER in NtUnmapViewOfSectionEx(). --- dlls/kernelbase/tests/process.c | 16 ++++++++-------- dlls/ntdll/unix/server.c | 2 +- dlls/ntdll/unix/virtual.c | 17 ++++++++++++----- include/wine/server_protocol.h | 4 ++-- server/protocol.def | 2 +- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/dlls/kernelbase/tests/process.c b/dlls/kernelbase/tests/process.c index 2e5bb7ca458..88a527c45d5 100644 --- a/dlls/kernelbase/tests/process.c +++ b/dlls/kernelbase/tests/process.c @@ -211,9 +211,9 @@ static void test_VirtualAlloc2(void) ret = VirtualFree( view1, size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER ); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got ret %d, error %lu.\n", ret, GetLastError()); ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, MEM_PRESERVE_PLACEHOLDER); - todo_wine ok(!ret && GetLastError() == ERROR_INVALID_ADDRESS, "Got ret %d, error %lu.\n", ret, GetLastError()); + ok(!ret && GetLastError() == ERROR_INVALID_ADDRESS, "Got ret %d, error %lu.\n", ret, GetLastError()); ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, 0); - todo_wine ok(ret, "Got error %lu.\n", GetLastError()); + ok(ret, "Got error %lu.\n", GetLastError()); view1 = pMapViewOfFile3(section, NULL, placeholder1, 0, size, MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, NULL, 0); ok(view1 == placeholder1, "Address does not match.\n"); @@ -248,9 +248,9 @@ static void test_VirtualAlloc2(void) memset(&info, 0, sizeof(info)); VirtualQuery(placeholder1, &info, sizeof(info)); - todo_wine ok(info.AllocationProtect == PAGE_NOACCESS, "Unexpected protection %#lx.\n", info.AllocationProtect); - todo_wine ok(info.State == MEM_RESERVE, "Unexpected state %#lx.\n", info.State); - todo_wine ok(info.Type == MEM_PRIVATE, "Unexpected type %#lx.\n", info.Type); + ok(info.AllocationProtect == PAGE_NOACCESS, "Unexpected protection %#lx.\n", info.AllocationProtect); + ok(info.State == MEM_RESERVE, "Unexpected state %#lx.\n", info.State); + ok(info.Type == MEM_PRIVATE, "Unexpected type %#lx.\n", info.Type); ok(info.RegionSize == size, "Unexpected size.\n"); ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, MEM_PRESERVE_PLACEHOLDER); @@ -260,21 +260,21 @@ static void test_VirtualAlloc2(void) ok(!ret && GetLastError() == ERROR_INVALID_ADDRESS, "Got error %lu.\n", GetLastError()); view1 = pMapViewOfFile3(section, NULL, placeholder1, 0, size, MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, NULL, 0); - todo_wine ok(view1 == placeholder1, "Address does not match.\n"); + ok(view1 == placeholder1, "Address does not match.\n"); CloseHandle(section); ret = VirtualFree( view1, size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER ); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got ret %d, error %lu.\n", ret, GetLastError()); ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, MEM_UNMAP_WITH_TRANSIENT_BOOST | MEM_PRESERVE_PLACEHOLDER); - todo_wine ok(ret, "Got error %lu.\n", GetLastError()); + ok(ret, "Got error %lu.\n", GetLastError()); ret = VirtualFree( placeholder1, size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER ); ok(!ret && GetLastError() == ERROR_INVALID_ADDRESS, "Got ret %d, error %lu.\n", ret, GetLastError()); ret = VirtualFreeEx(GetCurrentProcess(), placeholder1, size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER ); ok(!ret && GetLastError() == ERROR_INVALID_ADDRESS, "Got ret %d, error %lu.\n", ret, GetLastError()); ret = VirtualFree(placeholder1, 0, MEM_RELEASE); - todo_wine ok(ret, "Got error %lu.\n", GetLastError()); + ok(ret, "Got error %lu.\n", GetLastError()); UnmapViewOfFile(view2); diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c index 53deff744ba..227784448d3 100644 --- a/dlls/ntdll/unix/server.c +++ b/dlls/ntdll/unix/server.c @@ -615,7 +615,7 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result, BOO result->type = call->type; addr = wine_server_get_ptr( call->unmap_view.addr ); if ((ULONG_PTR)addr == call->unmap_view.addr) - result->unmap_view.status = NtUnmapViewOfSection( NtCurrentProcess(), addr ); + result->unmap_view.status = NtUnmapViewOfSectionEx( NtCurrentProcess(), addr, call->unmap_view.flags ); else result->unmap_view.status = STATUS_INVALID_PARAMETER; break; diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 40fe2c9b282..b208d7d8e9b 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -5225,7 +5225,7 @@ NTSTATUS WINAPI NtMapViewOfSectionEx( HANDLE handle, HANDLE process, PVOID *addr * * NtUnmapViewOfSection[Ex] implementation. */ -static NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr ) +static NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr, ULONG flags ) { struct file_view *view; unsigned int status = STATUS_NOT_MAPPED_VIEW; @@ -5240,6 +5240,7 @@ static NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr ) call.unmap_view.type = APC_UNMAP_VIEW; call.unmap_view.addr = wine_server_client_ptr( addr ); + call.unmap_view.flags = flags; status = server_queue_process_apc( process, &call, &result ); if (status == STATUS_SUCCESS) status = result.unmap_view.status; return status; @@ -5248,6 +5249,11 @@ static NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr ) server_enter_uninterrupted_section( &virtual_mutex, &sigset ); if (!(view = find_view( addr, 0 )) || is_view_valloc( view )) goto done; + if (flags & MEM_PRESERVE_PLACEHOLDER && !(view->protect & VPROT_PLACEHOLDER)) + { + status = STATUS_CONFLICTING_ADDRESSES; + goto done; + } if (view->protect & VPROT_SYSTEM) { struct builtin_module *builtin; @@ -5274,7 +5280,8 @@ static NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr ) if (!status) { if (view->protect & SEC_IMAGE) release_builtin_module( view->base ); - delete_view( view ); + if (flags & MEM_PRESERVE_PLACEHOLDER) free_pages_preserve_placeholder( view, view->base, view->size ); + else delete_view( view ); } else FIXME( "failed to unmap %p %x\n", view->base, status ); done: @@ -5289,7 +5296,7 @@ done: */ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr ) { - return unmap_view_of_section( process, addr ); + return unmap_view_of_section( process, addr, 0 ); } /*********************************************************************** @@ -5305,8 +5312,8 @@ NTSTATUS WINAPI NtUnmapViewOfSectionEx( HANDLE process, PVOID addr, ULONG flags WARN( "Unsupported flags %#x.\n", (int)flags ); return STATUS_INVALID_PARAMETER; } - if (flags) FIXME( "Ignoring flags %#x.\n", (int)flags ); - return unmap_view_of_section( process, addr ); + if (flags & MEM_UNMAP_WITH_TRANSIENT_BOOST) FIXME( "Ignoring MEM_UNMAP_WITH_TRANSIENT_BOOST.\n" ); + return unmap_view_of_section( process, addr, flags ); } /****************************************************************************** diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 87626aaf051..de56b8420d5 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -598,7 +598,7 @@ typedef union struct { enum apc_type type; - int __pad; + unsigned int flags; client_ptr_t addr; } unmap_view; struct @@ -6415,7 +6415,7 @@ union generic_reply /* ### protocol_version begin ### */ -#define SERVER_PROTOCOL_VERSION 770 +#define SERVER_PROTOCOL_VERSION 771 /* ### protocol_version end ### */ diff --git a/server/protocol.def b/server/protocol.def index 1c492ea5cc2..a1d066b0918 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -614,7 +614,7 @@ typedef union struct { enum apc_type type; /* APC_UNMAP_VIEW */ - int __pad; + unsigned int flags; /* unmap flags */ client_ptr_t addr; /* view address */ } unmap_view; struct
1
0
0
0
Paul Gofman : ntdll: Validate flags in NtUnmapViewOfSectionEx().
by Alexandre Julliard
30 May '23
30 May '23
Module: wine Branch: master Commit: 3e3ca7dd2880749afea498c386ce8b3194a9323d URL:
https://gitlab.winehq.org/wine/wine/-/commit/3e3ca7dd2880749afea498c386ce8b…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Thu May 25 21:11:41 2023 -0600 ntdll: Validate flags in NtUnmapViewOfSectionEx(). --- dlls/kernelbase/tests/process.c | 4 ++-- dlls/ntdll/unix/virtual.c | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dlls/kernelbase/tests/process.c b/dlls/kernelbase/tests/process.c index 7c6544f6dd9..2e5bb7ca458 100644 --- a/dlls/kernelbase/tests/process.c +++ b/dlls/kernelbase/tests/process.c @@ -242,9 +242,9 @@ static void test_VirtualAlloc2(void) ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got ret %d, error %lu.\n", ret, GetLastError()); ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER); - todo_wine ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got ret %d, error %lu.\n", ret, GetLastError()); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got ret %d, error %lu.\n", ret, GetLastError()); ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, MEM_PRESERVE_PLACEHOLDER); - todo_wine ok(ret, "Got error %lu.\n", GetLastError()); + ok(ret, "Got error %lu.\n", GetLastError()); memset(&info, 0, sizeof(info)); VirtualQuery(placeholder1, &info, sizeof(info)); diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index c701ce4fc03..40fe2c9b282 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -5298,7 +5298,14 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr ) */ NTSTATUS WINAPI NtUnmapViewOfSectionEx( HANDLE process, PVOID addr, ULONG flags ) { - if (flags) FIXME("Ignoring flags %#x.\n", (int)flags); + static const ULONG type_mask = MEM_UNMAP_WITH_TRANSIENT_BOOST | MEM_PRESERVE_PLACEHOLDER; + + if (flags & ~type_mask) + { + WARN( "Unsupported flags %#x.\n", (int)flags ); + return STATUS_INVALID_PARAMETER; + } + if (flags) FIXME( "Ignoring flags %#x.\n", (int)flags ); return unmap_view_of_section( process, addr ); }
1
0
0
0
Paul Gofman : kernelbase/tests: Add tests for MEM_PRESERVE_PLACEHOLDER with UnmapViewOfFile2().
by Alexandre Julliard
30 May '23
30 May '23
Module: wine Branch: master Commit: 4806b1c2265930c025aeae369fa999ce556c9b03 URL:
https://gitlab.winehq.org/wine/wine/-/commit/4806b1c2265930c025aeae369fa999…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Thu May 25 21:08:45 2023 -0600 kernelbase/tests: Add tests for MEM_PRESERVE_PLACEHOLDER with UnmapViewOfFile2(). --- dlls/kernelbase/tests/process.c | 65 +++++++++++++++++++++++++++++++++++++++-- include/winnt.h | 1 + 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/dlls/kernelbase/tests/process.c b/dlls/kernelbase/tests/process.c index e5185a2587d..7c6544f6dd9 100644 --- a/dlls/kernelbase/tests/process.c +++ b/dlls/kernelbase/tests/process.c @@ -41,6 +41,7 @@ static PVOID (WINAPI *pVirtualAllocFromApp)(PVOID, SIZE_T, DWORD, DWORD); static HANDLE (WINAPI *pOpenFileMappingFromApp)( ULONG, BOOL, LPCWSTR); static HANDLE (WINAPI *pCreateFileMappingFromApp)(HANDLE, PSECURITY_ATTRIBUTES, ULONG, ULONG64, PCWSTR); static LPVOID (WINAPI *pMapViewOfFileFromApp)(HANDLE, ULONG, ULONG64, SIZE_T); +static BOOL (WINAPI *pUnmapViewOfFile2)(HANDLE, void *, ULONG); static void test_CompareObjectHandles(void) { @@ -166,6 +167,13 @@ static void test_VirtualAlloc2(void) ret = VirtualFree(addr, 0, MEM_RELEASE); ok(ret, "Unexpected return value %d, error %lu.\n", ret, GetLastError()); + placeholder1 = pVirtualAlloc2(NULL, NULL, 2 * size, MEM_RESERVE, PAGE_NOACCESS, NULL, 0); + ok(!!placeholder1, "Failed to create a placeholder range.\n"); + ret = VirtualFree(placeholder1, size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER); + ok(!ret && GetLastError() == ERROR_INVALID_ADDRESS, "Got ret %d, error %lu.\n", ret, GetLastError()); + ret = VirtualFree(placeholder1, 0, MEM_RELEASE); + ok(ret, "Unexpected return value %d, error %lu.\n", ret, GetLastError()); + /* Placeholder splitting functionality */ placeholder1 = pVirtualAlloc2(NULL, NULL, 2 * size, MEM_RESERVE_PLACEHOLDER | MEM_RESERVE, PAGE_NOACCESS, NULL, 0); ok(!!placeholder1, "Failed to create a placeholder range.\n"); @@ -198,11 +206,20 @@ static void test_VirtualAlloc2(void) section = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, size, NULL); ok(!!section, "Failed to create a section.\n"); - view1 = pMapViewOfFile3(section, NULL, placeholder1, 0, size, MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, NULL, 0); + view1 = pMapViewOfFile3(section, NULL, NULL, 0, size, 0, PAGE_READWRITE, NULL, 0); ok(!!view1, "Failed to map a section.\n"); + ret = VirtualFree( view1, size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER ); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got ret %d, error %lu.\n", ret, GetLastError()); + ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, MEM_PRESERVE_PLACEHOLDER); + todo_wine ok(!ret && GetLastError() == ERROR_INVALID_ADDRESS, "Got ret %d, error %lu.\n", ret, GetLastError()); + ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, 0); + todo_wine ok(ret, "Got error %lu.\n", GetLastError()); + + view1 = pMapViewOfFile3(section, NULL, placeholder1, 0, size, MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, NULL, 0); + ok(view1 == placeholder1, "Address does not match.\n"); view2 = pMapViewOfFile3(section, NULL, placeholder2, 0, size, MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, NULL, 0); - ok(!!view2, "Failed to map a section.\n"); + ok(view2 == placeholder2, "Address does not match.\n"); memset(&info, 0, sizeof(info)); VirtualQuery(placeholder1, &info, sizeof(info)); @@ -218,8 +235,47 @@ static void test_VirtualAlloc2(void) ok(info.Type == MEM_MAPPED, "Unexpected type %#lx.\n", info.Type); ok(info.RegionSize == size, "Unexpected size.\n"); + ret = pUnmapViewOfFile2(NULL, view1, MEM_PRESERVE_PLACEHOLDER); + ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Got error %lu.\n", GetLastError()); + + ret = VirtualFree( placeholder1, size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER ); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got ret %d, error %lu.\n", ret, GetLastError()); + + ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER); + todo_wine ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got ret %d, error %lu.\n", ret, GetLastError()); + ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, MEM_PRESERVE_PLACEHOLDER); + todo_wine ok(ret, "Got error %lu.\n", GetLastError()); + + memset(&info, 0, sizeof(info)); + VirtualQuery(placeholder1, &info, sizeof(info)); + todo_wine ok(info.AllocationProtect == PAGE_NOACCESS, "Unexpected protection %#lx.\n", info.AllocationProtect); + todo_wine ok(info.State == MEM_RESERVE, "Unexpected state %#lx.\n", info.State); + todo_wine ok(info.Type == MEM_PRIVATE, "Unexpected type %#lx.\n", info.Type); + ok(info.RegionSize == size, "Unexpected size.\n"); + + ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, MEM_PRESERVE_PLACEHOLDER); + ok(!ret && GetLastError() == ERROR_INVALID_ADDRESS, "Got error %lu.\n", GetLastError()); + + ret = UnmapViewOfFile(view1); + ok(!ret && GetLastError() == ERROR_INVALID_ADDRESS, "Got error %lu.\n", GetLastError()); + + view1 = pMapViewOfFile3(section, NULL, placeholder1, 0, size, MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, NULL, 0); + todo_wine ok(view1 == placeholder1, "Address does not match.\n"); CloseHandle(section); - UnmapViewOfFile(view1); + + ret = VirtualFree( view1, size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER ); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got ret %d, error %lu.\n", ret, GetLastError()); + + ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, MEM_UNMAP_WITH_TRANSIENT_BOOST | MEM_PRESERVE_PLACEHOLDER); + todo_wine ok(ret, "Got error %lu.\n", GetLastError()); + + ret = VirtualFree( placeholder1, size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER ); + ok(!ret && GetLastError() == ERROR_INVALID_ADDRESS, "Got ret %d, error %lu.\n", ret, GetLastError()); + ret = VirtualFreeEx(GetCurrentProcess(), placeholder1, size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER ); + ok(!ret && GetLastError() == ERROR_INVALID_ADDRESS, "Got ret %d, error %lu.\n", ret, GetLastError()); + ret = VirtualFree(placeholder1, 0, MEM_RELEASE); + todo_wine ok(ret, "Got error %lu.\n", GetLastError()); + UnmapViewOfFile(view2); VirtualFree(placeholder1, 0, MEM_RELEASE); @@ -249,6 +305,8 @@ static void test_VirtualAlloc2(void) p1 = p; p2 = p + size / 2; + ret = VirtualFree(p1, 0, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got ret %d, error %lu.\n", ret, GetLastError()); ret = VirtualFree(p1, size / 2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER); ok(ret, "Failed to split a placeholder.\n"); check_region_size(p1, size / 2); @@ -461,6 +519,7 @@ static void init_funcs(void) X(VirtualAlloc2); X(VirtualAlloc2FromApp); X(VirtualAllocFromApp); + X(UnmapViewOfFile2); hmod = GetModuleHandleA("ntdll.dll"); diff --git a/include/winnt.h b/include/winnt.h index 1a7f65776a7..0117100a921 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -837,6 +837,7 @@ typedef struct DECLSPEC_ALIGN(8) MEM_EXTENDED_PARAMETER { #define MEM_PRESERVE_PLACEHOLDER 0x00000002 #define MEM_DECOMMIT 0x00004000 #define MEM_RELEASE 0x00008000 +#define MEM_UNMAP_WITH_TRANSIENT_BOOST 0x00000001 #define MEM_FREE 0x00010000 #define MEM_PRIVATE 0x00020000
1
0
0
0
Paul Gofman : ntdll: Factor out unmap_view_of_section() function.
by Alexandre Julliard
30 May '23
30 May '23
Module: wine Branch: master Commit: cd8f0fbac89810dda1f77d3ccca9de2892240901 URL:
https://gitlab.winehq.org/wine/wine/-/commit/cd8f0fbac89810dda1f77d3ccca9de…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Fri Nov 11 12:41:31 2022 -0600 ntdll: Factor out unmap_view_of_section() function. --- dlls/ntdll/unix/virtual.c | 70 +++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 6fe025d2a7b..c701ce4fc03 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -5219,11 +5219,13 @@ NTSTATUS WINAPI NtMapViewOfSectionEx( HANDLE handle, HANDLE process, PVOID *addr alloc_type, protect, machine ); } + /*********************************************************************** - * NtUnmapViewOfSection (NTDLL.@) - * ZwUnmapViewOfSection (NTDLL.@) + * unmap_view_of_section + * + * NtUnmapViewOfSection[Ex] implementation. */ -NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr ) +static NTSTATUS unmap_view_of_section( HANDLE process, PVOID addr ) { struct file_view *view; unsigned int status = STATUS_NOT_MAPPED_VIEW; @@ -5244,42 +5246,52 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr ) } server_enter_uninterrupted_section( &virtual_mutex, &sigset ); - if ((view = find_view( addr, 0 )) && !is_view_valloc( view )) + if (!(view = find_view( addr, 0 )) || is_view_valloc( view )) goto done; + + if (view->protect & VPROT_SYSTEM) { - if (view->protect & VPROT_SYSTEM) - { - struct builtin_module *builtin; + struct builtin_module *builtin; - LIST_FOR_EACH_ENTRY( builtin, &builtin_modules, struct builtin_module, entry ) + LIST_FOR_EACH_ENTRY( builtin, &builtin_modules, struct builtin_module, entry ) + { + if (builtin->module != view->base) continue; + if (builtin->refcount > 1) { - if (builtin->module != view->base) continue; - if (builtin->refcount > 1) - { - TRACE( "not freeing in-use builtin %p\n", view->base ); - builtin->refcount--; - server_leave_uninterrupted_section( &virtual_mutex, &sigset ); - return STATUS_SUCCESS; - } + TRACE( "not freeing in-use builtin %p\n", view->base ); + builtin->refcount--; + server_leave_uninterrupted_section( &virtual_mutex, &sigset ); + return STATUS_SUCCESS; } } + } - SERVER_START_REQ( unmap_view ) - { - req->base = wine_server_client_ptr( view->base ); - status = wine_server_call( req ); - } - SERVER_END_REQ; - if (!status) - { - if (view->protect & SEC_IMAGE) release_builtin_module( view->base ); - delete_view( view ); - } - else FIXME( "failed to unmap %p %x\n", view->base, status ); + SERVER_START_REQ( unmap_view ) + { + req->base = wine_server_client_ptr( view->base ); + status = wine_server_call( req ); } + SERVER_END_REQ; + if (!status) + { + if (view->protect & SEC_IMAGE) release_builtin_module( view->base ); + delete_view( view ); + } + else FIXME( "failed to unmap %p %x\n", view->base, status ); +done: server_leave_uninterrupted_section( &virtual_mutex, &sigset ); return status; } + +/*********************************************************************** + * NtUnmapViewOfSection (NTDLL.@) + * ZwUnmapViewOfSection (NTDLL.@) + */ +NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr ) +{ + return unmap_view_of_section( process, addr ); +} + /*********************************************************************** * NtUnmapViewOfSectionEx (NTDLL.@) * ZwUnmapViewOfSectionEx (NTDLL.@) @@ -5287,7 +5299,7 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr ) NTSTATUS WINAPI NtUnmapViewOfSectionEx( HANDLE process, PVOID addr, ULONG flags ) { if (flags) FIXME("Ignoring flags %#x.\n", (int)flags); - return NtUnmapViewOfSection( process, addr ); + return unmap_view_of_section( process, addr ); } /******************************************************************************
1
0
0
0
Paul Gofman : ntdll: Support MEM_COALESCE_PLACEHOLDERS in NtFreeVirtualMemory().
by Alexandre Julliard
30 May '23
30 May '23
Module: wine Branch: master Commit: 03096546c9b11983170469bb2eda651cef5bba7a URL:
https://gitlab.winehq.org/wine/wine/-/commit/03096546c9b11983170469bb2eda65…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Thu Nov 10 19:02:50 2022 -0600 ntdll: Support MEM_COALESCE_PLACEHOLDERS in NtFreeVirtualMemory(). --- dlls/ntdll/tests/virtual.c | 72 ++++++++++++++++++++++++++++++++++++++++++++-- dlls/ntdll/unix/virtual.c | 56 +++++++++++++++++++++++++++++++++++- 2 files changed, 125 insertions(+), 3 deletions(-) diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 45ba58868df..f5f1964e516 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -295,9 +295,9 @@ static void test_NtAllocateVirtualMemoryEx(void) { MEMORY_BASIC_INFORMATION mbi; MEM_EXTENDED_PARAMETER ext[2]; + char *p, *p1, *p2, *p3; void *addresses[16]; SIZE_T size, size2; - char *p, *p1, *p2; ULONG granularity; NTSTATUS status; ULONG_PTR count; @@ -510,6 +510,7 @@ static void test_NtAllocateVirtualMemoryEx(void) p1 = addr1; p2 = p1 + size / 4; + p3 = p2 + size / 4; size2 = size / 4; status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER); ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status); @@ -517,12 +518,79 @@ static void test_NtAllocateVirtualMemoryEx(void) ok(size2 == 0x4000, "Unexpected size %#Ix.\n", size2); ok(p1 == addr1, "Unexpected addr %p, expected %p.\n", p1, addr1); + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER); + ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status); + + check_region_size(p1, p2 - p1); + check_region_size(p2, p3 - p2); + check_region_size(p3, size - (p3 - p1)); + + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS); + ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status); + + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_COALESCE_PLACEHOLDERS); + ok(status == STATUS_INVALID_PARAMETER_4, "Unexpected status %08lx.\n", status); + + size2 = size + 0x1000; + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS); + ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status); + + size2 = size - 0x1000; + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS); + ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status); + + p1 = (char *)addr1 + 0x1000; + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS); + ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status); + p1 = addr1; + + size2 = 0; + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS); + ok(status == STATUS_INVALID_PARAMETER_3, "Unexpected status %08lx.\n", status); + + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_RELEASE); + ok(status == STATUS_UNABLE_TO_FREE_VM, "Unexpected status %08lx.\n", status); + + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS); + ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status); + ok(size == 0x10000, "Unexpected size %#Ix.\n", size); + ok(p1 == addr1, "Unexpected addr %p, expected %p.\n", p1, addr1); + check_region_size(p1, size); + + size2 = size / 4; + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER); + ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status); + ok(size2 == 0x4000, "Unexpected size %#Ix.\n", size2); + ok(p1 == addr1, "Unexpected addr %p, expected %p.\n", p1, addr1); check_region_size(p1, size / 4); check_region_size(p2, size - size / 4); - status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE); + + size2 = size - size / 4; + status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), (void **)&p2, &size2, MEM_RESERVE | MEM_REPLACE_PLACEHOLDER, + PAGE_READWRITE, NULL, 0); ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status); + + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS); + ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status); + + size2 = size - size / 4; status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p2, &size2, MEM_RELEASE); ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status); + ok(size2 == 0xc000, "Unexpected size %#Ix.\n", size2); + ok(p2 == p1 + size / 4, "Unexpected addr %p, expected %p.\n", p2, p1 + size / 4); + + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size, MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS); + ok(status == STATUS_CONFLICTING_ADDRESSES, "Unexpected status %08lx.\n", status); + + size2 = size / 4; + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p1, &size2, MEM_RELEASE); + ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status); + ok(size2 == 0x4000, "Unexpected size %#Ix.\n", size2); + ok(p1 == addr1, "Unexpected addr %p, expected %p.\n", p1, addr1); + + size2 = 0; + status = NtFreeVirtualMemory(NtCurrentProcess(), (void **)&p3, &size2, MEM_RELEASE); + ok(status == STATUS_MEMORY_NOT_ALLOCATED, "Unexpected status %08lx.\n", status); /* Split in two regions, specifying second half. */ addr1 = NULL; diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 2d0dda64249..6fe025d2a7b 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -2294,6 +2294,53 @@ static NTSTATUS free_pages( struct file_view *view, char *base, size_t size ) } +/*********************************************************************** + * coalesce_placeholders + * + * Coalesce placeholder views. + * virtual_mutex must be held by caller. + */ +static NTSTATUS coalesce_placeholders( struct file_view *view, char *base, size_t size ) +{ + struct rb_entry *next; + struct file_view *curr_view, *next_view; + unsigned int i, view_count = 0; + size_t views_size = 0; + + if (!size) return STATUS_INVALID_PARAMETER_3; + if (base != view->base) return STATUS_CONFLICTING_ADDRESSES; + + curr_view = view; + while (curr_view->protect & VPROT_FREE_PLACEHOLDER) + { + ++view_count; + views_size += curr_view->size; + if (views_size >= size) break; + if (!(next = rb_next( &curr_view->entry ))) break; + next_view = RB_ENTRY_VALUE( next, struct file_view, entry ); + if ((char *)curr_view->base + curr_view->size != next_view->base) break; + curr_view = next_view; + } + + if (view_count < 2 || size != views_size) return STATUS_CONFLICTING_ADDRESSES; + + for (i = 1; i < view_count; ++i) + { + curr_view = RB_ENTRY_VALUE( rb_next( &view->entry ), struct file_view, entry ); + unregister_view( curr_view ); + free_view( curr_view ); + } + + unregister_view( view ); + view->size = views_size; + register_view( view ); + + VIRTUAL_DEBUG_DUMP_VIEW( view ); + + return STATUS_SUCCESS; +} + + /*********************************************************************** * allocate_dos_memory * @@ -4445,7 +4492,8 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si else if (!(view = find_view( base, 0 ))) status = STATUS_MEMORY_NOT_ALLOCATED; else if (!is_view_valloc( view )) status = STATUS_INVALID_PARAMETER; else if (!size && base != view->base) status = STATUS_FREE_VM_NOT_AT_BASE; - else if ((char *)view->base + view->size - base < size) status = STATUS_UNABLE_TO_FREE_VM; + else if ((char *)view->base + view->size - base < size && !(type & MEM_COALESCE_PLACEHOLDERS)) + status = STATUS_UNABLE_TO_FREE_VM; else switch (type) { case MEM_DECOMMIT: @@ -4458,6 +4506,12 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si case MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER: status = free_pages_preserve_placeholder( view, base, size ); break; + case MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS: + status = coalesce_placeholders( view, base, size ); + break; + case MEM_COALESCE_PLACEHOLDERS: + status = STATUS_INVALID_PARAMETER_4; + break; default: status = STATUS_INVALID_PARAMETER; break;
1
0
0
0
Alexandre Julliard : ntdll: Use nameless unions/structs for IO_STATUS_BLOCK.
by Alexandre Julliard
30 May '23
30 May '23
Module: wine Branch: master Commit: d5f23441ad460844f552d301680e061dd1a5e90a URL:
https://gitlab.winehq.org/wine/wine/-/commit/d5f23441ad460844f552d301680e06…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue May 30 11:00:04 2023 +0200 ntdll: Use nameless unions/structs for IO_STATUS_BLOCK. --- dlls/ntdll/sync.c | 1 - dlls/ntdll/tests/threadpool.c | 4 +-- dlls/ntdll/threadpool.c | 7 ++--- dlls/ntdll/unix/cdrom.c | 3 +- dlls/ntdll/unix/file.c | 65 +++++++++++++++++++++--------------------- dlls/ntdll/unix/serial.c | 3 +- dlls/ntdll/unix/sync.c | 7 ++--- dlls/ntdll/unix/tape.c | 3 +- dlls/ntdll/unix/unix_private.h | 8 ------ 9 files changed, 42 insertions(+), 59 deletions(-)
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
9
...
78
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Results per page:
10
25
50
100
200