Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus_iohid.c | 38 +++++++++++++++++++++-- dlls/winebus.sys/bus_sdl.c | 4 ++- dlls/winebus.sys/bus_udev.c | 25 ++++++++++------ dlls/winebus.sys/main.c | 53 +++++---------------------------- dlls/winebus.sys/unix_private.h | 2 +- dlls/winebus.sys/unixlib.c | 17 ++++++----- dlls/winebus.sys/unixlib.h | 9 +----- 7 files changed, 75 insertions(+), 73 deletions(-)
diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 8bdd7857ae6..492d5a70ddb 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -95,9 +95,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(plugplay); #ifdef HAVE_IOHIDMANAGERCREATE
+static CRITICAL_SECTION iohid_cs; +static CRITICAL_SECTION_DEBUG iohid_cs_debug = +{ + 0, 0, &iohid_cs, + { &iohid_cs_debug.ProcessLocksList, &iohid_cs_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": iohid_cs") } +}; +static CRITICAL_SECTION iohid_cs = { &iohid_cs_debug, -1, 0, 0, 0, 0 }; + static IOHIDManagerRef hid_manager; static CFRunLoopRef run_loop; static struct list event_queue = LIST_INIT(event_queue); +static struct list device_list = LIST_INIT(device_list);
static const WCHAR busidW[] = {'I','O','H','I','D',0}; static struct iohid_bus_options options; @@ -114,6 +124,16 @@ static inline struct platform_private *impl_from_unix_device(struct unix_device return CONTAINING_RECORD(iface, struct platform_private, unix_device); }
+static struct platform_private *find_device_from_iohid(IOHIDDeviceRef IOHIDDevice) +{ + struct platform_private *private; + + LIST_FOR_EACH_ENTRY(private, &device_list, struct platform_private, unix_device.entry) + if (!private->device == IOHIDDevice) return private; + + return NULL; +} + static void CFStringToWSTR(CFStringRef cstr, LPWSTR wstr, int length) { int len = min(CFStringGetLength(cstr), length-1); @@ -170,6 +190,10 @@ static void iohid_device_stop(struct unix_device *iface) struct platform_private *private = impl_from_unix_device(iface);
IOHIDDeviceRegisterInputReportCallback(private->device, NULL, 0, NULL, NULL); + + EnterCriticalSection(&iohid_cs); + list_remove(&private->unix_device.entry); + LeaveCriticalSection(&iohid_cs); }
static NTSTATUS iohid_device_get_report_descriptor(struct unix_device *iface, BYTE *buffer, @@ -336,6 +360,7 @@ static void handle_DeviceMatchingCallback(void *context, IOReturn result, void * TRACE("dev %p, desc %s.\n", IOHIDDevice, debugstr_device_desc(&desc));
if (!(private = unix_device_create(&iohid_device_vtbl, sizeof(struct platform_private)))) return; + list_add_tail(&device_list, &private->unix_device.entry); private->device = IOHIDDevice; private->buffer = NULL;
@@ -344,13 +369,18 @@ static void handle_DeviceMatchingCallback(void *context, IOReturn result, void *
static void handle_RemovalCallback(void *context, IOReturn result, void *sender, IOHIDDeviceRef IOHIDDevice) { + struct platform_private *device; + TRACE("OS/X IOHID Device Removed %p\n", IOHIDDevice); IOHIDDeviceRegisterInputReportCallback(IOHIDDevice, NULL, 0, NULL, NULL); /* Note: Yes, we leak the buffer. But according to research there is no safe way to deallocate that buffer. */ IOHIDDeviceUnscheduleFromRunLoop(IOHIDDevice, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); IOHIDDeviceClose(IOHIDDevice, 0); - bus_event_queue_device_removed(&event_queue, busidW, IOHIDDevice); + + device = find_device_from_iohid(IOHIDDevice); + if (device) bus_event_queue_device_removed(&event_queue, &device->unix_device); + else WARN("failed to find device for iohid device %p\n", IOHIDDevice); }
NTSTATUS iohid_bus_init(void *args) @@ -377,6 +407,7 @@ NTSTATUS iohid_bus_init(void *args) NTSTATUS iohid_bus_wait(void *args) { struct bus_event *result = args; + CFRunLoopRunResult ret;
/* cleanup previously returned event */ bus_event_cleanup(result); @@ -384,7 +415,10 @@ NTSTATUS iohid_bus_wait(void *args) do { if (bus_event_queue_pop(&event_queue, result)) return STATUS_PENDING; - } while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, TRUE) != kCFRunLoopRunStopped); + EnterCriticalSection(&iohid_cs); + ret = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, TRUE); + LeaveCriticalSection(&iohid_cs); + } while (ret != kCFRunLoopRunStopped);
TRACE("IOHID main loop exiting\n"); bus_event_queue_destroy(&event_queue); diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 6a6f364edf6..d48f9507abb 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -799,7 +799,9 @@ static void process_device_event(SDL_Event *event) else if (event->type == SDL_JOYDEVICEREMOVED) { id = ((SDL_JoyDeviceEvent *)event)->which; - bus_event_queue_device_removed(&event_queue, sdl_busidW, ULongToPtr(id)); + device = find_device_from_id(id); + if (device) bus_event_queue_device_removed(&event_queue, &device->unix_device); + else WARN("failed to find device with id %d\n", id); } else if (event->type >= SDL_JOYAXISMOTION && event->type <= SDL_JOYBUTTONUP) { diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 23b649ff511..8cbcabf25e8 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -200,6 +200,16 @@ static struct platform_private *find_device_from_syspath(const char *path) return NULL; }
+static struct platform_private *find_device_from_udev(struct udev_device *dev) +{ + struct platform_private *device; + + LIST_FOR_EACH_ENTRY(device, &device_list, struct platform_private, unix_device.entry) + if (device->udev_device == dev) return device; + + return NULL; +} + #ifdef HAS_PROPER_INPUT_HEADER
static const BYTE ABS_TO_HID_MAP[][2] = { @@ -1062,14 +1072,6 @@ static void udev_add_device(struct udev_device *dev) #endif }
-static void try_remove_device(struct udev_device *dev) -{ - bus_event_queue_device_removed(&event_queue, hidraw_busidW, dev); -#ifdef HAS_PROPER_INPUT_HEADER - bus_event_queue_device_removed(&event_queue, lnxev_busidW, dev); -#endif -} - static void build_initial_deviceset(void) { struct udev_enumerate *enumerate; @@ -1161,6 +1163,7 @@ error:
static void process_monitor_event(struct udev_monitor *monitor) { + struct platform_private *device; struct udev_device *dev; const char *action;
@@ -1180,7 +1183,11 @@ static void process_monitor_event(struct udev_monitor *monitor) else if (strcmp(action, "add") == 0) udev_add_device(dev); else if (strcmp(action, "remove") == 0) - try_remove_device(dev); + { + device = find_device_from_udev(dev); + if (device) bus_event_queue_device_removed(&event_queue, &device->unix_device); + else WARN("failed to find device for udev device %p\n", dev); + } else WARN("Unhandled action %s\n", debugstr_a(action));
diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 162787c4e4a..a80bd8a186e 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -146,17 +146,6 @@ static void unix_device_remove(DEVICE_OBJECT *device) winebus_call(device_remove, ext->unix_device); }
-static int unix_device_compare(DEVICE_OBJECT *device, void *context) -{ - struct device_extension *ext = (struct device_extension *)device->DeviceExtension; - struct device_compare_params params = - { - .iface = ext->unix_device, - .context = context - }; - return winebus_call(device_compare, ¶ms); -} - static NTSTATUS unix_device_start(DEVICE_OBJECT *device) { struct device_extension *ext = (struct device_extension *)device->DeviceExtension; @@ -359,29 +348,6 @@ static DEVICE_OBJECT *bus_create_hid_device(struct device_desc *desc, struct uni return device; }
-static DEVICE_OBJECT *bus_find_hid_device(const WCHAR *bus_id, void *platform_dev) -{ - struct device_extension *ext; - DEVICE_OBJECT *ret = NULL; - - TRACE("bus_id %s, platform_dev %p\n", debugstr_w(bus_id), platform_dev); - - EnterCriticalSection(&device_list_cs); - LIST_FOR_EACH_ENTRY(ext, &device_list, struct device_extension, entry) - { - if (strcmpW(ext->desc.busid, bus_id)) continue; - if (unix_device_compare(ext->device, platform_dev) == 0) - { - ret = ext->device; - break; - } - } - LeaveCriticalSection(&device_list_cs); - - TRACE("returning %p\n", ret); - return ret; -} - static DEVICE_OBJECT *bus_find_unix_device(struct unix_device *unix_device) { struct device_extension *ext; @@ -625,28 +591,25 @@ static DWORD CALLBACK bus_main_thread(void *args) case BUS_EVENT_TYPE_NONE: break; case BUS_EVENT_TYPE_DEVICE_REMOVED: EnterCriticalSection(&device_list_cs); - if (!(device = bus_find_hid_device(event->device_removed.bus_id, event->device_removed.context))) - WARN("could not find removed device matching bus %s, context %p\n", - debugstr_w(event->device_removed.bus_id), event->device_removed.context); - else - bus_unlink_hid_device(device); + device = bus_find_unix_device(event->device); + if (!device) WARN("could not find device for %s bus device %p\n", debugstr_w(bus.name), event->device); + else bus_unlink_hid_device(device); LeaveCriticalSection(&device_list_cs); IoInvalidateDeviceRelations(bus_pdo, BusRelations); break; case BUS_EVENT_TYPE_DEVICE_CREATED: - device = bus_create_hid_device(&event->device_created.desc, event->device_created.device); + device = bus_create_hid_device(&event->device_created.desc, event->device); if (device) IoInvalidateDeviceRelations(bus_pdo, BusRelations); else { - WARN("failed to create device for %s bus device %p\n", - debugstr_w(bus.name), event->device_created.device); - winebus_call(device_remove, event->device_created.device); + WARN("failed to create device for %s bus device %p\n", debugstr_w(bus.name), event->device); + winebus_call(device_remove, event->device); } break; case BUS_EVENT_TYPE_INPUT_REPORT: EnterCriticalSection(&device_list_cs); - device = bus_find_unix_device(event->input_report.device); - if (!device) WARN("could not find device for %s bus device %p\n", debugstr_w(bus.name), event->input_report.device); + device = bus_find_unix_device(event->device); + if (!device) WARN("could not find device for %s bus device %p\n", debugstr_w(bus.name), event->device); else process_hid_report(device, event->input_report.buffer, event->input_report.length); LeaveCriticalSection(&device_list_cs); break; diff --git a/dlls/winebus.sys/unix_private.h b/dlls/winebus.sys/unix_private.h index 3f8d73d033a..9b2c6d81fa2 100644 --- a/dlls/winebus.sys/unix_private.h +++ b/dlls/winebus.sys/unix_private.h @@ -64,7 +64,7 @@ extern NTSTATUS iohid_bus_stop(void *) DECLSPEC_HIDDEN;
extern void bus_event_cleanup(struct bus_event *event) DECLSPEC_HIDDEN; extern void bus_event_queue_destroy(struct list *queue) DECLSPEC_HIDDEN; -extern BOOL bus_event_queue_device_removed(struct list *queue, const WCHAR *bus_id, void *context) DECLSPEC_HIDDEN; +extern BOOL bus_event_queue_device_removed(struct list *queue, struct unix_device *device) DECLSPEC_HIDDEN; extern BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *device, struct device_desc *desc) DECLSPEC_HIDDEN; extern BOOL bus_event_queue_input_report(struct list *queue, struct unix_device *device, BYTE *report, USHORT length) DECLSPEC_HIDDEN; diff --git a/dlls/winebus.sys/unixlib.c b/dlls/winebus.sys/unixlib.c index 87cc7de3474..008fb6e77a2 100644 --- a/dlls/winebus.sys/unixlib.c +++ b/dlls/winebus.sys/unixlib.c @@ -343,8 +343,8 @@ const unixlib_entry_t __wine_unix_call_funcs[] =
void bus_event_cleanup(struct bus_event *event) { - if (event->type == BUS_EVENT_TYPE_INPUT_REPORT) - unix_device_decref(event->input_report.device); + if (event->type == BUS_EVENT_TYPE_NONE) return; + unix_device_decref(event->device); }
void bus_event_queue_destroy(struct list *queue) @@ -358,15 +358,16 @@ void bus_event_queue_destroy(struct list *queue) } }
-BOOL bus_event_queue_device_removed(struct list *queue, const WCHAR *bus_id, void *context) +BOOL bus_event_queue_device_removed(struct list *queue, struct unix_device *device) { ULONG size = sizeof(struct bus_event); struct bus_event *event = HeapAlloc(GetProcessHeap(), 0, size); if (!event) return FALSE;
+ if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */ + event->type = BUS_EVENT_TYPE_DEVICE_REMOVED; - event->device_removed.bus_id = bus_id; - event->device_removed.context = context; + event->device = device; list_add_tail(queue, &event->entry);
return TRUE; @@ -378,8 +379,10 @@ BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *devi struct bus_event *event = HeapAlloc(GetProcessHeap(), 0, size); if (!event) return FALSE;
+ if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */ + event->type = BUS_EVENT_TYPE_DEVICE_CREATED; - event->device_created.device = device; + event->device = device; event->device_created.desc = *desc; list_add_tail(queue, &event->entry);
@@ -395,7 +398,7 @@ BOOL bus_event_queue_input_report(struct list *queue, struct unix_device *device if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */
event->type = BUS_EVENT_TYPE_INPUT_REPORT; - event->input_report.device = device; + event->device = device; event->input_report.length = length; memcpy(event->input_report.buffer, report, length); list_add_tail(queue, &event->entry); diff --git a/dlls/winebus.sys/unixlib.h b/dlls/winebus.sys/unixlib.h index 61684d0c0af..cd5f64cbb51 100644 --- a/dlls/winebus.sys/unixlib.h +++ b/dlls/winebus.sys/unixlib.h @@ -76,23 +76,16 @@ struct bus_event enum bus_event_type type; struct list entry;
+ struct unix_device *device; union { struct { - const WCHAR *bus_id; - void *context; - } device_removed; - - struct - { - struct unix_device *device; struct device_desc desc; } device_created;
struct { - struct unix_device *device; USHORT length; BYTE buffer[1]; } input_report;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus_iohid.c | 11 ----------- dlls/winebus.sys/bus_sdl.c | 6 ------ dlls/winebus.sys/bus_udev.c | 9 --------- dlls/winebus.sys/unix_private.h | 1 - dlls/winebus.sys/unixlib.c | 20 -------------------- dlls/winebus.sys/unixlib.h | 7 ------- 6 files changed, 54 deletions(-)
diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 492d5a70ddb..f3b55cc0f70 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -161,16 +161,6 @@ static void iohid_device_destroy(struct unix_device *iface) { }
-static int iohid_device_compare(struct unix_device *iface, void *context) -{ - struct platform_private *private = impl_from_unix_device(iface); - IOHIDDeviceRef dev2 = (IOHIDDeviceRef)context; - if (private->device != dev2) - return 1; - else - return 0; -} - static NTSTATUS iohid_device_start(struct unix_device *iface) { DWORD length; @@ -273,7 +263,6 @@ static void iohid_device_set_feature_report(struct unix_device *iface, HID_XFER_ static const struct unix_device_vtbl iohid_device_vtbl = { iohid_device_destroy, - iohid_device_compare, iohid_device_start, iohid_device_stop, iohid_device_get_report_descriptor, diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index d48f9507abb..bc7abcb933b 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -497,11 +497,6 @@ static void sdl_device_destroy(struct unix_device *iface) { }
-static int sdl_device_compare(struct unix_device *iface, void *context) -{ - return impl_from_unix_device(iface)->id - PtrToUlong(context); -} - static NTSTATUS sdl_device_start(struct unix_device *iface) { struct platform_private *ext = impl_from_unix_device(iface); @@ -596,7 +591,6 @@ static void sdl_device_set_feature_report(struct unix_device *iface, HID_XFER_PA static const struct unix_device_vtbl sdl_device_vtbl = { sdl_device_destroy, - sdl_device_compare, sdl_device_start, sdl_device_stop, sdl_device_get_reportdescriptor, diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 8cbcabf25e8..bfeb7bfc09b 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -619,13 +619,6 @@ static void hidraw_device_destroy(struct unix_device *iface) udev_device_unref(private->udev_device); }
-static int udev_device_compare(struct unix_device *iface, void *platform_dev) -{ - struct udev_device *dev1 = impl_from_unix_device(iface)->udev_device; - struct udev_device *dev2 = platform_dev; - return strcmp(udev_device_get_syspath(dev1), udev_device_get_syspath(dev2)); -} - static NTSTATUS hidraw_device_start(struct unix_device *iface) { EnterCriticalSection(&udev_cs); @@ -796,7 +789,6 @@ static void hidraw_device_set_feature_report(struct unix_device *iface, HID_XFER static const struct unix_device_vtbl hidraw_device_vtbl = { hidraw_device_destroy, - udev_device_compare, hidraw_device_start, hidraw_device_stop, hidraw_device_get_report_descriptor, @@ -898,7 +890,6 @@ static void lnxev_device_set_feature_report(struct unix_device *iface, HID_XFER_ static const struct unix_device_vtbl lnxev_device_vtbl = { lnxev_device_destroy, - udev_device_compare, lnxev_device_start, lnxev_device_stop, lnxev_device_get_report_descriptor, diff --git a/dlls/winebus.sys/unix_private.h b/dlls/winebus.sys/unix_private.h index 9b2c6d81fa2..f2af846473a 100644 --- a/dlls/winebus.sys/unix_private.h +++ b/dlls/winebus.sys/unix_private.h @@ -32,7 +32,6 @@ struct unix_device_vtbl { void (*destroy)(struct unix_device *iface); - int (*compare)(struct unix_device *iface, void *platform_dev); NTSTATUS (*start)(struct unix_device *iface); void (*stop)(struct unix_device *iface); NTSTATUS (*get_report_descriptor)(struct unix_device *iface, BYTE *buffer, DWORD length, DWORD *out_length); diff --git a/dlls/winebus.sys/unixlib.c b/dlls/winebus.sys/unixlib.c index 008fb6e77a2..b6fcdf18ffe 100644 --- a/dlls/winebus.sys/unixlib.c +++ b/dlls/winebus.sys/unixlib.c @@ -51,11 +51,6 @@ static void mouse_destroy(struct unix_device *iface) hid_descriptor_free(&impl->desc); }
-static int mouse_compare(struct unix_device *iface, void *context) -{ - return 0; -} - static NTSTATUS mouse_start(struct unix_device *iface) { struct mouse_device *impl = mouse_from_unix_device(iface); @@ -111,7 +106,6 @@ static void mouse_set_feature_report(struct unix_device *iface, HID_XFER_PACKET static const struct unix_device_vtbl mouse_vtbl = { mouse_destroy, - mouse_compare, mouse_start, mouse_stop, mouse_get_report_descriptor, @@ -155,11 +149,6 @@ static void keyboard_destroy(struct unix_device *iface) hid_descriptor_free(&impl->desc); }
-static int keyboard_compare(struct unix_device *iface, void *context) -{ - return 0; -} - static NTSTATUS keyboard_start(struct unix_device *iface) { struct keyboard_device *impl = keyboard_from_unix_device(iface); @@ -215,7 +204,6 @@ static void keyboard_set_feature_report(struct unix_device *iface, HID_XFER_PACK static const struct unix_device_vtbl keyboard_vtbl = { keyboard_destroy, - keyboard_compare, keyboard_start, keyboard_stop, keyboard_get_report_descriptor, @@ -275,13 +263,6 @@ static NTSTATUS unix_device_remove(void *args) return STATUS_SUCCESS; }
-static NTSTATUS unix_device_compare(void *args) -{ - struct device_compare_params *params = args; - struct unix_device *iface = params->iface; - return iface->vtbl->compare(iface, params->context); -} - static NTSTATUS unix_device_start(void *args) { struct unix_device *iface = args; @@ -333,7 +314,6 @@ const unixlib_entry_t __wine_unix_call_funcs[] = mouse_device_create, keyboard_device_create, unix_device_remove, - unix_device_compare, unix_device_start, unix_device_get_report_descriptor, unix_device_set_output_report, diff --git a/dlls/winebus.sys/unixlib.h b/dlls/winebus.sys/unixlib.h index cd5f64cbb51..ccca8d12e8b 100644 --- a/dlls/winebus.sys/unixlib.h +++ b/dlls/winebus.sys/unixlib.h @@ -98,12 +98,6 @@ struct device_create_params struct unix_device *device; };
-struct device_compare_params -{ - struct unix_device *iface; - void *context; -}; - struct device_descriptor_params { struct unix_device *iface; @@ -133,7 +127,6 @@ enum unix_funcs mouse_create, keyboard_create, device_remove, - device_compare, device_start, device_get_report_descriptor, device_set_output_report,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus.h | 3 --- dlls/winebus.sys/main.c | 38 --------------------------------- dlls/winebus.sys/unix_private.h | 2 ++ dlls/winebus.sys/unixlib.c | 19 +++++++++++++++++ 4 files changed, 21 insertions(+), 41 deletions(-)
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index df53508d2c0..96503a8267f 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -27,7 +27,4 @@
#include "unixlib.h"
-/* General Bus Functions */ -BOOL is_xbox_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN; - extern HANDLE driver_key DECLSPEC_HIDDEN; diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index a80bd8a186e..f1b0430509a 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -57,31 +57,6 @@ __ASM_STDCALL_FUNC( wrap_fastcall_func1, 8,
#endif
-struct product_desc -{ - WORD vid; - WORD pid; -}; - -#define VID_MICROSOFT 0x045e - -static const struct product_desc XBOX_CONTROLLERS[] = -{ - {VID_MICROSOFT, 0x0202}, /* Xbox Controller */ - {VID_MICROSOFT, 0x0285}, /* Xbox Controller S */ - {VID_MICROSOFT, 0x0289}, /* Xbox Controller S */ - {VID_MICROSOFT, 0x028e}, /* Xbox360 Controller */ - {VID_MICROSOFT, 0x028f}, /* Xbox360 Wireless Controller */ - {VID_MICROSOFT, 0x02d1}, /* Xbox One Controller */ - {VID_MICROSOFT, 0x02dd}, /* Xbox One Controller (Covert Forces/Firmware 2015) */ - {VID_MICROSOFT, 0x02e0}, /* Xbox One X Controller */ - {VID_MICROSOFT, 0x02e3}, /* Xbox One Elite Controller */ - {VID_MICROSOFT, 0x02e6}, /* Wireless XBox Controller Dongle */ - {VID_MICROSOFT, 0x02ea}, /* Xbox One S Controller */ - {VID_MICROSOFT, 0x02fd}, /* Xbox One S Controller (Firmware 2017) */ - {VID_MICROSOFT, 0x0719}, /* Xbox 360 Wireless Adapter */ -}; - static DRIVER_OBJECT *driver_obj;
static DEVICE_OBJECT *mouse_obj; @@ -1021,19 +996,6 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) return status; }
-BOOL is_xbox_gamepad(WORD vid, WORD pid) -{ - int i; - - if (vid != VID_MICROSOFT) - return FALSE; - - for (i = 0; i < ARRAY_SIZE(XBOX_CONTROLLERS); i++) - if (pid == XBOX_CONTROLLERS[i].pid) return TRUE; - - return FALSE; -} - static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *pdo) { NTSTATUS ret; diff --git a/dlls/winebus.sys/unix_private.h b/dlls/winebus.sys/unix_private.h index f2af846473a..cdc2be9b318 100644 --- a/dlls/winebus.sys/unix_private.h +++ b/dlls/winebus.sys/unix_private.h @@ -89,4 +89,6 @@ extern BOOL hid_descriptor_add_axes(struct hid_descriptor *desc, BYTE count, USA
extern BOOL hid_descriptor_add_haptics(struct hid_descriptor *desc) DECLSPEC_HIDDEN;
+BOOL is_xbox_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN; + #endif /* __WINEBUS_UNIX_PRIVATE_H */ diff --git a/dlls/winebus.sys/unixlib.c b/dlls/winebus.sys/unixlib.c index b6fcdf18ffe..57e81d3cba8 100644 --- a/dlls/winebus.sys/unixlib.c +++ b/dlls/winebus.sys/unixlib.c @@ -34,6 +34,25 @@
WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
+BOOL is_xbox_gamepad(WORD vid, WORD pid) +{ + if (vid != 0x045e) return FALSE; + if (pid == 0x0202) return TRUE; /* Xbox Controller */ + if (pid == 0x0285) return TRUE; /* Xbox Controller S */ + if (pid == 0x0289) return TRUE; /* Xbox Controller S */ + if (pid == 0x028e) return TRUE; /* Xbox360 Controller */ + if (pid == 0x028f) return TRUE; /* Xbox360 Wireless Controller */ + if (pid == 0x02d1) return TRUE; /* Xbox One Controller */ + if (pid == 0x02dd) return TRUE; /* Xbox One Controller (Covert Forces/Firmware 2015) */ + if (pid == 0x02e0) return TRUE; /* Xbox One X Controller */ + if (pid == 0x02e3) return TRUE; /* Xbox One Elite Controller */ + if (pid == 0x02e6) return TRUE; /* Wireless XBox Controller Dongle */ + if (pid == 0x02ea) return TRUE; /* Xbox One S Controller */ + if (pid == 0x02fd) return TRUE; /* Xbox One S Controller (Firmware 2017) */ + if (pid == 0x0719) return TRUE; /* Xbox 360 Wireless Adapter */ + return FALSE; +} + struct mouse_device { struct unix_device unix_device;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus.h | 30 ------------ dlls/winebus.sys/bus_iohid.c | 1 - dlls/winebus.sys/bus_sdl.c | 69 +++++++--------------------- dlls/winebus.sys/bus_udev.c | 1 - dlls/winebus.sys/main.c | 88 ++++++++++++++++++++++++++++++++++-- dlls/winebus.sys/unixlib.h | 3 ++ 6 files changed, 105 insertions(+), 87 deletions(-) delete mode 100644 dlls/winebus.sys/bus.h
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h deleted file mode 100644 index 96503a8267f..00000000000 --- a/dlls/winebus.sys/bus.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2016 Aric Stewart - * - * 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 <winternl.h> -#include <ddk/wdm.h> -#include <ddk/hidclass.h> -#include <hidusage.h> - -#include "unixlib.h" - -extern HANDLE driver_key DECLSPEC_HIDDEN; diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index f3b55cc0f70..6d3f621a15a 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -89,7 +89,6 @@ #include "ddk/hidtypes.h" #include "wine/debug.h"
-#include "bus.h" #include "unix_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(plugplay); diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index bc7abcb933b..ff3a7ca09d8 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -50,7 +50,6 @@ # define LE_WORD(x) (x) #endif
-#include "bus.h" #include "unix_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(plugplay); @@ -815,59 +814,11 @@ static void process_device_event(SDL_Event *event) LeaveCriticalSection(&sdl_cs); }
-static void sdl_load_mappings(void) +NTSTATUS sdl_bus_init(void *args) { - HKEY key; - static const WCHAR szPath[] = {'m','a','p',0}; const char *mapping; + int i;
- if ((mapping = getenv("SDL_GAMECONTROLLERCONFIG"))) - { - TRACE("Setting environment mapping %s\n", debugstr_a(mapping)); - if (pSDL_GameControllerAddMapping(mapping) < 0) - WARN("Failed to add environment mapping %s\n", pSDL_GetError()); - } - else if (!RegOpenKeyExW(driver_key, szPath, 0, KEY_QUERY_VALUE, &key)) - { - DWORD index = 0; - CHAR *buffer = NULL; - DWORD buffer_len = 0; - LSTATUS rc; - - do - { - CHAR name[255]; - DWORD name_len; - DWORD type; - DWORD data_len = buffer_len; - - name_len = sizeof(name); - rc = RegEnumValueA(key, index, name, &name_len, NULL, &type, (LPBYTE)buffer, &data_len); - if (rc == ERROR_MORE_DATA || buffer == NULL) - { - if (buffer) buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, data_len); - else buffer = HeapAlloc(GetProcessHeap(), 0, data_len); - buffer_len = data_len; - - name_len = sizeof(name); - rc = RegEnumValueA(key, index, name, &name_len, NULL, &type, (LPBYTE)buffer, &data_len); - } - - if (rc == STATUS_SUCCESS) - { - TRACE("Setting registry mapping %s\n", debugstr_a(buffer)); - if (pSDL_GameControllerAddMapping(buffer) < 0) - WARN("Failed to add registry mapping %s\n", pSDL_GetError()); - index++; - } - } while (rc == STATUS_SUCCESS); - HeapFree(GetProcessHeap(), 0, buffer); - NtClose(key); - } -} - -NTSTATUS sdl_bus_init(void *args) -{ TRACE("args %p\n", args);
options = *(struct sdl_bus_options *)args; @@ -942,7 +893,21 @@ NTSTATUS sdl_bus_init(void *args) pSDL_GameControllerEventState(SDL_ENABLE);
/* Process mappings */ - if (pSDL_GameControllerAddMapping != NULL) sdl_load_mappings(); + if (pSDL_GameControllerAddMapping) + { + if ((mapping = getenv("SDL_GAMECONTROLLERCONFIG"))) + { + TRACE("Setting environment mapping %s\n", debugstr_a(mapping)); + if (pSDL_GameControllerAddMapping(mapping) < 0) + WARN("Failed to add environment mapping %s\n", pSDL_GetError()); + } + else for (i = 0; i < options.mappings_count; ++i) + { + TRACE("Setting registry mapping %s\n", debugstr_a(options.mappings[i])); + if (pSDL_GameControllerAddMapping(options.mappings[i]) < 0) + WARN("Failed to add registry mapping %s\n", pSDL_GetError()); + } + }
return STATUS_SUCCESS;
diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index bfeb7bfc09b..b8b3a0f0a84 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -79,7 +79,6 @@ #define LE_DWORD(x) (x) #endif
-#include "bus.h" #include "unix_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(plugplay); diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index f1b0430509a..4528673f880 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -34,7 +34,6 @@ #include "wine/list.h" #include "wine/unixlib.h"
-#include "bus.h" #include "unixlib.h"
WINE_DEFAULT_DEBUG_CHANNEL(plugplay); @@ -66,7 +65,7 @@ static DEVICE_OBJECT *keyboard_obj; static DEVICE_OBJECT *bus_pdo; static DEVICE_OBJECT *bus_fdo;
-HANDLE driver_key; +static HANDLE driver_key;
enum device_state { @@ -630,6 +629,85 @@ static NTSTATUS bus_main_thread_start(struct bus_main_params *bus) return STATUS_SUCCESS; }
+static void sdl_bus_free_mappings(struct sdl_bus_options *options) +{ + DWORD count = options->mappings_count; + char **mappings = options->mappings; + + while (count) HeapFree(GetProcessHeap(), 0, mappings[--count]); + HeapFree(GetProcessHeap(), 0, mappings); +} + +static void sdl_bus_load_mappings(struct sdl_bus_options *options) +{ + static const WCHAR szPath[] = {'m','a','p',0}; + + ULONG idx = 0, len, count = 0, capacity, info_size, info_max_size; + KEY_VALUE_FULL_INFORMATION *info; + OBJECT_ATTRIBUTES attr = {0}; + char **mappings = NULL; + UNICODE_STRING path; + NTSTATUS status; + HANDLE key; + + options->mappings_count = 0; + options->mappings = NULL; + + RtlInitUnicodeString(&path, szPath); + InitializeObjectAttributes(&attr, &path, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, driver_key, NULL); + status = NtOpenKey(&key, KEY_ALL_ACCESS, &attr); + if (status) return; + + capacity = 1024; + mappings = HeapAlloc(GetProcessHeap(), 0, capacity * sizeof(*mappings)); + info_max_size = offsetof(KEY_VALUE_FULL_INFORMATION, Name) + 512; + info = HeapAlloc(GetProcessHeap(), 0, info_max_size); + + while (!status && info && mappings) + { + status = NtEnumerateValueKey(key, idx, KeyValueFullInformation, info, info_max_size, &info_size); + while (status == STATUS_BUFFER_OVERFLOW) + { + info_max_size = info_size; + if (!(info = HeapReAlloc(GetProcessHeap(), 0, info, info_max_size))) break; + status = NtEnumerateValueKey(key, idx, KeyValueFullInformation, info, info_max_size, &info_size); + } + + if (status == STATUS_NO_MORE_ENTRIES) + { + options->mappings_count = count; + options->mappings = mappings; + goto done; + } + + idx++; + if (status) break; + if (info->Type != REG_SZ) continue; + + RtlUnicodeToMultiByteSize(&len, (WCHAR *)((char *)info + info->DataOffset), info_size - info->DataOffset); + if (!len) continue; + + if (!(mappings[count++] = HeapAlloc(GetProcessHeap(), 0, len + 1))) break; + if (count > capacity) + { + capacity = capacity * 3 / 2; + if (!(mappings = HeapReAlloc(GetProcessHeap(), 0, mappings, capacity * sizeof(*mappings)))) + break; + } + + RtlUnicodeToMultiByteN(mappings[count], len, NULL, (WCHAR *)((char *)info + info->DataOffset), + info_size - info->DataOffset); + if (mappings[len - 1]) mappings[len] = 0; + } + + if (mappings) while (count) HeapFree(GetProcessHeap(), 0, mappings[--count]); + HeapFree(GetProcessHeap(), 0, mappings); + +done: + HeapFree(GetProcessHeap(), 0, info); + NtClose(key); +} + static NTSTATUS sdl_driver_init(void) { static const WCHAR bus_name[] = {'S','D','L',0}; @@ -643,11 +721,15 @@ static NTSTATUS sdl_driver_init(void) .init_code = sdl_init, .wait_code = sdl_wait, }; + NTSTATUS status;
bus_options.map_controllers = check_bus_option(&controller_mode, 1); if (!bus_options.map_controllers) TRACE("SDL controller to XInput HID gamepad mapping disabled\n"); + sdl_bus_load_mappings(&bus_options);
- return bus_main_thread_start(&bus); + status = bus_main_thread_start(&bus); + sdl_bus_free_mappings(&bus_options); + return status; }
static NTSTATUS udev_driver_init(void) diff --git a/dlls/winebus.sys/unixlib.h b/dlls/winebus.sys/unixlib.h index ccca8d12e8b..55ba42500cf 100644 --- a/dlls/winebus.sys/unixlib.h +++ b/dlls/winebus.sys/unixlib.h @@ -49,6 +49,9 @@ struct device_desc struct sdl_bus_options { BOOL map_controllers; + /* freed after bus_init */ + DWORD mappings_count; + char **mappings; };
struct udev_bus_options
Hello Rémi, I had a 32-bit build configured with "--without-mingw" around, that I updated in the last week a few times and wondered why since a few days one of the winedevice.exe processes started crashing.
A git bisect leads to this commit:
0017b5eb636ee4963636eaf83ae34f6077d695fd is the first bad commit commit 0017b5eb636ee4963636eaf83ae34f6077d695fd Author: Rémi Bernon rbernon@codeweavers.com Date: Thu Sep 16 10:17:55 2021 +0200
winebus.sys: Load SDL bus mappings before calling bus_init.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
dlls/winebus.sys/bus.h | 30 --------------- dlls/winebus.sys/bus_iohid.c | 1 - dlls/winebus.sys/bus_sdl.c | 69 +++++++++------------------------- dlls/winebus.sys/bus_udev.c | 1 - dlls/winebus.sys/main.c | 88 ++++++++++++++++++++++++++++++++++++++++++-- dlls/winebus.sys/unixlib.h | 3 ++ 6 files changed, 105 insertions(+), 87 deletions(-) delete mode 100644 dlls/winebus.sys/bus.h
This is a backtrace of such a crash:
(rr) cont Continuing.
Thread 2 received signal SIGSEGV, Segmentation fault. 0x7bc42c9a in RtlEnterCriticalSection (crit=0x7e4a084c <device_list_cs>) at .../wine-git/wine-git/include/winnt.h:6485 6485 return __sync_add_and_fetch( dest, 1 ); 1: x/i $pc => 0x7bc42c9a <RtlEnterCriticalSection+159>: lock xadd %eax,(%edx) (rr) bt #0 0x7bc42c9a in RtlEnterCriticalSection (crit=0x7e4a084c <device_list_cs>) at .../wine-git/wine-git/include/winnt.h:6485 #1 0x7e4a0e0e in bus_create_hid_device (desc=0xb1f4b4, unix_device=0x7e312af0) at .../wine-git/wine-git/dlls/winebus.sys/main.c:293 #2 0x7e4a1791 in mouse_device_create () at .../wine-git/wine-git/dlls/winebus.sys/main.c:519 #3 0x7e4a25b1 in fdo_pnp_dispatch (device=0x2485f0, irp=0x9102d8) at .../wine-git/wine-git/dlls/winebus.sys/main.c:773 #4 0x7e4a2a04 in common_pnp_dispatch (device=0x2485f0, irp=0x9102d8) at .../wine-git/wine-git/dlls/winebus.sys/main.c:877 #5 0x7e8cd668 in IoCallDriver (device=0x2485f0, irp=0x9102d8) at .../wine-git/wine-git/dlls/ntoskrnl.exe/ntoskrnl.c:1839 #6 0x7e8d4a7b in send_pnp_irp (device=0x2485f0, minor=0 '\000') at .../wine-git/wine-git/dlls/ntoskrnl.exe/pnp.c:114 #7 0x7e8d5346 in start_device (device=0x249a30, set=0x246a38, sp_device=0xb1f91e) at .../wine-git/wine-git/dlls/ntoskrnl.exe/pnp.c:302 #8 0x7e8d7b55 in wine_enumerate_root_devices (driver_name=0x2428e8) at .../wine-git/wine-git/dlls/ntoskrnl.exe/pnp.c:1180 #9 0x7e8d2860 in ZwLoadDriver (service_name=0xb1fdd8) at .../wine-git/wine-git/dlls/ntoskrnl.exe/ntoskrnl.c:3929 #10 0x7eba57d9 in device_handler (ctrl=0, driver_name=0x242712) at .../wine-git/wine-git/programs/winedevice/device.c:77 #11 0x7eba58c2 in service_handler (ctrl=2147483648, event_type=0, event_data=0x242712, context=0x245ec0) at .../wine-git/wine-git/programs/winedevice/device.c:104 #12 0x7eb11fa1 in service_handle_control (service=0x245760, control=2147483648, data=0x242712, data_size=16) at .../wine-git/wine-git/dlls/sechost/service.c:1660 #13 0x7eb12421 in service_control_dispatcher (arg=0x2457a0) at .../wine-git/wine-git/dlls/sechost/service.c:1745 #14 0x7b64e728 in __fastcall_BaseThreadInitThunk () at .../wine-git/wine-git/dlls/kernel32/kernel_private.h:30 #15 0x7bc7c48f in call_thread_func_wrapper () at .../wine-git/wine-git/dlls/ntdll/thread.c:191 #16 0x7bc7c4f6 in call_thread_func (entry=0x7eb11fa9 <service_control_dispatcher>, arg=0x2457a0) at .../wine-git/wine-git/dlls/ntdll/thread.c:225 #17 0x00000000 in ?? () (rr) print/x $edx $3 = 0x7e4a0850 (rr) when-tid Current tid: 2506348 (rr) shell cat /proc/2506348/maps | grep -i 7e4a 7e491000-7e4a4000 r-xp 00003000 08:01 172388224 .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_hardlink_4395_winebus.sys.so 7e4a4000-7e4a6000 r--p 00016000 08:01 172388224 .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_hardlink_4395_winebus.sys.so 7e4a6000-7e4a7000 r--p 00017000 08:01 172388224 .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_hardlink_4395_winebus.sys.so 7e4a7000-7e4a8000 rw-p 00018000 08:01 172388224 .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_hardlink_4395_winebus.sys.so 7e4a8000-7e4a9000 r--p 00000000 08:01 172385518 .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_hardlink_1008_version.dll.so 7e4a9000-7e4b0000 r-xp 00001000 08:01 172385518 .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_hardlink_1008_version.dll.so (rr) info target ... 0x7e4a0050 - 0x7e4a35e9 is .text in .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_pack_59_winebus.sys.so ... 0x7e4a7020 - 0x7e4a7948 is .data in .../wine-git/wine-6.17/build-32-prefix/.local/share/rr/wine-1/mmap_pack_59_winebus.sys.so ... (rr) print dest $2 = (volatile LONG *) 0x7e4a0850 <device_list_cs+4> (rr) cont Continuing. wine: Unhandled page fault on write access to 7E4A0850 at address 7BC42C9A (thread 007c), starting debugger... 006c:007c:trace:unixpid:CreateProcessInternalW app (null) cmdline L"winedbg --auto 108 80" :510
This looks like "device_list_cs" is part of the .text section, which is not writable - might this be the issue here?
In an PE-build of winebus.sys device_list_cs is stored in the .data section.
Now as I write this I remembered a similar issue in #47751, where the place, some static variables have related to some inline assembly, changed in which section they end up.
And indeed, when I move the static varibles right after the debug channel declarations, then device_list_cs gets put into the .data section and no crash happens.
Just wanted to forward the information in case this "--without-mingw" configuration is still valid.
Kind regards, Bernhard
Thanks Bernhard for the report and the debugging!
I've sent a patch yesterday to move the assembly function below the variables, it was likely the culprit.
Cheers,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus_iohid.c | 2 +- dlls/winebus.sys/bus_sdl.c | 8 ++++---- dlls/winebus.sys/bus_udev.c | 12 ++++++------ dlls/winebus.sys/hid.c | 8 ++++---- dlls/winebus.sys/main.c | 30 +++++++++++++++--------------- dlls/winebus.sys/unixlib.c | 14 +++++++------- 6 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 6d3f621a15a..4b2e607aa9b 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -168,7 +168,7 @@ static NTSTATUS iohid_device_start(struct unix_device *iface)
num = IOHIDDeviceGetProperty(private->device, CFSTR(kIOHIDMaxInputReportSizeKey)); length = CFNumberToDWORD(num); - private->buffer = HeapAlloc(GetProcessHeap(), 0, length); + private->buffer = RtlAllocateHeap(GetProcessHeap(), 0, length);
IOHIDDeviceRegisterInputReportCallback(private->device, private->buffer, length, handle_IOHIDDeviceIOHIDReportCallback, iface); return STATUS_SUCCESS; diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index ff3a7ca09d8..cff361fcaa6 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -370,7 +370,7 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext) return STATUS_NO_MEMORY;
ext->buffer_length = report_size; - if (!(ext->report_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, report_size))) + if (!(ext->report_buffer = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, report_size))) goto failed;
/* Initialize axis in the report */ @@ -382,7 +382,7 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext) return STATUS_SUCCESS;
failed: - HeapFree(GetProcessHeap(), 0, ext->report_buffer); + RtlFreeHeap(GetProcessHeap(), 0, ext->report_buffer); hid_descriptor_free(&ext->desc); return STATUS_NO_MEMORY; } @@ -471,7 +471,7 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext) if (!hid_descriptor_end(&ext->desc)) return STATUS_NO_MEMORY;
- if (!(ext->report_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ext->buffer_length))) + if (!(ext->report_buffer = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, ext->buffer_length))) goto failed;
/* Initialize axis in the report */ @@ -487,7 +487,7 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext) return STATUS_SUCCESS;
failed: - HeapFree(GetProcessHeap(), 0, ext->report_buffer); + RtlFreeHeap(GetProcessHeap(), 0, ext->report_buffer); hid_descriptor_free(&ext->desc); return STATUS_NO_MEMORY; } diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index b8b3a0f0a84..380b2b7d8f1 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -544,9 +544,9 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u TRACE("Report will be %i bytes\n", report_size);
ext->buffer_length = report_size; - if (!(ext->current_report_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, report_size))) + if (!(ext->current_report_buffer = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, report_size))) goto failed; - if (!(ext->last_report_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, report_size))) + if (!(ext->last_report_buffer = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, report_size))) goto failed; ext->report_state = FIRST;
@@ -558,8 +558,8 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u return STATUS_SUCCESS;
failed: - HeapFree(GetProcessHeap(), 0, ext->current_report_buffer); - HeapFree(GetProcessHeap(), 0, ext->last_report_buffer); + RtlFreeHeap(GetProcessHeap(), 0, ext->current_report_buffer); + RtlFreeHeap(GetProcessHeap(), 0, ext->last_report_buffer); hid_descriptor_free(&ext->desc); return STATUS_NO_MEMORY; } @@ -807,8 +807,8 @@ static void lnxev_device_destroy(struct unix_device *iface) { struct wine_input_private *ext = input_impl_from_unix_device(iface);
- HeapFree(GetProcessHeap(), 0, ext->current_report_buffer); - HeapFree(GetProcessHeap(), 0, ext->last_report_buffer); + RtlFreeHeap(GetProcessHeap(), 0, ext->current_report_buffer); + RtlFreeHeap(GetProcessHeap(), 0, ext->last_report_buffer); hid_descriptor_free(&ext->desc);
udev_device_unref(ext->base.udev_device); diff --git a/dlls/winebus.sys/hid.c b/dlls/winebus.sys/hid.c index e4623fab664..27c85d4f5a6 100644 --- a/dlls/winebus.sys/hid.c +++ b/dlls/winebus.sys/hid.c @@ -36,13 +36,13 @@ static BOOL hid_descriptor_append(struct hid_descriptor *desc, const BYTE *buffe if (desc->size + size > desc->max_size) { desc->max_size = max(desc->max_size * 3 / 2, desc->size + size); - if (!desc->data) desc->data = HeapAlloc(GetProcessHeap(), 0, desc->max_size); - else desc->data = HeapReAlloc(GetProcessHeap(), 0, tmp, desc->max_size); + if (!desc->data) desc->data = RtlAllocateHeap(GetProcessHeap(), 0, desc->max_size); + else desc->data = RtlReAllocateHeap(GetProcessHeap(), 0, tmp, desc->max_size); }
if (!desc->data) { - HeapFree(GetProcessHeap(), 0, tmp); + RtlFreeHeap(GetProcessHeap(), 0, tmp); return FALSE; }
@@ -89,7 +89,7 @@ BOOL hid_descriptor_end(struct hid_descriptor *desc)
void hid_descriptor_free(struct hid_descriptor *desc) { - HeapFree(GetProcessHeap(), 0, desc->data); + RtlFreeHeap(GetProcessHeap(), 0, desc->data); }
BOOL hid_descriptor_add_buttons(struct hid_descriptor *desc, USAGE usage_page, diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 4528673f880..4147a38706a 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -418,8 +418,8 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length EnterCriticalSection(&ext->cs); if (length > ext->buffer_size) { - HeapFree(GetProcessHeap(), 0, ext->last_report); - ext->last_report = HeapAlloc(GetProcessHeap(), 0, length); + RtlFreeHeap(GetProcessHeap(), 0, ext->last_report); + ext->last_report = RtlAllocateHeap(GetProcessHeap(), 0, length); if (!ext->last_report) { ERR_(hid_report)("Failed to alloc last report\n"); @@ -592,7 +592,7 @@ static DWORD CALLBACK bus_main_thread(void *args)
if (status) WARN("%s bus wait returned status %#x\n", debugstr_w(bus.name), status); else TRACE("%s main loop exited\n", debugstr_w(bus.name)); - HeapFree(GetProcessHeap(), 0, bus.bus_event); + RtlFreeHeap(GetProcessHeap(), 0, bus.bus_event); return status; }
@@ -608,7 +608,7 @@ static NTSTATUS bus_main_thread_start(struct bus_main_params *bus) }
max_size = offsetof(struct bus_event, input_report.buffer[0x10000]); - if (!(bus->bus_event = HeapAlloc(GetProcessHeap(), 0, max_size))) + if (!(bus->bus_event = RtlAllocateHeap(GetProcessHeap(), 0, max_size))) { ERR("failed to allocate %s bus event.\n", debugstr_w(bus->name)); CloseHandle(bus->init_done); @@ -634,8 +634,8 @@ static void sdl_bus_free_mappings(struct sdl_bus_options *options) DWORD count = options->mappings_count; char **mappings = options->mappings;
- while (count) HeapFree(GetProcessHeap(), 0, mappings[--count]); - HeapFree(GetProcessHeap(), 0, mappings); + while (count) RtlFreeHeap(GetProcessHeap(), 0, mappings[--count]); + RtlFreeHeap(GetProcessHeap(), 0, mappings); }
static void sdl_bus_load_mappings(struct sdl_bus_options *options) @@ -659,9 +659,9 @@ static void sdl_bus_load_mappings(struct sdl_bus_options *options) if (status) return;
capacity = 1024; - mappings = HeapAlloc(GetProcessHeap(), 0, capacity * sizeof(*mappings)); + mappings = RtlAllocateHeap(GetProcessHeap(), 0, capacity * sizeof(*mappings)); info_max_size = offsetof(KEY_VALUE_FULL_INFORMATION, Name) + 512; - info = HeapAlloc(GetProcessHeap(), 0, info_max_size); + info = RtlAllocateHeap(GetProcessHeap(), 0, info_max_size);
while (!status && info && mappings) { @@ -669,7 +669,7 @@ static void sdl_bus_load_mappings(struct sdl_bus_options *options) while (status == STATUS_BUFFER_OVERFLOW) { info_max_size = info_size; - if (!(info = HeapReAlloc(GetProcessHeap(), 0, info, info_max_size))) break; + if (!(info = RtlReAllocateHeap(GetProcessHeap(), 0, info, info_max_size))) break; status = NtEnumerateValueKey(key, idx, KeyValueFullInformation, info, info_max_size, &info_size); }
@@ -687,11 +687,11 @@ static void sdl_bus_load_mappings(struct sdl_bus_options *options) RtlUnicodeToMultiByteSize(&len, (WCHAR *)((char *)info + info->DataOffset), info_size - info->DataOffset); if (!len) continue;
- if (!(mappings[count++] = HeapAlloc(GetProcessHeap(), 0, len + 1))) break; + if (!(mappings[count++] = RtlAllocateHeap(GetProcessHeap(), 0, len + 1))) break; if (count > capacity) { capacity = capacity * 3 / 2; - if (!(mappings = HeapReAlloc(GetProcessHeap(), 0, mappings, capacity * sizeof(*mappings)))) + if (!(mappings = RtlReAllocateHeap(GetProcessHeap(), 0, mappings, capacity * sizeof(*mappings)))) break; }
@@ -700,11 +700,11 @@ static void sdl_bus_load_mappings(struct sdl_bus_options *options) if (mappings[len - 1]) mappings[len] = 0; }
- if (mappings) while (count) HeapFree(GetProcessHeap(), 0, mappings[--count]); - HeapFree(GetProcessHeap(), 0, mappings); + if (mappings) while (count) RtlFreeHeap(GetProcessHeap(), 0, mappings[--count]); + RtlFreeHeap(GetProcessHeap(), 0, mappings);
done: - HeapFree(GetProcessHeap(), 0, info); + RtlFreeHeap(GetProcessHeap(), 0, info); NtClose(key); }
@@ -864,7 +864,7 @@ static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) ext->cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&ext->cs);
- HeapFree(GetProcessHeap(), 0, ext->last_report); + RtlFreeHeap(GetProcessHeap(), 0, ext->last_report);
irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(irp, IO_NO_INCREMENT); diff --git a/dlls/winebus.sys/unixlib.c b/dlls/winebus.sys/unixlib.c index 57e81d3cba8..651b23aa8f4 100644 --- a/dlls/winebus.sys/unixlib.c +++ b/dlls/winebus.sys/unixlib.c @@ -253,7 +253,7 @@ void *unix_device_create(const struct unix_device_vtbl *vtbl, SIZE_T size) { struct unix_device *iface;
- if (!(iface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size))) return NULL; + if (!(iface = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, size))) return NULL; iface->vtbl = vtbl; iface->ref = 1;
@@ -265,7 +265,7 @@ static void unix_device_decref(struct unix_device *iface) if (!InterlockedDecrement(&iface->ref)) { iface->vtbl->destroy(iface); - HeapFree(GetProcessHeap(), 0, iface); + RtlFreeHeap(GetProcessHeap(), 0, iface); } }
@@ -353,14 +353,14 @@ void bus_event_queue_destroy(struct list *queue) LIST_FOR_EACH_ENTRY_SAFE(event, next, queue, struct bus_event, entry) { bus_event_cleanup(event); - HeapFree(GetProcessHeap(), 0, event); + RtlFreeHeap(GetProcessHeap(), 0, event); } }
BOOL bus_event_queue_device_removed(struct list *queue, struct unix_device *device) { ULONG size = sizeof(struct bus_event); - struct bus_event *event = HeapAlloc(GetProcessHeap(), 0, size); + struct bus_event *event = RtlAllocateHeap(GetProcessHeap(), 0, size); if (!event) return FALSE;
if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */ @@ -375,7 +375,7 @@ BOOL bus_event_queue_device_removed(struct list *queue, struct unix_device *devi BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *device, struct device_desc *desc) { ULONG size = sizeof(struct bus_event); - struct bus_event *event = HeapAlloc(GetProcessHeap(), 0, size); + struct bus_event *event = RtlAllocateHeap(GetProcessHeap(), 0, size); if (!event) return FALSE;
if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */ @@ -391,7 +391,7 @@ BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *devi BOOL bus_event_queue_input_report(struct list *queue, struct unix_device *device, BYTE *report, USHORT length) { ULONG size = offsetof(struct bus_event, input_report.buffer[length]); - struct bus_event *event = HeapAlloc(GetProcessHeap(), 0, size); + struct bus_event *event = RtlAllocateHeap(GetProcessHeap(), 0, size); if (!event) return FALSE;
if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */ @@ -420,7 +420,7 @@ BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event) else size = offsetof(struct bus_event, input_report.buffer[event->input_report.length]);
memcpy(event, tmp, size); - HeapFree(GetProcessHeap(), 0, tmp); + RtlFreeHeap(GetProcessHeap(), 0, tmp);
return TRUE; }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus_iohid.c | 8 +++---- dlls/winebus.sys/bus_sdl.c | 8 +++---- dlls/winebus.sys/bus_udev.c | 24 +++++++++---------- dlls/winebus.sys/main.c | 46 ++++++++++++++++++------------------ 4 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 4b2e607aa9b..8e6cb0a5ee9 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -180,9 +180,9 @@ static void iohid_device_stop(struct unix_device *iface)
IOHIDDeviceRegisterInputReportCallback(private->device, NULL, 0, NULL, NULL);
- EnterCriticalSection(&iohid_cs); + RtlEnterCriticalSection(&iohid_cs); list_remove(&private->unix_device.entry); - LeaveCriticalSection(&iohid_cs); + RtlLeaveCriticalSection(&iohid_cs); }
static NTSTATUS iohid_device_get_report_descriptor(struct unix_device *iface, BYTE *buffer, @@ -403,9 +403,9 @@ NTSTATUS iohid_bus_wait(void *args) do { if (bus_event_queue_pop(&event_queue, result)) return STATUS_PENDING; - EnterCriticalSection(&iohid_cs); + RtlEnterCriticalSection(&iohid_cs); ret = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, TRUE); - LeaveCriticalSection(&iohid_cs); + RtlLeaveCriticalSection(&iohid_cs); } while (ret != kCFRunLoopRunStopped);
TRACE("IOHID main loop exiting\n"); diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index cff361fcaa6..785d1045622 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -511,9 +511,9 @@ static void sdl_device_stop(struct unix_device *iface) if (private->sdl_controller) pSDL_GameControllerClose(private->sdl_controller); if (private->sdl_haptic) pSDL_HapticClose(private->sdl_haptic);
- EnterCriticalSection(&sdl_cs); + RtlEnterCriticalSection(&sdl_cs); list_remove(&private->unix_device.entry); - LeaveCriticalSection(&sdl_cs); + RtlLeaveCriticalSection(&sdl_cs); }
static NTSTATUS sdl_device_get_reportdescriptor(struct unix_device *iface, BYTE *buffer, @@ -785,7 +785,7 @@ static void process_device_event(SDL_Event *event)
TRACE_(hid_report)("Received action %x\n", event->type);
- EnterCriticalSection(&sdl_cs); + RtlEnterCriticalSection(&sdl_cs);
if (event->type == SDL_JOYDEVICEADDED) sdl_add_device(((SDL_JoyDeviceEvent *)event)->which); @@ -811,7 +811,7 @@ static void process_device_event(SDL_Event *event) else WARN("failed to find device with id %d\n", id); }
- LeaveCriticalSection(&sdl_cs); + RtlLeaveCriticalSection(&sdl_cs); }
NTSTATUS sdl_bus_init(void *args) diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 380b2b7d8f1..2cb727d8216 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -620,9 +620,9 @@ static void hidraw_device_destroy(struct unix_device *iface)
static NTSTATUS hidraw_device_start(struct unix_device *iface) { - EnterCriticalSection(&udev_cs); + RtlEnterCriticalSection(&udev_cs); start_polling_device(iface); - LeaveCriticalSection(&udev_cs); + RtlLeaveCriticalSection(&udev_cs); return STATUS_SUCCESS; }
@@ -630,10 +630,10 @@ static void hidraw_device_stop(struct unix_device *iface) { struct platform_private *private = impl_from_unix_device(iface);
- EnterCriticalSection(&udev_cs); + RtlEnterCriticalSection(&udev_cs); stop_polling_device(iface); list_remove(&private->unix_device.entry); - LeaveCriticalSection(&udev_cs); + RtlLeaveCriticalSection(&udev_cs); }
static NTSTATUS hidraw_device_get_report_descriptor(struct unix_device *iface, BYTE *buffer, @@ -822,9 +822,9 @@ static NTSTATUS lnxev_device_start(struct unix_device *iface) if ((status = build_report_descriptor(ext, ext->base.udev_device))) return status;
- EnterCriticalSection(&udev_cs); + RtlEnterCriticalSection(&udev_cs); start_polling_device(iface); - LeaveCriticalSection(&udev_cs); + RtlLeaveCriticalSection(&udev_cs); return STATUS_SUCCESS; }
@@ -832,10 +832,10 @@ static void lnxev_device_stop(struct unix_device *iface) { struct wine_input_private *ext = input_impl_from_unix_device(iface);
- EnterCriticalSection(&udev_cs); + RtlEnterCriticalSection(&udev_cs); stop_polling_device(iface); list_remove(&ext->base.unix_device.entry); - LeaveCriticalSection(&udev_cs); + RtlLeaveCriticalSection(&udev_cs); }
static NTSTATUS lnxev_device_get_report_descriptor(struct unix_device *iface, BYTE *buffer, @@ -1244,16 +1244,16 @@ NTSTATUS udev_bus_wait(void *args) { if (bus_event_queue_pop(&event_queue, result)) return STATUS_PENDING;
- EnterCriticalSection(&udev_cs); + RtlEnterCriticalSection(&udev_cs); while (close_count--) close(close_fds[close_count]); memcpy(pfd, poll_fds, poll_count * sizeof(*pfd)); count = poll_count; close_count = 0; - LeaveCriticalSection(&udev_cs); + RtlLeaveCriticalSection(&udev_cs);
while (poll(pfd, count, -1) <= 0) {}
- EnterCriticalSection(&udev_cs); + RtlEnterCriticalSection(&udev_cs); if (pfd[0].revents) process_monitor_event(udev_monitor); if (pfd[1].revents) read(deviceloop_control[0], &ctrl, 1); for (i = 2; i < count; ++i) @@ -1262,7 +1262,7 @@ NTSTATUS udev_bus_wait(void *args) device = find_device_from_fd(pfd[i].fd); if (device) device->read_report(&device->unix_device); } - LeaveCriticalSection(&udev_cs); + RtlLeaveCriticalSection(&udev_cs); }
TRACE("UDEV main loop exiting\n"); diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 4147a38706a..d19a2b7cb6c 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -294,7 +294,7 @@ static DEVICE_OBJECT *bus_create_hid_device(struct device_desc *desc, struct uni return NULL; }
- EnterCriticalSection(&device_list_cs); + RtlEnterCriticalSection(&device_list_cs);
/* fill out device_extension struct */ ext = (struct device_extension *)device->DeviceExtension; @@ -318,7 +318,7 @@ static DEVICE_OBJECT *bus_create_hid_device(struct device_desc *desc, struct uni /* add to list of pnp devices */ list_add_tail(&device_list, &ext->entry);
- LeaveCriticalSection(&device_list_cs); + RtlLeaveCriticalSection(&device_list_cs); return device; }
@@ -327,7 +327,7 @@ static DEVICE_OBJECT *bus_find_unix_device(struct unix_device *unix_device) struct device_extension *ext; DEVICE_OBJECT *ret = NULL;
- EnterCriticalSection(&device_list_cs); + RtlEnterCriticalSection(&device_list_cs); LIST_FOR_EACH_ENTRY(ext, &device_list, struct device_extension, entry) { if (ext->unix_device == unix_device) @@ -336,7 +336,7 @@ static DEVICE_OBJECT *bus_find_unix_device(struct unix_device *unix_device) break; } } - LeaveCriticalSection(&device_list_cs); + RtlLeaveCriticalSection(&device_list_cs);
return ret; } @@ -345,9 +345,9 @@ static void bus_unlink_hid_device(DEVICE_OBJECT *device) { struct device_extension *ext = (struct device_extension *)device->DeviceExtension;
- EnterCriticalSection(&device_list_cs); + RtlEnterCriticalSection(&device_list_cs); list_remove(&ext->entry); - LeaveCriticalSection(&device_list_cs); + RtlLeaveCriticalSection(&device_list_cs); }
static NTSTATUS build_device_relations(DEVICE_RELATIONS **devices) @@ -355,12 +355,12 @@ static NTSTATUS build_device_relations(DEVICE_RELATIONS **devices) struct device_extension *ext; int i;
- EnterCriticalSection(&device_list_cs); + RtlEnterCriticalSection(&device_list_cs); *devices = ExAllocatePool(PagedPool, offsetof(DEVICE_RELATIONS, Objects[list_count(&device_list)]));
if (!*devices) { - LeaveCriticalSection(&device_list_cs); + RtlLeaveCriticalSection(&device_list_cs); return STATUS_INSUFFICIENT_RESOURCES; }
@@ -371,7 +371,7 @@ static NTSTATUS build_device_relations(DEVICE_RELATIONS **devices) call_fastcall_func1(ObfReferenceObject, ext->device); i++; } - LeaveCriticalSection(&device_list_cs); + RtlLeaveCriticalSection(&device_list_cs); (*devices)->Count = i; return STATUS_SUCCESS; } @@ -415,7 +415,7 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length if (!length || !report) return;
- EnterCriticalSection(&ext->cs); + RtlEnterCriticalSection(&ext->cs); if (length > ext->buffer_size) { RtlFreeHeap(GetProcessHeap(), 0, ext->last_report); @@ -426,7 +426,7 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length ext->buffer_size = 0; ext->last_report_size = 0; ext->last_report_read = TRUE; - LeaveCriticalSection(&ext->cs); + RtlLeaveCriticalSection(&ext->cs); return; } else @@ -449,7 +449,7 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length ext->last_report_read = TRUE; IoCompleteRequest(irp, IO_NO_INCREMENT); } - LeaveCriticalSection(&ext->cs); + RtlLeaveCriticalSection(&ext->cs); }
static NTSTATUS handle_IRP_MN_QUERY_DEVICE_RELATIONS(IRP *irp) @@ -564,11 +564,11 @@ static DWORD CALLBACK bus_main_thread(void *args) { case BUS_EVENT_TYPE_NONE: break; case BUS_EVENT_TYPE_DEVICE_REMOVED: - EnterCriticalSection(&device_list_cs); + RtlEnterCriticalSection(&device_list_cs); device = bus_find_unix_device(event->device); if (!device) WARN("could not find device for %s bus device %p\n", debugstr_w(bus.name), event->device); else bus_unlink_hid_device(device); - LeaveCriticalSection(&device_list_cs); + RtlLeaveCriticalSection(&device_list_cs); IoInvalidateDeviceRelations(bus_pdo, BusRelations); break; case BUS_EVENT_TYPE_DEVICE_CREATED: @@ -581,11 +581,11 @@ static DWORD CALLBACK bus_main_thread(void *args) } break; case BUS_EVENT_TYPE_INPUT_REPORT: - EnterCriticalSection(&device_list_cs); + RtlEnterCriticalSection(&device_list_cs); device = bus_find_unix_device(event->device); if (!device) WARN("could not find device for %s bus device %p\n", debugstr_w(bus.name), event->device); else process_hid_report(device, event->input_report.buffer, event->input_report.length); - LeaveCriticalSection(&device_list_cs); + RtlLeaveCriticalSection(&device_list_cs); break; } } @@ -839,19 +839,19 @@ static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) break;
case IRP_MN_START_DEVICE: - EnterCriticalSection(&ext->cs); + RtlEnterCriticalSection(&ext->cs); if (ext->state != DEVICE_STATE_STOPPED) status = STATUS_SUCCESS; else if (ext->state == DEVICE_STATE_REMOVED) status = STATUS_DELETE_PENDING; else if (!(status = unix_device_start(device))) ext->state = DEVICE_STATE_STARTED; else ERR("failed to start device %p, status %#x\n", device, status); - LeaveCriticalSection(&ext->cs); + RtlLeaveCriticalSection(&ext->cs); break;
case IRP_MN_SURPRISE_REMOVAL: - EnterCriticalSection(&ext->cs); + RtlEnterCriticalSection(&ext->cs); remove_pending_irps(device); ext->state = DEVICE_STATE_REMOVED; - LeaveCriticalSection(&ext->cs); + RtlLeaveCriticalSection(&ext->cs); status = STATUS_SUCCESS; break;
@@ -934,11 +934,11 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) return IoCallDriver(bus_pdo, irp); }
- EnterCriticalSection(&ext->cs); + RtlEnterCriticalSection(&ext->cs);
if (ext->state == DEVICE_STATE_REMOVED) { - LeaveCriticalSection(&ext->cs); + RtlLeaveCriticalSection(&ext->cs); irp->IoStatus.Status = STATUS_DELETE_PENDING; IoCompleteRequest(irp, IO_NO_INCREMENT); return STATUS_DELETE_PENDING; @@ -1072,7 +1072,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) }
status = irp->IoStatus.Status; - LeaveCriticalSection(&ext->cs); + RtlLeaveCriticalSection(&ext->cs);
if (status != STATUS_PENDING) IoCompleteRequest(irp, IO_NO_INCREMENT); return status;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/Makefile.in | 2 +- dlls/winebus.sys/bus_iohid.c | 16 ++++++++----- dlls/winebus.sys/bus_sdl.c | 16 ++++++++----- dlls/winebus.sys/bus_udev.c | 16 ++++++++----- dlls/winebus.sys/hid.c | 4 ++++ dlls/winebus.sys/main.c | 41 ++++++++++++++++++++------------- dlls/winebus.sys/unix_private.h | 18 +++++++-------- dlls/winebus.sys/unixlib.c | 29 +++++++++++++++-------- dlls/winebus.sys/unixlib.h | 3 +-- 9 files changed, 90 insertions(+), 55 deletions(-)
diff --git a/dlls/winebus.sys/Makefile.in b/dlls/winebus.sys/Makefile.in index 658d27b70fd..1675bf1951c 100644 --- a/dlls/winebus.sys/Makefile.in +++ b/dlls/winebus.sys/Makefile.in @@ -2,7 +2,7 @@ MODULE = winebus.sys IMPORTS = ntoskrnl advapi32 EXTRALIBS = $(IOKIT_LIBS) $(UDEV_LIBS) EXTRAINCL = $(UDEV_CFLAGS) $(SDL2_CFLAGS) -EXTRADLLFLAGS = -Wl,--subsystem,native +EXTRADLLFLAGS = -mno-cygwin -Wl,--subsystem,native
C_SRCS = \ bus_iohid.c \ diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 8e6cb0a5ee9..0e36eac880c 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -17,6 +17,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h" #include "wine/port.h"
@@ -371,7 +375,7 @@ static void handle_RemovalCallback(void *context, IOReturn result, void *sender, else WARN("failed to find device for iohid device %p\n", IOHIDDevice); }
-NTSTATUS iohid_bus_init(void *args) +NTSTATUS WINAPI iohid_bus_init(void *args) { TRACE("args %p\n", args);
@@ -392,7 +396,7 @@ NTSTATUS iohid_bus_init(void *args) return STATUS_SUCCESS; }
-NTSTATUS iohid_bus_wait(void *args) +NTSTATUS WINAPI iohid_bus_wait(void *args) { struct bus_event *result = args; CFRunLoopRunResult ret; @@ -416,7 +420,7 @@ NTSTATUS iohid_bus_wait(void *args) return STATUS_SUCCESS; }
-NTSTATUS iohid_bus_stop(void *args) +NTSTATUS WINAPI iohid_bus_stop(void *args) { if (!run_loop) return STATUS_SUCCESS;
@@ -427,19 +431,19 @@ NTSTATUS iohid_bus_stop(void *args)
#else
-NTSTATUS iohid_bus_init(void *args) +NTSTATUS WINAPI iohid_bus_init(void *args) { WARN("IOHID support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; }
-NTSTATUS iohid_bus_wait(void *args) +NTSTATUS WINAPI iohid_bus_wait(void *args) { WARN("IOHID support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; }
-NTSTATUS iohid_bus_stop(void *args) +NTSTATUS WINAPI iohid_bus_stop(void *args) { WARN("IOHID support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 785d1045622..79dff5007c0 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -18,6 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h" #include "wine/port.h" #include <errno.h> @@ -814,7 +818,7 @@ static void process_device_event(SDL_Event *event) RtlLeaveCriticalSection(&sdl_cs); }
-NTSTATUS sdl_bus_init(void *args) +NTSTATUS WINAPI sdl_bus_init(void *args) { const char *mapping; int i; @@ -917,7 +921,7 @@ failed: return STATUS_UNSUCCESSFUL; }
-NTSTATUS sdl_bus_wait(void *args) +NTSTATUS WINAPI sdl_bus_wait(void *args) { struct bus_event *result = args; SDL_Event event; @@ -939,7 +943,7 @@ NTSTATUS sdl_bus_wait(void *args) return STATUS_SUCCESS; }
-NTSTATUS sdl_bus_stop(void *args) +NTSTATUS WINAPI sdl_bus_stop(void *args) { SDL_Event event;
@@ -957,19 +961,19 @@ NTSTATUS sdl_bus_stop(void *args)
#else
-NTSTATUS sdl_bus_init(void *args) +NTSTATUS WINAPI sdl_bus_init(void *args) { WARN("SDL support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; }
-NTSTATUS sdl_bus_wait(void *args) +NTSTATUS WINAPI sdl_bus_wait(void *args) { WARN("SDL support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; }
-NTSTATUS sdl_bus_stop(void *args) +NTSTATUS WINAPI sdl_bus_stop(void *args) { WARN("SDL support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 2cb727d8216..c859d5df546 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -18,6 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h" #include <errno.h> #include <fcntl.h> @@ -1184,7 +1188,7 @@ static void process_monitor_event(struct udev_monitor *monitor) udev_device_unref(dev); }
-NTSTATUS udev_bus_init(void *args) +NTSTATUS WINAPI udev_bus_init(void *args) { int monitor_fd;
@@ -1229,7 +1233,7 @@ error: return STATUS_UNSUCCESSFUL; }
-NTSTATUS udev_bus_wait(void *args) +NTSTATUS WINAPI udev_bus_wait(void *args) { struct platform_private *device; struct bus_event *result = args; @@ -1275,7 +1279,7 @@ NTSTATUS udev_bus_wait(void *args) return STATUS_SUCCESS; }
-NTSTATUS udev_bus_stop(void *args) +NTSTATUS WINAPI udev_bus_stop(void *args) { if (!udev_context) return STATUS_SUCCESS; write(deviceloop_control[1], "q", 1); @@ -1284,19 +1288,19 @@ NTSTATUS udev_bus_stop(void *args)
#else
-NTSTATUS udev_bus_init(void *args) +NTSTATUS WINAPI udev_bus_init(void *args) { WARN("UDEV support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; }
-NTSTATUS udev_bus_wait(void *args) +NTSTATUS WINAPI udev_bus_wait(void *args) { WARN("UDEV support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; }
-NTSTATUS udev_bus_stop(void *args) +NTSTATUS WINAPI udev_bus_stop(void *args) { WARN("UDEV support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; diff --git a/dlls/winebus.sys/hid.c b/dlls/winebus.sys/hid.c index 27c85d4f5a6..959cbf7c428 100644 --- a/dlls/winebus.sys/hid.c +++ b/dlls/winebus.sys/hid.c @@ -18,6 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include <stdarg.h>
#include "ntstatus.h" diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index d19a2b7cb6c..508b274d609 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -17,11 +17,14 @@ * 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 "config.h" + #include <stdarg.h>
#include "ntstatus.h" #define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winnls.h" #include "winternl.h" #include "winioctl.h" #include "hidusage.h" @@ -30,7 +33,6 @@ #include "ddk/hidtypes.h" #include "wine/asm.h" #include "wine/debug.h" -#include "wine/unicode.h" #include "wine/list.h" #include "wine/unixlib.h"
@@ -109,6 +111,9 @@ static CRITICAL_SECTION device_list_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
static struct list device_list = LIST_INIT(device_list);
+static HMODULE instance; +static const unix_entry_point *__wine_unix_call_funcs; + static NTSTATUS winebus_call(unsigned int code, void *args) { return __wine_unix_call_funcs[code]( args ); @@ -193,11 +198,11 @@ static WCHAR *get_instance_id(DEVICE_OBJECT *device) { static const WCHAR formatW[] = {'%','i','&','%','s','&','%','x','&','%','i',0}; struct device_extension *ext = (struct device_extension *)device->DeviceExtension; - DWORD len = strlenW(ext->serialnumber) + 33; + DWORD len = wcslen(ext->serialnumber) + 33; WCHAR *dst;
if ((dst = ExAllocatePool(PagedPool, len * sizeof(WCHAR)))) - sprintfW(dst, formatW, ext->desc.version, ext->serialnumber, ext->desc.uid, ext->index); + swprintf(dst, len, formatW, ext->desc.version, ext->serialnumber, ext->desc.uid, ext->index);
return dst; } @@ -208,13 +213,13 @@ static WCHAR *get_device_id(DEVICE_OBJECT *device) static const WCHAR formatW[] = {'%','s','\','v','i','d','_','%','0','4','x', '&','p','i','d','_','%','0','4','x',0}; struct device_extension *ext = (struct device_extension *)device->DeviceExtension; - DWORD len = strlenW(ext->desc.busid) + 34; - WCHAR *dst, *tmp; + DWORD pos = 0, len = wcslen(ext->desc.busid) + 34; + WCHAR *dst;
if ((dst = ExAllocatePool(PagedPool, len * sizeof(WCHAR)))) { - tmp = dst + sprintfW(dst, formatW, ext->desc.busid, ext->desc.vid, ext->desc.pid); - if (ext->desc.input != -1) sprintfW(tmp, input_formatW, ext->desc.input); + pos += swprintf(dst + pos, len - pos, formatW, ext->desc.busid, ext->desc.vid, ext->desc.pid); + if (ext->desc.input != -1) pos += swprintf(dst + pos, len - pos, input_formatW, ext->desc.input); }
return dst; @@ -225,10 +230,10 @@ static WCHAR *get_hardware_ids(DEVICE_OBJECT *device) struct device_extension *ext = (struct device_extension *)device->DeviceExtension; WCHAR *dst;
- if ((dst = ExAllocatePool(PagedPool, (strlenW(ext->desc.busid) + 2) * sizeof(WCHAR)))) + if ((dst = ExAllocatePool(PagedPool, (wcslen(ext->desc.busid) + 2) * sizeof(WCHAR)))) { - strcpyW(dst, ext->desc.busid); - dst[strlenW(dst) + 1] = 0; + wcscpy(dst, ext->desc.busid); + dst[wcslen(dst) + 1] = 0; }
return dst; @@ -285,7 +290,7 @@ static DEVICE_OBJECT *bus_create_hid_device(struct device_desc *desc, struct uni
TRACE("desc %s, unix_device %p\n", debugstr_device_desc(desc), unix_device);
- sprintfW(dev_name, device_name_fmtW, desc->busid, unix_device); + swprintf(dev_name, ARRAY_SIZE(dev_name), device_name_fmtW, desc->busid, unix_device); RtlInitUnicodeString(&nameW, dev_name); status = IoCreateDevice(driver_obj, sizeof(struct device_extension), &nameW, 0, 0, FALSE, &device); if (status) @@ -900,17 +905,17 @@ static NTSTATUS hid_get_device_string(DEVICE_OBJECT *device, DWORD index, WCHAR switch (index) { case HID_STRING_ID_IMANUFACTURER: - len = (strlenW(ext->manufacturer) + 1) * sizeof(WCHAR); + len = (wcslen(ext->manufacturer) + 1) * sizeof(WCHAR); if (len > buffer_len) return STATUS_BUFFER_TOO_SMALL; else memcpy(buffer, ext->manufacturer, len); return STATUS_SUCCESS; case HID_STRING_ID_IPRODUCT: - len = (strlenW(ext->product) + 1) * sizeof(WCHAR); + len = (wcslen(ext->product) + 1) * sizeof(WCHAR); if (len > buffer_len) return STATUS_BUFFER_TOO_SMALL; else memcpy(buffer, ext->product, len); return STATUS_SUCCESS; case HID_STRING_ID_ISERIALNUMBER: - len = (strlenW(ext->serialnumber) + 1) * sizeof(WCHAR); + len = (wcslen(ext->serialnumber) + 1) * sizeof(WCHAR); if (len > buffer_len) return STATUS_BUFFER_TOO_SMALL; else memcpy(buffer, ext->serialnumber, len); return STATUS_SUCCESS; @@ -1012,7 +1017,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
irp->IoStatus.Status = hid_get_device_string(device, index, (WCHAR *)irp->UserBuffer, buffer_len); if (irp->IoStatus.Status == STATUS_SUCCESS) - irp->IoStatus.Information = (strlenW((WCHAR *)irp->UserBuffer) + 1) * sizeof(WCHAR); + irp->IoStatus.Information = (wcslen((WCHAR *)irp->UserBuffer) + 1) * sizeof(WCHAR); break; } case IOCTL_HID_GET_INPUT_REPORT: @@ -1110,6 +1115,10 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
TRACE( "(%p, %s)\n", driver, debugstr_w(path->Buffer) );
+ RtlPcToFileHeader(&DriverEntry, (void *)&instance); + if ((ret = __wine_init_unix_lib(instance, DLL_PROCESS_ATTACH, NULL, &__wine_unix_call_funcs))) + return ret; + attr.Length = sizeof(attr); attr.ObjectName = path; attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE; diff --git a/dlls/winebus.sys/unix_private.h b/dlls/winebus.sys/unix_private.h index cdc2be9b318..5e30b21955a 100644 --- a/dlls/winebus.sys/unix_private.h +++ b/dlls/winebus.sys/unix_private.h @@ -49,17 +49,17 @@ struct unix_device
extern void *unix_device_create(const struct unix_device_vtbl *vtbl, SIZE_T size) DECLSPEC_HIDDEN;
-extern NTSTATUS sdl_bus_init(void *) DECLSPEC_HIDDEN; -extern NTSTATUS sdl_bus_wait(void *) DECLSPEC_HIDDEN; -extern NTSTATUS sdl_bus_stop(void *) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI sdl_bus_init(void *) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI sdl_bus_wait(void *) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI sdl_bus_stop(void *) DECLSPEC_HIDDEN;
-extern NTSTATUS udev_bus_init(void *) DECLSPEC_HIDDEN; -extern NTSTATUS udev_bus_wait(void *) DECLSPEC_HIDDEN; -extern NTSTATUS udev_bus_stop(void *) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI udev_bus_init(void *) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI udev_bus_wait(void *) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI udev_bus_stop(void *) DECLSPEC_HIDDEN;
-extern NTSTATUS iohid_bus_init(void *) DECLSPEC_HIDDEN; -extern NTSTATUS iohid_bus_wait(void *) DECLSPEC_HIDDEN; -extern NTSTATUS iohid_bus_stop(void *) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI iohid_bus_init(void *) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI iohid_bus_wait(void *) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI iohid_bus_stop(void *) DECLSPEC_HIDDEN;
extern void bus_event_cleanup(struct bus_event *event) DECLSPEC_HIDDEN; extern void bus_event_queue_destroy(struct list *queue) DECLSPEC_HIDDEN; diff --git a/dlls/winebus.sys/unixlib.c b/dlls/winebus.sys/unixlib.c index 651b23aa8f4..3c332838faf 100644 --- a/dlls/winebus.sys/unixlib.c +++ b/dlls/winebus.sys/unixlib.c @@ -16,6 +16,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#if 0 +#pragma makedep unix +#endif + #include "config.h"
#include <stdarg.h> @@ -143,7 +147,7 @@ static const struct device_desc mouse_device_desc = .serialnumber = {"0000"}, };
-static NTSTATUS mouse_device_create(void *args) +static NTSTATUS WINAPI mouse_device_create(void *args) { struct device_create_params *params = args; params->desc = mouse_device_desc; @@ -241,7 +245,7 @@ static const struct device_desc keyboard_device_desc = .serialnumber = {"0000"}, };
-static NTSTATUS keyboard_device_create(void *args) +static NTSTATUS WINAPI keyboard_device_create(void *args) { struct device_create_params *params = args; params->desc = keyboard_device_desc; @@ -274,7 +278,7 @@ static ULONG unix_device_incref(struct unix_device *iface) return InterlockedIncrement(&iface->ref); }
-static NTSTATUS unix_device_remove(void *args) +static NTSTATUS WINAPI unix_device_remove(void *args) { struct unix_device *iface = args; iface->vtbl->stop(iface); @@ -282,20 +286,20 @@ static NTSTATUS unix_device_remove(void *args) return STATUS_SUCCESS; }
-static NTSTATUS unix_device_start(void *args) +static NTSTATUS WINAPI unix_device_start(void *args) { struct unix_device *iface = args; return iface->vtbl->start(iface); }
-static NTSTATUS unix_device_get_report_descriptor(void *args) +static NTSTATUS WINAPI unix_device_get_report_descriptor(void *args) { struct device_descriptor_params *params = args; struct unix_device *iface = params->iface; return iface->vtbl->get_report_descriptor(iface, params->buffer, params->length, params->out_length); }
-static NTSTATUS unix_device_set_output_report(void *args) +static NTSTATUS WINAPI unix_device_set_output_report(void *args) { struct device_report_params *params = args; struct unix_device *iface = params->iface; @@ -303,7 +307,7 @@ static NTSTATUS unix_device_set_output_report(void *args) return STATUS_SUCCESS; }
-static NTSTATUS unix_device_get_feature_report(void *args) +static NTSTATUS WINAPI unix_device_get_feature_report(void *args) { struct device_report_params *params = args; struct unix_device *iface = params->iface; @@ -311,7 +315,7 @@ static NTSTATUS unix_device_get_feature_report(void *args) return STATUS_SUCCESS; }
-static NTSTATUS unix_device_set_feature_report(void *args) +static NTSTATUS WINAPI unix_device_set_feature_report(void *args) { struct device_report_params *params = args; struct unix_device *iface = params->iface; @@ -319,7 +323,7 @@ static NTSTATUS unix_device_set_feature_report(void *args) return STATUS_SUCCESS; }
-const unixlib_entry_t __wine_unix_call_funcs[] = +const unix_entry_point __wine_unix_call_funcs[] = { sdl_bus_init, sdl_bus_wait, @@ -424,3 +428,10 @@ BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event)
return TRUE; } + +NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out ) +{ + if (reason != DLL_PROCESS_ATTACH) return STATUS_SUCCESS; + *(const unix_entry_point **)ptr_out = __wine_unix_call_funcs; + return STATUS_SUCCESS; +} diff --git a/dlls/winebus.sys/unixlib.h b/dlls/winebus.sys/unixlib.h index 55ba42500cf..e5156176c46 100644 --- a/dlls/winebus.sys/unixlib.h +++ b/dlls/winebus.sys/unixlib.h @@ -29,7 +29,6 @@
#include "wine/debug.h" #include "wine/list.h" -#include "wine/unixlib.h"
struct device_desc { @@ -137,7 +136,7 @@ enum unix_funcs device_set_feature_report, };
-extern const unixlib_entry_t __wine_unix_call_funcs[] DECLSPEC_HIDDEN; +typedef NTSTATUS (WINAPI *unix_entry_point)(void *);
static inline const char *debugstr_device_desc(struct device_desc *desc) {
Rémi Bernon rbernon@codeweavers.com writes:
@@ -319,7 +323,7 @@ static NTSTATUS unix_device_set_feature_report(void *args) return STATUS_SUCCESS; }
-const unixlib_entry_t __wine_unix_call_funcs[] = +const unix_entry_point __wine_unix_call_funcs[] =
If it's not a proper entry point table for __wine_unix_call(), I'd suggest changing its name to avoid confusion. Of course it will all have to be changed back later...
On 9/16/21 10:54 AM, Alexandre Julliard wrote:
Rémi Bernon rbernon@codeweavers.com writes:
@@ -319,7 +323,7 @@ static NTSTATUS unix_device_set_feature_report(void *args) return STATUS_SUCCESS; }
-const unixlib_entry_t __wine_unix_call_funcs[] = +const unix_entry_point __wine_unix_call_funcs[] =
If it's not a proper entry point table for __wine_unix_call(), I'd suggest changing its name to avoid confusion. Of course it will all have to be changed back later...
Yes it was only temporary, as with the WINAPI declspec additions.
Let's just ignore that last patch then I'll resend it later with the conversion to the new unixlib interface.