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
November 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
951 discussions
Start a n
N
ew thread
Huw Davies : winecoreaudio: Move creation of the audio unit to IAudioClient_Initialize().
by Alexandre Julliard
22 Nov '21
22 Nov '21
Module: wine Branch: master Commit: 3810c693cacf7a8b763d32505a49bf70b151d169 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=3810c693cacf7a8b763d3250…
Author: Huw Davies <huw(a)codeweavers.com> Date: Thu Nov 18 07:52:33 2021 +0000 winecoreaudio: Move creation of the audio unit to IAudioClient_Initialize(). Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Andrew Eikum <aeikum(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winecoreaudio.drv/mmdevdrv.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index 642610b4b60..56f533f8bc1 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -580,12 +580,6 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient This->adevid = adevid; - if(!(This->stream->unit = get_audiounit(This->dataflow, This->adevid))){ - HeapFree(GetProcessHeap(), 0, This->stream); - HeapFree(GetProcessHeap(), 0, This); - return AUDCLNT_E_DEVICE_INVALIDATED; - } - *out = (IAudioClient *)&This->IAudioClient3_iface; IAudioClient3_AddRef(&This->IAudioClient3_iface); @@ -1262,6 +1256,14 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface, if(mode == AUDCLNT_SHAREMODE_EXCLUSIVE) This->stream->bufsize_frames -= This->stream->bufsize_frames % This->stream->period_frames; + if(!(This->stream->unit = get_audiounit(This->dataflow, This->adevid))){ + CoTaskMemFree(This->stream->fmt); + This->stream->fmt = NULL; + OSSpinLockUnlock(&This->stream->lock); + LeaveCriticalSection(&g_sessions_lock); + return AUDCLNT_E_DEVICE_INVALIDATED; + } + hr = ca_setup_audiounit(This->dataflow, This->stream->unit, This->stream->fmt, &This->stream->dev_desc, &This->stream->converter); if(FAILED(hr)){ CoTaskMemFree(This->stream->fmt);
1
0
0
0
Huw Davies : winecoreaudio: Use NtAllocateVirtualMemory() for local and tmp buffers.
by Alexandre Julliard
22 Nov '21
22 Nov '21
Module: wine Branch: master Commit: 7d76fee5f48a3f8ddff25c23cd74aad4aaa4e910 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=7d76fee5f48a3f8ddff25c23…
Author: Huw Davies <huw(a)codeweavers.com> Date: Thu Nov 18 07:52:32 2021 +0000 winecoreaudio: Use NtAllocateVirtualMemory() for local and tmp buffers. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Andrew Eikum <aeikum(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winecoreaudio.drv/mmdevdrv.c | 28 ++++++++++++++++++++-------- dlls/winecoreaudio.drv/unixlib.h | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index 1e37a2a9026..642610b4b60 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -653,9 +653,13 @@ static ULONG WINAPI AudioClient_Release(IAudioClient3 *iface) LeaveCriticalSection(&g_sessions_lock); } HeapFree(GetProcessHeap(), 0, This->vols); - HeapFree(GetProcessHeap(), 0, This->stream->tmp_buffer); HeapFree(GetProcessHeap(), 0, This->stream->cap_buffer); - HeapFree(GetProcessHeap(), 0, This->stream->local_buffer); + if(This->stream->local_buffer) + NtFreeVirtualMemory(GetCurrentProcess(), (void **)&This->stream->local_buffer, + &This->stream->local_buffer_size, MEM_RELEASE); + if(This->stream->tmp_buffer) + NtFreeVirtualMemory(GetCurrentProcess(), (void **)&This->stream->tmp_buffer, + &This->stream->tmp_buffer_size, MEM_RELEASE); free(This->stream->wrap_buffer); HeapFree(GetProcessHeap(), 0, This->stream->resamp_buffer); CoTaskMemFree(This->stream->fmt); @@ -1335,7 +1339,9 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface, return osstatus_to_hresult(sc); } - This->stream->local_buffer = HeapAlloc(GetProcessHeap(), 0, This->stream->bufsize_frames * fmt->nBlockAlign); + This->stream->local_buffer_size = This->stream->bufsize_frames * fmt->nBlockAlign; + NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&This->stream->local_buffer, 0, + &This->stream->local_buffer_size, MEM_COMMIT, PAGE_READWRITE); silence_buffer(This, This->stream->local_buffer, This->stream->bufsize_frames); if(This->dataflow == eCapture){ @@ -2292,9 +2298,12 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface, if(This->stream->wri_offs_frames + frames > This->stream->bufsize_frames){ if(This->stream->tmp_buffer_frames < frames){ - HeapFree(GetProcessHeap(), 0, This->stream->tmp_buffer); - This->stream->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, frames * This->stream->fmt->nBlockAlign); - if(!This->stream->tmp_buffer){ + NtFreeVirtualMemory(GetCurrentProcess(), (void **)&This->stream->tmp_buffer, + &This->stream->tmp_buffer_size, MEM_RELEASE); + This->stream->tmp_buffer_size = frames * This->stream->fmt->nBlockAlign; + if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&This->stream->tmp_buffer, 0, + &This->stream->tmp_buffer_size, MEM_COMMIT, PAGE_READWRITE)){ + This->stream->tmp_buffer_frames = 0; OSSpinLockUnlock(&This->stream->lock); return E_OUTOFMEMORY; } @@ -2449,8 +2458,11 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface, chunk_frames = This->stream->bufsize_frames - This->stream->lcl_offs_frames; if(chunk_frames < This->stream->period_frames){ chunk_bytes = chunk_frames * This->stream->fmt->nBlockAlign; - if(!This->stream->tmp_buffer) - This->stream->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, This->stream->period_frames * This->stream->fmt->nBlockAlign); + if(!This->stream->tmp_buffer){ + This->stream->tmp_buffer_size = This->stream->period_frames * This->stream->fmt->nBlockAlign; + NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&This->stream->tmp_buffer, 0, + &This->stream->tmp_buffer_size, MEM_COMMIT, PAGE_READWRITE); + } *data = This->stream->tmp_buffer; memcpy(*data, This->stream->local_buffer + This->stream->lcl_offs_frames * This->stream->fmt->nBlockAlign, chunk_bytes); memcpy((*data) + chunk_bytes, This->stream->local_buffer, This->stream->period_frames * This->stream->fmt->nBlockAlign - chunk_bytes); diff --git a/dlls/winecoreaudio.drv/unixlib.h b/dlls/winecoreaudio.drv/unixlib.h index 6a991f1de98..1b773b7f820 100644 --- a/dlls/winecoreaudio.drv/unixlib.h +++ b/dlls/winecoreaudio.drv/unixlib.h @@ -29,7 +29,6 @@ struct coreaudio_stream /* To be made private */ AUDCLNT_SHAREMODE share; BOOL playing; - SIZE_T local_buffer_size, tmp_buffer_size; UINT32 period_ms, period_frames; UINT32 bufsize_frames, resamp_bufsize_frames; UINT32 lcl_offs_frames, held_frames, wri_offs_frames, tmp_buffer_frames; @@ -39,6 +38,7 @@ struct coreaudio_stream /* To be made private */ INT32 getbuf_last; WAVEFORMATEX *fmt; BYTE *local_buffer, *cap_buffer, *wrap_buffer, *resamp_buffer, *tmp_buffer; + SIZE_T local_buffer_size, tmp_buffer_size; }; struct endpoint
1
0
0
0
Dmitry Timoshkov : user32: Add exception handler to GetWindowText.
by Alexandre Julliard
22 Nov '21
22 Nov '21
Module: wine Branch: master Commit: ecd1c66476d63ca85c144a814046bdf5b86f4327 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ecd1c66476d63ca85c144a81…
Author: Dmitry Timoshkov <dmitry(a)baikal.ru> Date: Mon Nov 22 10:48:21 2021 +0300 user32: Add exception handler to GetWindowText. Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/tests/win.c | 29 ++++++++++++++++++++----- dlls/user32/win.c | 57 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 67 insertions(+), 19 deletions(-) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 88989f4064b..0156987f529 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -7923,17 +7923,36 @@ static void test_gettext(void) if (0) { r = SendMessageA( hwnd, WM_GETTEXT, 0x10, 0x1000); - ok( r == 0, "settext should return zero\n"); + ok( r == 0, "WM_GETTEXT should return zero (%ld)\n", r ); r = SendMessageA( hwnd, WM_GETTEXT, 0x10000, 0); - ok( r == 0, "settext should return zero (%ld)\n", r); + ok( r == 0, "WM_GETTEXT should return zero (%ld)\n", r ); r = SendMessageA( hwnd, WM_GETTEXT, 0xff000000, 0x1000); - ok( r == 0, "settext should return zero (%ld)\n", r); + ok( r == 0, "WM_GETTEXT should return zero (%ld)\n", r ); r = SendMessageA( hwnd, WM_GETTEXT, 0x1000, 0xff000000); - ok( r == 0, "settext should return zero (%ld)\n", r); - } + ok( r == 0, "WM_GETTEXT should return zero (%ld)\n", r ); + } + + /* GetWindowText doesn't crash */ + r = GetWindowTextA( hwnd, (LPSTR)0x10, 0x1000 ); + ok( r == 0, "GetWindowText should return zero (%ld)\n", r ); + r = GetWindowTextA( hwnd, (LPSTR)0x10000, 0 ); + ok( r == 0, "GetWindowText should return zero (%ld)\n", r ); + r = GetWindowTextA( hwnd, (LPSTR)0xff000000, 0x1000 ); + ok( r == 0, "GetWindowText should return zero (%ld)\n", r ); + r = GetWindowTextA( hwnd, (LPSTR)0x1000, 0xff000000 ); + ok( r == 0, "GetWindowText should return zero (%ld)\n", r ); + + r = GetWindowTextW( hwnd, (LPWSTR)0x10, 0x1000 ); + ok( r == 0, "GetWindowText should return zero (%ld)\n", r ); + r = GetWindowTextW( hwnd, (LPWSTR)0x10000, 0 ); + ok( r == 0, "GetWindowText should return zero (%ld)\n", r ); + r = GetWindowTextW( hwnd, (LPWSTR)0xff000000, 0x1000 ); + ok( r == 0, "GetWindowText should return zero (%ld)\n", r ); + r = GetWindowTextW( hwnd, (LPWSTR)0x1000, 0xff000000); + ok( r == 0, "GetWindowText should return zero (%ld)\n", r ); DestroyWindow(hwnd); } diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 221607b3169..4f1f70d9802 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -31,6 +31,7 @@ #include "win.h" #include "controls.h" #include "winerror.h" +#include "wine/exception.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(win); @@ -2999,22 +3000,35 @@ LONG WINAPI DECLSPEC_HOTPATCH SetWindowLongW( INT WINAPI GetWindowTextA( HWND hwnd, LPSTR lpString, INT nMaxCount ) { WCHAR *buffer; + int ret = 0; if (!lpString || nMaxCount <= 0) return 0; - if (WIN_IsCurrentProcess( hwnd )) + __TRY { lpString[0] = 0; - return (INT)SendMessageA( hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString ); + + if (WIN_IsCurrentProcess( hwnd )) + { + ret = (INT)SendMessageA( hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString ); + } + else if ((buffer = HeapAlloc( GetProcessHeap(), 0, nMaxCount * sizeof(WCHAR) ))) + { + /* when window belongs to other process, don't send a message */ + get_server_window_text( hwnd, buffer, nMaxCount ); + if (!WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpString, nMaxCount, NULL, NULL )) + lpString[nMaxCount-1] = 0; + HeapFree( GetProcessHeap(), 0, buffer ); + ret = strlen(lpString); + } } + __EXCEPT_PAGE_FAULT + { + ret = 0; + } + __ENDTRY - /* when window belongs to other process, don't send a message */ - if (!(buffer = HeapAlloc( GetProcessHeap(), 0, nMaxCount * sizeof(WCHAR) ))) return 0; - get_server_window_text( hwnd, buffer, nMaxCount ); - if (!WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpString, nMaxCount, NULL, NULL )) - lpString[nMaxCount-1] = 0; - HeapFree( GetProcessHeap(), 0, buffer ); - return strlen(lpString); + return ret; } @@ -3047,17 +3061,32 @@ INT WINAPI InternalGetWindowText(HWND hwnd,LPWSTR lpString,INT nMaxCount ) */ INT WINAPI GetWindowTextW( HWND hwnd, LPWSTR lpString, INT nMaxCount ) { + int ret; + if (!lpString || nMaxCount <= 0) return 0; - if (WIN_IsCurrentProcess( hwnd )) + __TRY { lpString[0] = 0; - return (INT)SendMessageW( hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString ); + + if (WIN_IsCurrentProcess( hwnd )) + { + ret = (INT)SendMessageW( hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString ); + } + else + { + /* when window belongs to other process, don't send a message */ + get_server_window_text( hwnd, lpString, nMaxCount ); + ret = lstrlenW(lpString); + } } + __EXCEPT_PAGE_FAULT + { + ret = 0; + } + __ENDTRY - /* when window belongs to other process, don't send a message */ - get_server_window_text( hwnd, lpString, nMaxCount ); - return lstrlenW(lpString); + return ret; }
1
0
0
0
Hugh McMaster : kernelbase: Write NUL bytes to CPINFO.LeadByte for the CP_UTF7 and CP_UTF8 code pages.
by Alexandre Julliard
22 Nov '21
22 Nov '21
Module: wine Branch: master Commit: 4b9010d538173cd6f03a9d5f2e5e4e1cdaedf9d7 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=4b9010d538173cd6f03a9d5f…
Author: Hugh McMaster <hugh.mcmaster(a)outlook.com> Date: Mon Nov 22 22:43:29 2021 +1100 kernelbase: Write NUL bytes to CPINFO.LeadByte for the CP_UTF7 and CP_UTF8 code pages. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/tests/locale.c | 12 ++++-------- dlls/kernelbase/locale.c | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index 4fb30eb5318..cad2577379b 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -3976,10 +3976,8 @@ static void test_GetCPInfo(void) ok(ret, "GetCPInfo(CP_UTF7) error %u\n", GetLastError()); ok(cpinfo.DefaultChar[0] == 0x3f, "expected 0x3f, got 0x%x\n", cpinfo.DefaultChar[0]); ok(cpinfo.DefaultChar[1] == 0, "expected 0, got 0x%x\n", cpinfo.DefaultChar[1]); - ok(cpinfo.LeadByte[0] == 0, "expected 0, got 0x%x\n", cpinfo.LeadByte[0]); - ok(cpinfo.LeadByte[1] == 0, "expected 0, got 0x%x\n", cpinfo.LeadByte[1]); - for (i = 2; i < sizeof(cpinfo.LeadByte); i++) - todo_wine ok(!cpinfo.LeadByte[i], "expected NUL byte in index %u\n", i); + for (i = 0; i < sizeof(cpinfo.LeadByte); i++) + ok(!cpinfo.LeadByte[i], "expected NUL byte in index %u\n", i); ok(cpinfo.MaxCharSize == 5, "expected 5, got 0x%x\n", cpinfo.MaxCharSize); } @@ -3997,10 +3995,8 @@ static void test_GetCPInfo(void) ok(ret, "GetCPInfo(CP_UTF8) error %u\n", GetLastError()); ok(cpinfo.DefaultChar[0] == 0x3f, "expected 0x3f, got 0x%x\n", cpinfo.DefaultChar[0]); ok(cpinfo.DefaultChar[1] == 0, "expected 0, got 0x%x\n", cpinfo.DefaultChar[1]); - ok(cpinfo.LeadByte[0] == 0, "expected 0, got 0x%x\n", cpinfo.LeadByte[0]); - ok(cpinfo.LeadByte[1] == 0, "expected 0, got 0x%x\n", cpinfo.LeadByte[1]); - for (i = 2; i < sizeof(cpinfo.LeadByte); i++) - todo_wine ok(!cpinfo.LeadByte[i], "expected NUL byte in index %u\n", i); + for (i = 0; i < sizeof(cpinfo.LeadByte); i++) + ok(!cpinfo.LeadByte[i], "expected NUL byte in index %u\n", i); ok(cpinfo.MaxCharSize == 4 || broken(cpinfo.MaxCharSize == 3) /* win9x */, "expected 4, got %u\n", cpinfo.MaxCharSize); } diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c index 259b9d0d18e..10f3b2698b5 100644 --- a/dlls/kernelbase/locale.c +++ b/dlls/kernelbase/locale.c @@ -3905,7 +3905,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetCPInfo( UINT codepage, CPINFO *cpinfo ) case CP_UTF8: cpinfo->DefaultChar[0] = 0x3f; cpinfo->DefaultChar[1] = 0; - cpinfo->LeadByte[0] = cpinfo->LeadByte[1] = 0; + memset( cpinfo->LeadByte, 0, sizeof(cpinfo->LeadByte) ); cpinfo->MaxCharSize = (codepage == CP_UTF7) ? 5 : 4; break; default:
1
0
0
0
Hugh McMaster : kernel32/tests: Test whether every element of the CPINFO.LeadByte array is NUL.
by Alexandre Julliard
22 Nov '21
22 Nov '21
Module: wine Branch: master Commit: 381ea5413c29efc104c0b7fcb914e13ac6afd685 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=381ea5413c29efc104c0b7fc…
Author: Hugh McMaster <hugh.mcmaster(a)outlook.com> Date: Mon Nov 22 22:43:28 2021 +1100 kernel32/tests: Test whether every element of the CPINFO.LeadByte array is NUL. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/tests/locale.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index fa0ec374d34..4fb30eb5318 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -3962,6 +3962,7 @@ static void test_GetCPInfo(void) ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError()); + memset(cpinfo.LeadByte, '-', ARRAY_SIZE(cpinfo.LeadByte)); SetLastError(0xdeadbeef); ret = GetCPInfo(CP_UTF7, &cpinfo); if (!ret && GetLastError() == ERROR_INVALID_PARAMETER) @@ -3970,14 +3971,19 @@ static void test_GetCPInfo(void) } else { + unsigned int i; + ok(ret, "GetCPInfo(CP_UTF7) error %u\n", GetLastError()); ok(cpinfo.DefaultChar[0] == 0x3f, "expected 0x3f, got 0x%x\n", cpinfo.DefaultChar[0]); ok(cpinfo.DefaultChar[1] == 0, "expected 0, got 0x%x\n", cpinfo.DefaultChar[1]); ok(cpinfo.LeadByte[0] == 0, "expected 0, got 0x%x\n", cpinfo.LeadByte[0]); ok(cpinfo.LeadByte[1] == 0, "expected 0, got 0x%x\n", cpinfo.LeadByte[1]); + for (i = 2; i < sizeof(cpinfo.LeadByte); i++) + todo_wine ok(!cpinfo.LeadByte[i], "expected NUL byte in index %u\n", i); ok(cpinfo.MaxCharSize == 5, "expected 5, got 0x%x\n", cpinfo.MaxCharSize); } + memset(cpinfo.LeadByte, '-', ARRAY_SIZE(cpinfo.LeadByte)); SetLastError(0xdeadbeef); ret = GetCPInfo(CP_UTF8, &cpinfo); if (!ret && GetLastError() == ERROR_INVALID_PARAMETER) @@ -3986,11 +3992,15 @@ static void test_GetCPInfo(void) } else { + unsigned int i; + ok(ret, "GetCPInfo(CP_UTF8) error %u\n", GetLastError()); ok(cpinfo.DefaultChar[0] == 0x3f, "expected 0x3f, got 0x%x\n", cpinfo.DefaultChar[0]); ok(cpinfo.DefaultChar[1] == 0, "expected 0, got 0x%x\n", cpinfo.DefaultChar[1]); ok(cpinfo.LeadByte[0] == 0, "expected 0, got 0x%x\n", cpinfo.LeadByte[0]); ok(cpinfo.LeadByte[1] == 0, "expected 0, got 0x%x\n", cpinfo.LeadByte[1]); + for (i = 2; i < sizeof(cpinfo.LeadByte); i++) + todo_wine ok(!cpinfo.LeadByte[i], "expected NUL byte in index %u\n", i); ok(cpinfo.MaxCharSize == 4 || broken(cpinfo.MaxCharSize == 3) /* win9x */, "expected 4, got %u\n", cpinfo.MaxCharSize); }
1
0
0
0
Paul Gofman : advapi32: Improve PerfSetCounterRefValue() stub.
by Alexandre Julliard
22 Nov '21
22 Nov '21
Module: wine Branch: master Commit: 8cfbb1772481db3ff2f615a7706aa503a92d3f71 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=8cfbb1772481db3ff2f615a7…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Mon Nov 22 17:07:59 2021 +0300 advapi32: Improve PerfSetCounterRefValue() stub. Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/advapi32/tests/perf.c | 10 +++++----- dlls/kernelbase/main.c | 24 +++++++++++++++++++++--- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/dlls/advapi32/tests/perf.c b/dlls/advapi32/tests/perf.c index 9236ea8bb75..a0862e65ea4 100644 --- a/dlls/advapi32/tests/perf.c +++ b/dlls/advapi32/tests/perf.c @@ -155,16 +155,16 @@ void test_provider_init(void) ok(size == instance->dwSize, "Got unexpected size %u, instance->dwSize %u.\n", size, instance->dwSize); ret = PerfSetCounterRefValue(prov, instance, 1, &counter1); - todo_wine ok(!ret, "Got unexpected ret %u.\n", ret); + ok(!ret, "Got unexpected ret %u.\n", ret); ret = PerfSetCounterRefValue(prov, instance, 2, &counter2); - todo_wine ok(!ret, "Got unexpected ret %u.\n", ret); + ok(!ret, "Got unexpected ret %u.\n", ret); ret = PerfSetCounterRefValue(prov, instance, 0, &counter2); - todo_wine ok(ret == ERROR_NOT_FOUND, "Got unexpected ret %u.\n", ret); + ok(ret == ERROR_NOT_FOUND, "Got unexpected ret %u.\n", ret); - todo_wine ok(*(void **)(instance + 1) == &counter1, "Got unexpected counter value %p.\n", + ok(*(void **)(instance + 1) == &counter1, "Got unexpected counter value %p.\n", *(void **)(instance + 1)); - todo_wine ok(*(void **)((BYTE *)instance + sizeof(*instance) + sizeof(UINT64)) == &counter2, + ok(*(void **)((BYTE *)instance + sizeof(*instance) + sizeof(UINT64)) == &counter2, "Got unexpected counter value %p.\n", *(void **)(instance + 1)); ret = PerfDeleteInstance(prov, instance); diff --git a/dlls/kernelbase/main.c b/dlls/kernelbase/main.c index d90bedcc637..775c1c2ac07 100644 --- a/dlls/kernelbase/main.c +++ b/dlls/kernelbase/main.c @@ -312,11 +312,29 @@ ULONG WINAPI PerfSetCounterSetInfo( HANDLE handle, PERF_COUNTERSET_INFO *templat /*********************************************************************** * PerfSetCounterRefValue (KERNELBASE.@) */ -ULONG WINAPI PerfSetCounterRefValue(HANDLE provider, PPERF_COUNTERSET_INSTANCE instance, +ULONG WINAPI PerfSetCounterRefValue(HANDLE provider, PERF_COUNTERSET_INSTANCE *instance, ULONG counterid, void *address) { - FIXME("%p %p %u %p: stub\n", provider, instance, counterid, address); - return ERROR_CALL_NOT_IMPLEMENTED; + struct perf_provider *prov = perf_provider_from_handle( provider ); + struct counterset_template *template; + struct counterset_instance *inst; + unsigned int i; + + FIXME( "provider %p, instance %p, counterid %u, address %p semi-stub.\n", + provider, instance, counterid, address ); + + if (!prov || !instance || !address) return ERROR_INVALID_PARAMETER; + + inst = CONTAINING_RECORD(instance, struct counterset_instance, instance); + template = inst->template; + + for (i = 0; i < template->counterset.NumCounters; ++i) + if (template->counter[i].CounterId == counterid) break; + + if (i == template->counterset.NumCounters) return ERROR_NOT_FOUND; + *(void **)((BYTE *)&inst->instance + sizeof(PERF_COUNTERSET_INSTANCE) + template->counter[i].Offset) = address; + + return STATUS_SUCCESS; } /***********************************************************************
1
0
0
0
Paul Gofman : advapi32: Improve PerfCreateInstance() stub.
by Alexandre Julliard
22 Nov '21
22 Nov '21
Module: wine Branch: master Commit: eec443afc262c239c36052689431044072d28100 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=eec443afc262c239c3605268…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Mon Nov 22 17:07:58 2021 +0300 advapi32: Improve PerfCreateInstance() stub. Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/advapi32/tests/perf.c | 63 ++++++++++++++++++++++++++-- dlls/kernelbase/main.c | 102 +++++++++++++++++++++++++++++++++++++++++---- include/perflib.h | 3 ++ 3 files changed, 157 insertions(+), 11 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=eec443afc262c239c360…
1
0
0
0
Paul Gofman : advapi32: Improve PerfSetCounterSetInfo() stub.
by Alexandre Julliard
22 Nov '21
22 Nov '21
Module: wine Branch: master Commit: ee8af8ff280389aa9188505e7c9a60c72d4e30dd URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ee8af8ff280389aa9188505e…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Mon Nov 22 17:07:57 2021 +0300 advapi32: Improve PerfSetCounterSetInfo() stub. Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/advapi32/tests/perf.c | 39 ++++++++++++++++++++++++++++++++++ dlls/kernelbase/main.c | 52 +++++++++++++++++++++++++++++++++++++++++++--- include/perflib.h | 31 +++++++++++++++++++++++++++ include/winperf.h | 29 ++++++++++++++++++++++++++ 4 files changed, 148 insertions(+), 3 deletions(-) diff --git a/dlls/advapi32/tests/perf.c b/dlls/advapi32/tests/perf.c index 34fedd2b645..d76d6ddd44a 100644 --- a/dlls/advapi32/tests/perf.c +++ b/dlls/advapi32/tests/perf.c @@ -24,6 +24,7 @@ #include "winbase.h" #include "winerror.h" #include "perflib.h" +#include "winperf.h" #include "wine/test.h" @@ -35,7 +36,20 @@ static ULONG WINAPI test_provider_callback(ULONG code, void *buffer, ULONG size) void test_provider_init(void) { + static GUID test_set_guid = {0xdeadbeef, 0x0002, 0x0003, {0x0f, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00 ,0x0a}}; + static GUID test_set_guid2 = {0xdeadbeef, 0x0003, 0x0003, {0x0f, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00 ,0x0a}}; static GUID test_guid = {0xdeadbeef, 0x0001, 0x0002, {0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00 ,0x0a}}; + static struct + { + PERF_COUNTERSET_INFO counterset; + PERF_COUNTER_INFO counter; + } + pc_template = + { + {{0}}, + {1, PERF_COUNTER_COUNTER, PERF_ATTRIB_BY_REFERENCE, sizeof(PERF_COUNTER_INFO), PERF_DETAIL_NOVICE, 0, 0}, + }; + PERF_PROVIDER_CONTEXT prov_context; HANDLE prov, prov2; ULONG ret; @@ -76,6 +90,31 @@ void test_provider_init(void) bret = IsBadWritePtr(prov, 8); ok(!bret, "Handle does not point to the data.\n"); + pc_template.counterset.CounterSetGuid = test_set_guid; + pc_template.counterset.ProviderGuid = test_guid; + pc_template.counterset.NumCounters = 0; + pc_template.counterset.InstanceType = PERF_COUNTERSET_SINGLE_INSTANCE; + ret = PerfSetCounterSetInfo(prov, &pc_template.counterset, sizeof(pc_template.counterset)); + ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %u.\n", ret); + + pc_template.counterset.CounterSetGuid = test_set_guid; + pc_template.counterset.ProviderGuid = test_guid; + pc_template.counterset.NumCounters = 1; + pc_template.counterset.InstanceType = PERF_COUNTERSET_SINGLE_INSTANCE; + ret = PerfSetCounterSetInfo(prov, &pc_template.counterset, sizeof(pc_template)); + ok(!ret, "Got unexpected ret %u.\n", ret); + + pc_template.counterset.CounterSetGuid = test_set_guid2; + /* Looks like ProviderGuid doesn't need to match provider. */ + pc_template.counterset.ProviderGuid = test_set_guid; + pc_template.counterset.NumCounters = 1; + pc_template.counterset.InstanceType = PERF_COUNTERSET_SINGLE_INSTANCE; + ret = PerfSetCounterSetInfo(prov, &pc_template.counterset, sizeof(pc_template)); + ok(!ret, "Got unexpected ret %u.\n", ret); + + ret = PerfSetCounterSetInfo(prov, &pc_template.counterset, sizeof(pc_template)); + ok(ret == ERROR_ALREADY_EXISTS, "Got unexpected ret %u.\n", ret); + ret = PerfStopProvider(prov); ok(!ret, "Got unexpected ret %u.\n", ret); diff --git a/dlls/kernelbase/main.c b/dlls/kernelbase/main.c index d468c84f619..403c0cf6cd2 100644 --- a/dlls/kernelbase/main.c +++ b/dlls/kernelbase/main.c @@ -154,10 +154,18 @@ LONG WINAPI AppPolicyGetWindowingModel(HANDLE token, AppPolicyWindowingModel *po return ERROR_SUCCESS; } +struct counterset_template +{ + PERF_COUNTERSET_INFO counterset; + PERF_COUNTER_INFO counter[1]; +}; + struct perf_provider { GUID guid; PERFLIBREQUEST callback; + struct counterset_template **countersets; + unsigned int counterset_count; }; static struct perf_provider *perf_provider_from_handle(HANDLE prov) @@ -187,10 +195,44 @@ ULONG WINAPI PerfDeleteInstance(HANDLE provider, PPERF_COUNTERSET_INSTANCE block /*********************************************************************** * PerfSetCounterSetInfo (KERNELBASE.@) */ -ULONG WINAPI PerfSetCounterSetInfo(HANDLE handle, PPERF_COUNTERSET_INFO template, ULONG size) +ULONG WINAPI PerfSetCounterSetInfo( HANDLE handle, PERF_COUNTERSET_INFO *template, ULONG size ) { - FIXME("%p %p %u: stub\n", handle, template, size); - return ERROR_CALL_NOT_IMPLEMENTED; + struct perf_provider *prov = perf_provider_from_handle( handle ); + struct counterset_template **new_array; + struct counterset_template *new; + unsigned int i; + + FIXME( "handle %p, template %p, size %u semi-stub.\n", handle, template, size ); + + if (!prov || !template) return ERROR_INVALID_PARAMETER; + if (!template->NumCounters) return ERROR_INVALID_PARAMETER; + if (size < sizeof(*template) || (size - (sizeof(*template))) / sizeof(PERF_COUNTER_INFO) < template->NumCounters) + return ERROR_INVALID_PARAMETER; + + for (i = 0; i < prov->counterset_count; ++i) + { + if (IsEqualGUID( &template->CounterSetGuid, &prov->countersets[i]->counterset.CounterSetGuid )) + return ERROR_ALREADY_EXISTS; + } + + size = offsetof( struct counterset_template, counter[template->NumCounters] ); + if (!(new = heap_alloc( size ))) return ERROR_OUTOFMEMORY; + + if (prov->counterset_count) + new_array = heap_realloc( prov->countersets, sizeof(*prov->countersets) * (prov->counterset_count + 1) ); + else + new_array = heap_alloc( sizeof(*prov->countersets) ); + + if (!new_array) + { + heap_free( new ); + return ERROR_OUTOFMEMORY; + } + memcpy( new, template, size ); + new_array[prov->counterset_count++] = new; + prov->countersets = new_array; + + return STATUS_SUCCESS; } /*********************************************************************** @@ -245,9 +287,13 @@ ULONG WINAPI PerfStartProviderEx( GUID *guid, PERF_PROVIDER_CONTEXT *context, HA ULONG WINAPI PerfStopProvider(HANDLE handle) { struct perf_provider *prov = perf_provider_from_handle( handle ); + unsigned int i; TRACE( "handle %p.\n", handle ); + for (i = 0; i < prov->counterset_count; ++i) + heap_free( prov->countersets[i] ); + heap_free( prov->countersets ); heap_free( prov ); return STATUS_SUCCESS; } diff --git a/include/perflib.h b/include/perflib.h index 47bc0716541..5a2a1162ae7 100644 --- a/include/perflib.h +++ b/include/perflib.h @@ -34,6 +34,19 @@ typedef struct _PERF_COUNTERSET_INFO { ULONG InstanceType; } PERF_COUNTERSET_INFO, * PPERF_COUNTERSET_INFO; +/* PERF_COUNTERSET_INFO InstanceType values. */ +#define PERF_COUNTERSET_FLAG_MULTIPLE 0x00000002 +#define PERF_COUNTERSET_FLAG_AGGREGATE 0x00000004 +#define PERF_COUNTERSET_FLAG_HISTORY 0x00000008 +#define PERF_COUNTERSET_FLAG_INSTANCE 0x00000010 + +#define PERF_COUNTERSET_SINGLE_INSTANCE 0 +#define PERF_COUNTERSET_MULTI_INSTANCES PERF_COUNTERSET_FLAG_MULTIPLE +#define PERF_COUNTERSET_SINGLE_AGGREGATE PERF_COUNTERSET_FLAG_AGGREGATE +#define PERF_COUNTERSET_MULTI_AGGREGATE (PERF_COUNTERSET_FLAG_AGGREGATE | PERF_COUNTERSET_FLAG_MULTIPLE) +#define PERF_COUNTERSET_SINGLE_AGGREGATE_HISTORY (PERF_COUNTERSET_FLAG_HISTORY | PERF_COUNTERSET_SINGLE_AGGREGATE) +#define PERF_COUNTERSET_INSTANCE_AGGREGATE (PERF_COUNTERSET_MULTI_AGGREGATE | PERF_COUNTERSET_FLAG_INSTANCE) + typedef struct _PERF_COUNTERSET_INSTANCE { GUID CounterSetGuid; ULONG dwSize; @@ -42,6 +55,23 @@ typedef struct _PERF_COUNTERSET_INSTANCE { ULONG InstanceNameSize; } PERF_COUNTERSET_INSTANCE, * PPERF_COUNTERSET_INSTANCE; +typedef struct _PERF_COUNTER_INFO { + ULONG CounterId; + ULONG Type; + ULONGLONG Attrib; + ULONG Size; + ULONG DetailLevel; + LONG Scale; + ULONG Offset; +} PERF_COUNTER_INFO, *PPERF_COUNTER_INFO; + +/* PERF_COUNTER_INFO Attrib flags. */ +#define PERF_ATTRIB_BY_REFERENCE 0x00000001 +#define PERF_ATTRIB_NO_DISPLAYABLE 0x00000002 +#define PERF_ATTRIB_NO_GROUP_SEPARATOR 0x00000004 +#define PERF_ATTRIB_DISPLAY_AS_REAL 0x00000008 +#define PERF_ATTRIB_DISPLAY_AS_HEX 0x00000010 + typedef struct _PROVIDER_CONTEXT { DWORD ContextSize; DWORD Reserved; @@ -51,6 +81,7 @@ typedef struct _PROVIDER_CONTEXT { LPVOID pMemContext; } PERF_PROVIDER_CONTEXT, * PPERF_PROVIDER_CONTEXT; +ULONG WINAPI PerfSetCounterSetInfo(HANDLE, PERF_COUNTERSET_INFO *, ULONG); ULONG WINAPI PerfStartProvider(GUID *, PERFLIBREQUEST, HANDLE *); ULONG WINAPI PerfStartProviderEx(GUID *, PERF_PROVIDER_CONTEXT *, HANDLE *); ULONG WINAPI PerfStopProvider(HANDLE); diff --git a/include/winperf.h b/include/winperf.h index 113bfbae40f..926da8f8c4a 100644 --- a/include/winperf.h +++ b/include/winperf.h @@ -161,6 +161,35 @@ typedef struct _PERF_COUNTER_BLOCK DWORD ByteLength; } PERF_COUNTER_BLOCK, *PPERF_COUNTER_BLOCK; +#define PERF_COUNTER_VALUE 0x00000000 +#define PERF_COUNTER_RATE 0x00010000 +#define PERF_COUNTER_FRACTION 0x00020000 +#define PERF_COUNTER_BASE 0x00030000 +#define PERF_COUNTER_ELAPSED 0x00040000 +#define PERF_COUNTER_QUEUELEN 0x00050000 +#define PERF_COUNTER_HISTOGRAM 0x00060000 +#define PERF_COUNTER_PRECISION 0x00070000 + +#define PERF_TEXT_UNICODE 0x00000000 +#define PERF_TEXT_ASCII 0x00010000 + +#define PERF_TIMER_TICK 0x00000000 +#define PERF_TIMER_100NS 0x00100000 +#define PERF_OBJECT_TIMER 0x00200000 + +#define PERF_DELTA_COUNTER 0x00400000 +#define PERF_DELTA_BASE 0x00800000 +#define PERF_INVERSE_COUNTER 0x01000000 +#define PERF_MULTI_COUNTER 0x02000000 + +#define PERF_DISPLAY_NO_SUFFIX 0x00000000 +#define PERF_DISPLAY_PER_SEC 0x10000000 +#define PERF_DISPLAY_PERCENT 0x20000000 +#define PERF_DISPLAY_SECONDS 0x30000000 +#define PERF_DISPLAY_NOSHOW 0x40000000 + +#define PERF_COUNTER_COUNTER (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | \ + PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PER_SEC) #include <poppack.h>
1
0
0
0
Paul Gofman : advapi32: Improve perflib provider registration stubs.
by Alexandre Julliard
22 Nov '21
22 Nov '21
Module: wine Branch: master Commit: e843605b238a754c819f0a1f80242ee7f35deda1 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e843605b238a754c819f0a1f…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Mon Nov 22 17:07:56 2021 +0300 advapi32: Improve perflib provider registration stubs. Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/advapi32/tests/Makefile.in | 1 + dlls/advapi32/tests/perf.c | 100 ++++++++++++++++++++++++++++++++++++++++ dlls/kernelbase/main.c | 49 ++++++++++++++++---- include/perflib.h | 4 ++ 4 files changed, 146 insertions(+), 8 deletions(-) diff --git a/dlls/advapi32/tests/Makefile.in b/dlls/advapi32/tests/Makefile.in index 12583e59f57..2e9b007a91f 100644 --- a/dlls/advapi32/tests/Makefile.in +++ b/dlls/advapi32/tests/Makefile.in @@ -10,6 +10,7 @@ C_SRCS = \ crypt_sha.c \ eventlog.c \ lsa.c \ + perf.c \ registry.c \ security.c \ service.c diff --git a/dlls/advapi32/tests/perf.c b/dlls/advapi32/tests/perf.c new file mode 100644 index 00000000000..34fedd2b645 --- /dev/null +++ b/dlls/advapi32/tests/perf.c @@ -0,0 +1,100 @@ +/* + * Unit tests for Perflib functions + * + * Copyright (c) 2021 Paul Gofman for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#include "winerror.h" +#include "perflib.h" + +#include "wine/test.h" + +static ULONG WINAPI test_provider_callback(ULONG code, void *buffer, ULONG size) +{ + ok(0, "Provider callback called.\n"); + return ERROR_SUCCESS; +} + +void test_provider_init(void) +{ + static GUID test_guid = {0xdeadbeef, 0x0001, 0x0002, {0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00 ,0x0a}}; + PERF_PROVIDER_CONTEXT prov_context; + HANDLE prov, prov2; + ULONG ret; + BOOL bret; + + prov = (HANDLE)0xdeadbeef; + ret = PerfStartProvider(NULL, test_provider_callback, &prov); + ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %u.\n", ret); + ok(prov == (HANDLE)0xdeadbeef, "Got unexpected prov %p.\n", prov); + + prov = (HANDLE)0xdeadbeef; + ret = PerfStartProvider(&test_guid, test_provider_callback, NULL); + ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %u.\n", ret); + ok(prov == (HANDLE)0xdeadbeef, "Got unexpected prov %p.\n", prov); + + prov = (HANDLE)0xdeadbeef; + ret = PerfStartProvider(&test_guid, test_provider_callback, &prov); + ok(!ret, "Got unexpected ret %u.\n", ret); + ok(prov != (HANDLE)0xdeadbeef, "Provider handle is not set.\n"); + + prov2 = prov; + ret = PerfStartProvider(&test_guid, test_provider_callback, &prov2); + ok(!ret, "Got unexpected ret %u.\n", ret); + ok(prov2 != prov, "Got the same provider handle.\n"); + + ret = PerfStopProvider(prov2); + ok(!ret, "Got unexpected ret %u.\n", ret); + + if (0) + { + /* Access violation on Windows. */ + PerfStopProvider(prov2); + } + + /* Provider handle is a pointer and not a kernel object handle. */ + bret = DuplicateHandle(GetCurrentProcess(), prov, GetCurrentProcess(), &prov2, 0, FALSE, DUPLICATE_SAME_ACCESS); + ok(!bret && GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected bret %d, err %u.\n", bret, GetLastError()); + bret = IsBadWritePtr(prov, 8); + ok(!bret, "Handle does not point to the data.\n"); + + ret = PerfStopProvider(prov); + ok(!ret, "Got unexpected ret %u.\n", ret); + + memset( &prov_context, 0, sizeof(prov_context) ); + prov = (HANDLE)0xdeadbeef; + ret = PerfStartProviderEx( &test_guid, &prov_context, &prov ); + ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %u.\n", ret); + ok(prov == (HANDLE)0xdeadbeef, "Got unexpected prov %p.\n", prov); + + prov_context.ContextSize = sizeof(prov_context) + 1; + ret = PerfStartProviderEx( &test_guid, &prov_context, &prov ); + ok(!ret, "Got unexpected ret %u.\n", ret); + ok(prov != (HANDLE)0xdeadbeef, "Provider handle is not set.\n"); + + ret = PerfStopProvider(prov); + ok(!ret, "Got unexpected ret %u.\n", ret); +} + +START_TEST(perf) +{ + test_provider_init(); +} diff --git a/dlls/kernelbase/main.c b/dlls/kernelbase/main.c index e6cf892a4dc..d468c84f619 100644 --- a/dlls/kernelbase/main.c +++ b/dlls/kernelbase/main.c @@ -154,6 +154,17 @@ LONG WINAPI AppPolicyGetWindowingModel(HANDLE token, AppPolicyWindowingModel *po return ERROR_SUCCESS; } +struct perf_provider +{ + GUID guid; + PERFLIBREQUEST callback; +}; + +static struct perf_provider *perf_provider_from_handle(HANDLE prov) +{ + return (struct perf_provider *)prov; +} + /*********************************************************************** * PerfCreateInstance (KERNELBASE.@) */ @@ -195,19 +206,37 @@ ULONG WINAPI PerfSetCounterRefValue(HANDLE provider, PPERF_COUNTERSET_INSTANCE i /*********************************************************************** * PerfStartProvider (KERNELBASE.@) */ -ULONG WINAPI PerfStartProvider(GUID *guid, PERFLIBREQUEST callback, HANDLE *provider) +ULONG WINAPI PerfStartProvider( GUID *guid, PERFLIBREQUEST callback, HANDLE *provider ) { - FIXME("%s %p %p: stub\n", debugstr_guid(guid), callback, provider); - return ERROR_CALL_NOT_IMPLEMENTED; + PERF_PROVIDER_CONTEXT ctx; + + FIXME( "guid %s, callback %p, provider %p semi-stub.\n", debugstr_guid(guid), callback, provider ); + + memset( &ctx, 0, sizeof(ctx) ); + ctx.ContextSize = sizeof(ctx); + ctx.ControlCallback = callback; + + return PerfStartProviderEx( guid, &ctx, provider ); } /*********************************************************************** * PerfStartProviderEx (KERNELBASE.@) */ -ULONG WINAPI PerfStartProviderEx(GUID *guid, PPERF_PROVIDER_CONTEXT context, HANDLE *provider) +ULONG WINAPI PerfStartProviderEx( GUID *guid, PERF_PROVIDER_CONTEXT *context, HANDLE *provider ) { - FIXME("%s %p %p: stub\n", debugstr_guid(guid), context, provider); - return ERROR_CALL_NOT_IMPLEMENTED; + struct perf_provider *prov; + + FIXME( "guid %s, context %p, provider %p semi-stub.\n", debugstr_guid(guid), context, provider ); + + if (!guid || !context || !provider) return ERROR_INVALID_PARAMETER; + if (context->ContextSize < sizeof(*context)) return ERROR_INVALID_PARAMETER; + + if (!(prov = heap_alloc_zero( sizeof(*prov) ))) return ERROR_OUTOFMEMORY; + memcpy( &prov->guid, guid, sizeof(prov->guid) ); + prov->callback = context->ControlCallback; + *provider = prov; + + return STATUS_SUCCESS; } /*********************************************************************** @@ -215,8 +244,12 @@ ULONG WINAPI PerfStartProviderEx(GUID *guid, PPERF_PROVIDER_CONTEXT context, HAN */ ULONG WINAPI PerfStopProvider(HANDLE handle) { - FIXME("%p: stub\n", handle); - return ERROR_CALL_NOT_IMPLEMENTED; + struct perf_provider *prov = perf_provider_from_handle( handle ); + + TRACE( "handle %p.\n", handle ); + + heap_free( prov ); + return STATUS_SUCCESS; } /*********************************************************************** diff --git a/include/perflib.h b/include/perflib.h index 2d3f6efb419..47bc0716541 100644 --- a/include/perflib.h +++ b/include/perflib.h @@ -51,6 +51,10 @@ typedef struct _PROVIDER_CONTEXT { LPVOID pMemContext; } PERF_PROVIDER_CONTEXT, * PPERF_PROVIDER_CONTEXT; +ULONG WINAPI PerfStartProvider(GUID *, PERFLIBREQUEST, HANDLE *); +ULONG WINAPI PerfStartProviderEx(GUID *, PERF_PROVIDER_CONTEXT *, HANDLE *); +ULONG WINAPI PerfStopProvider(HANDLE); + #ifdef __cplusplus } /* extern "C" */ #endif
1
0
0
0
Zebediah Figura : win32u: Do not free user memory when deleting dibs created with NtGdiDdDDICreateDCFromMemory().
by Alexandre Julliard
22 Nov '21
22 Nov '21
Module: wine Branch: master Commit: 220b0a7c060e71a7a414cd89542769451274e873 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=220b0a7c060e71a7a414cd89…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Fri Nov 19 18:30:51 2021 -0600 win32u: Do not free user memory when deleting dibs created with NtGdiDdDDICreateDCFromMemory(). This fixes a test crash in ddraw:ddraw1 introduced by 7d2a7b94aad8a776a2ee3031a18bb3b53d5925cd. Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/gdi32/tests/bitmap.c | 6 +++--- dlls/win32u/dib.c | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index a244414660b..93793ad7108 100644 --- a/dlls/gdi32/tests/bitmap.c +++ b/dlls/gdi32/tests/bitmap.c @@ -5969,11 +5969,11 @@ static void test_D3DKMTCreateDCFromMemory( void ) size = VirtualQuery( alloc_data, &memory_info, sizeof(memory_info) ); ok(size == sizeof(memory_info), "Got unexpected size %u.\n", size); - todo_wine ok(memory_info.State == MEM_COMMIT, "Got state %#x.\n", memory_info.State); - todo_wine ok(memory_info.Protect == PAGE_READWRITE, "Got protection %#x.\n", memory_info.Protect); + ok(memory_info.State == MEM_COMMIT, "Got state %#x.\n", memory_info.State); + ok(memory_info.Protect == PAGE_READWRITE, "Got protection %#x.\n", memory_info.Protect); ret = VirtualFree( alloc_data, 0, MEM_RELEASE ); - todo_wine ok(ret, "Failed to free memory, error %u.\n", GetLastError()); + ok(ret, "Failed to free memory, error %u.\n", GetLastError()); } START_TEST(bitmap) diff --git a/dlls/win32u/dib.c b/dlls/win32u/dib.c index b27b341d470..ee82d1a8ed8 100644 --- a/dlls/win32u/dib.c +++ b/dlls/win32u/dib.c @@ -1574,6 +1574,24 @@ error: } +static BOOL memory_dib_DeleteObject( HGDIOBJ handle ) +{ + BITMAPOBJ *bmp; + + if (!(bmp = free_gdi_handle( handle ))) return FALSE; + + free( bmp->color_table ); + free( bmp ); + return TRUE; +} + + +static const struct gdi_obj_funcs memory_dib_funcs = +{ + .pGetObjectW = DIB_GetObject, + .pDeleteObject = memory_dib_DeleteObject, +}; + /*********************************************************************** * NtGdiDdDDICreateDCFromMemory (win32u.@) */ @@ -1673,7 +1691,7 @@ NTSTATUS WINAPI NtGdiDdDDICreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc ) } } - if (!(bitmap = alloc_gdi_handle( &bmp->obj, NTGDI_OBJ_BITMAP, &dib_funcs ))) goto error; + if (!(bitmap = alloc_gdi_handle( &bmp->obj, NTGDI_OBJ_BITMAP, &memory_dib_funcs ))) goto error; desc->hDc = dc; desc->hBitmap = bitmap;
1
0
0
0
← Newer
1
...
21
22
23
24
25
26
27
...
96
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Results per page:
10
25
50
100
200