Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 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
September 2016
- 41 participants
- 277 messages
Re: [10/11] kernel32: Implement LCMAP_FULLWIDTH.
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=25910
Your paranoid android.
=== w1064 (32 bit locale) ===
locale.c:2644: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2645: Test failed: unexpected error code -559038737
locale.c:2736: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4472: Test failed: IsValidLocaleName should have failed
locale.c:4474: Test failed: IsValidLocaleName should have failed
locale.c:4857: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4859: Test failed: For id 7, Expected IVC, got ''
=== w1064 (64 bit locale) ===
locale.c:2644: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2645: Test failed: unexpected error code -559038737
locale.c:2736: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4472: Test failed: IsValidLocaleName should have failed
locale.c:4474: Test failed: IsValidLocaleName should have failed
locale.c:4857: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4859: Test failed: For id 7, Expected IVC, got ''
Sept. 22, 2016
Re: [09/11] kernel32: Implement LCMAP_KATAKANA.
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=25909
Your paranoid android.
=== w1064 (32 bit locale) ===
locale.c:2640: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2641: Test failed: unexpected error code -559038737
locale.c:2732: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4468: Test failed: IsValidLocaleName should have failed
locale.c:4470: Test failed: IsValidLocaleName should have failed
locale.c:4853: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4855: Test failed: For id 7, Expected IVC, got ''
=== w1064 (64 bit locale) ===
locale.c:2640: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2641: Test failed: unexpected error code -559038737
locale.c:2732: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4468: Test failed: IsValidLocaleName should have failed
locale.c:4470: Test failed: IsValidLocaleName should have failed
locale.c:4853: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4855: Test failed: For id 7, Expected IVC, got ''
Sept. 22, 2016
Re: [08/11] kernel32: Implement LCMAP_HIRAGANA.
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=25908
Your paranoid android.
=== w1064 (32 bit locale) ===
locale.c:2636: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2637: Test failed: unexpected error code -559038737
locale.c:2728: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4464: Test failed: IsValidLocaleName should have failed
locale.c:4466: Test failed: IsValidLocaleName should have failed
locale.c:4849: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4851: Test failed: For id 7, Expected IVC, got ''
=== w1064 (64 bit locale) ===
locale.c:2636: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2637: Test failed: unexpected error code -559038737
locale.c:2728: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4464: Test failed: IsValidLocaleName should have failed
locale.c:4466: Test failed: IsValidLocaleName should have failed
locale.c:4849: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4851: Test failed: For id 7, Expected IVC, got ''
Sept. 22, 2016
Re: [05/11] kernel32/tests: Add more mapping tests for LCMapString.
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=25907
Your paranoid android.
=== w1064 (32 bit locale) ===
locale.c:2632: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2633: Test failed: unexpected error code -559038737
locale.c:2724: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4460: Test failed: IsValidLocaleName should have failed
locale.c:4462: Test failed: IsValidLocaleName should have failed
locale.c:4845: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4847: Test failed: For id 7, Expected IVC, got ''
=== w1064 (64 bit locale) ===
locale.c:2632: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2633: Test failed: unexpected error code -559038737
locale.c:2724: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4460: Test failed: IsValidLocaleName should have failed
locale.c:4462: Test failed: IsValidLocaleName should have failed
locale.c:4845: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4847: Test failed: For id 7, Expected IVC, got ''
Sept. 22, 2016
Re: [04/11] kernel32/tests: Add LCMAP_TITLECASE test.
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=25906
Your paranoid android.
=== w1064 (32 bit locale) ===
locale.c:2555: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2556: Test failed: unexpected error code -559038737
locale.c:2647: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4383: Test failed: IsValidLocaleName should have failed
locale.c:4385: Test failed: IsValidLocaleName should have failed
locale.c:4768: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4770: Test failed: For id 7, Expected IVC, got ''
=== w1064 (64 bit locale) ===
locale.c:2555: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2556: Test failed: unexpected error code -559038737
locale.c:2647: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4383: Test failed: IsValidLocaleName should have failed
locale.c:4385: Test failed: IsValidLocaleName should have failed
locale.c:4768: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4770: Test failed: For id 7, Expected IVC, got ''
Sept. 22, 2016
Re: [03/11] kernel32: Zero is an invalid flag value.
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=25905
Your paranoid android.
=== w1064 (32 bit locale) ===
locale.c:2556: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2557: Test failed: unexpected error code -559038737
locale.c:2648: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4384: Test failed: IsValidLocaleName should have failed
locale.c:4386: Test failed: IsValidLocaleName should have failed
locale.c:4769: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4771: Test failed: For id 7, Expected IVC, got ''
=== w1064 (64 bit locale) ===
locale.c:2556: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2557: Test failed: unexpected error code -559038737
locale.c:2648: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4384: Test failed: IsValidLocaleName should have failed
locale.c:4386: Test failed: IsValidLocaleName should have failed
locale.c:4769: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4771: Test failed: For id 7, Expected IVC, got ''
Sept. 22, 2016
Re: [02/11] kernel32: Do not allow to combine NORM_IGNORENONSPACE and/or NORM_IGNORESYMBOLS with other LCMAP flags.
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=25904
Your paranoid android.
=== w1064 (32 bit locale) ===
locale.c:2555: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2556: Test failed: unexpected error code -559038737
locale.c:2647: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4383: Test failed: IsValidLocaleName should have failed
locale.c:4385: Test failed: IsValidLocaleName should have failed
locale.c:4768: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4770: Test failed: For id 7, Expected IVC, got ''
=== w1064 (64 bit locale) ===
locale.c:2555: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2556: Test failed: unexpected error code -559038737
locale.c:2647: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4383: Test failed: IsValidLocaleName should have failed
locale.c:4385: Test failed: IsValidLocaleName should have failed
locale.c:4768: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4770: Test failed: For id 7, Expected IVC, got ''
Sept. 22, 2016
Re: [01/11] kernel32/tests: Consolidate duplicated code for invalid LCMapString flag tests.
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=25903
Your paranoid android.
=== w1064 (32 bit locale) ===
locale.c:2535: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2536: Test failed: unexpected error code -559038737
locale.c:2627: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4363: Test failed: IsValidLocaleName should have failed
locale.c:4365: Test failed: IsValidLocaleName should have failed
locale.c:4748: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4750: Test failed: For id 7, Expected IVC, got ''
=== w1064 (64 bit locale) ===
locale.c:2535: Test failed: LCMapStringEx should fail with bad locale name
locale.c:2536: Test failed: unexpected error code -559038737
locale.c:2627: Test failed: Expected lcid == 0, got 00001000, error -559038737
locale.c:4363: Test failed: IsValidLocaleName should have failed
locale.c:4365: Test failed: IsValidLocaleName should have failed
locale.c:4748: Test failed: For id 7, expected ret == 4, got 1, error 87
locale.c:4750: Test failed: For id 7, Expected IVC, got ''
Sept. 22, 2016
Re: [PATCH v3] winebus.sys: Watch for hid raw device addition and removal
by Aric Stewart
On 9/21/16 5:59 AM, Sebastian Lackner wrote:
> On 19.09.2016 15:35, Aric Stewart wrote:
>> v2: Correct poll timeout
>> Style changes
>> v3: vtable style instead of a callback
>>
>>
>> Signed-off-by: Aric Stewart <aric(a)codeweavers.com>
>> ---
>> dlls/winebus.sys/bus.h | 11 +++++-
>> dlls/winebus.sys/bus_udev.c | 92 ++++++++++++++++++++++++++++++++++++++++++++-
>> dlls/winebus.sys/main.c | 52 ++++++++++++++++++++++++-
>> 3 files changed, 152 insertions(+), 3 deletions(-)
>>
>
> Would you mind sharing some of the follow up patches, so that I can check if the vtbl solution
> really looks better than the previous approach?
>
Sure, Here is the full patchset for hidraw.
https://www.codeweavers.com/xfer/aric/HID/Hid_Patches_20160921.tgz
access-code: sLcm7EZ7
I did not include the iohid and linux event patches in that given set as I know they still need cleaning up and I am working on that. Also many of the later patches probably still need some cleaning up.
-aric
>>
>>
>> v3-0004-winebus.sys-Watch-for-hid-raw-device-addition-and-r.txt
>>
>>
>> diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h
>> index dcb50f2..cf10e80 100644
>> --- a/dlls/winebus.sys/bus.h
>> +++ b/dlls/winebus.sys/bus.h
>> @@ -19,8 +19,17 @@
>> /* Busses */
>> NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) DECLSPEC_HIDDEN;
>>
>> +/* Native device function table */
>> +typedef struct {
>> + int(*compare_native_device)(DEVICE_OBJECT *device, DEVICE_OBJECT *other);
>> +} platform_vtbl;
>> +
>> +void *get_native_device(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
>> +DEVICE_OBJECT *find_hid_device(const WCHAR* busidW, void *native) DECLSPEC_HIDDEN;
>> +
>> /* HID Plug and Play Bus */
>> NTSTATUS WINAPI common_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
>> DEVICE_OBJECT *bus_create_hid_device(DRIVER_OBJECT *driver, const WCHAR *busidW, void *native, WORD vid,
>> WORD pid, DWORD version, DWORD uid, const WCHAR *serialW, BOOL is_gamepad,
>> - const GUID *class) DECLSPEC_HIDDEN;
>> + const GUID *class, platform_vtbl* vtbl) DECLSPEC_HIDDEN;
>> +void bus_remove_hid_device(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
>> diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c
>> index 1525861..35b198a 100644
>> --- a/dlls/winebus.sys/bus_udev.c
>> +++ b/dlls/winebus.sys/bus_udev.c
>> @@ -26,6 +26,11 @@
>> #ifdef HAVE_UNISTD_H
>> # include <unistd.h>
>> #endif
>> +
>> +#ifdef HAVE_SYS_POLL_H
>> +# include <sys/poll.h>
>> +#endif
>> +
>> #ifdef HAVE_LIBUDEV_H
>> # include <libudev.h>
>> #endif
>> @@ -82,6 +87,17 @@ static WCHAR *get_sysattr_string(struct udev_device *dev, const char *sysattr)
>> return dst;
>> }
>>
>> +static int compare_native_device(DEVICE_OBJECT *device, DEVICE_OBJECT *other)
>> +{
>> + struct udev_device *dev1 = get_native_device(device);
>> + struct udev_device *dev2 = get_native_device(other);
>> + return (strcmp(udev_device_get_syspath(dev1), udev_device_get_syspath(dev2)));
>> +}
>> +
>> +static platform_vtbl hidraw_vtbl = {
>
> This should be made const.
>
>> + compare_native_device,
>> +};
>> +
>> static void try_add_device(struct udev_device *dev)
>> {
>> DWORD vid = 0, pid = 0, version = 0;
>> @@ -118,7 +134,7 @@ static void try_add_device(struct udev_device *dev)
>> if (strcmp(subsystem, "hidraw") == 0)
>> {
>> device = bus_create_hid_device(udev_driver_obj, hidraw_busidW, dev, vid, pid,
>> - version, 0, serial, FALSE, &GUID_DEVCLASS_HIDRAW);
>> + version, 0, serial, FALSE, &GUID_DEVCLASS_HIDRAW, &hidraw_vtbl);
>> }
>>
>> if (device)
>> @@ -164,6 +180,77 @@ static void build_initial_deviceset(void)
>> udev_enumerate_unref(enumerate);
>> }
>>
>> +/* This is our main even loop for reading devices */
>> +static DWORD CALLBACK deviceloop_thread(void *args)
>> +{
>> + struct pollfd plfds[1];
>> + struct udev_monitor *monitor = NULL;
>> +
>> + monitor = udev_monitor_new_from_netlink(udev_context, "udev");
>> + if (!monitor)
>> + {
>> + WARN("Unable to get udev monitor, device insertion and removal cannot be tracked\n");
>> + goto exit;
>> + }
>> + if (udev_monitor_filter_add_match_subsystem_devtype(monitor, "hidraw", NULL) < 0)
>> + {
>> + WARN("Failed to add 'hidraw' subsystem to monitor\n");
>> + goto exit;
>> + }
>> +
>> + if (udev_monitor_enable_receiving(monitor) < 0)
>> + {
>> + WARN("Failed to start monitoring\n");
>> + goto exit;
>> + }
>> +
>> + plfds[0].fd = udev_monitor_get_fd(monitor);
>> + plfds[0].events = POLLIN;
>> + if (plfds[0].fd < 0)
>> + {
>> + WARN("Failed to get monitor fd\n");
>> + goto exit;
>> + }
>> + /* Run the event loop */
>> + while (1)
>> + {
>> + struct udev_device *dev;
>> + const char* action;
>> +
>> + if (poll(plfds, 1, -1) <= 0) continue;
>> +
>> + TRACE("udev reports device changes\n");
>> + dev = udev_monitor_receive_device(monitor);
>> + if (!dev)
>> + {
>> + FIXME("Failed to get device that has changed\n");
>> + continue;
>> + }
>> + action = udev_device_get_action(dev);
>> + if (!action)
>> + WARN("No action recieved\n");
>> + else if (strcmp(action, "add") == 0)
>> + try_add_device(dev);
>> + else if (strcmp(action, "remove") == 0)
>> + {
>> + DEVICE_OBJECT *device = find_hid_device(hidraw_busidW, dev);
>> + if (device)
>> + {
>> + struct udev_device *original = get_native_device(device);
>> + bus_remove_hid_device(device);
>> + udev_device_unref(original);
>> + }
>> + }
>> + udev_device_unref(dev);
>> + }
>> +
>> +exit:
>> + TRACE("Monitor thread exiting\n");
>> + if (monitor)
>> + udev_monitor_unref(monitor);
>> + return 1;
>> +}
>> +
>> NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path)
>> {
>> TRACE("(%p, %s)\n", driver, debugstr_w(registry_path->Buffer));
>> @@ -178,6 +265,9 @@ NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry
>> driver->MajorFunction[IRP_MJ_PNP] = common_pnp_dispatch;
>>
>> build_initial_deviceset();
>> +
>> + CreateThread(NULL, 0, deviceloop_thread, NULL, 0, NULL);
>
> It would be better to check the result here (at least to print an ERR or something like that).
>
>> +
>> return STATUS_SUCCESS;
>> }
>>
>> diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c
>> index 1364eab..c7418e3 100644
>> --- a/dlls/winebus.sys/main.c
>> +++ b/dlls/winebus.sys/main.c
>> @@ -54,6 +54,7 @@ struct device_extension
>> BOOL is_gamepad;
>> WCHAR *serial;
>> const WCHAR *busid; /* Expected to be a static constant */
>> + platform_vtbl *vtbl;
>> };
>>
>> static CRITICAL_SECTION device_list_cs;
>> @@ -159,7 +160,7 @@ static WCHAR *get_compatible_ids(DEVICE_OBJECT *device)
>>
>> DEVICE_OBJECT *bus_create_hid_device(DRIVER_OBJECT *driver, const WCHAR *busidW, void *native, WORD vid,
>> WORD pid, DWORD version, DWORD uid, const WCHAR *serialW, BOOL is_gamepad,
>> - const GUID *class)
>> + const GUID *class, platform_vtbl *vtbl)
>> {
>> static const WCHAR device_name_fmtW[] = {'\\','D','e','v','i','c','e','\\','%','s','#','%','p',0};
>> struct device_extension *ext;
>> @@ -199,6 +200,7 @@ DEVICE_OBJECT *bus_create_hid_device(DRIVER_OBJECT *driver, const WCHAR *busidW,
>> ext->is_gamepad = is_gamepad;
>> ext->serial = strdupW(serialW);
>> ext->busid = busidW;
>> + ext->vtbl = vtbl;
>>
>> /* add to list of pnp devices */
>> pnp_dev->device = device;
>> @@ -265,6 +267,54 @@ static NTSTATUS handle_IRP_MN_QUERY_ID(DEVICE_OBJECT *device, IRP *irp)
>> return status;
>> }
>>
>> +void *get_native_device(DEVICE_OBJECT *device)
>> +{
>> + struct device_extension *ext = (struct device_extension*)device->DeviceExtension;
>> + return ext->native;
>> +}
>> +
>> +DEVICE_OBJECT *find_hid_device(const WCHAR* busidW, void *native)
>> +{
>> + struct pnp_device *dev, *ptr;
>> + DEVICE_OBJECT *ret = NULL;
>> +
>> + EnterCriticalSection(&device_list_cs);
>> + LIST_FOR_EACH_ENTRY_SAFE(dev, ptr, &pnp_devset, struct pnp_device, entry)
>> + {
>> + struct device_extension *ext = (struct device_extension*)dev->device->DeviceExtension;
>> + if ((strcmpW(busidW, ext->busid) == 0) &&
>> + (ext->vtbl->compare_native_device(dev->device, native) == 0))
>> + {
>> + TRACE("Found as device %p\n", dev->device);
>> + ret = dev->device;
>> + break;
>> + }
>> + }
>> + LeaveCriticalSection(&device_list_cs);
>> + return ret;
>> +}
>> +
>> +void bus_remove_hid_device(DEVICE_OBJECT *device)
>> +{
>> + struct pnp_device *dev, *ptr;
>> + TRACE("Remove hid device %p\n", device);
>> + EnterCriticalSection(&device_list_cs);
>> + LIST_FOR_EACH_ENTRY_SAFE(dev, ptr, &pnp_devset, struct pnp_device, entry)
>> + {
>> + struct device_extension *ext = (struct device_extension*)dev->device->DeviceExtension;
>> + if (device == dev->device)
>> + {
>> + list_remove(&dev->entry);
>> + IoInvalidateDeviceRelations(dev->device, RemovalRelations);
>> + HeapFree(GetProcessHeap(), 0, ext->serial);
>> + IoDeleteDevice(dev->device);
>> + HeapFree(GetProcessHeap(), 0, dev);
>> + break;
>> + }
>> + }
>> + LeaveCriticalSection(&device_list_cs);
>> +}
>> +
>> NTSTATUS WINAPI common_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
>> {
>> NTSTATUS status = irp->IoStatus.u.Status;
>>
>>
>>
>
Sept. 21, 2016
Re: [PATCH v3] winebus.sys: Watch for hid raw device addition and removal
by Sebastian Lackner
On 19.09.2016 15:35, Aric Stewart wrote:
> v2: Correct poll timeout
> Style changes
> v3: vtable style instead of a callback
>
>
> Signed-off-by: Aric Stewart <aric(a)codeweavers.com>
> ---
> dlls/winebus.sys/bus.h | 11 +++++-
> dlls/winebus.sys/bus_udev.c | 92 ++++++++++++++++++++++++++++++++++++++++++++-
> dlls/winebus.sys/main.c | 52 ++++++++++++++++++++++++-
> 3 files changed, 152 insertions(+), 3 deletions(-)
>
Would you mind sharing some of the follow up patches, so that I can check if the vtbl solution
really looks better than the previous approach?
>
>
> v3-0004-winebus.sys-Watch-for-hid-raw-device-addition-and-r.txt
>
>
> diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h
> index dcb50f2..cf10e80 100644
> --- a/dlls/winebus.sys/bus.h
> +++ b/dlls/winebus.sys/bus.h
> @@ -19,8 +19,17 @@
> /* Busses */
> NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) DECLSPEC_HIDDEN;
>
> +/* Native device function table */
> +typedef struct {
> + int(*compare_native_device)(DEVICE_OBJECT *device, DEVICE_OBJECT *other);
> +} platform_vtbl;
> +
> +void *get_native_device(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
> +DEVICE_OBJECT *find_hid_device(const WCHAR* busidW, void *native) DECLSPEC_HIDDEN;
> +
> /* HID Plug and Play Bus */
> NTSTATUS WINAPI common_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
> DEVICE_OBJECT *bus_create_hid_device(DRIVER_OBJECT *driver, const WCHAR *busidW, void *native, WORD vid,
> WORD pid, DWORD version, DWORD uid, const WCHAR *serialW, BOOL is_gamepad,
> - const GUID *class) DECLSPEC_HIDDEN;
> + const GUID *class, platform_vtbl* vtbl) DECLSPEC_HIDDEN;
> +void bus_remove_hid_device(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
> diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c
> index 1525861..35b198a 100644
> --- a/dlls/winebus.sys/bus_udev.c
> +++ b/dlls/winebus.sys/bus_udev.c
> @@ -26,6 +26,11 @@
> #ifdef HAVE_UNISTD_H
> # include <unistd.h>
> #endif
> +
> +#ifdef HAVE_SYS_POLL_H
> +# include <sys/poll.h>
> +#endif
> +
> #ifdef HAVE_LIBUDEV_H
> # include <libudev.h>
> #endif
> @@ -82,6 +87,17 @@ static WCHAR *get_sysattr_string(struct udev_device *dev, const char *sysattr)
> return dst;
> }
>
> +static int compare_native_device(DEVICE_OBJECT *device, DEVICE_OBJECT *other)
> +{
> + struct udev_device *dev1 = get_native_device(device);
> + struct udev_device *dev2 = get_native_device(other);
> + return (strcmp(udev_device_get_syspath(dev1), udev_device_get_syspath(dev2)));
> +}
> +
> +static platform_vtbl hidraw_vtbl = {
This should be made const.
> + compare_native_device,
> +};
> +
> static void try_add_device(struct udev_device *dev)
> {
> DWORD vid = 0, pid = 0, version = 0;
> @@ -118,7 +134,7 @@ static void try_add_device(struct udev_device *dev)
> if (strcmp(subsystem, "hidraw") == 0)
> {
> device = bus_create_hid_device(udev_driver_obj, hidraw_busidW, dev, vid, pid,
> - version, 0, serial, FALSE, &GUID_DEVCLASS_HIDRAW);
> + version, 0, serial, FALSE, &GUID_DEVCLASS_HIDRAW, &hidraw_vtbl);
> }
>
> if (device)
> @@ -164,6 +180,77 @@ static void build_initial_deviceset(void)
> udev_enumerate_unref(enumerate);
> }
>
> +/* This is our main even loop for reading devices */
> +static DWORD CALLBACK deviceloop_thread(void *args)
> +{
> + struct pollfd plfds[1];
> + struct udev_monitor *monitor = NULL;
> +
> + monitor = udev_monitor_new_from_netlink(udev_context, "udev");
> + if (!monitor)
> + {
> + WARN("Unable to get udev monitor, device insertion and removal cannot be tracked\n");
> + goto exit;
> + }
> + if (udev_monitor_filter_add_match_subsystem_devtype(monitor, "hidraw", NULL) < 0)
> + {
> + WARN("Failed to add 'hidraw' subsystem to monitor\n");
> + goto exit;
> + }
> +
> + if (udev_monitor_enable_receiving(monitor) < 0)
> + {
> + WARN("Failed to start monitoring\n");
> + goto exit;
> + }
> +
> + plfds[0].fd = udev_monitor_get_fd(monitor);
> + plfds[0].events = POLLIN;
> + if (plfds[0].fd < 0)
> + {
> + WARN("Failed to get monitor fd\n");
> + goto exit;
> + }
> + /* Run the event loop */
> + while (1)
> + {
> + struct udev_device *dev;
> + const char* action;
> +
> + if (poll(plfds, 1, -1) <= 0) continue;
> +
> + TRACE("udev reports device changes\n");
> + dev = udev_monitor_receive_device(monitor);
> + if (!dev)
> + {
> + FIXME("Failed to get device that has changed\n");
> + continue;
> + }
> + action = udev_device_get_action(dev);
> + if (!action)
> + WARN("No action recieved\n");
> + else if (strcmp(action, "add") == 0)
> + try_add_device(dev);
> + else if (strcmp(action, "remove") == 0)
> + {
> + DEVICE_OBJECT *device = find_hid_device(hidraw_busidW, dev);
> + if (device)
> + {
> + struct udev_device *original = get_native_device(device);
> + bus_remove_hid_device(device);
> + udev_device_unref(original);
> + }
> + }
> + udev_device_unref(dev);
> + }
> +
> +exit:
> + TRACE("Monitor thread exiting\n");
> + if (monitor)
> + udev_monitor_unref(monitor);
> + return 1;
> +}
> +
> NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path)
> {
> TRACE("(%p, %s)\n", driver, debugstr_w(registry_path->Buffer));
> @@ -178,6 +265,9 @@ NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry
> driver->MajorFunction[IRP_MJ_PNP] = common_pnp_dispatch;
>
> build_initial_deviceset();
> +
> + CreateThread(NULL, 0, deviceloop_thread, NULL, 0, NULL);
It would be better to check the result here (at least to print an ERR or something like that).
> +
> return STATUS_SUCCESS;
> }
>
> diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c
> index 1364eab..c7418e3 100644
> --- a/dlls/winebus.sys/main.c
> +++ b/dlls/winebus.sys/main.c
> @@ -54,6 +54,7 @@ struct device_extension
> BOOL is_gamepad;
> WCHAR *serial;
> const WCHAR *busid; /* Expected to be a static constant */
> + platform_vtbl *vtbl;
> };
>
> static CRITICAL_SECTION device_list_cs;
> @@ -159,7 +160,7 @@ static WCHAR *get_compatible_ids(DEVICE_OBJECT *device)
>
> DEVICE_OBJECT *bus_create_hid_device(DRIVER_OBJECT *driver, const WCHAR *busidW, void *native, WORD vid,
> WORD pid, DWORD version, DWORD uid, const WCHAR *serialW, BOOL is_gamepad,
> - const GUID *class)
> + const GUID *class, platform_vtbl *vtbl)
> {
> static const WCHAR device_name_fmtW[] = {'\\','D','e','v','i','c','e','\\','%','s','#','%','p',0};
> struct device_extension *ext;
> @@ -199,6 +200,7 @@ DEVICE_OBJECT *bus_create_hid_device(DRIVER_OBJECT *driver, const WCHAR *busidW,
> ext->is_gamepad = is_gamepad;
> ext->serial = strdupW(serialW);
> ext->busid = busidW;
> + ext->vtbl = vtbl;
>
> /* add to list of pnp devices */
> pnp_dev->device = device;
> @@ -265,6 +267,54 @@ static NTSTATUS handle_IRP_MN_QUERY_ID(DEVICE_OBJECT *device, IRP *irp)
> return status;
> }
>
> +void *get_native_device(DEVICE_OBJECT *device)
> +{
> + struct device_extension *ext = (struct device_extension*)device->DeviceExtension;
> + return ext->native;
> +}
> +
> +DEVICE_OBJECT *find_hid_device(const WCHAR* busidW, void *native)
> +{
> + struct pnp_device *dev, *ptr;
> + DEVICE_OBJECT *ret = NULL;
> +
> + EnterCriticalSection(&device_list_cs);
> + LIST_FOR_EACH_ENTRY_SAFE(dev, ptr, &pnp_devset, struct pnp_device, entry)
> + {
> + struct device_extension *ext = (struct device_extension*)dev->device->DeviceExtension;
> + if ((strcmpW(busidW, ext->busid) == 0) &&
> + (ext->vtbl->compare_native_device(dev->device, native) == 0))
> + {
> + TRACE("Found as device %p\n", dev->device);
> + ret = dev->device;
> + break;
> + }
> + }
> + LeaveCriticalSection(&device_list_cs);
> + return ret;
> +}
> +
> +void bus_remove_hid_device(DEVICE_OBJECT *device)
> +{
> + struct pnp_device *dev, *ptr;
> + TRACE("Remove hid device %p\n", device);
> + EnterCriticalSection(&device_list_cs);
> + LIST_FOR_EACH_ENTRY_SAFE(dev, ptr, &pnp_devset, struct pnp_device, entry)
> + {
> + struct device_extension *ext = (struct device_extension*)dev->device->DeviceExtension;
> + if (device == dev->device)
> + {
> + list_remove(&dev->entry);
> + IoInvalidateDeviceRelations(dev->device, RemovalRelations);
> + HeapFree(GetProcessHeap(), 0, ext->serial);
> + IoDeleteDevice(dev->device);
> + HeapFree(GetProcessHeap(), 0, dev);
> + break;
> + }
> + }
> + LeaveCriticalSection(&device_list_cs);
> +}
> +
> NTSTATUS WINAPI common_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
> {
> NTSTATUS status = irp->IoStatus.u.Status;
>
>
>
Sept. 21, 2016