winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
May 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
770 discussions
Start a n
N
ew thread
Rémi Bernon : user32: Add a default ActivateKeyboardLayout implementation.
by Alexandre Julliard
03 May '21
03 May '21
Module: wine Branch: master Commit: 66a46120a0fda1c5d5d046683497d06404203514 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=66a46120a0fda1c5d5d04668…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Mon May 3 11:37:56 2021 +0200 user32: Add a default ActivateKeyboardLayout implementation. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/driver.c | 2 +- dlls/user32/input.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c index c075a49a350..f683cf25b7e 100644 --- a/dlls/user32/driver.c +++ b/dlls/user32/driver.c @@ -189,7 +189,7 @@ void USER_unload_driver(void) static HKL CDECL nulldrv_ActivateKeyboardLayout( HKL layout, UINT flags ) { - return 0; + return (HKL)~0; /* use default implementation */ } static void CDECL nulldrv_Beep(void) diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 97be83369d9..ff90bc6f343 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -1310,11 +1310,16 @@ INT WINAPI ToAsciiEx( UINT virtKey, UINT scanCode, const BYTE *lpKeyState, /********************************************************************** * ActivateKeyboardLayout (USER32.@) */ -HKL WINAPI ActivateKeyboardLayout(HKL hLayout, UINT flags) +HKL WINAPI ActivateKeyboardLayout( HKL layout, UINT flags ) { - TRACE_(keyboard)("(%p, %d)\n", hLayout, flags); + HKL old_layout; - return USER_Driver->pActivateKeyboardLayout(hLayout, flags); + TRACE_(keyboard)( "layout %p, flags %x\n", layout, flags ); + + if ((old_layout = USER_Driver->pActivateKeyboardLayout( layout, flags )) != (HKL)~0) + return old_layout; + + return get_locale_kbd_layout(); } /**********************************************************************
1
0
0
0
Zebediah Figura : d3d8/tests: Port test_sample_mask() from d3d9.
by Alexandre Julliard
03 May '21
03 May '21
Module: wine Branch: master Commit: 30fe080965409e68cc86a04af1935e4944f4b049 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=30fe080965409e68cc86a04a…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Fri Apr 30 11:08:26 2021 -0500 d3d8/tests: Port test_sample_mask() from d3d9. 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/d3d8/tests/visual.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index fc8a05a3c40..f25549388d0 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -11070,6 +11070,93 @@ static void test_desktop_window(void) IDirect3D8_Release(d3d); } +static void test_sample_mask(void) +{ + IDirect3DSurface8 *rt, *ms_rt; + struct surface_readback rb; + IDirect3DDevice8 *device; + IDirect3D8 *d3d; + ULONG refcount; + DWORD colour; + HWND window; + HRESULT hr; + + static const struct + { + struct vec3 position; + DWORD diffuse; + } + quad[] = + { + {{-1.0f, -1.0f, 0.1f}, 0xffffffff}, + {{-1.0f, 1.0f, 0.1f}, 0xffffffff}, + {{ 1.0f, -1.0f, 0.1f}, 0xffffffff}, + {{ 1.0f, 1.0f, 0.1f}, 0xffffffff}, + }; + + window = create_window(); + d3d = Direct3DCreate8(D3D_SDK_VERSION); + ok(!!d3d, "Failed to create a D3D object.\n"); + + if (FAILED(IDirect3D8_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, + D3DFMT_A8R8G8B8, TRUE, D3DMULTISAMPLE_2_SAMPLES))) + { + skip("Multisampling not supported for D3DFMT_A8R8G8B8.\n"); + IDirect3D8_Release(d3d); + DestroyWindow(window); + return; + } + + if (!(device = create_device(d3d, window, window, TRUE))) + { + skip("Failed to create a 3D device.\n"); + IDirect3D8_Release(d3d); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice8_CreateRenderTarget(device, 128, 128, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, FALSE, &rt); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice8_CreateRenderTarget(device, 128, 128, + D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, FALSE, &ms_rt); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice8_SetRenderTarget(device, ms_rt, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice8_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice8_SetRenderState(device, D3DRS_MULTISAMPLEMASK, 0x5); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0])); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice8_CopyRects(device, ms_rt, NULL, 0, rt, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + get_rt_readback(rt, &rb); + colour = get_readback_color(&rb, 64, 64); + ok(color_match(colour, 0xffff8080, 1), "Got unexpected colour %08x.\n", colour); + release_surface_readback(&rb); + + hr = IDirect3DDevice8_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + IDirect3DSurface8_Release(ms_rt); + IDirect3DSurface8_Release(rt); + refcount = IDirect3DDevice8_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + IDirect3D8_Release(d3d); + DestroyWindow(window); +} + START_TEST(visual) { D3DADAPTER_IDENTIFIER8 identifier; @@ -11147,4 +11234,5 @@ START_TEST(visual) test_sysmem_draw(); test_alphatest(); test_desktop_window(); + test_sample_mask(); }
1
0
0
0
Zebediah Figura : ws2_32: Move service lookup functions to protocol.c.
by Alexandre Julliard
03 May '21
03 May '21
Module: wine Branch: master Commit: cfdaa7fdaf8f102d5eb9482ef0d18be615fe2684 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=cfdaa7fdaf8f102d5eb9482e…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Fri Apr 30 19:10:02 2021 -0500 ws2_32: Move service lookup functions to protocol.c. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ws2_32/protocol.c | 121 +++++++++++++++++++++++++++++++++++++ dlls/ws2_32/socket.c | 160 ------------------------------------------------- 2 files changed, 121 insertions(+), 160 deletions(-) diff --git a/dlls/ws2_32/protocol.c b/dlls/ws2_32/protocol.c index ad840aaeb6f..2cb6ef4be1c 100644 --- a/dlls/ws2_32/protocol.c +++ b/dlls/ws2_32/protocol.c @@ -1532,3 +1532,124 @@ struct WS_protoent * WINAPI WS_getprotobynumber( int number ) TRACE( "%d ret %p\n", number, retval ); return retval; } + + +static char *strdup_lower( const char *str ) +{ + char *ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 ); + int i; + + if (ret) + { + for (i = 0; str[i]; i++) ret[i] = tolower( str[i] ); + ret[i] = 0; + } + else SetLastError( WSAENOBUFS ); + return ret; +} + +static struct WS_servent *get_servent_buffer( int size ) +{ + struct per_thread_data *data = get_per_thread_data(); + if (data->se_buffer) + { + if (data->se_len >= size) return data->se_buffer; + HeapFree( GetProcessHeap(), 0, data->se_buffer ); + } + data->se_len = size; + data->se_buffer = HeapAlloc( GetProcessHeap(), 0, size ); + if (!data->se_buffer) SetLastError( WSAENOBUFS ); + return data->se_buffer; +} + +static struct WS_servent *servent_from_unix( const struct servent *p_se ) +{ + char *p; + struct WS_servent *p_to; + + int size = (sizeof(*p_se) + + strlen(p_se->s_proto) + 1 + + strlen(p_se->s_name) + 1 + + list_size(p_se->s_aliases, 0)); + + if (!(p_to = get_servent_buffer( size ))) return NULL; + p_to->s_port = p_se->s_port; + + p = (char *)(p_to + 1); + p_to->s_name = p; + strcpy( p, p_se->s_name ); + p += strlen(p) + 1; + + p_to->s_proto = p; + strcpy( p, p_se->s_proto ); + p += strlen(p) + 1; + + p_to->s_aliases = (char **)p; + list_dup( p_se->s_aliases, p_to->s_aliases, 0 ); + return p_to; +} + + +/*********************************************************************** + * getservbyname (ws2_32.55) + */ +struct WS_servent * WINAPI WS_getservbyname( const char *name, const char *proto ) +{ + struct WS_servent *retval = NULL; + struct servent *serv; + char *name_str; + char *proto_str = NULL; + + if (!(name_str = strdup_lower( name ))) return NULL; + + if (proto && *proto) + { + if (!(proto_str = strdup_lower( proto ))) + { + HeapFree( GetProcessHeap(), 0, name_str ); + return NULL; + } + } + + EnterCriticalSection( &csWSgetXXXbyYYY ); + serv = getservbyname( name_str, proto_str ); + if (serv) + retval = servent_from_unix( serv ); + else + SetLastError( WSANO_DATA ); + LeaveCriticalSection( &csWSgetXXXbyYYY ); + + HeapFree( GetProcessHeap(), 0, proto_str ); + HeapFree( GetProcessHeap(), 0, name_str ); + TRACE( "%s, %s ret %p\n", debugstr_a(name), debugstr_a(proto), retval ); + return retval; +} + + +/*********************************************************************** + * getservbyport (ws2_32.56) + */ +struct WS_servent * WINAPI WS_getservbyport( int port, const char *proto ) +{ + struct WS_servent *retval = NULL; +#ifdef HAVE_GETSERVBYPORT + struct servent *serv; + char *proto_str = NULL; + + if (proto && *proto) + { + if (!(proto_str = strdup_lower( proto ))) return NULL; + } + + EnterCriticalSection( &csWSgetXXXbyYYY ); + if ((serv = getservbyport( port, proto_str ))) + retval = servent_from_unix( serv ); + else + SetLastError( WSANO_DATA ); + LeaveCriticalSection( &csWSgetXXXbyYYY ); + + HeapFree( GetProcessHeap(), 0, proto_str ); +#endif + TRACE( "%d (i.e. port %d), %s ret %p\n", port, (int)ntohl(port), debugstr_a(proto), retval ); + return retval; +} diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index c3c73568c83..2776e2f0014 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -225,7 +225,6 @@ static int WS2_recv_base( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, LPWSABUF lpControlBuffer ); -DECLARE_CRITICAL_SECTION(csWSgetXXXbyYYY); DECLARE_CRITICAL_SECTION(cs_if_addr_cache); DECLARE_CRITICAL_SECTION(cs_socket_list); @@ -609,7 +608,6 @@ int num_startup; static FARPROC blocking_hook = (FARPROC)WSA_DefaultBlockingHook; /* function prototypes */ -static struct WS_servent *WS_dup_se(const struct servent* p_se); static int ws_protocol_info(SOCKET s, int unicode, WSAPROTOCOL_INFOW *buffer, int *size); int WSAIOCTL_GetInterfaceCount(void); @@ -1340,22 +1338,6 @@ static int convert_sockopt(INT *level, INT *optname) return 0; } -/* ----------------------------------- Per-thread info (or per-process?) */ - -static char *strdup_lower(const char *str) -{ - int i; - char *ret = HeapAlloc( GetProcessHeap(), 0, strlen(str) + 1 ); - - if (ret) - { - for (i = 0; str[i]; i++) ret[i] = tolower(str[i]); - ret[i] = 0; - } - else SetLastError(WSAENOBUFS); - return ret; -} - /* Utility: get the SO_RCVTIMEO or SO_SNDTIMEO socket option * from an fd and return the value converted to milli seconds * or 0 if there is an infinite time out */ @@ -1564,19 +1546,6 @@ void WINAPI WSASetLastError(INT iError) { SetLastError(iError); } -static struct WS_servent *check_buffer_se(int size) -{ - struct per_thread_data * ptb = get_per_thread_data(); - if (ptb->se_buffer) - { - if (ptb->se_len >= size ) return ptb->se_buffer; - HeapFree( GetProcessHeap(), 0, ptb->se_buffer ); - } - ptb->se_buffer = HeapAlloc( GetProcessHeap(), 0, (ptb->se_len = size) ); - if (!ptb->se_buffer) SetLastError(WSAENOBUFS); - return ptb->se_buffer; -} - static inline BOOL supported_pf(int pf) { switch (pf) @@ -5721,68 +5690,6 @@ SOCKET WINAPI WS_socket(int af, int type, int protocol) } -/*********************************************************************** - * getservbyname (WS2_32.55) - */ -struct WS_servent* WINAPI WS_getservbyname(const char *name, const char *proto) -{ - struct WS_servent* retval = NULL; - struct servent* serv; - char *name_str; - char *proto_str = NULL; - - if (!(name_str = strdup_lower(name))) return NULL; - - if (proto && *proto) - { - if (!(proto_str = strdup_lower(proto))) - { - HeapFree( GetProcessHeap(), 0, name_str ); - return NULL; - } - } - - EnterCriticalSection( &csWSgetXXXbyYYY ); - serv = getservbyname(name_str, proto_str); - if( serv != NULL ) - { - retval = WS_dup_se(serv); - } - else SetLastError(WSANO_DATA); - LeaveCriticalSection( &csWSgetXXXbyYYY ); - HeapFree( GetProcessHeap(), 0, proto_str ); - HeapFree( GetProcessHeap(), 0, name_str ); - TRACE( "%s, %s ret %p\n", debugstr_a(name), debugstr_a(proto), retval ); - return retval; -} - -/*********************************************************************** - * getservbyport (WS2_32.56) - */ -struct WS_servent* WINAPI WS_getservbyport(int port, const char *proto) -{ - struct WS_servent* retval = NULL; -#ifdef HAVE_GETSERVBYPORT - struct servent* serv; - char *proto_str = NULL; - - if (proto && *proto) - { - if (!(proto_str = strdup_lower(proto))) return NULL; - } - EnterCriticalSection( &csWSgetXXXbyYYY ); - if( (serv = getservbyport(port, proto_str)) != NULL ) { - retval = WS_dup_se(serv); - } - else SetLastError(WSANO_DATA); - LeaveCriticalSection( &csWSgetXXXbyYYY ); - HeapFree( GetProcessHeap(), 0, proto_str ); -#endif - TRACE("%d (i.e. port %d), %s ret %p\n", port, (int)ntohl(port), debugstr_a(proto), retval); - return retval; -} - - /*********************************************************************** * WSAEnumNetworkEvents (WS2_32.36) */ @@ -6187,73 +6094,6 @@ INT WINAPI WSAUnhookBlockingHook(void) } -/* ----------------------------------- end of API stuff */ - -/* ----------------------------------- helper functions - - * - * TODO: Merge WS_dup_..() stuff into one function that - * would operate with a generic structure containing internal - * pointers (via a template of some kind). - */ - -static int list_size(char** l, int item_size) -{ - int i,j = 0; - if(l) - { for(i=0;l[i];i++) - j += (item_size) ? item_size : strlen(l[i]) + 1; - j += (i + 1) * sizeof(char*); } - return j; -} - -static int list_dup(char** l_src, char** l_to, int item_size) -{ - char *p; - int i; - - for (i = 0; l_src[i]; i++) ; - p = (char *)(l_to + i + 1); - for (i = 0; l_src[i]; i++) - { - int count = ( item_size ) ? item_size : strlen(l_src[i]) + 1; - memcpy(p, l_src[i], count); - l_to[i] = p; - p += count; - } - l_to[i] = NULL; - return p - (char *)l_to; -} - -/* ----- servent */ - -static struct WS_servent *WS_dup_se(const struct servent* p_se) -{ - char *p; - struct WS_servent *p_to; - - int size = (sizeof(*p_se) + - strlen(p_se->s_proto) + 1 + - strlen(p_se->s_name) + 1 + - list_size(p_se->s_aliases, 0)); - - if (!(p_to = check_buffer_se(size))) return NULL; - p_to->s_port = p_se->s_port; - - p = (char *)(p_to + 1); - p_to->s_name = p; - strcpy(p, p_se->s_name); - p += strlen(p) + 1; - - p_to->s_proto = p; - strcpy(p, p_se->s_proto); - p += strlen(p) + 1; - - p_to->s_aliases = (char **)p; - list_dup(p_se->s_aliases, p_to->s_aliases, 0); - return p_to; -} - - /*********************************************************************** * WSARecv (WS2_32.67) */
1
0
0
0
Zebediah Figura : ws2_32: Move protocol lookup functions to protocol.c.
by Alexandre Julliard
03 May '21
03 May '21
Module: wine Branch: master Commit: 5d9fe0363728d729cfee31c62420fe5a7db0335e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=5d9fe0363728d729cfee31c6…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Fri Apr 30 19:10:01 2021 -0500 ws2_32: Move protocol lookup functions to protocol.c. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ws2_32/protocol.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++++ dlls/ws2_32/socket.c | 103 ----------------------------------- 2 files changed, 144 insertions(+), 103 deletions(-) diff --git a/dlls/ws2_32/protocol.c b/dlls/ws2_32/protocol.c index c2e661c03dc..ad840aaeb6f 100644 --- a/dlls/ws2_32/protocol.c +++ b/dlls/ws2_32/protocol.c @@ -1388,3 +1388,147 @@ int WINAPI GetHostNameW( WCHAR *name, int namelen ) MultiByteToWideChar( CP_ACP, 0, buf, -1, name, namelen ); return 0; } + + +static int list_size( char **list, int item_size ) +{ + int i, size = 0; + if (list) + { + for (i = 0; list[i]; i++) + size += (item_size ? item_size : strlen(list[i]) + 1); + size += (i + 1) * sizeof(char *); + } + return size; +} + +static int list_dup( char **src, char **dst, int item_size ) +{ + char *p; + int i; + + for (i = 0; src[i]; i++) + ; + p = (char *)(dst + i + 1); + + for (i = 0; src[i]; i++) + { + int count = item_size ? item_size : strlen(src[i]) + 1; + memcpy( p, src[i], count ); + dst[i] = p; + p += count; + } + dst[i] = NULL; + return p - (char *)dst; +} + +static const struct +{ + int prot; + const char *names[3]; +} +protocols[] = +{ + { 0, {"ip", "IP"}}, + { 1, {"icmp", "ICMP"}}, + { 3, {"ggp", "GGP"}}, + { 6, {"tcp", "TCP"}}, + { 8, {"egp", "EGP"}}, + {12, {"pup", "PUP"}}, + {17, {"udp", "UDP"}}, + {20, {"hmp", "HMP"}}, + {22, {"xns-idp", "XNS-IDP"}}, + {27, {"rdp", "RDP"}}, + {41, {"ipv6", "IPv6"}}, + {43, {"ipv6-route", "IPv6-Route"}}, + {44, {"ipv6-frag", "IPv6-Frag"}}, + {50, {"esp", "ESP"}}, + {51, {"ah", "AH"}}, + {58, {"ipv6-icmp", "IPv6-ICMP"}}, + {59, {"ipv6-nonxt", "IPv6-NoNxt"}}, + {60, {"ipv6-opts", "IPv6-Opts"}}, + {66, {"rvd", "RVD"}}, +}; + +static struct WS_protoent *get_protoent_buffer( unsigned int size ) +{ + struct per_thread_data *data = get_per_thread_data(); + + if (data->pe_buffer) + { + if (data->pe_len >= size) return data->pe_buffer; + HeapFree( GetProcessHeap(), 0, data->pe_buffer ); + } + data->pe_len = size; + data->pe_buffer = HeapAlloc( GetProcessHeap(), 0, size ); + if (!data->pe_buffer) SetLastError( WSAENOBUFS ); + return data->pe_buffer; +} + +static struct WS_protoent *create_protoent( const char *name, char **aliases, int prot ) +{ + struct WS_protoent *ret; + unsigned int size = sizeof(*ret) + strlen( name ) + sizeof(char *) + list_size( aliases, 0 ); + + if (!(ret = get_protoent_buffer( size ))) return NULL; + ret->p_proto = prot; + ret->p_name = (char *)(ret + 1); + strcpy( ret->p_name, name ); + ret->p_aliases = (char **)ret->p_name + strlen( name ) / sizeof(char *) + 1; + list_dup( aliases, ret->p_aliases, 0 ); + return ret; +} + + +/*********************************************************************** + * getprotobyname (ws2_32.53) + */ +struct WS_protoent * WINAPI WS_getprotobyname( const char *name ) +{ + struct WS_protoent *retval = NULL; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(protocols); i++) + { + if (!_strnicmp( protocols[i].names[0], name, -1 )) + { + retval = create_protoent( protocols[i].names[0], (char **)protocols[i].names + 1, + protocols[i].prot ); + break; + } + } + if (!retval) + { + WARN( "protocol %s not found\n", debugstr_a(name) ); + SetLastError( WSANO_DATA ); + } + TRACE( "%s ret %p\n", debugstr_a(name), retval ); + return retval; +} + + +/*********************************************************************** + * getprotobynumber (ws2_32.54) + */ +struct WS_protoent * WINAPI WS_getprotobynumber( int number ) +{ + struct WS_protoent *retval = NULL; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(protocols); i++) + { + if (protocols[i].prot == number) + { + retval = create_protoent( protocols[i].names[0], (char **)protocols[i].names + 1, + protocols[i].prot ); + break; + } + } + if (!retval) + { + WARN( "protocol %d not found\n", number ); + SetLastError( WSANO_DATA ); + } + TRACE( "%d ret %p\n", number, retval ); + return retval; +} diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 5ced4720558..c3c73568c83 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -609,7 +609,6 @@ int num_startup; static FARPROC blocking_hook = (FARPROC)WSA_DefaultBlockingHook; /* function prototypes */ -static struct WS_protoent *WS_create_pe( const char *name, char **aliases, int prot ); static struct WS_servent *WS_dup_se(const struct servent* p_se); static int ws_protocol_info(SOCKET s, int unicode, WSAPROTOCOL_INFOW *buffer, int *size); @@ -1578,21 +1577,6 @@ static struct WS_servent *check_buffer_se(int size) return ptb->se_buffer; } -static struct WS_protoent *check_buffer_pe(int size) -{ - struct per_thread_data * ptb = get_per_thread_data(); - if (ptb->pe_buffer) - { - if (ptb->pe_len >= size ) return ptb->pe_buffer; - HeapFree( GetProcessHeap(), 0, ptb->pe_buffer ); - } - ptb->pe_buffer = HeapAlloc( GetProcessHeap(), 0, (ptb->pe_len = size) ); - if (!ptb->pe_buffer) SetLastError(WSAENOBUFS); - return ptb->pe_buffer; -} - -/* ----------------------------------- i/o APIs */ - static inline BOOL supported_pf(int pf) { switch (pf) @@ -5737,79 +5721,6 @@ SOCKET WINAPI WS_socket(int af, int type, int protocol) } -static const struct { int prot; const char *names[3]; } protocols[] = -{ - { 0, { "ip", "IP" }}, - { 1, { "icmp", "ICMP" }}, - { 3, { "ggp", "GGP" }}, - { 6, { "tcp", "TCP" }}, - { 8, { "egp", "EGP" }}, - { 12, { "pup", "PUP" }}, - { 17, { "udp", "UDP" }}, - { 20, { "hmp", "HMP" }}, - { 22, { "xns-idp", "XNS-IDP" }}, - { 27, { "rdp", "RDP" }}, - { 41, { "ipv6", "IPv6" }}, - { 43, { "ipv6-route", "IPv6-Route" }}, - { 44, { "ipv6-frag", "IPv6-Frag" }}, - { 50, { "esp", "ESP" }}, - { 51, { "ah", "AH" }}, - { 58, { "ipv6-icmp", "IPv6-ICMP" }}, - { 59, { "ipv6-nonxt", "IPv6-NoNxt" }}, - { 60, { "ipv6-opts", "IPv6-Opts" }}, - { 66, { "rvd", "RVD" }}, -}; - -/*********************************************************************** - * getprotobyname (WS2_32.53) - */ -struct WS_protoent* WINAPI WS_getprotobyname(const char* name) -{ - struct WS_protoent* retval = NULL; - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(protocols); i++) - { - if (_strnicmp( protocols[i].names[0], name, -1 )) continue; - retval = WS_create_pe( protocols[i].names[0], (char **)protocols[i].names + 1, - protocols[i].prot ); - break; - } - if (!retval) - { - WARN( "protocol %s not found\n", debugstr_a(name) ); - SetLastError(WSANO_DATA); - } - TRACE( "%s ret %p\n", debugstr_a(name), retval ); - return retval; -} - - -/*********************************************************************** - * getprotobynumber (WS2_32.54) - */ -struct WS_protoent* WINAPI WS_getprotobynumber(int number) -{ - struct WS_protoent* retval = NULL; - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(protocols); i++) - { - if (protocols[i].prot != number) continue; - retval = WS_create_pe( protocols[i].names[0], (char **)protocols[i].names + 1, - protocols[i].prot ); - break; - } - if (!retval) - { - WARN( "protocol %d not found\n", number ); - SetLastError(WSANO_DATA); - } - TRACE("%i ret %p\n", number, retval); - return retval; -} - - /*********************************************************************** * getservbyname (WS2_32.55) */ @@ -6313,20 +6224,6 @@ static int list_dup(char** l_src, char** l_to, int item_size) return p - (char *)l_to; } -static struct WS_protoent *WS_create_pe( const char *name, char **aliases, int prot ) -{ - struct WS_protoent *ret; - unsigned int size = sizeof(*ret) + strlen(name) + sizeof(char *) + list_size(aliases, 0); - - if (!(ret = check_buffer_pe( size ))) return NULL; - ret->p_proto = prot; - ret->p_name = (char *)(ret + 1); - strcpy( ret->p_name, name ); - ret->p_aliases = (char **)ret->p_name + strlen(name) / sizeof(char *) + 1; - list_dup( aliases, ret->p_aliases, 0 ); - return ret; -} - /* ----- servent */ static struct WS_servent *WS_dup_se(const struct servent* p_se)
1
0
0
0
Zebediah Figura : ws2_32: Move name info functions to protocol.c.
by Alexandre Julliard
03 May '21
03 May '21
Module: wine Branch: master Commit: 877e3e24d4c76146f5613b0a9b3b70b25b007a93 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=877e3e24d4c76146f5613b0a…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Fri Apr 30 19:10:00 2021 -0500 ws2_32: Move name info functions to protocol.c. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ws2_32/protocol.c | 87 ++++++++++++++++++++++++++++++++++++++++++++ dlls/ws2_32/socket.c | 83 +----------------------------------------- dlls/ws2_32/ws2_32_private.h | 8 ++++ 3 files changed, 97 insertions(+), 81 deletions(-) diff --git a/dlls/ws2_32/protocol.c b/dlls/ws2_32/protocol.c index 460f4e78dcc..c2e661c03dc 100644 --- a/dlls/ws2_32/protocol.c +++ b/dlls/ws2_32/protocol.c @@ -854,6 +854,93 @@ void WINAPI FreeAddrInfoExW( ADDRINFOEXW *ai ) } +static const int ws_niflag_map[][2] = +{ + MAP_OPTION( NI_NOFQDN ), + MAP_OPTION( NI_NUMERICHOST ), + MAP_OPTION( NI_NAMEREQD ), + MAP_OPTION( NI_NUMERICSERV ), + MAP_OPTION( NI_DGRAM ), +}; + +static int convert_niflag_w2u( int winflags ) +{ + unsigned int i; + int unixflags = 0; + + for (i = 0; i < ARRAY_SIZE(ws_niflag_map); i++) + { + if (ws_niflag_map[i][0] & winflags) + { + unixflags |= ws_niflag_map[i][1]; + winflags &= ~ws_niflag_map[i][0]; + } + } + if (winflags) + FIXME("Unhandled windows NI_xxx flags 0x%x\n", winflags); + return unixflags; +} + + +/*********************************************************************** + * getnameinfo (ws2_32.@) + */ +int WINAPI WS_getnameinfo( const SOCKADDR *addr, WS_socklen_t addr_len, char *host, + DWORD host_len, char *serv, DWORD serv_len, int flags ) +{ +#ifdef HAVE_GETNAMEINFO + int ret; + union generic_unix_sockaddr uaddr; + unsigned int uaddr_len; + + TRACE( "addr %s, addr_len %d, host %p, host_len %u, serv %p, serv_len %d, flags %#x\n", + debugstr_sockaddr(addr), addr_len, host, host_len, serv, serv_len, flags ); + + uaddr_len = ws_sockaddr_ws2u( addr, addr_len, &uaddr ); + if (!uaddr_len) + { + SetLastError( WSAEFAULT ); + return WSA_NOT_ENOUGH_MEMORY; + } + ret = getnameinfo( &uaddr.addr, uaddr_len, host, host_len, serv, serv_len, convert_niflag_w2u(flags) ); + return convert_eai_u2w( ret ); +#else + FIXME( "getnameinfo() failed, not found during buildtime.\n" ); + return EAI_FAIL; +#endif +} + + +/*********************************************************************** + * GetNameInfoW (ws2_32.@) + */ +int WINAPI GetNameInfoW( const SOCKADDR *addr, WS_socklen_t addr_len, WCHAR *host, + DWORD host_len, WCHAR *serv, DWORD serv_len, int flags ) +{ + int ret; + char *hostA = NULL, *servA = NULL; + + if (host && (!(hostA = HeapAlloc( GetProcessHeap(), 0, host_len )))) + return EAI_MEMORY; + if (serv && (!(servA = HeapAlloc( GetProcessHeap(), 0, serv_len )))) + { + HeapFree( GetProcessHeap(), 0, hostA ); + return EAI_MEMORY; + } + + ret = WS_getnameinfo( addr, addr_len, hostA, host_len, servA, serv_len, flags ); + if (!ret) + { + if (host) MultiByteToWideChar( CP_ACP, 0, hostA, -1, host, host_len ); + if (serv) MultiByteToWideChar( CP_ACP, 0, servA, -1, serv, serv_len ); + } + + HeapFree( GetProcessHeap(), 0, hostA ); + HeapFree( GetProcessHeap(), 0, servA ); + return ret; +} + + static UINT host_errno_from_unix( int err ) { WARN( "%d\n", err ); diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 7313741e4b1..5ced4720558 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -235,12 +235,6 @@ static unsigned int if_addr_cache_size; static SOCKET *socket_list; static unsigned int socket_list_size; -union generic_unix_sockaddr -{ - struct sockaddr addr; - char data[128]; /* should be big enough for all families */ -}; - const char *debugstr_sockaddr( const struct WS_sockaddr *a ) { if (!a) return "(nil)"; @@ -717,15 +711,6 @@ static const int ws_socktype_map[][2] = {FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO}, }; -static const int ws_niflag_map[][2] = -{ - MAP_OPTION( NI_NOFQDN ), - MAP_OPTION( NI_NUMERICHOST ), - MAP_OPTION( NI_NAMEREQD ), - MAP_OPTION( NI_NUMERICSERV ), - MAP_OPTION( NI_DGRAM ), -}; - static const int ws_poll_map[][2] = { MAP_OPTION( POLLERR ), @@ -1633,8 +1618,8 @@ static inline BOOL supported_pf(int pf) /* Returns the length of the converted address if successful, 0 if it was too * small to start with or unknown family or invalid address buffer. */ -static unsigned int ws_sockaddr_ws2u(const struct WS_sockaddr* wsaddr, int wsaddrlen, - union generic_unix_sockaddr *uaddr) +unsigned int ws_sockaddr_ws2u( const struct WS_sockaddr *wsaddr, int wsaddrlen, + union generic_unix_sockaddr *uaddr ) { unsigned int uaddrlen = 0; @@ -5860,70 +5845,6 @@ struct WS_servent* WINAPI WS_getservbyname(const char *name, const char *proto) return retval; } -static int convert_niflag_w2u(int winflags) { - unsigned int i; - int unixflags = 0; - - for (i = 0; i < ARRAY_SIZE(ws_niflag_map); i++) - if (ws_niflag_map[i][0] & winflags) { - unixflags |= ws_niflag_map[i][1]; - winflags &= ~ws_niflag_map[i][0]; - } - if (winflags) - FIXME("Unhandled windows NI_xxx flags 0x%x\n", winflags); - return unixflags; -} - -int WINAPI WS_getnameinfo(const SOCKADDR *sa, WS_socklen_t salen, PCHAR host, - DWORD hostlen, PCHAR serv, DWORD servlen, INT flags) -{ -#ifdef HAVE_GETNAMEINFO - int ret; - union generic_unix_sockaddr sa_u; - unsigned int size; - - TRACE("%s %d %p %d %p %d %d\n", debugstr_sockaddr(sa), salen, host, hostlen, - serv, servlen, flags); - - size = ws_sockaddr_ws2u(sa, salen, &sa_u); - if (!size) - { - SetLastError(WSAEFAULT); - return WSA_NOT_ENOUGH_MEMORY; - } - ret = getnameinfo(&sa_u.addr, size, host, hostlen, serv, servlen, convert_niflag_w2u(flags)); - return convert_eai_u2w(ret); -#else - FIXME("getnameinfo() failed, not found during buildtime.\n"); - return EAI_FAIL; -#endif -} - -int WINAPI GetNameInfoW(const SOCKADDR *sa, WS_socklen_t salen, PWCHAR host, - DWORD hostlen, PWCHAR serv, DWORD servlen, INT flags) -{ - int ret; - char *hostA = NULL, *servA = NULL; - - if (host && (!(hostA = HeapAlloc(GetProcessHeap(), 0, hostlen)))) return EAI_MEMORY; - if (serv && (!(servA = HeapAlloc(GetProcessHeap(), 0, servlen)))) - { - HeapFree(GetProcessHeap(), 0, hostA); - return EAI_MEMORY; - } - - ret = WS_getnameinfo(sa, salen, hostA, hostlen, servA, servlen, flags); - if (!ret) - { - if (host) MultiByteToWideChar(CP_ACP, 0, hostA, -1, host, hostlen); - if (serv) MultiByteToWideChar(CP_ACP, 0, servA, -1, serv, servlen); - } - - HeapFree(GetProcessHeap(), 0, hostA); - HeapFree(GetProcessHeap(), 0, servA); - return ret; -} - /*********************************************************************** * getservbyport (WS2_32.56) */ diff --git a/dlls/ws2_32/ws2_32_private.h b/dlls/ws2_32/ws2_32_private.h index 121ce25ad1d..e86a3569510 100644 --- a/dlls/ws2_32/ws2_32_private.h +++ b/dlls/ws2_32/ws2_32_private.h @@ -161,11 +161,19 @@ static const char magic_loopback_addr[] = {127, 12, 34, 56}; +union generic_unix_sockaddr +{ + struct sockaddr addr; + char data[128]; /* should be big enough for all families */ +}; + int convert_eai_u2w( int ret ) DECLSPEC_HIDDEN; int convert_socktype_u2w( int type ) DECLSPEC_HIDDEN; int convert_socktype_w2u( int type ) DECLSPEC_HIDDEN; int ws_sockaddr_u2ws( const struct sockaddr *unix_addr, struct WS_sockaddr *win_addr, int *win_addr_len ) DECLSPEC_HIDDEN; +unsigned int ws_sockaddr_ws2u( const struct WS_sockaddr *win_addr, int win_addr_len, + union generic_unix_sockaddr *unix_addr ) DECLSPEC_HIDDEN; const char *debugstr_sockaddr( const struct WS_sockaddr *addr ) DECLSPEC_HIDDEN;
1
0
0
0
Zebediah Figura : ws2_32: Move host lookup functions to protocol.c.
by Alexandre Julliard
03 May '21
03 May '21
Module: wine Branch: master Commit: ec9f3119306e34f5a8bd3bfeb233eed740c1c6ae URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ec9f3119306e34f5a8bd3bfe…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Fri Apr 30 19:09:59 2021 -0500 ws2_32: Move host lookup functions to protocol.c. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ws2_32/protocol.c | 491 ++++++++++++++++++++++++++++++++++++++++ dlls/ws2_32/socket.c | 516 +------------------------------------------ dlls/ws2_32/ws2_32_private.h | 29 ++- 3 files changed, 520 insertions(+), 516 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=ec9f3119306e34f5a8bd…
1
0
0
0
Zebediah Figura : ws2_32: Move getaddrinfo() and related functions to a separate file.
by Alexandre Julliard
03 May '21
03 May '21
Module: wine Branch: master Commit: e30b16d738d90d2e9da44ff8557396ad78042174 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e30b16d738d90d2e9da44ff8…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Fri Apr 30 19:09:58 2021 -0500 ws2_32: Move getaddrinfo() and related functions to a separate file. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ws2_32/Makefile.in | 1 + dlls/ws2_32/protocol.c | 812 +++++++++++++++++++++++++++++++++++++++ dlls/ws2_32/socket.c | 890 +------------------------------------------ dlls/ws2_32/ws2_32_private.h | 167 ++++++++ 4 files changed, 988 insertions(+), 882 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=e30b16d738d90d2e9da4…
1
0
0
0
Hugh McMaster : reg: Only prompt the user to overwrite registry data if the given key already exists and [/f] is not supplied.
by Alexandre Julliard
03 May '21
03 May '21
Module: wine Branch: master Commit: cf1e6d3f3fcb726062b957a973bb0a78b7e00eab URL:
https://source.winehq.org/git/wine.git/?a=commit;h=cf1e6d3f3fcb726062b957a9…
Author: Hugh McMaster <hugh.mcmaster(a)outlook.com> Date: Mon May 3 23:20:37 2021 +1000 reg: Only prompt the user to overwrite registry data if the given key already exists and [/f] is not supplied. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/reg/add.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/programs/reg/add.c b/programs/reg/add.c index 258e3e8cb25..9aaa3fc1acc 100644 --- a/programs/reg/add.c +++ b/programs/reg/add.c @@ -154,18 +154,18 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, WCHAR *type, WCHAR separator, WCHAR *data, BOOL force) { HKEY hkey; - DWORD data_type, data_size; + DWORD dispos, data_type, data_size; BYTE *reg_data = NULL; LONG rc; if (RegCreateKeyExW(root, path, 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_READ|KEY_WRITE, NULL, &hkey, NULL)) + KEY_READ|KEY_WRITE, NULL, &hkey, &dispos)) { output_message(STRING_ACCESS_DENIED); return 1; } - if (!force) + if (!force && dispos == REG_OPENED_EXISTING_KEY) { if (RegQueryValueExW(hkey, value_name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
1
0
0
0
Hugh McMaster : reg: Fail if access is denied when adding registry data.
by Alexandre Julliard
03 May '21
03 May '21
Module: wine Branch: master Commit: d433d1f122a85b7902b48bae1930eef503a239a5 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d433d1f122a85b7902b48bae…
Author: Hugh McMaster <hugh.mcmaster(a)outlook.com> Date: Mon May 3 23:20:36 2021 +1000 reg: Fail if access is denied when adding registry data. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/reg/add.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/programs/reg/add.c b/programs/reg/add.c index 897c6f60621..258e3e8cb25 100644 --- a/programs/reg/add.c +++ b/programs/reg/add.c @@ -156,6 +156,7 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, HKEY hkey; DWORD data_type, data_size; BYTE *reg_data = NULL; + LONG rc; if (RegCreateKeyExW(root, path, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ|KEY_WRITE, NULL, &hkey, NULL)) @@ -199,10 +200,17 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, return 1; } - RegSetValueExW(hkey, value_name, 0, data_type, reg_data, data_size); - free(reg_data); + rc = RegSetValueExW(hkey, value_name, 0, data_type, reg_data, data_size); + free(reg_data); RegCloseKey(hkey); + + if (rc) + { + output_message(STRING_ACCESS_DENIED); + return 1; + } + output_message(STRING_SUCCESS); return 0;
1
0
0
0
Hugh McMaster : reg: Add or modify the (Default) registry value if [/v] is not specified.
by Alexandre Julliard
03 May '21
03 May '21
Module: wine Branch: master Commit: a0dc4d7ce37fa8cc515cd4c908245d12fc07cfae URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a0dc4d7ce37fa8cc515cd4c9…
Author: Hugh McMaster <hugh.mcmaster(a)outlook.com> Date: Mon May 3 23:20:35 2021 +1000 reg: Add or modify the (Default) registry value if [/v] is not specified. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/reg/add.c | 63 +++++++++++++++++++++++------------------------- programs/reg/tests/add.c | 30 +++++++++++------------ 2 files changed, 45 insertions(+), 48 deletions(-) diff --git a/programs/reg/add.c b/programs/reg/add.c index c3dec2d5b7f..897c6f60621 100644 --- a/programs/reg/add.c +++ b/programs/reg/add.c @@ -154,6 +154,8 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, WCHAR *type, WCHAR separator, WCHAR *data, BOOL force) { HKEY hkey; + DWORD data_type, data_size; + BYTE *reg_data = NULL; if (RegCreateKeyExW(root, path, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ|KEY_WRITE, NULL, &hkey, NULL)) @@ -162,49 +164,44 @@ static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, return 1; } - if (value_name || value_empty || data) + if (!force) { - DWORD reg_type; - DWORD data_size = 0; - BYTE* reg_data = NULL; - - if (!force) + if (RegQueryValueExW(hkey, value_name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { - if (RegQueryValueExW(hkey, value_name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) + if (!ask_confirm(STRING_OVERWRITE_VALUE, value_name)) { - if (!ask_confirm(STRING_OVERWRITE_VALUE, value_name)) - { - RegCloseKey(hkey); - output_message(STRING_CANCELLED); - return 0; - } + RegCloseKey(hkey); + output_message(STRING_CANCELLED); + return 0; } } + } - reg_type = wchar_get_type(type); - if (reg_type == ~0u) - { - RegCloseKey(hkey); - output_message(STRING_UNSUPPORTED_TYPE, type); - return 1; - } - if ((reg_type == REG_DWORD || reg_type == REG_DWORD_BIG_ENDIAN) && !data) - { - RegCloseKey(hkey); - output_message(STRING_INVALID_CMDLINE); - return 1; - } + data_type = wchar_get_type(type); - if (!(reg_data = get_regdata(data, reg_type, separator, &data_size))) - { - RegCloseKey(hkey); - return 1; - } + if (data_type == ~0u) + { + RegCloseKey(hkey); + output_message(STRING_UNSUPPORTED_TYPE, type); + return 1; + } - RegSetValueExW(hkey, value_name, 0, reg_type, reg_data, data_size); - free(reg_data); + if ((data_type == REG_DWORD || data_type == REG_DWORD_BIG_ENDIAN) && !data) + { + RegCloseKey(hkey); + output_message(STRING_INVALID_CMDLINE); + return 1; } + if (!(reg_data = get_regdata(data, data_type, separator, &data_size))) + { + RegCloseKey(hkey); + return 1; + } + + RegSetValueExW(hkey, value_name, 0, data_type, reg_data, data_size); + free(reg_data); + RegCloseKey(hkey); output_message(STRING_SUCCESS); diff --git a/programs/reg/tests/add.c b/programs/reg/tests/add.c index 23d0115fd64..7fad8333ed5 100644 --- a/programs/reg/tests/add.c +++ b/programs/reg/tests/add.c @@ -330,8 +330,8 @@ static void test_add(void) open_key(HKEY_CURRENT_USER, KEY_BASE, KEY_WRITE, &hkey); /* The Default value is initialized if no parameters are specified */ - todo_wine verify_reg(hkey, NULL, REG_SZ, "", 1, 0); - todo_wine delete_value(hkey, NULL); + verify_reg(hkey, NULL, REG_SZ, "", 1, 0); + delete_value(hkey, NULL); /* This also occurs when specifying a registry type and passing data */ run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /d 0x5 /f", &r); @@ -342,7 +342,7 @@ static void test_add(void) /* The Default value can also be overwritten as an empty string */ run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); - verify_reg(hkey, NULL, REG_SZ, "", 1, TODO_REG_TYPE|TODO_REG_SIZE|TODO_REG_DATA); + verify_reg(hkey, NULL, REG_SZ, "", 1, 0); close_key(hkey); delete_key(HKEY_CURRENT_USER, KEY_BASE); @@ -366,8 +366,8 @@ static void test_add(void) /* ... but we can add it without passing [/f] to reg.exe */ run_reg_exe("reg add HKCU\\" KEY_BASE, &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); - todo_wine verify_reg(hkey, NULL, REG_SZ, "", 1, 0); - todo_wine delete_value(hkey, NULL); + verify_reg(hkey, NULL, REG_SZ, "", 1, 0); + delete_value(hkey, NULL); /* Test whether overwriting a registry key modifies existing keys and values */ add_key(hkey, "Subkey", NULL); @@ -382,7 +382,7 @@ static void test_add(void) verify_key(hkey, "Subkey"); verify_reg(hkey, "Test1", REG_SZ, "Value1", 7, 0); verify_reg(hkey, "Test2", REG_DWORD, &dword, sizeof(dword), 0); - todo_wine verify_reg(hkey, NULL, REG_SZ, "", 1, 0); + verify_reg(hkey, NULL, REG_SZ, "", 1, 0); run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_NONE /d Test /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); @@ -406,9 +406,9 @@ static void test_reg_none(void) run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_NONE /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); - todo_wine verify_reg(hkey, NULL, REG_NONE, "\0", 2, 0); + verify_reg(hkey, NULL, REG_NONE, "\0", 2, 0); - todo_wine delete_value(hkey, NULL); + delete_value(hkey, NULL); run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_NONE /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r); @@ -435,7 +435,7 @@ static void test_reg_sz(void) run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r); - todo_wine verify_reg(hkey, NULL, REG_SZ, "", 1, 0); + verify_reg(hkey, NULL, REG_SZ, "", 1, 0); run_reg_exe("reg add HKCU\\" KEY_BASE " /d WineTest /f", &r); ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */), @@ -513,9 +513,9 @@ static void test_reg_expand_sz(void) run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r); - todo_wine verify_reg(hkey, NULL, REG_EXPAND_SZ, "", 1, 0); + verify_reg(hkey, NULL, REG_EXPAND_SZ, "", 1, 0); - todo_wine delete_value(hkey, NULL); + delete_value(hkey, NULL); run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_EXPAND_SZ /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r); @@ -556,9 +556,9 @@ static void test_reg_binary(void) run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r); - todo_wine verify_reg(hkey, NULL, REG_BINARY, buffer, 0, 0); + verify_reg(hkey, NULL, REG_BINARY, buffer, 0, 0); - todo_wine delete_value(hkey, NULL); + delete_value(hkey, NULL); run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_BINARY /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r); @@ -754,9 +754,9 @@ static void test_reg_multi_sz(void) run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r); - todo_wine verify_reg(hkey, NULL, REG_MULTI_SZ, "", 1, 0); + verify_reg(hkey, NULL, REG_MULTI_SZ, "", 1, 0); - todo_wine delete_value(hkey, NULL); + delete_value(hkey, NULL); run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_MULTI_SZ /f", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
1
0
0
0
← Newer
1
...
72
73
74
75
76
77
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
Results per page:
10
25
50
100
200