Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winebus.sys/bus.h | 4 +--- dlls/winebus.sys/bus_iohid.c | 24 ++++++++---------------- dlls/winebus.sys/bus_sdl.c | 16 +++------------- dlls/winebus.sys/bus_udev.c | 10 ++-------- dlls/winebus.sys/main.c | 20 +++++++++++++------- 5 files changed, 27 insertions(+), 47 deletions(-)
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index df39fb9ce7c..c74221b1ec7 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -41,13 +41,11 @@ typedef struct void *get_platform_private(DEVICE_OBJECT *device) 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, WORD vid, WORD pid, +DEVICE_OBJECT *bus_create_hid_device(const WCHAR *busidW, WORD vid, WORD pid, WORD input, DWORD version, DWORD uid, const WCHAR *serialW, BOOL is_gamepad, const GUID *class, const platform_vtbl *vtbl, DWORD platform_data_size) DECLSPEC_HIDDEN; DEVICE_OBJECT *bus_find_hid_device(const platform_vtbl *vtbl, void *platform_dev) DECLSPEC_HIDDEN; void bus_remove_hid_device(DEVICE_OBJECT *device) DECLSPEC_HIDDEN; -NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN; void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) DECLSPEC_HIDDEN; DEVICE_OBJECT* bus_enumerate_hid_devices(const platform_vtbl *vtbl, enum_func function, void* context) DECLSPEC_HIDDEN;
diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 9b7cc35faa5..dcc0dcf1061 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -96,7 +96,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(plugplay); #ifdef HAVE_IOHIDMANAGERCREATE
-static DRIVER_OBJECT *iohid_driver_obj = NULL; static IOHIDManagerRef hid_manager; static CFRunLoopRef run_loop; static HANDLE run_loop_handle; @@ -348,7 +347,7 @@ static void handle_DeviceMatchingCallback(void *context, IOReturn result, void * if (is_gamepad) input = 0;
- device = bus_create_hid_device(iohid_driver_obj, busidW, vid, pid, input, + device = bus_create_hid_device(busidW, vid, pid, input, version, uid, str?serial_string:NULL, is_gamepad, &GUID_DEVCLASS_IOHID, &iohid_vtbl, sizeof(struct platform_private)); if (!device) @@ -404,14 +403,10 @@ NTSTATUS WINAPI iohid_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registr { TRACE("(%p, %s)\n", driver, debugstr_w(registry_path->Buffer));
- iohid_driver_obj = driver; - driver->MajorFunction[IRP_MJ_PNP] = common_pnp_dispatch; - driver->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = hid_internal_dispatch; hid_manager = IOHIDManagerCreate(kCFAllocatorDefault, 0L); if (!(run_loop_handle = CreateThread(NULL, 0, runloop_thread, NULL, 0, NULL))) { ERR("Failed to initialize IOHID Manager thread\n"); - iohid_driver_obj = NULL; CFRelease(hid_manager); return STATUS_UNSUCCESSFUL; } @@ -422,16 +417,13 @@ NTSTATUS WINAPI iohid_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registr void iohid_driver_unload( void ) { TRACE("Unloading Driver\n"); - if (iohid_driver_obj != NULL) - { - IOHIDManagerUnscheduleFromRunLoop(hid_manager, run_loop, kCFRunLoopDefaultMode); - CFRunLoopStop(run_loop); - WaitForSingleObject(run_loop_handle, INFINITE); - CloseHandle(run_loop_handle); - IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, NULL, NULL); - IOHIDManagerRegisterDeviceRemovalCallback(hid_manager, NULL, NULL); - CFRelease(hid_manager); - } + IOHIDManagerUnscheduleFromRunLoop(hid_manager, run_loop, kCFRunLoopDefaultMode); + CFRunLoopStop(run_loop); + WaitForSingleObject(run_loop_handle, INFINITE); + CloseHandle(run_loop_handle); + IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, NULL, NULL); + IOHIDManagerRegisterDeviceRemovalCallback(hid_manager, NULL, NULL); + CFRelease(hid_manager); TRACE("Driver Unloaded\n"); }
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 2b367e5794a..c53402d79d2 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -62,8 +62,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
WINE_DECLARE_DEBUG_CHANNEL(hid_report);
-static DRIVER_OBJECT *sdl_driver_obj = NULL; - static const WCHAR sdl_busidW[] = {'S','D','L','J','O','Y',0};
static DWORD map_controllers = 0; @@ -951,7 +949,7 @@ static void try_add_device(SDL_JoystickID index) if (is_xbox_gamepad) input = 0;
- device = bus_create_hid_device(sdl_driver_obj, sdl_busidW, vid, pid, + device = bus_create_hid_device(sdl_busidW, vid, pid, input, version, id, serial, is_xbox_gamepad, &GUID_DEVCLASS_SDL, &sdl_vtbl, sizeof(struct platform_private));
@@ -1095,7 +1093,6 @@ NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_ sdl_handle = wine_dlopen(SONAME_LIBSDL2, RTLD_NOW, NULL, 0); if (!sdl_handle) { WARN("could not load %s\n", SONAME_LIBSDL2); - sdl_driver_obj = NULL; return STATUS_UNSUCCESSFUL; } #define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(sdl_handle, #f, NULL, 0)) == NULL){WARN("Can't find symbol %s\n", #f); goto sym_not_found;} @@ -1139,20 +1136,16 @@ NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_ pSDL_JoystickGetVendor = wine_dlsym(sdl_handle, "SDL_JoystickGetVendor", NULL, 0); }
- sdl_driver_obj = driver; - driver->MajorFunction[IRP_MJ_PNP] = common_pnp_dispatch; - driver->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = hid_internal_dispatch; - map_controllers = check_bus_option(registry_path, &controller_mode, 1);
if (!(events[0] = CreateEventW(NULL, TRUE, FALSE, NULL))) - goto error; + return STATUS_UNSUCCESSFUL; args.event = events[0]; args.registry_path = registry_path; if (!(events[1] = CreateThread(NULL, 0, deviceloop_thread, &args, 0, NULL))) { CloseHandle(events[0]); - goto error; + return STATUS_UNSUCCESSFUL; }
result = WaitForMultipleObjects(2, events, FALSE, INFINITE); @@ -1164,9 +1157,6 @@ NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_ return STATUS_SUCCESS; }
-error: - sdl_driver_obj = NULL; - return STATUS_UNSUCCESSFUL; sym_not_found: wine_dlclose(sdl_handle, NULL, 0); sdl_handle = NULL; diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index a37f7bda875..1f45f8c434c 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -90,7 +90,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(plugplay); WINE_DECLARE_DEBUG_CHANNEL(hid_report);
static struct udev *udev_context = NULL; -static DRIVER_OBJECT *udev_driver_obj = NULL; static DWORD disable_hidraw = 0; static DWORD disable_input = 0;
@@ -1214,13 +1213,13 @@ static void try_add_device(struct udev_device *dev)
if (strcmp(subsystem, "hidraw") == 0) { - device = bus_create_hid_device(udev_driver_obj, hidraw_busidW, vid, pid, input, version, 0, serial, is_gamepad, + device = bus_create_hid_device(hidraw_busidW, vid, pid, input, version, 0, serial, is_gamepad, &GUID_DEVCLASS_HIDRAW, &hidraw_vtbl, sizeof(struct platform_private)); } #ifdef HAS_PROPER_INPUT_HEADER else if (strcmp(subsystem, "input") == 0) { - device = bus_create_hid_device(udev_driver_obj, lnxev_busidW, vid, pid, input, version, 0, serial, is_gamepad, + device = bus_create_hid_device(lnxev_busidW, vid, pid, input, version, 0, serial, is_gamepad, &GUID_DEVCLASS_LINUXEVENT, &lnxev_vtbl, sizeof(struct wine_input_private)); } #endif @@ -1469,10 +1468,6 @@ NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry return STATUS_UNSUCCESSFUL; }
- udev_driver_obj = driver; - driver->MajorFunction[IRP_MJ_PNP] = common_pnp_dispatch; - driver->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = hid_internal_dispatch; - disable_hidraw = check_bus_option(registry_path, &hidraw_disabled, 0); if (disable_hidraw) TRACE("UDEV hidraw devices disabled in registry\n"); @@ -1504,7 +1499,6 @@ error: ERR("Failed to initialize udev device thread\n"); udev_unref(udev_context); udev_context = NULL; - udev_driver_obj = NULL; return STATUS_UNSUCCESSFUL; }
diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 0abadf4160e..bf13d2f0a07 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -61,6 +61,8 @@ static const WORD PID_XBOX_CONTROLLERS[] = { 0x0719, /* Xbox 360 Wireless Adapter */ };
+static DRIVER_OBJECT *driver_obj; + struct pnp_device { struct list entry; @@ -208,7 +210,7 @@ static WCHAR *get_compatible_ids(DEVICE_OBJECT *device) return dst; }
-DEVICE_OBJECT *bus_create_hid_device(DRIVER_OBJECT *driver, const WCHAR *busidW, WORD vid, WORD pid, +DEVICE_OBJECT *bus_create_hid_device(const WCHAR *busidW, WORD vid, WORD pid, WORD input, DWORD version, DWORD uid, const WCHAR *serialW, BOOL is_gamepad, const GUID *class, const platform_vtbl *vtbl, DWORD platform_data_size) { @@ -224,7 +226,7 @@ DEVICE_OBJECT *bus_create_hid_device(DRIVER_OBJECT *driver, const WCHAR *busidW, NTSTATUS status; DWORD length;
- TRACE("(%p, %s, %04x, %04x, %04x, %u, %u, %s, %u, %s, %p, %u)\n", driver, + TRACE("(%s, %04x, %04x, %04x, %u, %u, %s, %u, %s, %p, %u)\n", debugstr_w(busidW), vid, pid, input, version, uid, debugstr_w(serialW), is_gamepad, debugstr_guid(class), vtbl, platform_data_size);
@@ -234,7 +236,7 @@ DEVICE_OBJECT *bus_create_hid_device(DRIVER_OBJECT *driver, const WCHAR *busidW, sprintfW(dev_name, device_name_fmtW, busidW, pnp_dev); RtlInitUnicodeString(&nameW, dev_name); length = FIELD_OFFSET(struct device_extension, platform_private[platform_data_size]); - status = IoCreateDevice(driver, length, &nameW, 0, 0, FALSE, &device); + status = IoCreateDevice(driver_obj, length, &nameW, 0, 0, FALSE, &device); if (status) { FIXME("failed to create device error %x\n", status); @@ -469,7 +471,7 @@ static NTSTATUS handle_IRP_MN_QUERY_ID(DEVICE_OBJECT *device, IRP *irp) return status; }
-NTSTATUS WINAPI common_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) +static NTSTATUS WINAPI common_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) { NTSTATUS status = irp->IoStatus.u.Status; IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); @@ -514,7 +516,7 @@ static NTSTATUS deliver_last_report(struct device_extension *ext, DWORD buffer_l } }
-NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) +static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) { NTSTATUS status = irp->IoStatus.u.Status; IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); @@ -795,6 +797,12 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
TRACE( "(%p, %s)\n", driver, debugstr_w(path->Buffer) );
+ driver_obj = driver; + + driver->MajorFunction[IRP_MJ_PNP] = common_pnp_dispatch; + driver->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = hid_internal_dispatch; + driver->DriverUnload = driver_unload; + if (check_bus_option(path, &SDL_enabled, 1)) { if (IoCreateDriver(&sdl, sdl_driver_init) == STATUS_SUCCESS) @@ -803,7 +811,5 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) IoCreateDriver(&udev, udev_driver_init); IoCreateDriver(&iohid, iohid_driver_init);
- driver->DriverUnload = driver_unload; - return STATUS_SUCCESS; }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winebus.sys/bus.h | 4 +++- dlls/winebus.sys/bus_sdl.c | 30 ++++++++-------------------- dlls/winebus.sys/bus_udev.c | 4 ++-- dlls/winebus.sys/main.c | 40 ++++++++++++++++++------------------- 4 files changed, 33 insertions(+), 45 deletions(-)
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index c74221b1ec7..4de723f76ff 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -50,5 +50,7 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) DECLS DEVICE_OBJECT* bus_enumerate_hid_devices(const platform_vtbl *vtbl, enum_func function, void* context) DECLSPEC_HIDDEN;
/* General Bus Functions */ -DWORD check_bus_option(UNICODE_STRING *registry_path, const UNICODE_STRING *option, DWORD default_value) DECLSPEC_HIDDEN; +DWORD check_bus_option(const UNICODE_STRING *option, DWORD default_value) DECLSPEC_HIDDEN; BOOL is_xbox_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN; + +HANDLE driver_key DECLSPEC_HIDDEN; diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index c53402d79d2..284ff486763 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -993,14 +993,9 @@ static void process_device_event(SDL_Event *event) set_mapped_report_from_event(event); }
-typedef struct _thread_args { - HANDLE event; - UNICODE_STRING *registry_path; -} thread_arguments; - static DWORD CALLBACK deviceloop_thread(void *args) { - thread_arguments *thread_args = args; + HANDLE init_done = args; SDL_Event event;
if (pSDL_Init(SDL_INIT_GAMECONTROLLER|SDL_INIT_HAPTIC) < 0) @@ -1015,16 +1010,10 @@ static DWORD CALLBACK deviceloop_thread(void *args) /* Process mappings */ if (pSDL_GameControllerAddMapping != NULL) { - HANDLE key; - OBJECT_ATTRIBUTES attr; - WCHAR buffer[MAX_PATH]; - UNICODE_STRING regpath = {0, sizeof(buffer), buffer}; - static const WCHAR szPath[] = {'\','m','a','p',0}; - - RtlCopyUnicodeString(®path, thread_args->registry_path); - RtlAppendUnicodeToString(®path, szPath); - InitializeObjectAttributes(&attr, ®path, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); - if (NtOpenKey(&key, KEY_ALL_ACCESS, &attr) == STATUS_SUCCESS) + HKEY key; + static const WCHAR szPath[] = {'m','a','p',0}; + + if (!RegOpenKeyExW(driver_key, szPath, 0, KEY_ENUMERATE_SUB_KEYS, &key)) { DWORD index = 0; CHAR *buffer = NULL; @@ -1063,7 +1052,7 @@ static DWORD CALLBACK deviceloop_thread(void *args) } }
- SetEvent(thread_args->event); + SetEvent(init_done);
while (1) while (pSDL_WaitEvent(&event) != 0) @@ -1085,7 +1074,6 @@ NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_
HANDLE events[2]; DWORD result; - thread_arguments args;
TRACE("(%p, %s)\n", driver, debugstr_w(registry_path->Buffer)); if (sdl_handle == NULL) @@ -1136,13 +1124,11 @@ NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_ pSDL_JoystickGetVendor = wine_dlsym(sdl_handle, "SDL_JoystickGetVendor", NULL, 0); }
- map_controllers = check_bus_option(registry_path, &controller_mode, 1); + map_controllers = check_bus_option(&controller_mode, 1);
if (!(events[0] = CreateEventW(NULL, TRUE, FALSE, NULL))) return STATUS_UNSUCCESSFUL; - args.event = events[0]; - args.registry_path = registry_path; - if (!(events[1] = CreateThread(NULL, 0, deviceloop_thread, &args, 0, NULL))) + if (!(events[1] = CreateThread(NULL, 0, deviceloop_thread, events[0], 0, NULL))) { CloseHandle(events[0]); return STATUS_UNSUCCESSFUL; diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 1f45f8c434c..716a43714ec 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -1468,12 +1468,12 @@ NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry return STATUS_UNSUCCESSFUL; }
- disable_hidraw = check_bus_option(registry_path, &hidraw_disabled, 0); + disable_hidraw = check_bus_option(&hidraw_disabled, 0); if (disable_hidraw) TRACE("UDEV hidraw devices disabled in registry\n");
#ifdef HAS_PROPER_INPUT_HEADER - disable_input = check_bus_option(registry_path, &input_disabled, 0); + disable_input = check_bus_option(&input_disabled, 0); if (disable_input) TRACE("UDEV input devices disabled in registry\n"); #endif diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index bf13d2f0a07..f7cdc4dcf03 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -63,6 +63,8 @@ static const WORD PID_XBOX_CONTROLLERS[] = {
static DRIVER_OBJECT *driver_obj;
+HANDLE driver_key; + struct pnp_device { struct list entry; @@ -738,30 +740,19 @@ void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) LeaveCriticalSection(&ext->report_cs); }
-DWORD check_bus_option(UNICODE_STRING *registry_path, const UNICODE_STRING *option, DWORD default_value) +DWORD check_bus_option(const UNICODE_STRING *option, DWORD default_value) { - OBJECT_ATTRIBUTES attr; - HANDLE key; - DWORD output = default_value; + char buffer[FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[sizeof(DWORD)])]; + KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION*)buffer; + DWORD size;
- InitializeObjectAttributes(&attr, registry_path, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); - if (NtOpenKey(&key, KEY_ALL_ACCESS, &attr) == STATUS_SUCCESS) + if (NtQueryValueKey(driver_key, option, KeyValuePartialInformation, info, sizeof(buffer), &size) == STATUS_SUCCESS) { - DWORD size; - char buffer[FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[sizeof(DWORD)])]; - - KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION*)buffer; - - if (NtQueryValueKey(key, option, KeyValuePartialInformation, info, sizeof(buffer), &size) == STATUS_SUCCESS) - { - if (info->Type == REG_DWORD) - output = *(DWORD*)info->Data; - } - - NtClose(key); + if (info->Type == REG_DWORD) + return *(DWORD*)info->Data; }
- return output; + return default_value; }
BOOL is_xbox_gamepad(WORD vid, WORD pid) @@ -782,6 +773,7 @@ static void WINAPI driver_unload(DRIVER_OBJECT *driver) udev_driver_unload(); iohid_driver_unload(); sdl_driver_unload(); + NtClose(driver_key); }
NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) @@ -794,16 +786,24 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) static UNICODE_STRING sdl = {sizeof(sdlW) - sizeof(WCHAR), sizeof(sdlW), (WCHAR *)sdlW}; static const WCHAR SDL_enabledW[] = {'E','n','a','b','l','e',' ','S','D','L',0}; static const UNICODE_STRING SDL_enabled = {sizeof(SDL_enabledW) - sizeof(WCHAR), sizeof(SDL_enabledW), (WCHAR*)SDL_enabledW}; + OBJECT_ATTRIBUTES attr = {0}; + NTSTATUS ret;
TRACE( "(%p, %s)\n", driver, debugstr_w(path->Buffer) );
+ attr.Length = sizeof(attr); + attr.ObjectName = path; + attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE; + if ((ret = NtOpenKey(&driver_key, KEY_ALL_ACCESS, &attr)) != STATUS_SUCCESS) + ERR("Failed to open driver key, status %#x.\n", ret); + driver_obj = driver;
driver->MajorFunction[IRP_MJ_PNP] = common_pnp_dispatch; driver->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = hid_internal_dispatch; driver->DriverUnload = driver_unload;
- if (check_bus_option(path, &SDL_enabled, 1)) + if (check_bus_option(&SDL_enabled, 1)) { if (IoCreateDriver(&sdl, sdl_driver_init) == STATUS_SUCCESS) return STATUS_SUCCESS;
This is not a documented function, and anyway we don't need separate driver objects.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winebus.sys/bus.h | 6 +++--- dlls/winebus.sys/bus_iohid.c | 6 ++---- dlls/winebus.sys/bus_sdl.c | 5 ++--- dlls/winebus.sys/bus_udev.c | 6 ++---- dlls/winebus.sys/main.c | 12 +++--------- 5 files changed, 12 insertions(+), 23 deletions(-)
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index 4de723f76ff..de8ddf7ad9d 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -19,9 +19,9 @@ typedef int(*enum_func)(DEVICE_OBJECT *device, void *context);
/* Buses */ -NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) DECLSPEC_HIDDEN; -NTSTATUS WINAPI iohid_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) DECLSPEC_HIDDEN; -NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) DECLSPEC_HIDDEN; +NTSTATUS udev_driver_init(void) DECLSPEC_HIDDEN; +NTSTATUS iohid_driver_init(void) DECLSPEC_HIDDEN; +NTSTATUS sdl_driver_init(void) DECLSPEC_HIDDEN; void udev_driver_unload( void ) DECLSPEC_HIDDEN; void iohid_driver_unload( void ) DECLSPEC_HIDDEN; void sdl_driver_unload( void ) DECLSPEC_HIDDEN; diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index dcc0dcf1061..7933374007e 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -399,10 +399,8 @@ static DWORD CALLBACK runloop_thread(void *args)
}
-NTSTATUS WINAPI iohid_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) +NTSTATUS iohid_driver_init(void) { - TRACE("(%p, %s)\n", driver, debugstr_w(registry_path->Buffer)); - hid_manager = IOHIDManagerCreate(kCFAllocatorDefault, 0L); if (!(run_loop_handle = CreateThread(NULL, 0, runloop_thread, NULL, 0, NULL))) { @@ -429,7 +427,7 @@ void iohid_driver_unload( void )
#else
-NTSTATUS WINAPI iohid_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) +NTSTATUS iohid_driver_init(void) { WARN("IOHID Support not compiled into Wine.\n"); return STATUS_NOT_IMPLEMENTED; diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 284ff486763..1a938aa1313 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -1067,7 +1067,7 @@ void sdl_driver_unload( void ) TRACE("Unload Driver\n"); }
-NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) +NTSTATUS sdl_driver_init(void) { static const WCHAR controller_modeW[] = {'M','a','p',' ','C','o','n','t','r','o','l','l','e','r','s',0}; static const UNICODE_STRING controller_mode = {sizeof(controller_modeW) - sizeof(WCHAR), sizeof(controller_modeW), (WCHAR*)controller_modeW}; @@ -1075,7 +1075,6 @@ NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_ HANDLE events[2]; DWORD result;
- TRACE("(%p, %s)\n", driver, debugstr_w(registry_path->Buffer)); if (sdl_handle == NULL) { sdl_handle = wine_dlopen(SONAME_LIBSDL2, RTLD_NOW, NULL, 0); @@ -1151,7 +1150,7 @@ sym_not_found:
#else
-NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) +NTSTATUS sdl_driver_init(void) { WARN("compiled without SDL support\n"); return STATUS_NOT_IMPLEMENTED; diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 716a43714ec..a3255dfc856 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -1451,7 +1451,7 @@ void udev_driver_unload( void ) TRACE("Unload Driver\n"); }
-NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) +NTSTATUS udev_driver_init(void) { HANDLE events[2]; DWORD result; @@ -1460,8 +1460,6 @@ NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry static const WCHAR input_disabledW[] = {'D','i','s','a','b','l','e','I','n','p','u','t',0}; static const UNICODE_STRING input_disabled = {sizeof(input_disabledW) - sizeof(WCHAR), sizeof(input_disabledW), (WCHAR*)input_disabledW};
- TRACE("(%p, %s)\n", driver, debugstr_w(registry_path->Buffer)); - if (!(udev_context = udev_new())) { ERR("Can't create udev object\n"); @@ -1504,7 +1502,7 @@ error:
#else
-NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) +NTSTATUS udev_driver_init(void) { WARN("Wine was compiled without UDEV support\n"); return STATUS_NOT_IMPLEMENTED; diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index f7cdc4dcf03..73e31549ff4 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -778,12 +778,6 @@ static void WINAPI driver_unload(DRIVER_OBJECT *driver)
NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) { - static const WCHAR udevW[] = {'\','D','r','i','v','e','r','\','U','D','E','V',0}; - static UNICODE_STRING udev = {sizeof(udevW) - sizeof(WCHAR), sizeof(udevW), (WCHAR *)udevW}; - static const WCHAR iohidW[] = {'\','D','r','i','v','e','r','\','I','O','H','I','D',0}; - static UNICODE_STRING iohid = {sizeof(iohidW) - sizeof(WCHAR), sizeof(iohidW), (WCHAR *)iohidW}; - static const WCHAR sdlW[] = {'\','D','r','i','v','e','r','\','S','D','L','J','O','Y',0}; - static UNICODE_STRING sdl = {sizeof(sdlW) - sizeof(WCHAR), sizeof(sdlW), (WCHAR *)sdlW}; static const WCHAR SDL_enabledW[] = {'E','n','a','b','l','e',' ','S','D','L',0}; static const UNICODE_STRING SDL_enabled = {sizeof(SDL_enabledW) - sizeof(WCHAR), sizeof(SDL_enabledW), (WCHAR*)SDL_enabledW}; OBJECT_ATTRIBUTES attr = {0}; @@ -805,11 +799,11 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
if (check_bus_option(&SDL_enabled, 1)) { - if (IoCreateDriver(&sdl, sdl_driver_init) == STATUS_SUCCESS) + if (sdl_driver_init() == STATUS_SUCCESS) return STATUS_SUCCESS; } - IoCreateDriver(&udev, udev_driver_init); - IoCreateDriver(&iohid, iohid_driver_init); + udev_driver_init(); + iohid_driver_init();
return STATUS_SUCCESS; }