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 2018
----- 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
Nikolay Sivov : shcore: Add SHCreateThread().
by Alexandre Julliard
28 Nov '18
28 Nov '18
Module: wine Branch: master Commit: e44a4173cd3ce2ec8034635caa2a0c2f31d5e988 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e44a4173cd3ce2ec8034635c…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Wed Nov 28 09:59:02 2018 +0300 shcore: Add SHCreateThread(). Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/shcore/main.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++++ dlls/shcore/shcore.spec | 2 +- 2 files changed, 120 insertions(+), 1 deletion(-) diff --git a/dlls/shcore/main.c b/dlls/shcore/main.c index 488e78e..93effef 100644 --- a/dlls/shcore/main.c +++ b/dlls/shcore/main.c @@ -28,6 +28,7 @@ #include "initguid.h" #include "ocidl.h" #include "shellscalingapi.h" +#include "shlwapi.h" #include "wine/debug.h" #include "wine/heap.h" @@ -1290,3 +1291,121 @@ void WINAPI SetProcessReference(IUnknown *obj) process_ref = obj; } + +struct thread_data +{ + LPTHREAD_START_ROUTINE thread_proc; + LPTHREAD_START_ROUTINE callback; + void *data; + DWORD flags; + HANDLE hEvent; + IUnknown *thread_ref; + IUnknown *process_ref; +}; + +static DWORD WINAPI shcore_thread_wrapper(void *data) +{ + struct thread_data thread_data; + HRESULT hr = E_FAIL; + DWORD retval; + + TRACE("(%p)\n", data); + + /* We are now executing in the context of the newly created thread. + * So we copy the data passed to us (it is on the stack of the function + * that called us, which is waiting for us to signal an event before + * returning). */ + thread_data = *(struct thread_data *)data; + + if (thread_data.flags & CTF_COINIT) + { + hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + if (FAILED(hr)) + hr = CoInitializeEx(NULL, COINIT_DISABLE_OLE1DDE); + } + + if (thread_data.callback) + thread_data.callback(thread_data.data); + + /* Signal the thread that created us; it can return now. */ + SetEvent(thread_data.hEvent); + + /* Execute the callers start code. */ + retval = thread_data.thread_proc(thread_data.data); + + /* Release thread and process references. */ + if (thread_data.thread_ref) + IUnknown_Release(thread_data.thread_ref); + + if (thread_data.process_ref) + IUnknown_Release(thread_data.process_ref); + + if (SUCCEEDED(hr)) + CoUninitialize(); + + return retval; +} + +/************************************************************************* + * SHCreateThread [SHCORE.@] + */ +BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE thread_proc, void *data, DWORD flags, LPTHREAD_START_ROUTINE callback) +{ + struct thread_data thread_data; + BOOL called = FALSE; + + TRACE("(%p, %p, %#x, %p)\n", thread_proc, data, flags, callback); + + thread_data.thread_proc = thread_proc; + thread_data.callback = callback; + thread_data.data = data; + thread_data.flags = flags; + thread_data.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); + + if (flags & CTF_THREAD_REF) + SHGetThreadRef(&thread_data.thread_ref); + else + thread_data.thread_ref = NULL; + + if (flags & CTF_PROCESS_REF) + GetProcessReference(&thread_data.process_ref); + else + thread_data.process_ref = NULL; + + /* Create the thread */ + if (thread_data.hEvent) + { + HANDLE hThread; + DWORD retval; + + hThread = CreateThread(NULL, 0, shcore_thread_wrapper, &thread_data, 0, &retval); + if (hThread) + { + /* Wait for the thread to signal us to continue */ + WaitForSingleObject(thread_data.hEvent, INFINITE); + CloseHandle(hThread); + called = TRUE; + } + CloseHandle(thread_data.hEvent); + } + + if (!called) + { + if (!thread_data.callback && flags & CTF_INSIST) + { + /* Couldn't call, call synchronously */ + thread_data.thread_proc(data); + called = TRUE; + } + else + { + if (thread_data.thread_ref) + IUnknown_Release(thread_data.thread_ref); + + if (thread_data.process_ref) + IUnknown_Release(thread_data.process_ref); + } + } + + return called; +} diff --git a/dlls/shcore/shcore.spec b/dlls/shcore/shcore.spec index c98f2db..a08c2da 100644 --- a/dlls/shcore/shcore.spec +++ b/dlls/shcore/shcore.spec @@ -37,7 +37,7 @@ @ stdcall SHCreateStreamOnFileA(str long ptr) @ stdcall SHCreateStreamOnFileEx(wstr long long long ptr ptr) @ stdcall SHCreateStreamOnFileW(wstr long ptr) -@ stdcall SHCreateThread(ptr ptr long ptr) shlwapi.SHCreateThread +@ stdcall SHCreateThread(ptr ptr long ptr) @ stdcall SHCreateThreadRef(ptr ptr) @ stub SHCreateThreadWithHandle @ stdcall SHDeleteEmptyKeyA(long ptr) shlwapi.SHDeleteEmptyKeyA
1
0
0
0
Dmitry Timoshkov : user32: If there is no dialog controls to set focus to then set focus to dialog itself.
by Alexandre Julliard
28 Nov '18
28 Nov '18
Module: wine Branch: master Commit: 44f89322ba8825a8e4851aaaf7de89910701ca75 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=44f89322ba8825a8e4851aaa…
Author: Dmitry Timoshkov <dmitry(a)baikal.ru> Date: Wed Nov 28 09:03:15 2018 +0300 user32: If there is no dialog controls to set focus to then set focus to dialog itself. Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/dialog.c | 2 ++ dlls/user32/tests/msg.c | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c index c47bd57..0b33a57 100644 --- a/dlls/user32/dialog.c +++ b/dlls/user32/dialog.c @@ -691,6 +691,8 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate, SendMessageW( focus, EM_SETSEL, 0, MAXLONG ); SetFocus( focus ); } + else + SetFocus( hwnd ); } } diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 2fdb118..366a138 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -13574,10 +13574,12 @@ static const struct message WmCreateDialogParamSeq_1[] = { { WM_MOVE, sent }, { WM_SETFONT, sent }, { WM_INITDIALOG, sent }, - { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 }, + { WM_GETDLGCODE, sent|wparam|lparam|optional, 0, 0 }, /* FIXME: Wine doesn't send it */ { HCBT_SETFOCUS, hook }, { HCBT_ACTIVATE, hook }, - { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE }, + { WM_QUERYNEWPALETTE, sent|optional }, + { WM_PALETTEISCHANGING, sent|optional }, + { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, { WM_ACTIVATEAPP, sent|wparam, 1 }, { WM_NCACTIVATE, sent }, { WM_ACTIVATE, sent|wparam, 1 }, @@ -13760,9 +13762,8 @@ static void test_dialog_messages(void) flush_sequence(); hdlg = CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 1); ok(IsWindow(hdlg), "CreateDialogParam failed\n"); - ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", TRUE); + ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", FALSE); hfocus = GetFocus(); -todo_wine ok(hfocus == hdlg, "wrong focus %p\n", hfocus); EndDialog(hdlg, 0); DestroyWindow(hdlg);
1
0
0
0
Dmitry Timoshkov : user32/tests: Add a focus test for an empty dialog that returns TRUE in WM_INITDIALOG.
by Alexandre Julliard
28 Nov '18
28 Nov '18
Module: wine Branch: master Commit: 87d194dd1de7ab1473a805a8d4c5602a8d2d2f53 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=87d194dd1de7ab1473a805a8…
Author: Dmitry Timoshkov <dmitry(a)baikal.ru> Date: Wed Nov 28 09:03:11 2018 +0300 user32/tests: Add a focus test for an empty dialog that returns TRUE in WM_INITDIALOG. Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/tests/msg.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index f78858f..2fdb118 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -13440,6 +13440,8 @@ static INT_PTR WINAPI test_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPAR switch (message) { case WM_INITDIALOG: + return lParam; + case WM_GETDLGCODE: return 0; } @@ -13548,6 +13550,20 @@ static const struct message WmDefDlgSetFocus_2[] = { { 0 } }; /* Creation of a dialog */ +static const struct message WmCreateDialogParamSeq_0[] = { + { HCBT_CREATEWND, hook }, + { WM_NCCREATE, sent }, + { WM_NCCALCSIZE, sent|wparam, 0 }, + { WM_CREATE, sent }, + { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 }, + { WM_SIZE, sent|wparam, SIZE_RESTORED }, + { WM_MOVE, sent }, + { WM_SETFONT, sent }, + { WM_INITDIALOG, sent }, + { WM_CHANGEUISTATE, sent|optional }, + { 0 } +}; +/* Creation of a dialog */ static const struct message WmCreateDialogParamSeq_1[] = { { HCBT_CREATEWND, hook }, { WM_NCCREATE, sent }, @@ -13558,6 +13574,14 @@ static const struct message WmCreateDialogParamSeq_1[] = { { WM_MOVE, sent }, { WM_SETFONT, sent }, { WM_INITDIALOG, sent }, + { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 }, + { HCBT_SETFOCUS, hook }, + { HCBT_ACTIVATE, hook }, + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE }, + { WM_ACTIVATEAPP, sent|wparam, 1 }, + { WM_NCACTIVATE, sent }, + { WM_ACTIVATE, sent|wparam, 1 }, + { WM_SETFOCUS, sent }, { WM_CHANGEUISTATE, sent|optional }, { 0 } }; @@ -13721,9 +13745,25 @@ static void test_dialog_messages(void) cls.lpfnWndProc = test_dlg_proc; if (!RegisterClassA(&cls)) assert(0); + SetFocus(0); + flush_sequence(); hdlg = CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 0); ok(IsWindow(hdlg), "CreateDialogParam failed\n"); - ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", FALSE); + ok_sequence(WmCreateDialogParamSeq_0, "CreateDialogParam_0", FALSE); + hfocus = GetFocus(); + ok(hfocus == 0, "wrong focus %p\n", hfocus); + EndDialog(hdlg, 0); + DestroyWindow(hdlg); + flush_sequence(); + + SetFocus(0); + flush_sequence(); + hdlg = CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 1); + ok(IsWindow(hdlg), "CreateDialogParam failed\n"); + ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", TRUE); + hfocus = GetFocus(); +todo_wine + ok(hfocus == hdlg, "wrong focus %p\n", hfocus); EndDialog(hdlg, 0); DestroyWindow(hdlg); flush_sequence();
1
0
0
0
Zebediah Figura : setupapi: Avoid unnecessary buffer allocation in SETUPDI_EnumerateMatchingDeviceInstances ().
by Alexandre Julliard
28 Nov '18
28 Nov '18
Module: wine Branch: master Commit: 0c0aa90a907f8cfeca47c2dc965f1642f05f502e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=0c0aa90a907f8cfeca47c2dc…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Tue Nov 27 19:55:38 2018 -0600 setupapi: Avoid unnecessary buffer allocation in SETUPDI_EnumerateMatchingDeviceInstances(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/setupapi/devinst.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index ff7aca0..55fca89 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -2083,6 +2083,7 @@ static void SETUPDI_EnumerateMatchingDeviceInstances(struct DeviceInfoSet *set, LPCWSTR enumerator, LPCWSTR deviceName, HKEY deviceKey, const GUID *class, DWORD flags) { + WCHAR id[MAX_DEVICE_ID_LEN]; DWORD i, len; WCHAR deviceInstance[MAX_PATH]; LONG l = ERROR_SUCCESS; @@ -2120,18 +2121,11 @@ static void SETUPDI_EnumerateMatchingDeviceInstances(struct DeviceInfoSet *set, { static const WCHAR fmt[] = {'%','s','\\','%','s','\\','%','s',0}; - LPWSTR instanceId; - instanceId = HeapAlloc(GetProcessHeap(), 0, - (lstrlenW(enumerator) + lstrlenW(deviceName) + - lstrlenW(deviceInstance) + 3) * sizeof(WCHAR)); - if (instanceId) + if (snprintfW(id, ARRAY_SIZE(id), fmt, enumerator, + deviceName, deviceInstance) != -1) { - sprintfW(instanceId, fmt, enumerator, - deviceName, deviceInstance); - SETUPDI_CreateDeviceInfo(set, &deviceClass, - instanceId, FALSE); - HeapFree(GetProcessHeap(), 0, instanceId); + SETUPDI_CreateDeviceInfo(set, &deviceClass, id, FALSE); } } }
1
0
0
0
Zebediah Figura : setupapi: Avoid unnecessary buffer allocation in SetupDiCreateDeviceInfoW().
by Alexandre Julliard
28 Nov '18
28 Nov '18
Module: wine Branch: master Commit: 462c74bcdb070caab87d33777a4b69accedd02d3 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=462c74bcdb070caab87d3377…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Tue Nov 27 19:55:37 2018 -0600 setupapi: Avoid unnecessary buffer allocation in SetupDiCreateDeviceInfoW(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/setupapi/devinst.c | 132 +++++++++++++++++++++--------------------------- 1 file changed, 58 insertions(+), 74 deletions(-) diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index be7ce64..ff7aca0 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -1394,19 +1394,18 @@ static DWORD SETUPDI_DevNameToDevID(LPCWSTR devName) /*********************************************************************** * SetupDiCreateDeviceInfoW (SETUPAPI.@) */ -BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, PCWSTR DeviceName, - const GUID *ClassGuid, PCWSTR DeviceDescription, HWND hwndParent, DWORD CreationFlags, - SP_DEVINFO_DATA *device_data) +BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, const WCHAR *name, const GUID *class, + const WCHAR *description, HWND parent, DWORD flags, SP_DEVINFO_DATA *device_data) { + WCHAR id[MAX_DEVICE_ID_LEN]; struct DeviceInfoSet *set; - BOOL ret = FALSE, allocatedInstanceId = FALSE; - LPCWSTR instanceId = NULL; + struct device *device; TRACE("devinfo %p, name %s, class %s, description %s, hwnd %p, flags %#x, device_data %p.\n", - devinfo, debugstr_w(DeviceName), debugstr_guid(ClassGuid), debugstr_w(DeviceDescription), - hwndParent, CreationFlags, device_data); + devinfo, debugstr_w(name), debugstr_guid(class), debugstr_w(description), + parent, flags, device_data); - if (!DeviceName || strlenW(DeviceName) >= MAX_DEVICE_ID_LEN) + if (!name || strlenW(name) >= MAX_DEVICE_ID_LEN) { SetLastError(ERROR_INVALID_DEVINST_NAME); return FALSE; @@ -1415,105 +1414,90 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, PCWSTR DeviceName, if (!(set = get_device_set(devinfo))) return FALSE; - if (!ClassGuid) + if (!class) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } - if (!IsEqualGUID(&set->ClassGuid, &GUID_NULL) && - !IsEqualGUID(ClassGuid, &set->ClassGuid)) + if (!IsEqualGUID(&set->ClassGuid, &GUID_NULL) && !IsEqualGUID(class, &set->ClassGuid)) { SetLastError(ERROR_CLASS_MISMATCH); return FALSE; } - if ((CreationFlags & DICD_GENERATE_ID)) + if ((flags & DICD_GENERATE_ID)) { - if (strchrW(DeviceName, '\\')) + static const WCHAR formatW[] = {'R','O','O','T','\\','%','s','\\','%','0','4','d',0}; + DWORD devId; + + if (strchrW(name, '\\')) + { SetLastError(ERROR_INVALID_DEVINST_NAME); - else + return FALSE; + } + + if (set->cDevices) { - static const WCHAR newDeviceFmt[] = {'R','O','O','T','\\','%','s', - '\\','%','0','4','d',0}; - DWORD devId; + DWORD highestDevID = 0; - if (set->cDevices) + LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry) { - DWORD highestDevID = 0; - struct device *device; + const WCHAR *devName = strrchrW(device->instanceId, '\\'); + DWORD id; - LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry) - { - const WCHAR *devName = strrchrW(device->instanceId, '\\'); - DWORD id; - - if (devName) - devName++; - else - devName = device->instanceId; - id = SETUPDI_DevNameToDevID(devName); - if (id != 0xffffffff && id > highestDevID) - highestDevID = id; - } - devId = highestDevID + 1; - } - else - devId = 0; - /* 17 == lstrlenW(L"Root\\") + lstrlenW("\\") + 1 + %d max size */ - instanceId = HeapAlloc(GetProcessHeap(), 0, - (17 + lstrlenW(DeviceName)) * sizeof(WCHAR)); - if (instanceId) - { - sprintfW((LPWSTR)instanceId, newDeviceFmt, DeviceName, - devId); - allocatedInstanceId = TRUE; - ret = TRUE; + if (devName) + devName++; + else + devName = device->instanceId; + id = SETUPDI_DevNameToDevID(devName); + if (id != 0xffffffff && id > highestDevID) + highestDevID = id; } - else - ret = FALSE; + devId = highestDevID + 1; + } + else + devId = 0; + + if (snprintfW(id, ARRAY_SIZE(id), formatW, name, devId) == -1) + { + SetLastError(ERROR_INVALID_DEVINST_NAME); + return FALSE; } } else { - struct device *device; - - ret = TRUE; - instanceId = DeviceName; + strcpyW(id, name); LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry) { - if (!lstrcmpiW(DeviceName, device->instanceId)) + if (!lstrcmpiW(name, device->instanceId)) { SetLastError(ERROR_DEVINST_ALREADY_EXISTS); - ret = FALSE; + return FALSE; } } } - if (ret) + + if (!(device = SETUPDI_CreateDeviceInfo(set, class, id, TRUE))) + return FALSE; + + if (description) { - struct device *device = NULL; + SETUPDI_SetDeviceRegistryPropertyW(device, SPDRP_DEVICEDESC, + (const BYTE *)description, lstrlenW(description) * sizeof(WCHAR)); + } - if ((device = SETUPDI_CreateDeviceInfo(set, ClassGuid, instanceId, TRUE))) + if (device_data) + { + if (device_data->cbSize != sizeof(SP_DEVINFO_DATA)) { - if (DeviceDescription) - SETUPDI_SetDeviceRegistryPropertyW(device, SPDRP_DEVICEDESC, - (const BYTE *)DeviceDescription, - lstrlenW(DeviceDescription) * sizeof(WCHAR)); - if (device_data) - { - if (device_data->cbSize != sizeof(SP_DEVINFO_DATA)) - { - SetLastError(ERROR_INVALID_USER_BUFFER); - ret = FALSE; - } - else - copy_device_data(device_data, device); - } + SetLastError(ERROR_INVALID_USER_BUFFER); + return FALSE; } + else + copy_device_data(device_data, device); } - if (allocatedInstanceId) - HeapFree(GetProcessHeap(), 0, (LPWSTR)instanceId); - return ret; + return TRUE; } /***********************************************************************
1
0
0
0
Zebediah Figura : setupapi: Avoid unnecessary buffer allocation in SetupDiGetDeviceInstanceIdA().
by Alexandre Julliard
28 Nov '18
28 Nov '18
Module: wine Branch: master Commit: 81d2b419b87214ead8e0b2d8dd696536b45d82aa URL:
https://source.winehq.org/git/wine.git/?a=commit;h=81d2b419b87214ead8e0b2d8…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Tue Nov 27 19:55:36 2018 -0600 setupapi: Avoid unnecessary buffer allocation in SetupDiGetDeviceInstanceIdA(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/setupapi/devinst.c | 64 +++++++++++++------------------------------------ 1 file changed, 16 insertions(+), 48 deletions(-) diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index a9145ad..be7ce64 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -1607,57 +1607,25 @@ BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, SP_DEVINFO_DATA /*********************************************************************** * SetupDiGetDeviceInstanceIdA (SETUPAPI.@) */ -BOOL WINAPI SetupDiGetDeviceInstanceIdA( - HDEVINFO DeviceInfoSet, - PSP_DEVINFO_DATA DeviceInfoData, - PSTR DeviceInstanceId, - DWORD DeviceInstanceIdSize, - PDWORD RequiredSize) +BOOL WINAPI SetupDiGetDeviceInstanceIdA(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data, + char *id, DWORD size, DWORD *needed) { - BOOL ret = FALSE; - DWORD size; - PWSTR instanceId; - - TRACE("%p %p %p %d %p\n", DeviceInfoSet, DeviceInfoData, DeviceInstanceId, - DeviceInstanceIdSize, RequiredSize); - - SetupDiGetDeviceInstanceIdW(DeviceInfoSet, - DeviceInfoData, - NULL, - 0, - &size); - if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) + WCHAR idW[MAX_DEVICE_ID_LEN]; + + TRACE("devinfo %p, device_data %p, id %p, size %d, needed %p.\n", + devinfo, device_data, id, size, needed); + + if (!SetupDiGetDeviceInstanceIdW(devinfo, device_data, idW, ARRAY_SIZE(idW), NULL)) return FALSE; - instanceId = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); - if (instanceId) - { - ret = SetupDiGetDeviceInstanceIdW(DeviceInfoSet, - DeviceInfoData, - instanceId, - size, - &size); - if (ret) - { - int len = WideCharToMultiByte(CP_ACP, 0, instanceId, -1, - DeviceInstanceId, - DeviceInstanceIdSize, NULL, NULL); - if (!len) - ret = FALSE; - else - { - if (len > DeviceInstanceIdSize) - { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - ret = FALSE; - } - if (RequiredSize) - *RequiredSize = len; - } - } - HeapFree(GetProcessHeap(), 0, instanceId); - } - return ret; + if (needed) + *needed = WideCharToMultiByte(CP_ACP, 0, idW, -1, NULL, 0, NULL, NULL); + + if (size && WideCharToMultiByte(CP_ACP, 0, idW, -1, id, size, NULL, NULL)) + return TRUE; + + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return FALSE; } /***********************************************************************
1
0
0
0
Zebediah Figura : setupapi: Avoid unnecessary buffer allocation in SetupDiCreateDeviceInfoA().
by Alexandre Julliard
28 Nov '18
28 Nov '18
Module: wine Branch: master Commit: ad5314040b559a00325a85565fe9da3f2b6765c5 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ad5314040b559a00325a8556…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Tue Nov 27 19:55:35 2018 -0600 setupapi: Avoid unnecessary buffer allocation in SetupDiCreateDeviceInfoA(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/setupapi/devinst.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 8ce1344..a9145ad 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -1341,8 +1341,8 @@ BOOL WINAPI SetupDiCreateDeviceInfoA(HDEVINFO DeviceInfoSet, const char *name, const GUID *ClassGuid, PCSTR DeviceDescription, HWND hwndParent, DWORD CreationFlags, PSP_DEVINFO_DATA DeviceInfoData) { + WCHAR nameW[MAX_DEVICE_ID_LEN]; BOOL ret = FALSE; - LPWSTR DeviceNameW = NULL; LPWSTR DeviceDescriptionW = NULL; if (!name || strlen(name) >= MAX_DEVICE_ID_LEN) @@ -1351,23 +1351,18 @@ BOOL WINAPI SetupDiCreateDeviceInfoA(HDEVINFO DeviceInfoSet, const char *name, return FALSE; } - DeviceNameW = MultiByteToUnicode(name, CP_ACP); - if (DeviceNameW == NULL) return FALSE; + MultiByteToWideChar(CP_ACP, 0, name, -1, nameW, sizeof(nameW)); if (DeviceDescription) { DeviceDescriptionW = MultiByteToUnicode(DeviceDescription, CP_ACP); if (DeviceDescriptionW == NULL) - { - MyFree(DeviceNameW); return FALSE; - } } - ret = SetupDiCreateDeviceInfoW(DeviceInfoSet, DeviceNameW, ClassGuid, DeviceDescriptionW, + ret = SetupDiCreateDeviceInfoW(DeviceInfoSet, nameW, ClassGuid, DeviceDescriptionW, hwndParent, CreationFlags, DeviceInfoData); - MyFree(DeviceNameW); MyFree(DeviceDescriptionW); return ret;
1
0
0
0
Zebediah Figura : setupapi: Enforce a maximum device instance ID length.
by Alexandre Julliard
28 Nov '18
28 Nov '18
Module: wine Branch: master Commit: 8289c651c04a4dbecad11199d206f2f82b849364 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=8289c651c04a4dbecad11199…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Tue Nov 27 19:55:34 2018 -0600 setupapi: Enforce a maximum device instance ID length. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/setupapi/devinst.c | 14 +++++++++----- dlls/setupapi/tests/devinst.c | 20 +++++++++++++++++++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 64c0413..8ce1344 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -1337,7 +1337,7 @@ HKEY WINAPI SetupDiCreateDevRegKeyW(HDEVINFO devinfo, SP_DEVINFO_DATA *device_da /*********************************************************************** * SetupDiCreateDeviceInfoA (SETUPAPI.@) */ -BOOL WINAPI SetupDiCreateDeviceInfoA(HDEVINFO DeviceInfoSet, PCSTR DeviceName, +BOOL WINAPI SetupDiCreateDeviceInfoA(HDEVINFO DeviceInfoSet, const char *name, const GUID *ClassGuid, PCSTR DeviceDescription, HWND hwndParent, DWORD CreationFlags, PSP_DEVINFO_DATA DeviceInfoData) { @@ -1345,11 +1345,15 @@ BOOL WINAPI SetupDiCreateDeviceInfoA(HDEVINFO DeviceInfoSet, PCSTR DeviceName, LPWSTR DeviceNameW = NULL; LPWSTR DeviceDescriptionW = NULL; - if (DeviceName) + if (!name || strlen(name) >= MAX_DEVICE_ID_LEN) { - DeviceNameW = MultiByteToUnicode(DeviceName, CP_ACP); - if (DeviceNameW == NULL) return FALSE; + SetLastError(ERROR_INVALID_DEVINST_NAME); + return FALSE; } + + DeviceNameW = MultiByteToUnicode(name, CP_ACP); + if (DeviceNameW == NULL) return FALSE; + if (DeviceDescription) { DeviceDescriptionW = MultiByteToUnicode(DeviceDescription, CP_ACP); @@ -1407,7 +1411,7 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, PCWSTR DeviceName, devinfo, debugstr_w(DeviceName), debugstr_guid(ClassGuid), debugstr_w(DeviceDescription), hwndParent, CreationFlags, device_data); - if (!DeviceName) + if (!DeviceName || strlenW(DeviceName) >= MAX_DEVICE_ID_LEN) { SetLastError(ERROR_INVALID_DEVINST_NAME); return FALSE; diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 0e6a1c0..338393e 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -271,8 +271,8 @@ static void test_device_info(void) { static const GUID deadbeef = {0xdeadbeef,0xdead,0xbeef,{0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef}}; SP_DEVINFO_DATA device = {0}, ret_device = {sizeof(ret_device)}; + char id[MAX_DEVICE_ID_LEN + 2]; HDEVINFO set; - char id[50]; BOOL ret; SetLastError(0xdeadbeef); @@ -382,6 +382,24 @@ todo_wine { check_device_info(set, 2, &guid, "ROOT\\LEGACY_BOGUS\\testguid"); check_device_info(set, 3, NULL, NULL); + memset(id, 'x', sizeof(id)); + memcpy(id, "Root\\LEGACY_BOGUS\\", strlen("Root\\LEGACY_BOGUS\\")); + id[MAX_DEVICE_ID_LEN + 1] = 0; + SetLastError(0xdeadbeef); + ret = SetupDiCreateDeviceInfoA(set, id, &guid, NULL, NULL, 0, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_DEVINST_NAME, "Got unexpected error %#x.\n", GetLastError()); + + id[MAX_DEVICE_ID_LEN] = 0; + SetLastError(0xdeadbeef); + ret = SetupDiCreateDeviceInfoA(set, id, &guid, NULL, NULL, 0, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_DEVINST_NAME, "Got unexpected error %#x.\n", GetLastError()); + + id[MAX_DEVICE_ID_LEN - 1] = 0; + ret = SetupDiCreateDeviceInfoA(set, id, &guid, NULL, NULL, 0, NULL); + ok(ret, "Failed to create device, error %#x.\n", GetLastError()); + SetupDiDestroyDeviceInfoList(set); }
1
0
0
0
Zebediah Figura : ntoskrnl.exe: Implement KeDelayExecutionThread().
by Alexandre Julliard
28 Nov '18
28 Nov '18
Module: wine Branch: master Commit: c00a322d97cd092e0bd06cfa9a7de129fccffce7 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=c00a322d97cd092e0bd06cfa…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Tue Nov 27 19:43:09 2018 -0600 ntoskrnl.exe: Implement KeDelayExecutionThread(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntoskrnl.exe/ntoskrnl.c | 9 --------- dlls/ntoskrnl.exe/sync.c | 9 +++++++++ include/ddk/wdm.h | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index c7b1f43..81731ce 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -3198,15 +3198,6 @@ NTSTATUS WINAPI CmUnRegisterCallback(LARGE_INTEGER cookie) } /*********************************************************************** - * KeDelayExecutionThread (NTOSKRNL.EXE.@) - */ -NTSTATUS WINAPI KeDelayExecutionThread(KPROCESSOR_MODE waitmode, BOOLEAN alertable, PLARGE_INTEGER interval) -{ - FIXME("(%u, %u, %p): stub\n", waitmode, alertable, interval); - return STATUS_NOT_IMPLEMENTED; -} - -/*********************************************************************** * IoAttachDevice (NTOSKRNL.EXE.@) */ NTSTATUS WINAPI IoAttachDevice(DEVICE_OBJECT *source, UNICODE_STRING *target, DEVICE_OBJECT *attached) diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c index 1cd0e52..da51ca0 100644 --- a/dlls/ntoskrnl.exe/sync.c +++ b/dlls/ntoskrnl.exe/sync.c @@ -364,3 +364,12 @@ BOOLEAN WINAPI KeCancelTimer( KTIMER *timer ) return ret; } + +/*********************************************************************** + * KeDelayExecutionThread (NTOSKRNL.EXE.@) + */ +NTSTATUS WINAPI KeDelayExecutionThread( KPROCESSOR_MODE mode, BOOLEAN alertable, LARGE_INTEGER *timeout ) +{ + TRACE("mode %d, alertable %u, timeout %p.\n", mode, alertable, timeout); + return NtDelayExecution( alertable, timeout ); +} diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h index 56e1d84..077fec1 100644 --- a/include/ddk/wdm.h +++ b/include/ddk/wdm.h @@ -1421,6 +1421,7 @@ NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT,ULONG); BOOLEAN WINAPI KeCancelTimer(KTIMER*); void WINAPI KeClearEvent(PRKEVENT); +NTSTATUS WINAPI KeDelayExecutionThread(KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*); PKTHREAD WINAPI KeGetCurrentThread(void); void WINAPI KeInitializeEvent(PRKEVENT,EVENT_TYPE,BOOLEAN); void WINAPI KeInitializeMutex(PRKMUTEX,ULONG);
1
0
0
0
Zebediah Figura : ntoskrnl.exe/tests: Add tests for waiting on timers.
by Alexandre Julliard
28 Nov '18
28 Nov '18
Module: wine Branch: master Commit: 49e580122a1d280b920210ef2d47b1fbacbd1b16 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=49e580122a1d280b920210ef…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Tue Nov 27 19:43:08 2018 -0600 ntoskrnl.exe/tests: Add tests for waiting on timers. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntoskrnl.exe/tests/driver.c | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index 8294882..17e54cd 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -260,6 +260,8 @@ static void test_sync(void) { KSEMAPHORE semaphore, semaphore2; KEVENT manual_event, auto_event; + KTIMER timer; + LARGE_INTEGER timeout; void *objs[2]; NTSTATUS ret; int i; @@ -444,6 +446,55 @@ static void test_sync(void) ok(ret == 0, "got %#x\n", ret); run_thread(mutex_thread, (void *)0); + + /* test timers */ + KeInitializeTimerEx(&timer, NotificationTimer); + + timeout.QuadPart = -100; + KeSetTimerEx(&timer, timeout, 0, NULL); + + ret = wait_single(&timer, 0); + ok(ret == WAIT_TIMEOUT, "got %#x\n", ret); + + ret = wait_single(&timer, -200); + ok(ret == 0, "got %#x\n", ret); + + ret = wait_single(&timer, 0); + ok(ret == 0, "got %#x\n", ret); + + KeCancelTimer(&timer); + KeInitializeTimerEx(&timer, SynchronizationTimer); + + KeSetTimerEx(&timer, timeout, 0, NULL); + + ret = wait_single(&timer, 0); + ok(ret == WAIT_TIMEOUT, "got %#x\n", ret); + + ret = wait_single(&timer, -200); + ok(ret == 0, "got %#x\n", ret); + + ret = wait_single(&timer, 0); + ok(ret == WAIT_TIMEOUT, "got %#x\n", ret); + + KeCancelTimer(&timer); + KeSetTimerEx(&timer, timeout, 10, NULL); + + ret = wait_single(&timer, 0); + ok(ret == WAIT_TIMEOUT, "got %#x\n", ret); + + ret = wait_single(&timer, -200); + ok(ret == 0, "got %#x\n", ret); + + ret = wait_single(&timer, 0); + ok(ret == WAIT_TIMEOUT, "got %#x\n", ret); + + ret = wait_single(&timer, -20 * 10000); + ok(ret == 0, "got %#x\n", ret); + + ret = wait_single(&timer, -20 * 10000); + ok(ret == 0, "got %#x\n", ret); + + KeCancelTimer(&timer); } static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
1
0
0
0
← Newer
1
...
27
28
29
30
31
32
33
...
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