diff --git a/dlls/user/driver.c b/dlls/user/driver.c index 7fd90f38643..e127516f424 100644 --- a/dlls/user/driver.c +++ b/dlls/user/driver.c @@ -137,6 +137,13 @@ static const USER_DRIVER *load_driver(void) return driver; } +/* unload the graphics driver on process exit */ +void USER_unload_driver(void) +{ + /* make sure we don't try to call the driver after it has been detached */ + USER_Driver = &null_driver; +} + /********************************************************************** * Null user driver diff --git a/dlls/user/user_main.c b/dlls/user/user_main.c index 9e9cb4232f9..73d92ecbd63 100644 --- a/dlls/user/user_main.c +++ b/dlls/user/user_main.c @@ -228,6 +228,9 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) case DLL_THREAD_DETACH: thread_detach(); break; + case DLL_PROCESS_DETACH: + USER_unload_driver(); + break; } return ret; } diff --git a/dlls/user/user_private.h b/dlls/user/user_private.h index ed83cf466f9..5d205aa8a12 100644 --- a/dlls/user/user_private.h +++ b/dlls/user/user_private.h @@ -159,6 +159,8 @@ typedef struct tagUSER_DRIVER { extern const USER_DRIVER *USER_Driver; +extern void USER_unload_driver(void); + struct received_message_info; struct hook16_queue_info;