From: "Rémi Bernon" Subject: [PATCH 4/5] winebus.sys: Use new unixlib subsystem. Message-Id: <20210917065035.3294478-4-rbernon@codeweavers.com> Date: Fri, 17 Sep 2021 08:50:34 +0200 In-Reply-To: <20210917065035.3294478-1-rbernon@codeweavers.com> References: <20210917065035.3294478-1-rbernon@codeweavers.com> Signed-off-by: Rémi Bernon --- dlls/winebus.sys/Makefile.in | 2 +- dlls/winebus.sys/bus_iohid.c | 12 ++++++------ dlls/winebus.sys/bus_sdl.c | 12 ++++++------ dlls/winebus.sys/bus_udev.c | 12 ++++++------ dlls/winebus.sys/main.c | 7 ++++--- dlls/winebus.sys/unix_private.h | 18 +++++++++--------- dlls/winebus.sys/unixlib.c | 25 +++++++++---------------- dlls/winebus.sys/unixlib.h | 2 -- 8 files changed, 41 insertions(+), 49 deletions(-) diff --git a/dlls/winebus.sys/Makefile.in b/dlls/winebus.sys/Makefile.in index ec731c2b85c..d358517000d 100644 --- a/dlls/winebus.sys/Makefile.in +++ b/dlls/winebus.sys/Makefile.in @@ -1,6 +1,6 @@ MODULE = winebus.sys IMPORTS = ntoskrnl advapi32 -EXTRALIBS = $(IOKIT_LIBS) $(UDEV_LIBS) $(PTHREAD_LIBS) +EXTRALIBS = $(IOKIT_LIBS) $(UDEV_LIBS) $(PTHREAD_LIBS) -Wl,--subsystem,unixlib EXTRAINCL = $(UDEV_CFLAGS) $(SDL2_CFLAGS) EXTRADLLFLAGS = -mno-cygwin -Wl,--subsystem,native diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 8dc9e6c3df1..15f37dd2188 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -370,7 +370,7 @@ static void handle_RemovalCallback(void *context, IOReturn result, void *sender, else WARN("failed to find device for iohid device %p\n", IOHIDDevice); } -NTSTATUS WINAPI iohid_bus_init(void *args) +NTSTATUS iohid_bus_init(void *args) { TRACE("args %p\n", args); @@ -391,7 +391,7 @@ NTSTATUS WINAPI iohid_bus_init(void *args) return STATUS_SUCCESS; } -NTSTATUS WINAPI iohid_bus_wait(void *args) +NTSTATUS iohid_bus_wait(void *args) { struct bus_event *result = args; CFRunLoopRunResult ret; @@ -415,7 +415,7 @@ NTSTATUS WINAPI iohid_bus_wait(void *args) return STATUS_SUCCESS; } -NTSTATUS WINAPI iohid_bus_stop(void *args) +NTSTATUS iohid_bus_stop(void *args) { if (!run_loop) return STATUS_SUCCESS; @@ -426,19 +426,19 @@ NTSTATUS WINAPI iohid_bus_stop(void *args) #else -NTSTATUS WINAPI iohid_bus_init(void *args) +NTSTATUS iohid_bus_init(void *args) { WARN("IOHID support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; } -NTSTATUS WINAPI iohid_bus_wait(void *args) +NTSTATUS iohid_bus_wait(void *args) { WARN("IOHID support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; } -NTSTATUS WINAPI iohid_bus_stop(void *args) +NTSTATUS 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 b7c3b28ba4e..a446eb77375 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -810,7 +810,7 @@ static void process_device_event(SDL_Event *event) pthread_mutex_unlock(&sdl_cs); } -NTSTATUS WINAPI sdl_bus_init(void *args) +NTSTATUS sdl_bus_init(void *args) { const char *mapping; int i; @@ -913,7 +913,7 @@ failed: return STATUS_UNSUCCESSFUL; } -NTSTATUS WINAPI sdl_bus_wait(void *args) +NTSTATUS sdl_bus_wait(void *args) { struct bus_event *result = args; SDL_Event event; @@ -935,7 +935,7 @@ NTSTATUS WINAPI sdl_bus_wait(void *args) return STATUS_SUCCESS; } -NTSTATUS WINAPI sdl_bus_stop(void *args) +NTSTATUS sdl_bus_stop(void *args) { SDL_Event event; @@ -953,19 +953,19 @@ NTSTATUS WINAPI sdl_bus_stop(void *args) #else -NTSTATUS WINAPI sdl_bus_init(void *args) +NTSTATUS sdl_bus_init(void *args) { WARN("SDL support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; } -NTSTATUS WINAPI sdl_bus_wait(void *args) +NTSTATUS sdl_bus_wait(void *args) { WARN("SDL support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; } -NTSTATUS WINAPI sdl_bus_stop(void *args) +NTSTATUS 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 c73a6dd2259..cd9b065e56b 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -1181,7 +1181,7 @@ static void process_monitor_event(struct udev_monitor *monitor) udev_device_unref(dev); } -NTSTATUS WINAPI udev_bus_init(void *args) +NTSTATUS udev_bus_init(void *args) { int monitor_fd; @@ -1226,7 +1226,7 @@ error: return STATUS_UNSUCCESSFUL; } -NTSTATUS WINAPI udev_bus_wait(void *args) +NTSTATUS udev_bus_wait(void *args) { struct platform_private *device; struct bus_event *result = args; @@ -1272,7 +1272,7 @@ NTSTATUS WINAPI udev_bus_wait(void *args) return STATUS_SUCCESS; } -NTSTATUS WINAPI udev_bus_stop(void *args) +NTSTATUS udev_bus_stop(void *args) { if (!udev_context) return STATUS_SUCCESS; write(deviceloop_control[1], "q", 1); @@ -1281,19 +1281,19 @@ NTSTATUS WINAPI udev_bus_stop(void *args) #else -NTSTATUS WINAPI udev_bus_init(void *args) +NTSTATUS udev_bus_init(void *args) { WARN("UDEV support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; } -NTSTATUS WINAPI udev_bus_wait(void *args) +NTSTATUS udev_bus_wait(void *args) { WARN("UDEV support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; } -NTSTATUS WINAPI udev_bus_stop(void *args) +NTSTATUS udev_bus_stop(void *args) { WARN("UDEV support not compiled in!\n"); return STATUS_NOT_IMPLEMENTED; diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 5fd7744c259..6ba3e7c73ce 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -112,11 +112,11 @@ 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 *unix_funcs; +static unixlib_handle_t winebus_handle; static NTSTATUS winebus_call(unsigned int code, void *args) { - return unix_funcs[code]( args ); + return __wine_unix_call(winebus_handle, code, args); } static void unix_device_remove(DEVICE_OBJECT *device) @@ -1116,7 +1116,8 @@ 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, &unix_funcs))) + if ((ret = NtQueryVirtualMemory(GetCurrentProcess(), instance, MemoryWineUnixFuncs, + &winebus_handle, sizeof(winebus_handle), NULL))) return ret; attr.Length = sizeof(attr); diff --git a/dlls/winebus.sys/unix_private.h b/dlls/winebus.sys/unix_private.h index 5e30b21955a..cdc2be9b318 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 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 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 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 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 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 NTSTATUS iohid_bus_init(void *) DECLSPEC_HIDDEN; +extern NTSTATUS iohid_bus_wait(void *) DECLSPEC_HIDDEN; +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; diff --git a/dlls/winebus.sys/unixlib.c b/dlls/winebus.sys/unixlib.c index f33b7cacfe3..929997f1aa7 100644 --- a/dlls/winebus.sys/unixlib.c +++ b/dlls/winebus.sys/unixlib.c @@ -149,7 +149,7 @@ static const struct device_desc mouse_device_desc = .serialnumber = {"0000"}, }; -static NTSTATUS WINAPI mouse_device_create(void *args) +static NTSTATUS mouse_device_create(void *args) { struct device_create_params *params = args; params->desc = mouse_device_desc; @@ -247,7 +247,7 @@ static const struct device_desc keyboard_device_desc = .serialnumber = {"0000"}, }; -static NTSTATUS WINAPI keyboard_device_create(void *args) +static NTSTATUS keyboard_device_create(void *args) { struct device_create_params *params = args; params->desc = keyboard_device_desc; @@ -280,7 +280,7 @@ static ULONG unix_device_incref(struct unix_device *iface) return InterlockedIncrement(&iface->ref); } -static NTSTATUS WINAPI unix_device_remove(void *args) +static NTSTATUS unix_device_remove(void *args) { struct unix_device *iface = args; iface->vtbl->stop(iface); @@ -288,20 +288,20 @@ static NTSTATUS WINAPI unix_device_remove(void *args) return STATUS_SUCCESS; } -static NTSTATUS WINAPI unix_device_start(void *args) +static NTSTATUS unix_device_start(void *args) { struct unix_device *iface = args; return iface->vtbl->start(iface); } -static NTSTATUS WINAPI unix_device_get_report_descriptor(void *args) +static NTSTATUS 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 WINAPI unix_device_set_output_report(void *args) +static NTSTATUS unix_device_set_output_report(void *args) { struct device_report_params *params = args; struct unix_device *iface = params->iface; @@ -309,7 +309,7 @@ static NTSTATUS WINAPI unix_device_set_output_report(void *args) return STATUS_SUCCESS; } -static NTSTATUS WINAPI unix_device_get_feature_report(void *args) +static NTSTATUS unix_device_get_feature_report(void *args) { struct device_report_params *params = args; struct unix_device *iface = params->iface; @@ -317,7 +317,7 @@ static NTSTATUS WINAPI unix_device_get_feature_report(void *args) return STATUS_SUCCESS; } -static NTSTATUS WINAPI unix_device_set_feature_report(void *args) +static NTSTATUS unix_device_set_feature_report(void *args) { struct device_report_params *params = args; struct unix_device *iface = params->iface; @@ -325,7 +325,7 @@ static NTSTATUS WINAPI unix_device_set_feature_report(void *args) return STATUS_SUCCESS; } -static const unix_entry_point unix_funcs[] = +const unixlib_entry_t __wine_unix_call_funcs[] = { sdl_bus_init, sdl_bus_wait, @@ -430,10 +430,3 @@ 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 = unix_funcs; - return STATUS_SUCCESS; -} diff --git a/dlls/winebus.sys/unixlib.h b/dlls/winebus.sys/unixlib.h index e5156176c46..a088cb1266b 100644 --- a/dlls/winebus.sys/unixlib.h +++ b/dlls/winebus.sys/unixlib.h @@ -136,8 +136,6 @@ enum unix_funcs device_set_feature_report, }; -typedef NTSTATUS (WINAPI *unix_entry_point)(void *); - static inline const char *debugstr_device_desc(struct device_desc *desc) { if (!desc) return "(null)"; -- 2.33.0