Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45805 Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/ntoskrnl.c | 7 +++++++ dlls/ntoskrnl.exe/tests/driver.c | 3 +++ 2 files changed, 10 insertions(+)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 2b3b2ec0ef..d0112f4904 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -3520,6 +3520,13 @@ NTSTATUS WINAPI ZwLoadDriver( const UNICODE_STRING *service_name ) return STATUS_NO_MEMORY; }
+ if (wine_rb_get( &wine_drivers, &drv_name )) + { + TRACE( "driver %s already loaded\n", debugstr_us(&drv_name) ); + RtlFreeUnicodeString( &drv_name ); + return STATUS_IMAGE_ALREADY_LOADED; + } + set_service_status( service_handle, SERVICE_START_PENDING, 0 );
status = IoCreateDriver( &drv_name, init_driver ); diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index 17e54cd508..6ab5c3e054 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -206,6 +206,9 @@ static void test_load_driver(void) ret = ZwLoadDriver(&name); ok(!ret, "got %#x\n", ret);
+ ret = ZwLoadDriver(&name); + ok(ret == STATUS_IMAGE_ALREADY_LOADED, "got %#x\n", ret); + ret = ZwUnloadDriver(&name); ok(!ret, "got %#x\n", ret); }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/ntoskrnl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index d0112f4904..29a85b304e 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -3757,7 +3757,10 @@ static void handle_bus_relations( DEVICE_OBJECT *device ) strcpyW( buffer, servicesW ); strcatW( buffer, driver ); RtlInitUnicodeString( &string, buffer ); - if (ZwLoadDriver( &string ) != STATUS_SUCCESS) + status = ZwLoadDriver( &string ); + if (status == STATUS_IMAGE_ALREADY_LOADED) + return; + else if (status != STATUS_SUCCESS) { ERR_(plugplay)( "Failed to load driver %s\n", debugstr_w(driver) ); return;