1 | /** @file
|
---|
2 | * VBoxGuest -- VirtualBox Win32 guest support driver
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
|
---|
18 | /*******************************************************************************
|
---|
19 | * Header Files *
|
---|
20 | *******************************************************************************/
|
---|
21 | #include "VBoxGuest_Internal.h"
|
---|
22 | #include "Helper.h"
|
---|
23 | #include <VBox/err.h>
|
---|
24 | #include <VBox/log.h>
|
---|
25 | #include <VBox/VBoxGuestLib.h>
|
---|
26 |
|
---|
27 | #ifndef TARGET_NT4
|
---|
28 | # include <aux_klib.h>
|
---|
29 | #endif
|
---|
30 |
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Called when a bug check occurs.
|
---|
34 | *
|
---|
35 | * @param pvBuffer Pointer to our device extension, just in case it
|
---|
36 | * comes in handy some day.
|
---|
37 | * @param cbBuffer The size of our device extension.
|
---|
38 | */
|
---|
39 | static VOID hlpVBoxGuestBugCheckCallback(PVOID pvBuffer, ULONG cbBuffer)
|
---|
40 | {
|
---|
41 | /*PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pvBuffer;*/
|
---|
42 |
|
---|
43 | LogRelBackdoor(("Windows bug check (bluescreen) detected!\n"));
|
---|
44 |
|
---|
45 | # ifndef TARGET_NT4
|
---|
46 | /*
|
---|
47 | * Try get details.
|
---|
48 | */
|
---|
49 | KBUGCHECK_DATA bugCheckData;
|
---|
50 | bugCheckData.BugCheckDataSize = sizeof(KBUGCHECK_DATA);
|
---|
51 | NTSTATUS rc = AuxKlibGetBugCheckData(&bugCheckData);
|
---|
52 | if (NT_SUCCESS(rc))
|
---|
53 | {
|
---|
54 | LogRelBackdoor(("Bug check code: 0x%08x\n", bugCheckData.BugCheckCode));
|
---|
55 | LogRelBackdoor(("Bug check parameters: 1=0x%p 2=0x%p 3=0x%p 4=0x%p\n",
|
---|
56 | bugCheckData.Parameter1,
|
---|
57 | bugCheckData.Parameter2,
|
---|
58 | bugCheckData.Parameter3,
|
---|
59 | bugCheckData.Parameter4));
|
---|
60 | LogRelBackdoor(("For details run \"!analyze -show %x %p %p %p %p\" in WinDbg.\n",
|
---|
61 | bugCheckData.BugCheckCode,
|
---|
62 | bugCheckData.Parameter1,
|
---|
63 | bugCheckData.Parameter2,
|
---|
64 | bugCheckData.Parameter3,
|
---|
65 | bugCheckData.Parameter4));
|
---|
66 | }
|
---|
67 | else
|
---|
68 | LogRelBackdoor(("Unable to retrieve bugcheck details! Error: %#x\n", rc));
|
---|
69 | # else /* NT4 */
|
---|
70 | LogRelBackdoor(("No additional information for Windows NT 4.0 bugcheck available.\n"));
|
---|
71 | # endif /* NT4 */
|
---|
72 |
|
---|
73 | /*
|
---|
74 | * Notify the host that we've panicked.
|
---|
75 | */
|
---|
76 | /** @todo Notify the host somehow over DevVMM. */
|
---|
77 |
|
---|
78 | NOREF(pvBuffer); NOREF(cbBuffer);
|
---|
79 | }
|
---|
80 |
|
---|
81 | void hlpRegisterBugCheckCallback(PVBOXGUESTDEVEXT pDevExt)
|
---|
82 | {
|
---|
83 | pDevExt->bBugcheckCallbackRegistered = FALSE;
|
---|
84 |
|
---|
85 | # ifndef TARGET_NT4
|
---|
86 | /*
|
---|
87 | * This is required for calling AuxKlibGetBugCheckData() in hlpVBoxGuestBugCheckCallback().
|
---|
88 | */
|
---|
89 | NTSTATUS rc = AuxKlibInitialize();
|
---|
90 | if (NT_ERROR(rc))
|
---|
91 | {
|
---|
92 | LogRelBackdoor(("VBoxGuest: Failed to initialize AuxKlib! rc=%#x\n", rc));
|
---|
93 | return;
|
---|
94 | }
|
---|
95 | # endif
|
---|
96 |
|
---|
97 | /*
|
---|
98 | * Setup bugcheck callback routine.
|
---|
99 | */
|
---|
100 | pDevExt->bBugcheckCallbackRegistered = FALSE;
|
---|
101 | KeInitializeCallbackRecord(&pDevExt->bugcheckRecord);
|
---|
102 | if (KeRegisterBugCheckCallback(&pDevExt->bugcheckRecord,
|
---|
103 | &hlpVBoxGuestBugCheckCallback,
|
---|
104 | pDevExt,
|
---|
105 | sizeof(*pDevExt),
|
---|
106 | (PUCHAR)"VBoxGuest"))
|
---|
107 | {
|
---|
108 | pDevExt->bBugcheckCallbackRegistered = TRUE;
|
---|
109 | dprintf(("VBoxGuest::hlpRegisterBugCheckCallback: Bugcheck callback registered.\n"));
|
---|
110 | }
|
---|
111 | else
|
---|
112 | LogRelBackdoor(("VBoxGuest: Could not register bugcheck callback routine!\n"));
|
---|
113 | }
|
---|
114 |
|
---|
115 | void hlpDeregisterBugCheckCallback(PVBOXGUESTDEVEXT pDevExt)
|
---|
116 | {
|
---|
117 | if (pDevExt->bBugcheckCallbackRegistered)
|
---|
118 | {
|
---|
119 | if (!KeDeregisterBugCheckCallback(&pDevExt->bugcheckRecord))
|
---|
120 | dprintf(("VBoxGuest::VBoxGuestUnload: Unregistering bugcheck callback routine failed!\n"));
|
---|
121 | pDevExt->bBugcheckCallbackRegistered = FALSE;
|
---|
122 | }
|
---|
123 | }
|
---|
124 |
|
---|
125 | #endif /* VBOX_WITH_GUEST_BUGCHECK_DETECTION */
|
---|
126 |
|
---|