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
August 2020
----- 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
692 discussions
Start a n
N
ew thread
Hans Leidekker : ws2_32: Avoid a crash in WS_getaddrinfo when the specified service doesn't exist.
by Alexandre Julliard
11 Aug '20
11 Aug '20
Module: wine Branch: master Commit: a6d9f46b25a481648a2a06ed8d1594fc59a4e313 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a6d9f46b25a481648a2a06ed…
Author: Hans Leidekker <hans(a)codeweavers.com> Date: Tue Aug 11 14:11:05 2020 +0200 ws2_32: Avoid a crash in WS_getaddrinfo when the specified service doesn't exist. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=49656
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ws2_32/socket.c | 2 +- dlls/ws2_32/tests/sock.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index eb21e4b4b3..4d2afa946b 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -6787,7 +6787,7 @@ int WINAPI WS_getaddrinfo(LPCSTR nodename, LPCSTR servname, const struct WS_addr result = getaddrinfo(node, servname, punixhints, &unixaires); if (result && (!hints || !(hints->ai_flags & WS_AI_NUMERICHOST)) - && (!strcmp(fqdn, node) || (!strncmp(fqdn, node, hostname_len) && !node[hostname_len]))) + && node && (!strcmp(fqdn, node) || (!strncmp(fqdn, node, hostname_len) && !node[hostname_len]))) { /* If it didn't work it means the host name IP is not in /etc/hosts, try again * by sending a NULL host and avoid sending a NULL servname too because that diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index b7a3fc4453..b523c326d6 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -7778,6 +7778,10 @@ static void test_getaddrinfo(void) ok(0, "test %d: getaddrinfo failed with %d (err %d)\n", i, ret, err); } } + + memset(&hint, 0, sizeof(hint)); + ret = pgetaddrinfo(NULL, "nonexistentservice", &hint, &result); + ok(ret == WSATYPE_NOT_FOUND, "got %d\n", ret); } static void test_ConnectEx(void)
1
0
0
0
Stefan Dösinger : ddraw: Thunk to surface1, not surface7 in flip.
by Alexandre Julliard
11 Aug '20
11 Aug '20
Module: wine Branch: master Commit: 6a276eba1693bb25190bfd8db34a143d69f0fc20 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=6a276eba1693bb25190bfd8d…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Tue Aug 11 14:50:44 2020 +0300 ddraw: Thunk to surface1, not surface7 in flip. Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ddraw/surface.c | 62 +++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 83b2114176..fd788a96ac 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -1270,16 +1270,18 @@ static unsigned int ddraw_swap_interval_from_flags(DWORD flags) } } -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Flip(IDirectDrawSurface7 *iface, - IDirectDrawSurface7 *src, DWORD flags) +/* FRAPS hooks IDirectDrawSurface::Flip and expects the version 1 method to be called when the + * game uses later interfaces. */ +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_Flip(IDirectDrawSurface *iface, + IDirectDrawSurface *src, DWORD flags) { - struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface7(iface); - struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface7(src); + struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface(iface); + struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface(src); struct ddraw_texture *dst_ddraw_texture, *src_ddraw_texture; struct wined3d_rendertarget_view *tmp_rtv, *src_rtv, *rtv; - DDSCAPS2 caps = {DDSCAPS_FLIP, 0, 0, {0}}; + DDSCAPS caps = {DDSCAPS_FLIP}; struct wined3d_texture *texture; - IDirectDrawSurface7 *current; + IDirectDrawSurface *current; void *texture_memory; HRESULT hr; @@ -1313,13 +1315,13 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Flip(IDirectDrawSurface7 { for (current = iface; current != src;) { - if (FAILED(hr = ddraw_surface7_GetAttachedSurface(current, &caps, ¤t))) + if (FAILED(hr = ddraw_surface1_GetAttachedSurface(current, &caps, ¤t))) { WARN("Surface %p is not on the same flip chain as surface %p.\n", src, iface); wined3d_mutex_unlock(); return DDERR_NOTFLIPPABLE; } - ddraw_surface7_Release(current); + ddraw_surface1_Release(current); if (current == iface) { WARN("Surface %p is not on the same flip chain as surface %p.\n", src, iface); @@ -1346,20 +1348,20 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Flip(IDirectDrawSurface7 { for (current = iface;;) { - if (FAILED(hr = ddraw_surface7_GetAttachedSurface(current, &caps, ¤t))) + if (FAILED(hr = ddraw_surface1_GetAttachedSurface(current, &caps, ¤t))) { ERR("Can't find a flip target\n"); wined3d_mutex_unlock(); return DDERR_NOTFLIPPABLE; /* Unchecked */ } - ddraw_surface7_Release(current); + ddraw_surface1_Release(current); if (current == iface) { - dst_impl = impl_from_IDirectDrawSurface7(iface); + dst_impl = impl_from_IDirectDrawSurface(iface); break; } - src_impl = impl_from_IDirectDrawSurface7(current); + src_impl = impl_from_IDirectDrawSurface(current); src_rtv = ddraw_surface_get_rendertarget_view(src_impl); if (rtv == dst_impl->wined3d_rtv) wined3d_device_set_rendertarget_view(dst_impl->ddraw->wined3d_device, 0, src_rtv, FALSE); @@ -1407,6 +1409,18 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Flip(IDirectDrawSurface7 return hr; } +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Flip(IDirectDrawSurface7 *iface, + IDirectDrawSurface7 *src, DWORD flags) +{ + struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface); + struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface7(src); + + TRACE("iface %p, src %p, flags %#x.\n", iface, src, flags); + + return ddraw_surface1_Flip(&surface->IDirectDrawSurface_iface, + src_impl ? &src_impl->IDirectDrawSurface_iface : NULL, flags); +} + static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface4_Flip(IDirectDrawSurface4 *iface, IDirectDrawSurface4 *src, DWORD flags) { @@ -1415,8 +1429,8 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface4_Flip(IDirectDrawSurface4 TRACE("iface %p, src %p, flags %#x.\n", iface, src, flags); - return ddraw_surface7_Flip(&surface->IDirectDrawSurface7_iface, - src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, flags); + return ddraw_surface1_Flip(&surface->IDirectDrawSurface_iface, + src_impl ? &src_impl->IDirectDrawSurface_iface : NULL, flags); } static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface3_Flip(IDirectDrawSurface3 *iface, @@ -1427,8 +1441,8 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface3_Flip(IDirectDrawSurface3 TRACE("iface %p, src %p, flags %#x.\n", iface, src, flags); - return ddraw_surface7_Flip(&surface->IDirectDrawSurface7_iface, - src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, flags); + return ddraw_surface1_Flip(&surface->IDirectDrawSurface_iface, + src_impl ? &src_impl->IDirectDrawSurface_iface : NULL, flags); } static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface2_Flip(IDirectDrawSurface2 *iface, @@ -1439,20 +1453,8 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface2_Flip(IDirectDrawSurface2 TRACE("iface %p, src %p, flags %#x.\n", iface, src, flags); - return ddraw_surface7_Flip(&surface->IDirectDrawSurface7_iface, - src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, flags); -} - -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_Flip(IDirectDrawSurface *iface, - IDirectDrawSurface *src, DWORD flags) -{ - struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface); - struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface(src); - - TRACE("iface %p, src %p, flags %#x.\n", iface, src, flags); - - return ddraw_surface7_Flip(&surface->IDirectDrawSurface7_iface, - src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, flags); + return ddraw_surface1_Flip(&surface->IDirectDrawSurface_iface, + src_impl ? &src_impl->IDirectDrawSurface_iface : NULL, flags); } static HRESULT ddraw_surface_blt(struct ddraw_surface *dst_surface, const RECT *dst_rect,
1
0
0
0
Stefan Dösinger : ddraw: Thunk to surface1, not surface7 in surface_unlock.
by Alexandre Julliard
11 Aug '20
11 Aug '20
Module: wine Branch: master Commit: 6b5ea56905991a37789f1607263e92a23c141d1e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=6b5ea56905991a37789f1607…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Tue Aug 11 14:50:43 2020 +0300 ddraw: Thunk to surface1, not surface7 in surface_unlock. Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ddraw/surface.c | 51 +++++++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 22bebffce6..83b2114176 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -1198,24 +1198,14 @@ static HRESULT WINAPI ddraw_surface1_Lock(IDirectDrawSurface *iface, RECT *rect, return ddraw_surface_lock_ddsd(surface, rect, surface_desc, flags, h); } -/***************************************************************************** - * IDirectDrawSurface7::Unlock - * - * Unlocks an locked surface - * - * Params: - * Rect: Not used by this implementation - * - * Returns: - * D3D_OK on success, error code otherwise. - * - *****************************************************************************/ -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Unlock(IDirectDrawSurface7 *iface, RECT *pRect) +/* FRAPS hooks IDirectDrawSurface::Unlock and expects the version 1 method to be called when the + * game uses later interfaces. */ +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_Unlock(IDirectDrawSurface *iface, void *data) { - struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface); + struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface); HRESULT hr; - TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(pRect)); + TRACE("iface %p, data %p.\n", iface, data); wined3d_mutex_lock(); hr = wined3d_resource_unmap(wined3d_texture_get_resource(surface->wined3d_texture), surface->sub_resource_idx); @@ -1226,43 +1216,40 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Unlock(IDirectDrawSurface return hr; } -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface4_Unlock(IDirectDrawSurface4 *iface, RECT *pRect) +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Unlock(IDirectDrawSurface7 *iface, RECT *rect) { - struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface); + struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface); - TRACE("iface %p, rect %p.\n", iface, pRect); + TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(rect)); - return ddraw_surface7_Unlock(&surface->IDirectDrawSurface7_iface, pRect); + return ddraw_surface1_Unlock(&surface->IDirectDrawSurface_iface, NULL); } -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface3_Unlock(IDirectDrawSurface3 *iface, void *data) +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface4_Unlock(IDirectDrawSurface4 *iface, RECT *rect) { - struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface); + struct ddraw_surface *surface = impl_from_IDirectDrawSurface4(iface); - TRACE("iface %p, data %p.\n", iface, data); + TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(rect)); - /* data might not be the LPRECT of later versions, so drop it. */ - return ddraw_surface7_Unlock(&surface->IDirectDrawSurface7_iface, NULL); + return ddraw_surface1_Unlock(&surface->IDirectDrawSurface_iface, NULL); } -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface2_Unlock(IDirectDrawSurface2 *iface, void *data) +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface3_Unlock(IDirectDrawSurface3 *iface, void *data) { - struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface); + struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface); TRACE("iface %p, data %p.\n", iface, data); - /* data might not be the LPRECT of later versions, so drop it. */ - return ddraw_surface7_Unlock(&surface->IDirectDrawSurface7_iface, NULL); + return ddraw_surface1_Unlock(&surface->IDirectDrawSurface_iface, data); } -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_Unlock(IDirectDrawSurface *iface, void *data) +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface2_Unlock(IDirectDrawSurface2 *iface, void *data) { - struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface); + struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface); TRACE("iface %p, data %p.\n", iface, data); - /* data might not be the LPRECT of later versions, so drop it. */ - return ddraw_surface7_Unlock(&surface->IDirectDrawSurface7_iface, NULL); + return ddraw_surface1_Unlock(&surface->IDirectDrawSurface_iface, data); } static unsigned int ddraw_swap_interval_from_flags(DWORD flags)
1
0
0
0
Stefan Dösinger : ddraw: Thunk to surface1, not surface7 in blt.
by Alexandre Julliard
11 Aug '20
11 Aug '20
Module: wine Branch: master Commit: 3b2aab9a8c9dfbf44d08dc55e7ce6c1758a1d341 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=3b2aab9a8c9dfbf44d08dc55…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Tue Aug 11 14:50:42 2020 +0300 ddraw: Thunk to surface1, not surface7 in blt. Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ddraw/surface.c | 68 +++++++++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index a5f032eabf..22bebffce6 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -1635,27 +1635,13 @@ static HRESULT ddraw_surface_blt_clipped(struct ddraw_surface *dst_surface, cons return hr; } -/***************************************************************************** - * IDirectDrawSurface7::Blt - * - * Performs a blit on the surface - * - * Params: - * DestRect: Destination rectangle, can be NULL - * SrcSurface: Source surface, can be NULL - * SrcRect: Source rectangle, can be NULL - * Flags: Blt flags - * DDBltFx: Some extended blt parameters, connected to the flags - * - * Returns: - * D3D_OK on success, error code otherwise. - * - *****************************************************************************/ -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Blt(IDirectDrawSurface7 *iface, RECT *dst_rect, - IDirectDrawSurface7 *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx) +/* FRAPS hooks IDirectDrawSurface::Blt and expects the version 1 method to be called when the + * game uses later interfaces. */ +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_Blt(IDirectDrawSurface *iface, RECT *dst_rect, + IDirectDrawSurface *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx) { - struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface7(iface); - struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface7(src_surface); + struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface(iface); + struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface(src_surface); struct wined3d_blt_fx wined3d_fx; DWORD unsupported_flags; DWORD fill_colour = 0; @@ -1834,6 +1820,19 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Blt(IDirectDrawSurface7 * } } +static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Blt(IDirectDrawSurface7 *iface, RECT *dst_rect, + IDirectDrawSurface7 *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx) +{ + struct ddraw_surface *dst = impl_from_IDirectDrawSurface7(iface); + struct ddraw_surface *src = unsafe_impl_from_IDirectDrawSurface7(src_surface); + + TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n", + iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx); + + return ddraw_surface1_Blt(&dst->IDirectDrawSurface_iface, dst_rect, + src ? &src->IDirectDrawSurface_iface : NULL, src_rect, flags, fx); +} + static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface4_Blt(IDirectDrawSurface4 *iface, RECT *dst_rect, IDirectDrawSurface4 *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx) { @@ -1843,47 +1842,34 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface4_Blt(IDirectDrawSurface4 * TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n", iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx); - return ddraw_surface7_Blt(&dst->IDirectDrawSurface7_iface, dst_rect, - src ? &src->IDirectDrawSurface7_iface : NULL, src_rect, flags, fx); + return ddraw_surface1_Blt(&dst->IDirectDrawSurface_iface, dst_rect, + src ? &src->IDirectDrawSurface_iface : NULL, src_rect, flags, fx); } static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface3_Blt(IDirectDrawSurface3 *iface, RECT *dst_rect, IDirectDrawSurface3 *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx) { struct ddraw_surface *dst = impl_from_IDirectDrawSurface3(iface); - struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface3(src_surface); + struct ddraw_surface *src = unsafe_impl_from_IDirectDrawSurface3(src_surface); TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n", iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx); - return ddraw_surface7_Blt(&dst->IDirectDrawSurface7_iface, dst_rect, - src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags, fx); + return ddraw_surface1_Blt(&dst->IDirectDrawSurface_iface, dst_rect, + src ? &src->IDirectDrawSurface_iface : NULL, src_rect, flags, fx); } static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface2_Blt(IDirectDrawSurface2 *iface, RECT *dst_rect, IDirectDrawSurface2 *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx) { struct ddraw_surface *dst = impl_from_IDirectDrawSurface2(iface); - struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface2(src_surface); - - TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n", - iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx); - - return ddraw_surface7_Blt(&dst->IDirectDrawSurface7_iface, dst_rect, - src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags, fx); -} - -static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_Blt(IDirectDrawSurface *iface, RECT *dst_rect, - IDirectDrawSurface *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx) -{ - struct ddraw_surface *dst = impl_from_IDirectDrawSurface(iface); - struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface(src_surface); + struct ddraw_surface *src = unsafe_impl_from_IDirectDrawSurface2(src_surface); TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n", iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx); - return ddraw_surface7_Blt(&dst->IDirectDrawSurface7_iface, dst_rect, - src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags, fx); + return ddraw_surface1_Blt(&dst->IDirectDrawSurface_iface, dst_rect, + src ? &src->IDirectDrawSurface_iface : NULL, src_rect, flags, fx); } /*****************************************************************************
1
0
0
0
Dmitry Timoshkov : ole32: Allow SetSize to move a fixed memory block.
by Alexandre Julliard
11 Aug '20
11 Aug '20
Module: wine Branch: master Commit: 6faa530e1286e40b0749adbae9ab538020bc9d8f URL:
https://source.winehq.org/git/wine.git/?a=commit;h=6faa530e1286e40b0749adba…
Author: Dmitry Timoshkov <dmitry(a)baikal.ru> Date: Tue Aug 11 12:49:53 2020 +0100 ole32: Allow SetSize to move a fixed memory block. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ole32/hglobalstream.c | 2 +- dlls/ole32/tests/hglobalstream.c | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c index ee345f6293..4590bb9c43 100644 --- a/dlls/ole32/hglobalstream.c +++ b/dlls/ole32/hglobalstream.c @@ -426,7 +426,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_SetSize( /* * Re allocate the HGlobal to fit the new size of the stream. */ - supportHandle = GlobalReAlloc(This->handle->hglobal, libNewSize.u.LowPart, 0); + supportHandle = GlobalReAlloc(This->handle->hglobal, libNewSize.u.LowPart, GMEM_MOVEABLE); if (supportHandle == 0) return E_OUTOFMEMORY; diff --git a/dlls/ole32/tests/hglobalstream.c b/dlls/ole32/tests/hglobalstream.c index 87c502dc2f..2f386914af 100644 --- a/dlls/ole32/tests/hglobalstream.c +++ b/dlls/ole32/tests/hglobalstream.c @@ -625,20 +625,16 @@ static void test_IStream_Clone(void) newsize.QuadPart = 0x8000; hr = IStream_SetSize(stream, newsize); -todo_wine ok(hr == S_OK, "unexpected %#x\n", hr); stream_info(stream, &hmem, &size, &pos); ok(hmem != 0, "unexpected %p\n", hmem); -todo_wine ok(hmem != orig_hmem, "unexpected %p\n", hmem); -todo_wine ok(size == 0x8000, "unexpected %#x\n", size); ok(pos == 0, "unexpected %d\n", pos); stream_info(clone, &hmem_clone, &size, &pos); ok(hmem_clone == hmem, "handles should match\n"); -todo_wine ok(size == 0x8000, "unexpected %#x\n", size); ok(pos == 0, "unexpected %d\n", pos);
1
0
0
0
Huw Davies : ole32: Allow Clone to access the original memory block.
by Alexandre Julliard
11 Aug '20
11 Aug '20
Module: wine Branch: master Commit: 63dd8743352bdf7f1ae4f6244770a45581806126 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=63dd8743352bdf7f1ae4f624…
Author: Huw Davies <huw(a)codeweavers.com> Date: Tue Aug 11 12:49:52 2020 +0100 ole32: Allow Clone to access the original memory block. Based on a patch by Dmitry Timoshkov. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ole32/hglobalstream.c | 21 ++++++++++++++++----- dlls/ole32/tests/hglobalstream.c | 12 ------------ 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c index e715cd8950..ee345f6293 100644 --- a/dlls/ole32/hglobalstream.c +++ b/dlls/ole32/hglobalstream.c @@ -51,6 +51,11 @@ struct handle_wrapper BOOL delete_on_release; }; +static void handle_addref(struct handle_wrapper *handle) +{ + InterlockedIncrement(&handle->ref); +} + static void handle_release(struct handle_wrapper *handle) { ULONG ref = InterlockedDecrement(&handle->ref); @@ -586,15 +591,21 @@ static HRESULT WINAPI HGLOBALStreamImpl_Clone( IStream* iface, IStream** ppstm) /* [out] */ { - HGLOBALStreamImpl* This = impl_from_IStream(iface); + HGLOBALStreamImpl* This = impl_from_IStream(iface), *clone; ULARGE_INTEGER dummy; LARGE_INTEGER offset; - HRESULT hr; TRACE(" Cloning %p (deleteOnRelease=%d seek position=%ld)\n",iface,This->handle->delete_on_release,(long)This->currentPosition.QuadPart); - hr = CreateStreamOnHGlobal(This->handle->hglobal, FALSE, ppstm); - if(FAILED(hr)) - return hr; + + *ppstm = NULL; + + clone = hglobalstream_construct(); + if (!clone) return E_OUTOFMEMORY; + + *ppstm = &clone->IStream_iface; + handle_addref(This->handle); + clone->handle = This->handle; + offset.QuadPart = (LONGLONG)This->currentPosition.QuadPart; IStream_Seek(*ppstm, offset, STREAM_SEEK_SET, &dummy); return S_OK; diff --git a/dlls/ole32/tests/hglobalstream.c b/dlls/ole32/tests/hglobalstream.c index 1825fa9c1e..87c502dc2f 100644 --- a/dlls/ole32/tests/hglobalstream.c +++ b/dlls/ole32/tests/hglobalstream.c @@ -579,14 +579,12 @@ static void test_IStream_Clone(void) stream_info(clone, &hmem_clone, &size, &pos); ok(hmem_clone == hmem, "handles should match\n"); -todo_wine ok(size == 13, "unexpected %d\n", size); ok(pos == 0, "unexpected %d\n", pos); buf[0] = 0; hr = IStream_Read(clone, buf, sizeof(buf), NULL); ok(hr == S_OK, "unexpected %#x\n", hr); -todo_wine ok(!strcmp(buf, hello), "wrong stream contents\n"); newsize.QuadPart = 0x8000; @@ -600,9 +598,7 @@ todo_wine stream_info(clone, &hmem_clone, &size, &pos); ok(hmem_clone == hmem, "handles should match\n"); -todo_wine ok(size == 0x8000, "unexpected %#x\n", size); -todo_wine ok(pos == 13, "unexpected %d\n", pos); IStream_Release(clone); @@ -671,24 +667,19 @@ todo_wine newsize.QuadPart = 0x8000; hr = IStream_SetSize(clone, newsize); -todo_wine ok(hr == S_OK, "unexpected %#x\n", hr); stream_info(clone, &hmem_clone, &size, &pos); ok(hmem_clone == hmem, "handles should match\n"); -todo_wine ok(size == 0x8000, "unexpected %#x\n", size); ok(pos == 0, "unexpected %d\n", pos); hr = IStream_Write(clone, hello, sizeof(hello), NULL); -todo_wine ok(hr == S_OK, "unexpected %#x\n", hr); stream_info(clone, &hmem_clone, &size, &pos); ok(hmem_clone == hmem, "handles should match\n"); -todo_wine ok(size == 0x8000, "unexpected %#x\n", size); -todo_wine ok(pos == 13, "unexpected %d\n", pos); offset.QuadPart = 0; @@ -698,14 +689,11 @@ todo_wine buf[0] = 0; hr = IStream_Read(clone, buf, sizeof(buf), NULL); ok(hr == S_OK, "unexpected %#x\n", hr); -todo_wine ok(!strcmp(buf, hello), "wrong stream contents\n"); stream_info(clone, &hmem_clone, &size, &pos); ok(hmem_clone == hmem, "handles should match\n"); -todo_wine ok(size == 0x8000, "unexpected %#x\n", size); -todo_wine ok(pos == 32, "unexpected %d\n", pos); ret = IStream_Release(clone);
1
0
0
0
Huw Davies : ole32: Add a constructor helper.
by Alexandre Julliard
11 Aug '20
11 Aug '20
Module: wine Branch: master Commit: f946aa5b7f185faaff163dd9ceddd0e97fbf5070 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f946aa5b7f185faaff163dd9…
Author: Huw Davies <huw(a)codeweavers.com> Date: Tue Aug 11 12:49:51 2020 +0100 ole32: Add a constructor helper. Based on a patch by Dmitry Timoshkov. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ole32/hglobalstream.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c index 8fd1e03913..e715cd8950 100644 --- a/dlls/ole32/hglobalstream.c +++ b/dlls/ole32/hglobalstream.c @@ -106,6 +106,22 @@ static inline HGLOBALStreamImpl *impl_from_IStream(IStream *iface) return CONTAINING_RECORD(iface, HGLOBALStreamImpl, IStream_iface); } +static const IStreamVtbl HGLOBALStreamImplVtbl; + +static HGLOBALStreamImpl *hglobalstream_construct(void) +{ + HGLOBALStreamImpl *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); + + if (This) + { + This->IStream_iface.lpVtbl = &HGLOBALStreamImplVtbl; + This->ref = 1; + This->handle = NULL; + This->currentPosition.QuadPart = 0; + } + return This; +} + static HRESULT WINAPI HGLOBALStreamImpl_QueryInterface( IStream* iface, REFIID riid, /* [in] */ @@ -615,12 +631,9 @@ HRESULT WINAPI CreateStreamOnHGlobal( if (!ppstm) return E_INVALIDARG; - This = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALStreamImpl)); + This = hglobalstream_construct(); if (!This) return E_OUTOFMEMORY; - This->IStream_iface.lpVtbl = &HGLOBALStreamImplVtbl; - This->ref = 1; - This->handle = handle_create(hGlobal, fDeleteOnRelease); if (!This->handle) { @@ -628,10 +641,6 @@ HRESULT WINAPI CreateStreamOnHGlobal( return E_OUTOFMEMORY; } - /* start at the beginning */ - This->currentPosition.u.HighPart = 0; - This->currentPosition.u.LowPart = 0; - *ppstm = &This->IStream_iface; return S_OK;
1
0
0
0
Huw Davies : ole32: Add a ref-count to the handle structure.
by Alexandre Julliard
11 Aug '20
11 Aug '20
Module: wine Branch: master Commit: fe3421ba2c863993bb411b0bd4d5b6b2ed4b956e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=fe3421ba2c863993bb411b0b…
Author: Huw Davies <huw(a)codeweavers.com> Date: Tue Aug 11 12:49:50 2020 +0100 ole32: Add a ref-count to the handle structure. Based on a patch by Dmitry Timoshkov. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ole32/hglobalstream.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c index 300119dcc7..8fd1e03913 100644 --- a/dlls/ole32/hglobalstream.c +++ b/dlls/ole32/hglobalstream.c @@ -45,6 +45,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(storage); struct handle_wrapper { + LONG ref; HGLOBAL hglobal; ULONG size; BOOL delete_on_release; @@ -52,8 +53,13 @@ struct handle_wrapper static void handle_release(struct handle_wrapper *handle) { + ULONG ref = InterlockedDecrement(&handle->ref); + + if (!ref) + { if (handle->delete_on_release) GlobalFree(handle->hglobal); HeapFree(GetProcessHeap(), 0, handle); + } } static struct handle_wrapper *handle_create(HGLOBAL hglobal, BOOL delete_on_release) @@ -70,6 +76,7 @@ static struct handle_wrapper *handle_create(HGLOBAL hglobal, BOOL delete_on_rele HeapFree(GetProcessHeap(), 0, handle); return NULL; } + handle->ref = 1; handle->hglobal = hglobal; handle->size = GlobalSize(hglobal); handle->delete_on_release = delete_on_release;
1
0
0
0
Huw Davies : ole32: Add a structure to hold memory block information.
by Alexandre Julliard
11 Aug '20
11 Aug '20
Module: wine Branch: master Commit: 54b6cbc287025a6c7745830b983eb067f4a64427 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=54b6cbc287025a6c7745830b…
Author: Huw Davies <huw(a)codeweavers.com> Date: Tue Aug 11 12:49:49 2020 +0100 ole32: Add a structure to hold memory block information. Based on a patch by Dmitry Timoshkov which was based on a suggestion by Sebastian Lackner. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ole32/hglobalstream.c | 102 ++++++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 42 deletions(-) diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c index 6133690d9d..300119dcc7 100644 --- a/dlls/ole32/hglobalstream.c +++ b/dlls/ole32/hglobalstream.c @@ -5,6 +5,7 @@ * for streams contained supported by an HGLOBAL pointer. * * Copyright 1999 Francis Beaudet + * Copyright 2016 Dmitry Timoshkov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -42,6 +43,40 @@ WINE_DEFAULT_DEBUG_CHANNEL(storage); +struct handle_wrapper +{ + HGLOBAL hglobal; + ULONG size; + BOOL delete_on_release; +}; + +static void handle_release(struct handle_wrapper *handle) +{ + if (handle->delete_on_release) GlobalFree(handle->hglobal); + HeapFree(GetProcessHeap(), 0, handle); +} + +static struct handle_wrapper *handle_create(HGLOBAL hglobal, BOOL delete_on_release) +{ + struct handle_wrapper *handle; + + handle = HeapAlloc(GetProcessHeap(), 0, sizeof(*handle)); + if (!handle) return NULL; + + /* allocate a handle if one is not supplied */ + if (!hglobal) hglobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD | GMEM_SHARE, 0); + if (!hglobal) + { + HeapFree(GetProcessHeap(), 0, handle); + return NULL; + } + handle->hglobal = hglobal; + handle->size = GlobalSize(hglobal); + handle->delete_on_release = delete_on_release; + + return handle; +} + /**************************************************************************** * HGLOBALStreamImpl definition. * @@ -53,14 +88,7 @@ typedef struct IStream IStream_iface; LONG ref; - /* support for the stream */ - HGLOBAL supportHandle; - - /* if TRUE the HGLOBAL is destroyed when the stream is finally released */ - BOOL deleteOnRelease; - - /* size of the stream */ - ULARGE_INTEGER streamSize; + struct handle_wrapper *handle; /* current position of the cursor */ ULARGE_INTEGER currentPosition; @@ -112,12 +140,7 @@ static ULONG WINAPI HGLOBALStreamImpl_Release( if (!ref) { - if (This->deleteOnRelease) - { - GlobalFree(This->supportHandle); - This->supportHandle = NULL; - } - + handle_release(This->handle); HeapFree(GetProcessHeap(), 0, This); } @@ -159,15 +182,15 @@ static HRESULT WINAPI HGLOBALStreamImpl_Read( * Using the known size of the stream, calculate the number of bytes * to read from the block chain */ - bytesToReadFromBuffer = min( This->streamSize.u.LowPart - This->currentPosition.u.LowPart, cb); + bytesToReadFromBuffer = min( This->handle->size - This->currentPosition.u.LowPart, cb); /* * Lock the buffer in position and copy the data. */ - supportBuffer = GlobalLock(This->supportHandle); + supportBuffer = GlobalLock(This->handle->hglobal); if (!supportBuffer) { - WARN("read from invalid hglobal %p\n", This->supportHandle); + WARN("read from invalid hglobal %p\n", This->handle->hglobal); *pcbRead = 0; return S_OK; } @@ -187,7 +210,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_Read( /* * Cleanup */ - GlobalUnlock(This->supportHandle); + GlobalUnlock(This->handle->hglobal); /* * Always returns S_OK even if the end of the stream is reached before the @@ -239,7 +262,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_Write( /* * Verify if we need to grow the stream */ - if (newSize.u.LowPart > This->streamSize.u.LowPart) + if (newSize.u.LowPart > This->handle->size) { /* grow stream */ HRESULT hr = IStream_SetSize(iface, newSize); @@ -253,10 +276,10 @@ static HRESULT WINAPI HGLOBALStreamImpl_Write( /* * Lock the buffer in position and copy the data. */ - supportBuffer = GlobalLock(This->supportHandle); + supportBuffer = GlobalLock(This->handle->hglobal); if (!supportBuffer) { - WARN("write to invalid hglobal %p\n", This->supportHandle); + WARN("write to invalid hglobal %p\n", This->handle->hglobal); return S_OK; } @@ -270,7 +293,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_Write( /* * Cleanup */ - GlobalUnlock(This->supportHandle); + GlobalUnlock(This->handle->hglobal); out: /* @@ -316,7 +339,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_Seek( case STREAM_SEEK_CUR: break; case STREAM_SEEK_END: - newPosition = This->streamSize; + newPosition.QuadPart = This->handle->size; break; default: hr = STG_E_SEEKERROR; @@ -369,19 +392,19 @@ static HRESULT WINAPI HGLOBALStreamImpl_SetSize( * HighPart is ignored as shown in tests */ - if (This->streamSize.u.LowPart == libNewSize.u.LowPart) + if (This->handle->size == libNewSize.u.LowPart) return S_OK; /* * Re allocate the HGlobal to fit the new size of the stream. */ - supportHandle = GlobalReAlloc(This->supportHandle, libNewSize.u.LowPart, 0); + supportHandle = GlobalReAlloc(This->handle->hglobal, libNewSize.u.LowPart, 0); if (supportHandle == 0) return E_OUTOFMEMORY; - This->supportHandle = supportHandle; - This->streamSize.u.LowPart = libNewSize.u.LowPart; + This->handle->hglobal = supportHandle; + This->handle->size = libNewSize.u.LowPart; return S_OK; } @@ -531,7 +554,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_Stat( pstatstg->pwcsName = NULL; pstatstg->type = STGTY_STREAM; - pstatstg->cbSize = This->streamSize; + pstatstg->cbSize.QuadPart = This->handle->size; return S_OK; } @@ -545,8 +568,8 @@ static HRESULT WINAPI HGLOBALStreamImpl_Clone( LARGE_INTEGER offset; HRESULT hr; - TRACE(" Cloning %p (deleteOnRelease=%d seek position=%ld)\n",iface,This->deleteOnRelease,(long)This->currentPosition.QuadPart); - hr = CreateStreamOnHGlobal(This->supportHandle, FALSE, ppstm); + TRACE(" Cloning %p (deleteOnRelease=%d seek position=%ld)\n",iface,This->handle->delete_on_release,(long)This->currentPosition.QuadPart); + hr = CreateStreamOnHGlobal(This->handle->hglobal, FALSE, ppstm); if(FAILED(hr)) return hr; offset.QuadPart = (LONGLONG)This->currentPosition.QuadPart; @@ -591,22 +614,17 @@ HRESULT WINAPI CreateStreamOnHGlobal( This->IStream_iface.lpVtbl = &HGLOBALStreamImplVtbl; This->ref = 1; - /* initialize the support */ - This->supportHandle = hGlobal; - This->deleteOnRelease = fDeleteOnRelease; - - /* allocate a handle if one is not supplied */ - if (!This->supportHandle) - This->supportHandle = GlobalAlloc(GMEM_MOVEABLE|GMEM_NODISCARD|GMEM_SHARE, 0); + This->handle = handle_create(hGlobal, fDeleteOnRelease); + if (!This->handle) + { + HeapFree(GetProcessHeap(), 0, This); + return E_OUTOFMEMORY; + } /* start at the beginning */ This->currentPosition.u.HighPart = 0; This->currentPosition.u.LowPart = 0; - /* initialize the size of the stream to the size of the handle */ - This->streamSize.u.HighPart = 0; - This->streamSize.u.LowPart = GlobalSize(This->supportHandle); - *ppstm = &This->IStream_iface; return S_OK; @@ -628,7 +646,7 @@ HRESULT WINAPI GetHGlobalFromStream(IStream* pstm, HGLOBAL* phglobal) * Verify that the stream object was created with CreateStreamOnHGlobal. */ if (pStream->IStream_iface.lpVtbl == &HGLOBALStreamImplVtbl) - *phglobal = pStream->supportHandle; + *phglobal = pStream->handle->hglobal; else { *phglobal = 0;
1
0
0
0
Dmitry Timoshkov : ole32/tests: Add tests for HGLOBAL based IStream::Clone.
by Alexandre Julliard
11 Aug '20
11 Aug '20
Module: wine Branch: master Commit: 3f4f6fca3ce6484c4918be9db57047176a8388e7 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=3f4f6fca3ce6484c4918be9d…
Author: Dmitry Timoshkov <dmitry(a)baikal.ru> Date: Tue Aug 11 12:49:48 2020 +0100 ole32/tests: Add tests for HGLOBAL based IStream::Clone. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ole32/tests/hglobalstream.c | 199 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) diff --git a/dlls/ole32/tests/hglobalstream.c b/dlls/ole32/tests/hglobalstream.c index 6a0498aa60..1825fa9c1e 100644 --- a/dlls/ole32/tests/hglobalstream.c +++ b/dlls/ole32/tests/hglobalstream.c @@ -2,6 +2,7 @@ * Stream on HGLOBAL Tests * * Copyright 2006 Robert Shearman (for CodeWeavers) + * Copyright 2016 Dmitry Timoshkov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -514,9 +515,207 @@ static void test_freed_hglobal(void) IStream_Release(pStream); } +static void stream_info(IStream *stream, HGLOBAL *hmem, int *size, int *pos) +{ + HRESULT hr; + STATSTG stat; + LARGE_INTEGER offset; + ULARGE_INTEGER newpos; + + *hmem = 0; + *size = *pos = -1; + + hr = GetHGlobalFromStream(stream, hmem); + ok(hr == S_OK, "unexpected %#x\n", hr); + + memset(&stat, 0x55, sizeof(stat)); + hr = IStream_Stat(stream, &stat, STATFLAG_DEFAULT); + ok(hr == S_OK, "unexpected %#x\n", hr); + ok(stat.type == STGTY_STREAM, "unexpected %#x\n", stat.type); + ok(!stat.pwcsName, "unexpected %p\n", stat.pwcsName); + ok(IsEqualIID(&stat.clsid, &GUID_NULL), "unexpected %s\n", wine_dbgstr_guid(&stat.clsid)); + ok(!stat.cbSize.HighPart, "unexpected %#x\n", stat.cbSize.HighPart); + *size = stat.cbSize.LowPart; + + offset.QuadPart = 0; + hr = IStream_Seek(stream, offset, STREAM_SEEK_CUR, &newpos); + ok(hr == S_OK, "unexpected %#x\n", hr); + ok(!newpos.HighPart, "unexpected %#x\n", newpos.HighPart); + *pos = newpos.LowPart; +} + +static void test_IStream_Clone(void) +{ + static const char hello[] = "Hello World!"; + char buf[32]; + HRESULT hr; + IStream *stream, *clone; + HGLOBAL orig_hmem, hmem, hmem_clone; + ULARGE_INTEGER newsize; + LARGE_INTEGER offset; + int size, pos, ret; + + /* test simple case for Clone */ + orig_hmem = GlobalAlloc(GMEM_MOVEABLE, 0); + ok(orig_hmem != 0, "unexpected %p\n", orig_hmem); + hr = CreateStreamOnHGlobal(orig_hmem, TRUE, &stream); + ok(hr == S_OK, "unexpected %#x\n", hr); + + stream_info(stream, &hmem, &size, &pos); + ok(hmem == orig_hmem, "handles should match\n"); + ok(size == 0, "unexpected %d\n", size); + ok(pos == 0, "unexpected %d\n", pos); + + hr = IStream_Clone(stream, &clone); + ok(hr == S_OK, "unexpected %#x\n", hr); + + hr = IStream_Write(stream, hello, sizeof(hello), NULL); + ok(hr == S_OK, "unexpected %#x\n", hr); + + stream_info(stream, &hmem, &size, &pos); + ok(hmem == orig_hmem, "handles should match\n"); + ok(size == 13, "unexpected %d\n", size); + ok(pos == 13, "unexpected %d\n", pos); + + stream_info(clone, &hmem_clone, &size, &pos); + ok(hmem_clone == hmem, "handles should match\n"); +todo_wine + ok(size == 13, "unexpected %d\n", size); + ok(pos == 0, "unexpected %d\n", pos); + + buf[0] = 0; + hr = IStream_Read(clone, buf, sizeof(buf), NULL); + ok(hr == S_OK, "unexpected %#x\n", hr); +todo_wine + ok(!strcmp(buf, hello), "wrong stream contents\n"); + + newsize.QuadPart = 0x8000; + hr = IStream_SetSize(stream, newsize); + ok(hr == S_OK, "unexpected %#x\n", hr); + + stream_info(stream, &hmem, &size, &pos); + ok(hmem == orig_hmem, "handles should match\n"); + ok(size == 0x8000, "unexpected %#x\n", size); + ok(pos == 13, "unexpected %d\n", pos); + + stream_info(clone, &hmem_clone, &size, &pos); + ok(hmem_clone == hmem, "handles should match\n"); +todo_wine + ok(size == 0x8000, "unexpected %#x\n", size); +todo_wine + ok(pos == 13, "unexpected %d\n", pos); + + IStream_Release(clone); + IStream_Release(stream); + + /* exploit GMEM_FIXED forced move for the same base streams */ + orig_hmem = GlobalAlloc(GMEM_FIXED, 1); + ok(orig_hmem != 0, "unexpected %p\n", orig_hmem); + hr = CreateStreamOnHGlobal(orig_hmem, TRUE, &stream); + ok(hr == S_OK, "unexpected %#x\n", hr); + + hr = IStream_Clone(stream, &clone); + ok(hr == S_OK, "unexpected %#x\n", hr); + + stream_info(stream, &hmem, &size, &pos); + ok(hmem == orig_hmem, "handles should match\n"); + ok(size == 1, "unexpected %d\n", size); + ok(pos == 0, "unexpected %d\n", pos); + + stream_info(clone, &hmem_clone, &size, &pos); + ok(hmem_clone == hmem, "handles should match\n"); + ok(size == 1, "unexpected %d\n", size); + ok(pos == 0, "unexpected %d\n", pos); + + newsize.QuadPart = 0x8000; + hr = IStream_SetSize(stream, newsize); +todo_wine + ok(hr == S_OK, "unexpected %#x\n", hr); + + stream_info(stream, &hmem, &size, &pos); + ok(hmem != 0, "unexpected %p\n", hmem); +todo_wine + ok(hmem != orig_hmem, "unexpected %p\n", hmem); +todo_wine + ok(size == 0x8000, "unexpected %#x\n", size); + ok(pos == 0, "unexpected %d\n", pos); + + stream_info(clone, &hmem_clone, &size, &pos); + ok(hmem_clone == hmem, "handles should match\n"); +todo_wine + ok(size == 0x8000, "unexpected %#x\n", size); + ok(pos == 0, "unexpected %d\n", pos); + + IStream_Release(stream); + IStream_Release(clone); + + /* test Release of cloned stream */ + hr = CreateStreamOnHGlobal(0, TRUE, &stream); + ok(hr == S_OK, "unexpected %#x\n", hr); + + hr = IStream_Clone(stream, &clone); + ok(hr == S_OK, "unexpected %#x\n", hr); + + stream_info(stream, &hmem, &size, &pos); + ok(hmem != 0, "unexpected %p\n", hmem); + ok(size == 0, "unexpected %d\n", size); + ok(pos == 0, "unexpected %d\n", pos); + + stream_info(clone, &hmem_clone, &size, &pos); + ok(hmem_clone == hmem, "handles should match\n"); + ok(size == 0, "unexpected %#x\n", size); + ok(pos == 0, "unexpected %d\n", pos); + + ret = IStream_Release(stream); + ok(ret == 0, "unexpected %d\n", ret); + + newsize.QuadPart = 0x8000; + hr = IStream_SetSize(clone, newsize); +todo_wine + ok(hr == S_OK, "unexpected %#x\n", hr); + + stream_info(clone, &hmem_clone, &size, &pos); + ok(hmem_clone == hmem, "handles should match\n"); +todo_wine + ok(size == 0x8000, "unexpected %#x\n", size); + ok(pos == 0, "unexpected %d\n", pos); + + hr = IStream_Write(clone, hello, sizeof(hello), NULL); +todo_wine + ok(hr == S_OK, "unexpected %#x\n", hr); + + stream_info(clone, &hmem_clone, &size, &pos); + ok(hmem_clone == hmem, "handles should match\n"); +todo_wine + ok(size == 0x8000, "unexpected %#x\n", size); +todo_wine + ok(pos == 13, "unexpected %d\n", pos); + + offset.QuadPart = 0; + hr = IStream_Seek(clone, offset, STREAM_SEEK_SET, NULL); + ok(hr == S_OK, "unexpected %#x\n", hr); + + buf[0] = 0; + hr = IStream_Read(clone, buf, sizeof(buf), NULL); + ok(hr == S_OK, "unexpected %#x\n", hr); +todo_wine + ok(!strcmp(buf, hello), "wrong stream contents\n"); + + stream_info(clone, &hmem_clone, &size, &pos); + ok(hmem_clone == hmem, "handles should match\n"); +todo_wine + ok(size == 0x8000, "unexpected %#x\n", size); +todo_wine + ok(pos == 32, "unexpected %d\n", pos); + + ret = IStream_Release(clone); + ok(ret == 0, "unexpected %d\n", ret); +} + START_TEST(hglobalstream) { test_streamonhglobal(); test_copyto(); test_freed_hglobal(); + test_IStream_Clone(); }
1
0
0
0
← Newer
1
...
36
37
38
39
40
41
42
...
70
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
Results per page:
10
25
50
100
200