[driver] Wait for bus thread to terminate on unload
authorShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Fri, 31 Dec 2010 12:19:01 +0000 (07:19 -0500)
committerShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Fri, 31 Dec 2010 12:19:01 +0000 (07:19 -0500)
src/winvblock/driver.c

index f03f655..38adca8 100644 (file)
@@ -563,6 +563,14 @@ static NTSTATUS driver__dispatch_pnp_(
 
 static void STDCALL driver__unload_(IN PDRIVER_OBJECT DriverObject) {
     DBG("Unloading...\n");
+    WvDriverBus_.Stop = TRUE;
+    KeWaitForSingleObject(
+        &WvDriverBus_.ThreadStopped,
+        Executive,
+        KernelMode,
+        FALSE,
+        NULL
+      );
     if (WvDriverStateHandle_ != NULL)
       PoUnregisterSystemState(WvDriverStateHandle_);
     IoDeleteSymbolicLink(&WvDriverBusDosname_);