[PATCH 3/3] winebus.sys: Avoid IoCreateDriver().

Zebediah Figura z.figura12 at gmail.com
Wed May 29 23:02:30 CDT 2019


This is not a documented function, and anyway we don't need separate driver
objects.

Signed-off-by: Zebediah Figura <z.figura12 at 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;
 }
-- 
2.21.0




More information about the wine-devel mailing list