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
March 2021
----- 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
2 participants
1163 discussions
Start a n
N
ew thread
Zebediah Figura : wined3d: Introduce wined3d_device_context_set_depth_stencil_view().
by Alexandre Julliard
22 Mar '21
22 Mar '21
Module: wine Branch: master Commit: 0acd15dec8e6b35ae461ca40c514439465ed1606 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=0acd15dec8e6b35ae461ca40…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Thu Mar 18 23:16:35 2021 -0500 wined3d: Introduce wined3d_device_context_set_depth_stencil_view(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wined3d/device.c | 58 +++++++++++++++++++++++++++-------------------- dlls/wined3d/wined3d.spec | 1 + include/wine/wined3d.h | 2 ++ 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index de4f38578a0..267a8cae17d 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2372,6 +2372,38 @@ HRESULT CDECL wined3d_device_context_set_rendertarget_view(struct wined3d_device return WINED3D_OK; } +HRESULT CDECL wined3d_device_context_set_depth_stencil_view(struct wined3d_device_context *context, + struct wined3d_rendertarget_view *view) +{ + struct wined3d_fb_state *fb = &context->state->fb; + struct wined3d_rendertarget_view *prev; + + TRACE("context %p, view %p.\n", context, view); + + if (view && !(view->resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL)) + { + WARN("View resource %p has incompatible %s bind flags.\n", + view->resource, wined3d_debug_bind_flags(view->resource->bind_flags)); + return WINED3DERR_INVALIDCALL; + } + + prev = fb->depth_stencil; + if (prev == view) + { + TRACE("Trying to do a NOP SetRenderTarget operation.\n"); + return WINED3D_OK; + } + + if ((fb->depth_stencil = view)) + wined3d_rendertarget_view_incref(view); + wined3d_device_context_emit_set_depth_stencil_view(context, view); + if (prev) + wined3d_rendertarget_view_decref(prev); + wined3d_device_context_unbind_srv_for_rtv(context, view, TRUE); + + return WINED3D_OK; +} + void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader) { TRACE("device %p, shader %p.\n", device, shader); @@ -5272,33 +5304,9 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device HRESULT CDECL wined3d_device_set_depth_stencil_view(struct wined3d_device *device, struct wined3d_rendertarget_view *view) { - struct wined3d_fb_state *fb = &device->cs->c.state->fb; - struct wined3d_rendertarget_view *prev; - TRACE("device %p, view %p.\n", device, view); - if (view && !(view->resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL)) - { - WARN("View resource %p has incompatible %s bind flags.\n", - view->resource, wined3d_debug_bind_flags(view->resource->bind_flags)); - return WINED3DERR_INVALIDCALL; - } - - prev = fb->depth_stencil; - if (prev == view) - { - TRACE("Trying to do a NOP SetRenderTarget operation.\n"); - return WINED3D_OK; - } - - if ((fb->depth_stencil = view)) - wined3d_rendertarget_view_incref(view); - wined3d_device_context_emit_set_depth_stencil_view(&device->cs->c, view); - if (prev) - wined3d_rendertarget_view_decref(prev); - wined3d_device_context_unbind_srv_for_rtv(&device->cs->c, view, TRUE); - - return WINED3D_OK; + return wined3d_device_context_set_depth_stencil_view(&device->cs->c, view); } static struct wined3d_texture *wined3d_device_create_cursor_texture(struct wined3d_device *device, diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index ad66cef0f9c..ae4244bcbfd 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -169,6 +169,7 @@ @ cdecl wined3d_device_context_set_blend_state(ptr ptr ptr long) @ cdecl wined3d_device_context_set_constant_buffer(ptr long long ptr) @ cdecl wined3d_device_context_set_depth_stencil_state(ptr ptr long) +@ cdecl wined3d_device_context_set_depth_stencil_view(ptr ptr) @ cdecl wined3d_device_context_set_rasterizer_state(ptr ptr) @ cdecl wined3d_device_context_set_rendertarget_view(ptr long ptr long) @ cdecl wined3d_device_context_set_sampler(ptr long long ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index e066e688125..60625eda5c5 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2561,6 +2561,8 @@ void __cdecl wined3d_device_context_set_constant_buffer(struct wined3d_device_co enum wined3d_shader_type type, unsigned int idx, struct wined3d_buffer *buffer); void __cdecl wined3d_device_context_set_depth_stencil_state(struct wined3d_device_context *context, struct wined3d_depth_stencil_state *depth_stencil_state, unsigned int stencil_ref); +HRESULT __cdecl wined3d_device_context_set_depth_stencil_view(struct wined3d_device_context *context, + struct wined3d_rendertarget_view *view); void __cdecl wined3d_device_context_set_rasterizer_state(struct wined3d_device_context *context, struct wined3d_rasterizer_state *rasterizer_state); HRESULT __cdecl wined3d_device_context_set_rendertarget_view(struct wined3d_device_context *context,
1
0
0
0
Zebediah Figura : wined3d: Pass a wined3d_device_context to wined3d_device_context_emit_set_depth_stencil_view().
by Alexandre Julliard
22 Mar '21
22 Mar '21
Module: wine Branch: master Commit: 4a5d3206096c7181d37558cce1f41f27909a1530 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=4a5d3206096c7181d37558cc…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Thu Mar 18 23:16:34 2021 -0500 wined3d: Pass a wined3d_device_context to wined3d_device_context_emit_set_depth_stencil_view(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wined3d/cs.c | 7 ++++--- dlls/wined3d/device.c | 4 ++-- dlls/wined3d/wined3d_private.h | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 4dbf95cc9f7..1611a9efd27 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -1252,15 +1252,16 @@ static void wined3d_cs_exec_set_depth_stencil_view(struct wined3d_cs *cs, const device_invalidate_state(device, STATE_FRAMEBUFFER); } -void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs, struct wined3d_rendertarget_view *view) +void wined3d_device_context_emit_set_depth_stencil_view(struct wined3d_device_context *context, + struct wined3d_rendertarget_view *view) { struct wined3d_cs_set_depth_stencil_view *op; - op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); + op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); op->opcode = WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW; op->view = view; - wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT); + wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); } static void wined3d_cs_exec_set_vertex_declaration(struct wined3d_cs *cs, const void *data) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index e7b57a34595..de4f38578a0 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1877,7 +1877,7 @@ void CDECL wined3d_device_set_state(struct wined3d_device *device, struct wined3 wined3d_device_context_emit_set_rendertarget_view(context, i, state->fb.render_targets[i]); } - wined3d_cs_emit_set_depth_stencil_view(device->cs, state->fb.depth_stencil); + wined3d_device_context_emit_set_depth_stencil_view(context, state->fb.depth_stencil); wined3d_cs_emit_set_vertex_declaration(device->cs, state->vertex_declaration); for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i) @@ -5293,7 +5293,7 @@ HRESULT CDECL wined3d_device_set_depth_stencil_view(struct wined3d_device *devic if ((fb->depth_stencil = view)) wined3d_rendertarget_view_incref(view); - wined3d_cs_emit_set_depth_stencil_view(device->cs, view); + wined3d_device_context_emit_set_depth_stencil_view(&device->cs->c, view); if (prev) wined3d_rendertarget_view_decref(prev); wined3d_device_context_unbind_srv_for_rtv(&device->cs->c, view, TRUE); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 34fcf8f9fac..2541ca10c1e 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4749,8 +4749,6 @@ void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture, WORD flags, const struct wined3d_color_key *color_key) DECLSPEC_HIDDEN; -void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs, - struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_feature_level(struct wined3d_cs *cs, enum wined3d_feature_level level) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buffer *buffer, enum wined3d_format_id format_id, unsigned int offset) DECLSPEC_HIDDEN; @@ -4805,6 +4803,8 @@ void wined3d_device_context_emit_set_constant_buffer(struct wined3d_device_conte enum wined3d_shader_type type, UINT cb_idx, struct wined3d_buffer *buffer) DECLSPEC_HIDDEN; void wined3d_device_context_emit_set_depth_stencil_state(struct wined3d_device_context *context, struct wined3d_depth_stencil_state *state, unsigned int stencil_ref) DECLSPEC_HIDDEN; +void wined3d_device_context_emit_set_depth_stencil_view(struct wined3d_device_context *context, + struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN; void wined3d_device_context_emit_set_rasterizer_state(struct wined3d_device_context *context, struct wined3d_rasterizer_state *rasterizer_state) DECLSPEC_HIDDEN; void wined3d_device_context_emit_set_rendertarget_view(struct wined3d_device_context *context, unsigned int view_idx,
1
0
0
0
Zebediah Figura : d3d11: Use wined3d_device_context_set_unordered_access_view() in CSSetUnorderedAccessViews().
by Alexandre Julliard
22 Mar '21
22 Mar '21
Module: wine Branch: master Commit: ff5bacbba21cf69a3ec309569998efb0c3182a55 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ff5bacbba21cf69a3ec30956…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Thu Mar 18 23:16:33 2021 -0500 d3d11: Use wined3d_device_context_set_unordered_access_view() in CSSetUnorderedAccessViews(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d3d11/device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index cab5ebefcc2..4840c014b6c 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -1575,7 +1575,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShaderResources(ID3D1 static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11UnorderedAccessView *const *views, const UINT *initial_counts) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p.\n", @@ -1586,8 +1586,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetUnorderedAccessViews( { struct d3d11_unordered_access_view *view = unsafe_impl_from_ID3D11UnorderedAccessView(views[i]); - wined3d_device_set_cs_uav(device->wined3d_device, start_slot + i, - view ? view->wined3d_view : NULL, initial_counts ? initial_counts[i] : ~0u); + wined3d_device_context_set_unordered_access_view(context->wined3d_context, WINED3D_PIPELINE_COMPUTE, + start_slot + i, view ? view->wined3d_view : NULL, initial_counts ? initial_counts[i] : ~0u); } wined3d_mutex_unlock(); }
1
0
0
0
Alexandre Julliard : ntdll: Load builtin dlls through NtMapViewOfSection().
by Alexandre Julliard
22 Mar '21
22 Mar '21
Module: wine Branch: master Commit: ab8f0c3e214e2605b83c6fcf8e508c31f3bcf7d9 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ab8f0c3e214e2605b83c6fcf…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Mar 22 16:28:35 2021 +0100 ntdll: Load builtin dlls through NtMapViewOfSection(). Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/tests/virtual.c | 1 - dlls/ntdll/loader.c | 58 +++++++++++-------------------------------- 2 files changed, 14 insertions(+), 45 deletions(-) diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 854d3e04e19..e6d9e8621a9 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -1331,7 +1331,6 @@ static void test_NtAreMappedFilesTheSame(void) ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 ); ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() ); status = pNtAreMappedFilesTheSame( ptr, GetModuleHandleA("kernel32.dll") ); - todo_wine ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %x\n", status ); file2 = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 ); diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index c7e7c86e88f..eddceb60623 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -2316,8 +2316,19 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, const UNICODE_STRING *nt_nam ViewShare, 0, PAGE_EXECUTE_READ ); if (status == STATUS_IMAGE_NOT_AT_BASE) status = STATUS_SUCCESS; + if (status) return status; + + if ((*pwm = find_existing_module( module ))) /* already loaded */ + { + if ((*pwm)->ldr.LoadCount != -1) (*pwm)->ldr.LoadCount++; + TRACE( "found %s for %s at %p, count=%d\n", + debugstr_us(&(*pwm)->ldr.FullDllName), debugstr_us(nt_name), + (*pwm)->ldr.DllBase, (*pwm)->ldr.LoadCount); + if (module != (*pwm)->ldr.DllBase) NtUnmapViewOfSection( NtCurrentProcess(), module ); + return STATUS_SUCCESS; + } #ifdef _WIN64 - if (!status && !convert_to_pe64( module, image_info )) status = STATUS_INVALID_IMAGE_FORMAT; + if (!convert_to_pe64( module, image_info )) status = STATUS_INVALID_IMAGE_FORMAT; #endif if (!status) status = build_module( load_path, nt_name, &module, image_info, id, flags, pwm ); if (status && module) NtUnmapViewOfSection( NtCurrentProcess(), module ); @@ -2683,49 +2694,8 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WC break; case STATUS_SUCCESS: /* valid PE file */ - if (image_info.u.s.WineBuiltin) - { - switch (loadorder) - { - case LO_NATIVE_BUILTIN: - case LO_BUILTIN: - case LO_BUILTIN_NATIVE: - case LO_DEFAULT: - nts = load_builtin_dll( load_path, &nt_name, flags, pwm, FALSE ); - if (nts == STATUS_DLL_NOT_FOUND) - nts = load_native_dll( load_path, &nt_name, mapping, &image_info, &id, flags, pwm ); - break; - default: - nts = STATUS_DLL_NOT_FOUND; - break; - } - break; - } - if (!(image_info.u.s.WineFakeDll)) - { - switch (loadorder) - { - case LO_NATIVE: - case LO_NATIVE_BUILTIN: - nts = load_native_dll( load_path, &nt_name, mapping, &image_info, &id, flags, pwm ); - break; - case LO_BUILTIN: - nts = load_builtin_dll( load_path, &nt_name, flags, pwm, FALSE ); - break; - case LO_BUILTIN_NATIVE: - case LO_DEFAULT: - nts = load_builtin_dll( load_path, &nt_name, flags, pwm, loadorder == LO_DEFAULT ); - if (nts == STATUS_DLL_NOT_FOUND || nts == STATUS_IMAGE_ALREADY_LOADED) - nts = load_native_dll( load_path, &nt_name, mapping, &image_info, &id, flags, pwm ); - break; - default: - nts = STATUS_DLL_NOT_FOUND; - break; - } - break; - } - TRACE( "%s is a fake Wine dll\n", debugstr_us(&nt_name) ); - /* fall through */ + nts = load_native_dll( load_path, &nt_name, mapping, &image_info, &id, flags, pwm ); + break; case STATUS_DLL_NOT_FOUND: /* no file found, try builtin */ switch (loadorder)
1
0
0
0
Alexandre Julliard : ntdll: Don't return an existing address when mapping a builtin PE dll.
by Alexandre Julliard
22 Mar '21
22 Mar '21
Module: wine Branch: master Commit: 49f12d65d86fe0005dd446adf67caa48776e21b0 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=49f12d65d86fe0005dd446ad…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Mar 22 16:14:31 2021 +0100 ntdll: Don't return an existing address when mapping a builtin PE dll. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/unix/virtual.c | 44 +++----------------------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 06b9c02a73f..8ceba611875 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -87,8 +87,6 @@ struct builtin_module { struct list entry; unsigned int refcount; - dev_t dev; - ino_t ino; void *handle; void *module; char *unix_name; @@ -565,7 +563,7 @@ static void mmap_init( const struct preload_info *preload_info ) /*********************************************************************** * add_builtin_module */ -static void add_builtin_module( void *module, void *handle, const struct stat *st ) +static void add_builtin_module( void *module, void *handle ) { struct builtin_module *builtin; @@ -576,16 +574,6 @@ static void add_builtin_module( void *module, void *handle, const struct stat *s builtin->unix_name = NULL; builtin->unix_handle = NULL; builtin->unix_entry = NULL; - if (st) - { - builtin->dev = st->st_dev; - builtin->ino = st->st_ino; - } - else - { - builtin->dev = 0; - builtin->ino = 0; - } list_add_tail( &builtin_modules, &builtin->entry ); } @@ -614,19 +602,6 @@ NTSTATUS release_builtin_module( void *module ) } -/*********************************************************************** - * find_builtin_module - */ -static void *find_builtin_module( const struct stat *st ) -{ - struct builtin_module *builtin; - - LIST_FOR_EACH_ENTRY( builtin, &builtin_modules, struct builtin_module, entry ) - if (builtin->dev == st->st_dev && builtin->ino == st->st_ino) return builtin->module; - return NULL; -} - - /*********************************************************************** * get_builtin_so_handle */ @@ -2411,7 +2386,6 @@ static NTSTATUS virtual_map_image( HANDLE mapping, ACCESS_MASK access, void **ad SIZE_T size = image_info->map_size; struct file_view *view; NTSTATUS status; - struct stat st; sigset_t sigset; void *base; @@ -2428,18 +2402,6 @@ static NTSTATUS virtual_map_image( HANDLE mapping, ACCESS_MASK access, void **ad status = STATUS_INVALID_PARAMETER; server_enter_uninterrupted_section( &virtual_mutex, &sigset ); - if (is_builtin) /* check for already loaded builtin */ - { - fstat( unix_fd, &st ); - if ((base = find_builtin_module( &st ))) - { - *addr_ptr = base; - *size_ptr = size; - status = STATUS_SUCCESS; - goto done; - } - } - base = wine_server_get_ptr( image_info->base ); if ((ULONG_PTR)base != image_info->base) base = NULL; @@ -2465,7 +2427,7 @@ static NTSTATUS virtual_map_image( HANDLE mapping, ACCESS_MASK access, void **ad } if (status >= 0) { - if (is_builtin) add_builtin_module( view->base, NULL, &st ); + if (is_builtin) add_builtin_module( view->base, NULL ); *addr_ptr = view->base; *size_ptr = size; VIRTUAL_DEBUG_DUMP_VIEW( view ); @@ -2832,7 +2794,7 @@ NTSTATUS virtual_create_builtin_view( void *module, const UNICODE_STRING *nt_nam if (status >= 0) { - add_builtin_module( view->base, so_handle, NULL ); + add_builtin_module( view->base, so_handle ); VIRTUAL_DEBUG_DUMP_VIEW( view ); if (is_beyond_limit( base, size, working_set_limit )) working_set_limit = address_space_limit; }
1
0
0
0
Alexandre Julliard : ntdll: Move the builtin image checks to virtual_map_builtin_module().
by Alexandre Julliard
22 Mar '21
22 Mar '21
Module: wine Branch: master Commit: cb14be78ffdba9273af1cb3441d38295900a2490 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=cb14be78ffdba9273af1cb34…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Mar 22 09:57:03 2021 +0100 ntdll: Move the builtin image checks to virtual_map_builtin_module(). Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/unix/loader.c | 69 ++++++++++-------------------------------- dlls/ntdll/unix/unix_private.h | 5 ++- dlls/ntdll/unix/virtual.c | 28 +++++++++++++++-- 3 files changed, 45 insertions(+), 57 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=cb14be78ffdba9273af1…
1
0
0
0
Alexandre Julliard : ntdll: Replace image mapping by the builtin module directly in NtMapViewOfSection().
by Alexandre Julliard
22 Mar '21
22 Mar '21
Module: wine Branch: master Commit: 24a5a101426e16aa3f9ab9981af67c2edc72adcf URL:
https://source.winehq.org/git/wine.git/?a=commit;h=24a5a101426e16aa3f9ab998…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Mar 22 09:56:57 2021 +0100 ntdll: Replace image mapping by the builtin module directly in NtMapViewOfSection(). Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/unix/loader.c | 68 ++++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/unix/unix_private.h | 2 ++ dlls/ntdll/unix/virtual.c | 7 +++-- 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 25be205c696..fd30c5ac939 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1421,6 +1421,74 @@ static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module, } +/*********************************************************************** + * load_builtin + * + * Load the builtin dll if specified by load order configuration. + * Return STATUS_IMAGE_ALREADY_LOADED if we should keep the native one that we have found. + */ +NTSTATUS load_builtin( const pe_image_info_t *image_info, const WCHAR *filename, + void **module, SIZE_T *size ) +{ + NTSTATUS status; + UNICODE_STRING nt_name; + SECTION_IMAGE_INFORMATION info; + enum loadorder loadorder; + const WCHAR *app_name = NULL; + + if (NtCurrentTeb()->Peb->ImageBaseAddress) + app_name = NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer; + + init_unicode_string( &nt_name, filename ); + loadorder = get_load_order( app_name, &nt_name ); + + if (image_info->image_flags & IMAGE_FLAGS_WineBuiltin) + { + switch (loadorder) + { + case LO_NATIVE_BUILTIN: + case LO_BUILTIN: + case LO_BUILTIN_NATIVE: + case LO_DEFAULT: + status = find_builtin_dll( &nt_name, module, size, &info, FALSE ); + if (status == STATUS_DLL_NOT_FOUND) return STATUS_IMAGE_ALREADY_LOADED; + return status; + default: + return STATUS_DLL_NOT_FOUND; + } + } + if (image_info->image_flags & IMAGE_FLAGS_WineFakeDll) + { + TRACE( "%s is a fake Wine dll\n", debugstr_us(&nt_name) ); + switch (loadorder) + { + case LO_NATIVE_BUILTIN: + case LO_BUILTIN: + case LO_BUILTIN_NATIVE: + case LO_DEFAULT: + return find_builtin_dll( &nt_name, module, size, &info, FALSE ); + default: + return STATUS_DLL_NOT_FOUND; + } + } + switch (loadorder) + { + case LO_NATIVE: + case LO_NATIVE_BUILTIN: + return STATUS_IMAGE_ALREADY_LOADED; + case LO_BUILTIN: + return find_builtin_dll( &nt_name, module, size, &info, FALSE ); + case LO_BUILTIN_NATIVE: + case LO_DEFAULT: + status = find_builtin_dll( &nt_name, module, size, &info, (loadorder == LO_DEFAULT) ); + if (status == STATUS_DLL_NOT_FOUND) return STATUS_IMAGE_ALREADY_LOADED; + return status; + default: + return STATUS_DLL_NOT_FOUND; + } +} + + #ifdef __FreeBSD__ /* The PT_LOAD segments are sorted in increasing order, and the first * starts at the beginning of the ELF file. By parsing the file, we can diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index e527f5f799b..5e9eacb3bf8 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -141,6 +141,8 @@ extern DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD d extern int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict ) DECLSPEC_HIDDEN; extern char **build_envp( const WCHAR *envW ) DECLSPEC_HIDDEN; extern NTSTATUS exec_wineloader( char **argv, int socketfd, const pe_image_info_t *pe_info ) DECLSPEC_HIDDEN; +extern NTSTATUS load_builtin( const pe_image_info_t *image_info, const WCHAR *filename, + void **addr_ptr, SIZE_T *size_ptr ) DECLSPEC_HIDDEN; extern void start_server( BOOL debug ) DECLSPEC_HIDDEN; extern ULONG_PTR get_image_address(void) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index a38b8478371..69592892840 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -2531,8 +2531,11 @@ static NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, unsigned sh if (image_info) { filename = (WCHAR *)(image_info + 1); - res = virtual_map_image( handle, access, addr_ptr, size_ptr, zero_bits_64, shared_file, - alloc_type, image_info, filename, FALSE ); + /* check if we can replace that mapping with the builtin */ + res = load_builtin( image_info, filename, addr_ptr, size_ptr ); + if (res == STATUS_IMAGE_ALREADY_LOADED) + res = virtual_map_image( handle, access, addr_ptr, size_ptr, zero_bits_64, shared_file, + alloc_type, image_info, filename, FALSE ); if (shared_file) NtClose( shared_file ); free( image_info ); return res;
1
0
0
0
Alexandre Julliard : ntdll: Return the mapping size in virtual_map_builtin_module().
by Alexandre Julliard
22 Mar '21
22 Mar '21
Module: wine Branch: master Commit: 5dcd3c1dd97de2f20a4ed886ffe3e72be2ab8da0 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=5dcd3c1dd97de2f20a4ed886…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Mar 22 09:56:48 2021 +0100 ntdll: Return the mapping size in virtual_map_builtin_module(). Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/unix/loader.c | 42 ++++++++++++++++++++++++++++-------------- dlls/ntdll/unix/unix_private.h | 2 +- dlls/ntdll/unix/virtual.c | 6 +++--- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index f7bdb055871..25be205c696 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1234,7 +1234,7 @@ static inline char *prepend( char *buffer, const char *str, size_t len ) * Open a file for a new dll. Helper for open_builtin_file. */ static NTSTATUS open_dll_file( const char *name, OBJECT_ATTRIBUTES *attr, void **module, - SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native ) + SIZE_T *size_ptr, SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native ) { LARGE_INTEGER size; NTSTATUS status; @@ -1281,7 +1281,7 @@ static NTSTATUS open_dll_file( const char *name, OBJECT_ATTRIBUTES *attr, void * NtClose( mapping ); return STATUS_IMAGE_ALREADY_LOADED; } - status = virtual_map_builtin_module( mapping, module ); + status = virtual_map_builtin_module( mapping, module, size_ptr ); NtClose( mapping ); return status; } @@ -1290,14 +1290,14 @@ static NTSTATUS open_dll_file( const char *name, OBJECT_ATTRIBUTES *attr, void * /*********************************************************************** * open_builtin_file */ -static NTSTATUS open_builtin_file( char *name, OBJECT_ATTRIBUTES *attr, void **module, +static NTSTATUS open_builtin_file( char *name, OBJECT_ATTRIBUTES *attr, void **module, SIZE_T *size, SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native ) { NTSTATUS status; int fd; *module = NULL; - status = open_dll_file( name, attr, module, image_info, prefer_native ); + status = open_dll_file( name, attr, module, size, image_info, prefer_native ); if (status != STATUS_DLL_NOT_FOUND) return status; /* try .so file */ @@ -1325,10 +1325,10 @@ static NTSTATUS open_builtin_file( char *name, OBJECT_ATTRIBUTES *attr, void **m /*********************************************************************** - * load_builtin_dll + * find_builtin_dll */ -static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module, - SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native ) +static NTSTATUS find_builtin_dll( UNICODE_STRING *nt_name, void **module, SIZE_T *size_ptr, + SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native ) { unsigned int i, pos, namepos, namelen, maxlen = 0; unsigned int len = nt_name->Length / sizeof(WCHAR); @@ -1369,7 +1369,7 @@ static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module, ptr = prepend( ptr, ptr, namelen ); ptr = prepend( ptr, "/dlls", sizeof("/dlls") - 1 ); ptr = prepend( ptr, build_dir, strlen(build_dir) ); - status = open_builtin_file( ptr, &attr, module, image_info, prefer_native ); + status = open_builtin_file( ptr, &attr, module, size_ptr, image_info, prefer_native ); if (status != STATUS_DLL_NOT_FOUND) goto done; /* now as a program */ @@ -1380,7 +1380,7 @@ static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module, ptr = prepend( ptr, ptr, namelen ); ptr = prepend( ptr, "/programs", sizeof("/programs") - 1 ); ptr = prepend( ptr, build_dir, strlen(build_dir) ); - status = open_builtin_file( ptr, &attr, module, image_info, prefer_native ); + status = open_builtin_file( ptr, &attr, module, size_ptr, image_info, prefer_native ); if (status != STATUS_DLL_NOT_FOUND) goto done; } @@ -1388,17 +1388,15 @@ static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module, { file[pos + len + 1] = 0; ptr = prepend( file + pos, dll_paths[i], strlen(dll_paths[i]) ); - status = open_builtin_file( ptr, &attr, module, image_info, prefer_native ); + status = open_builtin_file( ptr, &attr, module, size_ptr, image_info, prefer_native ); if (status == STATUS_IMAGE_MACHINE_TYPE_MISMATCH) found_image = TRUE; else if (status != STATUS_DLL_NOT_FOUND) goto done; } if (found_image) status = STATUS_IMAGE_MACHINE_TYPE_MISMATCH; WARN( "cannot find builtin library for %s\n", debugstr_us(nt_name) ); - done: - if (status == STATUS_IMAGE_NOT_AT_BASE) status = STATUS_SUCCESS; - if (!status && ext) + if (status >= 0 && ext) { strcpy( ext, ".so" ); set_builtin_unix_info( *module, ptr, NULL, NULL ); @@ -1408,6 +1406,21 @@ done: } +/*********************************************************************** + * load_builtin_dll + */ +static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module, + SECTION_IMAGE_INFORMATION *image_info, BOOL prefer_native ) +{ + SIZE_T size; + NTSTATUS status; + + status = find_builtin_dll( nt_name, module, &size, image_info, prefer_native ); + if (status == STATUS_IMAGE_NOT_AT_BASE) status = STATUS_SUCCESS; + return status; +} + + #ifdef __FreeBSD__ /* The PT_LOAD segments are sorted in increasing order, and the first * starts at the beginning of the ELF file. By parsing the file, we can @@ -1500,12 +1513,13 @@ static void load_ntdll(void) OBJECT_ATTRIBUTES attr; UNICODE_STRING str; void *module; + SIZE_T size = 0; char *name = build_path( dll_dir, "ntdll.dll.so" ); init_unicode_string( &str, path ); InitializeObjectAttributes( &attr, &str, 0, 0, NULL ); name[strlen(name) - 3] = 0; /* remove .so */ - status = open_builtin_file( name, &attr, &module, &info, FALSE ); + status = open_builtin_file( name, &attr, &module, &size, &info, FALSE ); if (status == STATUS_IMAGE_NOT_AT_BASE) relocate_ntdll( module ); else if (status) fatal_error( "failed to load %s error %x\n", name, status ); free( name ); diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 1307364d5d3..e527f5f799b 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -178,7 +178,7 @@ extern void *anon_mmap_alloc( size_t size, int prot ) DECLSPEC_HIDDEN; extern void virtual_init(void) DECLSPEC_HIDDEN; extern ULONG_PTR get_system_affinity_mask(void) DECLSPEC_HIDDEN; extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECLSPEC_HIDDEN; -extern NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module ) DECLSPEC_HIDDEN; +extern NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module, SIZE_T *size ) DECLSPEC_HIDDEN; extern NTSTATUS virtual_create_builtin_view( void *module, const UNICODE_STRING *nt_name, pe_image_info_t *info, void *so_handle ) DECLSPEC_HIDDEN; extern TEB *virtual_alloc_first_teb(void) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index d00178d6261..a38b8478371 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -2732,14 +2732,13 @@ void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) /*********************************************************************** * virtual_map_builtin_module */ -NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module ) +NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module, SIZE_T *size ) { mem_size_t full_size; unsigned int sec_flags; HANDLE shared_file; pe_image_info_t *image_info = NULL; ACCESS_MASK access = SECTION_MAP_READ | SECTION_MAP_EXECUTE; - SIZE_T size = 0; NTSTATUS status; WCHAR *filename; @@ -2749,9 +2748,10 @@ NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module ) if (!image_info) return STATUS_INVALID_PARAMETER; *module = NULL; + *size = 0; filename = (WCHAR *)(image_info + 1); status = virtual_map_image( mapping, SECTION_MAP_READ | SECTION_MAP_EXECUTE, - module, &size, 0, shared_file, 0, image_info, filename, TRUE ); + module, size, 0, shared_file, 0, image_info, filename, TRUE ); if (shared_file) NtClose( shared_file ); free( image_info ); return status;
1
0
0
0
Alexandre Julliard : ntdll: Use NtAreMappedFilesTheSame() to find duplicated module mappings.
by Alexandre Julliard
22 Mar '21
22 Mar '21
Module: wine Branch: master Commit: 0ea5772113684f5884b44cd7e76d45508ef3fbd7 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=0ea5772113684f5884b44cd7…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Mar 22 20:38:25 2021 +0100 ntdll: Use NtAreMappedFilesTheSame() to find duplicated module mappings. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/loader.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 092c47eac3b..c7e7c86e88f 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -1167,6 +1167,8 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name wm->ldr.Flags = LDR_DONT_RESOLVE_REFS | (builtin ? LDR_WINE_INTERNAL : 0); wm->ldr.TlsIndex = -1; wm->ldr.LoadCount = 1; + wm->ldr.CheckSum = nt->OptionalHeader.CheckSum; + wm->ldr.TimeDateStamp = nt->FileHeader.TimeDateStamp; if (!(buffer = RtlAllocateHeap( GetProcessHeap(), 0, nt_name->Length - 3 * sizeof(WCHAR) ))) { @@ -2274,6 +2276,33 @@ static NTSTATUS open_dll_file( UNICODE_STRING *nt_name, WINE_MODREF **pwm, HANDL } +/****************************************************************************** + * find_existing_module + * + * Find an existing module that is the same mapping as the new module. + */ +static WINE_MODREF *find_existing_module( HMODULE module ) +{ + WINE_MODREF *wm; + LIST_ENTRY *mark, *entry; + LDR_DATA_TABLE_ENTRY *mod; + IMAGE_NT_HEADERS *nt = RtlImageNtHeader( module ); + + if ((wm = get_modref( module ))) return wm; + + mark = &NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList; + for (entry = mark->Flink; entry != mark; entry = entry->Flink) + { + mod = CONTAINING_RECORD( entry, LDR_DATA_TABLE_ENTRY, InMemoryOrderLinks ); + if (mod->TimeDateStamp != nt->FileHeader.TimeDateStamp) continue; + if (mod->CheckSum != nt->OptionalHeader.CheckSum) continue; + if (NtAreMappedFilesTheSame( mod->DllBase, module ) != STATUS_SUCCESS) continue; + return CONTAINING_RECORD( mod, WINE_MODREF, ldr ); + } + return NULL; +} + + /****************************************************************************** * load_native_dll (internal) */ @@ -2351,12 +2380,13 @@ static NTSTATUS load_builtin_dll( LPCWSTR load_path, UNICODE_STRING *nt_name, status = unix_funcs->load_builtin_dll( nt_name, &module, &image_info, prefer_native ); if (status) return status; - if ((*pwm = get_modref( module ))) /* already loaded */ + if ((*pwm = find_existing_module( module ))) /* already loaded */ { if ((*pwm)->ldr.LoadCount != -1) (*pwm)->ldr.LoadCount++; TRACE( "Found %s for %s at %p, count=%d\n", debugstr_us(&(*pwm)->ldr.FullDllName), debugstr_us(nt_name), (*pwm)->ldr.DllBase, (*pwm)->ldr.LoadCount); + if (module != (*pwm)->ldr.DllBase) NtUnmapViewOfSection( NtCurrentProcess(), module ); return STATUS_SUCCESS; }
1
0
0
0
Alexandre Julliard : ntdll: Add refcounting for .so builtin dlls.
by Alexandre Julliard
22 Mar '21
22 Mar '21
Module: wine Branch: master Commit: 20c4ae45cecb2b08544880da5aeb7b9435d1ec65 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=20c4ae45cecb2b08544880da…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Mar 22 16:11:51 2021 +0100 ntdll: Add refcounting for .so builtin dlls. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/unix/loader.c | 4 ++- dlls/ntdll/unix/unix_private.h | 1 + dlls/ntdll/unix/virtual.c | 58 +++++++++++++++++++++++++++++------------- 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 1c95b84e965..f7bdb055871 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1456,7 +1456,9 @@ static void CDECL init_builtin_dll( void *module ) #endif if (!(handle = get_builtin_so_handle( module ))) return; - if (dlinfo( handle, RTLD_DI_LINKMAP, &map )) return; + if (dlinfo( handle, RTLD_DI_LINKMAP, &map )) map = NULL; + release_builtin_module( module ); + if (!map) return; for (dyn = map->l_ld; dyn->d_tag; dyn++) { diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 5877a00bac8..1307364d5d3 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -202,6 +202,7 @@ extern void virtual_set_force_exec( BOOL enable ) DECLSPEC_HIDDEN; extern void virtual_set_large_address_space(void) DECLSPEC_HIDDEN; extern void virtual_fill_image_information( const pe_image_info_t *pe_info, SECTION_IMAGE_INFORMATION *info ) DECLSPEC_HIDDEN; +extern NTSTATUS release_builtin_module( void *module ) DECLSPEC_HIDDEN; extern void *get_builtin_so_handle( void *module ) DECLSPEC_HIDDEN; extern NTSTATUS get_builtin_unix_info( void *module, const char **name, void **handle, void **entry ) DECLSPEC_HIDDEN; extern NTSTATUS set_builtin_unix_info( void *module, const char *name, void *handle, void *entry ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 4edc7d0261e..d00178d6261 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -85,14 +85,15 @@ static struct list reserved_areas = LIST_INIT(reserved_areas); struct builtin_module { - struct list entry; - dev_t dev; - ino_t ino; - void *handle; - void *module; - char *unix_name; - void *unix_handle; - void *unix_entry; + struct list entry; + unsigned int refcount; + dev_t dev; + ino_t ino; + void *handle; + void *module; + char *unix_name; + void *unix_handle; + void *unix_entry; }; static struct list builtin_modules = LIST_INIT( builtin_modules ); @@ -569,8 +570,9 @@ static void add_builtin_module( void *module, void *handle, const struct stat *s struct builtin_module *builtin; if (!(builtin = malloc( sizeof(*builtin) ))) return; - builtin->handle = handle; - builtin->module = module; + builtin->handle = handle; + builtin->module = module; + builtin->refcount = 1; builtin->unix_name = NULL; builtin->unix_handle = NULL; builtin->unix_entry = NULL; @@ -589,19 +591,23 @@ static void add_builtin_module( void *module, void *handle, const struct stat *s /*********************************************************************** - * remove_builtin_module + * release_builtin_module */ -static NTSTATUS remove_builtin_module( void *module ) +NTSTATUS release_builtin_module( void *module ) { struct builtin_module *builtin; LIST_FOR_EACH_ENTRY( builtin, &builtin_modules, struct builtin_module, entry ) { if (builtin->module != module) continue; - list_remove( &builtin->entry ); - if (builtin->handle) dlclose( builtin->handle ); - if (builtin->unix_handle) dlclose( builtin->unix_handle ); - free( builtin ); + if (!--builtin->refcount) + { + list_remove( &builtin->entry ); + if (builtin->handle) dlclose( builtin->handle ); + if (builtin->unix_handle) dlclose( builtin->unix_handle ); + free( builtin->unix_name ); + free( builtin ); + } return STATUS_SUCCESS; } return STATUS_INVALID_PARAMETER; @@ -635,6 +641,7 @@ void *get_builtin_so_handle( void *module ) { if (builtin->module != module) continue; ret = builtin->handle; + if (ret) builtin->refcount++; break; } server_leave_uninterrupted_section( &virtual_mutex, &sigset ); @@ -4374,6 +4381,23 @@ 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->protect & VPROT_SYSTEM) + { + struct builtin_module *builtin; + + LIST_FOR_EACH_ENTRY( builtin, &builtin_modules, struct builtin_module, entry ) + { + 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; + } + } + } + SERVER_START_REQ( unmap_view ) { req->base = wine_server_client_ptr( view->base ); @@ -4382,7 +4406,7 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr ) SERVER_END_REQ; if (!status) { - if (view->protect & SEC_IMAGE) remove_builtin_module( view->base ); + if (view->protect & SEC_IMAGE) release_builtin_module( view->base ); delete_view( view ); } else FIXME( "failed to unmap %p %x\n", view->base, status );
1
0
0
0
← Newer
1
...
42
43
44
45
46
47
48
...
117
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Results per page:
10
25
50
100
200