Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ionescu007/SimpleVisor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Benes <w.benny@outlook.com>2018-08-04 17:32:18 +0300
committerPetr Benes <w.benny@outlook.com>2018-08-05 13:45:52 +0300
commit3581425b5bed4905db4460cd3ee1f4897d0d5cad (patch)
treee62dc7ec35a5eccc87aeef4ccf6a9c60a652b8c1
parenta2efa4b6c0e9191afe4b3d164941db8fa7b1f337 (diff)
Fix BSOD on shutdown when DriverEntry fails
The registered power callback needs to be unregistered when ShvLoad happens to fail, as DriverUnload is not called when DriverEntry does not succeed. Code before patch allowed to create a situation, where ShvLoad in DriverEntry failed, which resulted in the leak of PowerCallback, which - on machine shutdown/reboot - resulted in critical pagefault in the area of the unloaded driver and the system went blue.
-rw-r--r--nt/shvos.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/nt/shvos.c b/nt/shvos.c
index 532fcf0..4017525 100644
--- a/nt/shvos.c
+++ b/nt/shvos.c
@@ -418,6 +418,17 @@ DriverEntry (
//
// Load the hypervisor
//
- return ShvOsErrorToError(ShvLoad());
+ status = ShvOsErrorToError(ShvLoad());
+
+ //
+ // If load of the hypervisor happened to fail, unregister previously registered
+ // power callback, otherwise we would get BSOD on shutdown.
+ //
+ if (!NT_SUCCESS(status))
+ {
+ ExUnregisterCallback(g_PowerCallbackRegistration);
+ }
+
+ return status;
}