ntoskrnl.exe: Avoid loading a driver multiple times in ZwLoadDriver().

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45805
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2018-12-21 17:28:46 -06:00 committed by Alexandre Julliard
parent d209055e91
commit e3ad1cff73
2 changed files with 10 additions and 0 deletions

View File

@ -3519,6 +3519,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 );

View File

@ -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);
}