VirtualBox

Changeset 18019 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 17, 2009 1:08:12 PM (16 years ago)
Author:
vboxsync
Message:

VBoxGuest/Windows: Added bugcheck detection + details (not enabled by default yet).

Location:
trunk/src/VBox/Additions/WINNT/VBoxGuest
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/Helper.cpp

    r13837 r18019  
    2323#include "Helper.h"
    2424#include <VBox/err.h>
     25#include <VBox/log.h>
    2526#include <VBox/VBoxGuestLib.h>
     27
     28#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
     29 #ifndef TARGET_NT4
     30  #include <aux_klib.h>
     31 #endif
     32#endif
    2633
    2734#ifdef ALLOC_PRAGMA
     
    245252    return RT_FAILURE(rc) ? STATUS_UNSUCCESSFUL : STATUS_SUCCESS;
    246253}
     254
     255#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
     256NTSTATUS hlpRegisterBugCheckCallback (PVBOXGUESTDEVEXT pDevExt)
     257{
     258    int rc = STATUS_SUCCESS;
     259
     260 #ifndef TARGET_NT4
     261    rc = AuxKlibInitialize();
     262    if (NT_ERROR(rc))
     263    {
     264        dprintf(("VBoxGuest::VBoxGuestAddDevice: Unabled to initialize AuxKlib!\n"));
     265        return STATUS_DRIVER_UNABLE_TO_LOAD;
     266    }
     267 #endif
     268
     269    /*
     270     * Setup bugcheck callback routine ASAP.
     271     */
     272    pDevExt->bBugcheckCallbackRegistered = FALSE;
     273    pDevExt->bugcheckContext = (VBOXBUGCHECKCONTEXT*)ExAllocatePool(NonPagedPool, sizeof(VBOXBUGCHECKCONTEXT));
     274    if(!pDevExt->bugcheckContext)
     275    {
     276        dprintf(("VBoxGuest::VBoxGuestAddDevice: Not enough memory for bugcheck context!\n"));
     277        return STATUS_INSUFFICIENT_RESOURCES;
     278    }
     279
     280    KeInitializeCallbackRecord(&pDevExt->bugcheckContext->bugcheckRecord);
     281    if (FALSE == KeRegisterBugCheckCallback(&pDevExt->bugcheckContext->bugcheckRecord,
     282                                            &hlpVBoxGuestBugCheckCallback,
     283                                            pDevExt->bugcheckContext,
     284                                            sizeof(VBOXBUGCHECKCONTEXT),
     285                                            (PUCHAR)"VBoxGuest"))
     286    {
     287        LogRelBackdoor(("Could not register bugcheck callback routine!\n"));
     288    }
     289    else
     290    {
     291        pDevExt->bBugcheckCallbackRegistered = TRUE;
     292        dprintf(("VBoxGuest::VBoxGuestAddDevice: Bugcheck callback registered.\n"));
     293    }
     294
     295    return rc;
     296}
     297
     298VOID hlpVBoxGuestBugCheckCallback(PVOID pvBuffer, ULONG ulLength)
     299{
     300    NTSTATUS rc = 0;
     301    PVBOXBUGCHECKCONTEXT pContext = (PVBOXBUGCHECKCONTEXT)pvBuffer;
     302
     303    LogRelBackdoor(("Windows bugcheck (bluescreen) detected!\n"));
     304
     305#ifndef TARGET_NT4
     306    KBUGCHECK_DATA bugcheckData;
     307    bugcheckData.BugCheckDataSize = sizeof(KBUGCHECK_DATA);
     308    rc = AuxKlibGetBugCheckData(&bugcheckData);
     309    if (!RT_SUCCESS(rc))
     310    {
     311        LogRelBackdoor(("Unable to retrieve bugcheck details! Error: %d\n", rc));
     312        return;
     313    }
     314
     315    LogRelBackdoor(("Bugcheck code: 0x%08x\n", bugcheckData.BugCheckCode));
     316    LogRelBackdoor(("Bugcheck parameters: 1=%ld 2=%ld 3=%ld 4=%ld\n",
     317                   bugcheckData.Parameter1,
     318                   bugcheckData.Parameter2,
     319                   bugcheckData.Parameter3,
     320                   bugcheckData.Parameter4));
     321#else
     322    LogRelBackdoor(("No additional information for Windows NT 4.0 bugcheck available.\n"));
     323#endif
     324
     325    if (pvBuffer)
     326    {
     327        /* @todo - Not used yet. */
     328    }
     329
     330    /* @todo Notify the host somehow over DevVMM. */
     331}
     332#endif
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/Helper.h

    r8155 r18019  
    5454 */
    5555NTSTATUS hlpVBoxReportGuestInfo (PVBOXGUESTDEVEXT pDevExt);
     56
     57#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
     58/**
     59 * Helper for registering the bugcheck callback rountine(s).
     60 *
     61 * @param pDevExt   VMMDev device extension
     62 * @return NT status code
     63 */
     64NTSTATUS hlpRegisterBugCheckCallback (PVBOXGUESTDEVEXT pDevExt);
     65
     66VOID hlpVBoxGuestBugCheckCallback (PVOID pvBuffer, ULONG ulLength);
     67#endif
    5668}
    5769
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/Makefile.kmk

    r14491 r18019  
    3232endif
    3333VBoxGuest_DEFS        = LOG_TO_BACKDOOR VBGL_VBOXGUEST VBOX_WITH_HGCM VBOX_REBOOT_ON_UNINSTALL
     34ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
     35 VBoxGuest_DEFS      += VBOX_WITH_GUEST_BUGCHECK_DETECTION
     36endif
    3437#VBoxGuest_DEFS       += LOG_ENABLED
    35 VBoxGuest_INCS        = ../include
     38VBoxGuest_INCS        = \
     39        ../include     
    3640VBoxGuest_LDFLAGS.x86   = -Entry:DriverEntry@8
    3741VBoxGuest_LDFLAGS.amd64 = -Entry:DriverEntry
    38 VBoxGuest_SOURCES     = \
     42VBoxGuest_SDKS          = WINDDKWLH
     43VBoxGuest_SOURCES       = \
    3944        VBoxGuest.cpp \
    4045        VBoxGuestPnP.cpp \
     
    4247        VBoxGuest.rc
    4348VBoxGuest_LIBS        = \
    44         $(PATH_SDK_W2K3DDK_LIB)/ntoskrnl.lib \
    45         $(PATH_SDK_W2K3DDK_LIB)/hal.lib \
     49        $(PATH_SDK_WINDDKWLH_LIB)/ntoskrnl.lib \
     50        $(PATH_SDK_WINDDKWLH_LIB)/hal.lib \
    4651        $(VBOX_LIB_VBGL_R0BASE) \
    47         $(VBOX_LIB_IPRT_GUEST_R0)
     52        $(VBOX_LIB_IPRT_GUEST_R0) \
    4853
     54ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
     55 VBoxGuest_LIBS += \
     56        $(PATH_SDK_WINDDKWLH_LIB)/ksecdd.lib \
     57        $(PATH_SDK_WINDDKWLH_LIB)/BufferOverflowK.lib \
     58        $(PATH_SDK_WINDDKWLH_LIB)/aux_klib.lib
     59endif
    4960
    5061#
     
    5566VBoxGuestNT_NOINST    = $(NO_SUCH_VARIABLE)
    5667VBoxGuestNT_DEFS      = $(VBoxGuest_DEFS) TARGET_NT4
     68
    5769VBoxGuestNT_SOURCES   = \
    5870        VBoxGuest.cpp \
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/NTLegacy.cpp

    r17163 r18019  
    129129    pDevExt->busNumber = busNumber;
    130130    pDevExt->slotNumber = slotNumber;
     131
     132#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
     133    rc = hlpRegisterBugCheckCallback(pDevExt);
     134#endif
    131135
    132136    //
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest.cpp

    r17499 r18019  
    3232#include "Helper.h"
    3333#include <excpt.h>
     34#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
     35 #ifndef TARGET_NT4
     36  #include <aux_klib.h>
     37 #endif
     38#endif
    3439#include <VBox/err.h>
    3540#include <VBox/log.h>
     
    6772static NTSTATUS VBoxGuestShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    6873static NTSTATUS VBoxGuestNotSupportedStub(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    69 static VOID     VBoxGuestBugCheckCallback(PVOID pszBuffer, ULONG ulLength);
    7074static VOID     vboxWorkerThread(PVOID context);
    7175static VOID     reserveHypervisorMemory(PVBOXGUESTDEVEXT pDevExt);
     
    242246#endif
    243247
    244     /*
    245      * Setup bugcheck callback routine ASAP.
    246      */
    247 #if 0 /** @todo r=bird: The 3rd and 4th parameters aren't according to spec and
    248        * pcBugcheckBuffer isn't initialized anywhere. (Figuring out what it's
    249        * good for is also nice.) Either explain why the spec is wrong in the
    250        * comment above or fix it. Also pc should be pch if you wish to keep it
    251        * a char pointer. */
    252     RtlZeroMemory(pDevExt->szDriverName, sizeof(pDevExt->szDriverName));
    253     KeInitializeCallbackRecord(&pDevExt->bugcheckRecord);
    254 
    255     if (FALSE == KeRegisterBugCheckCallback(&pDevExt->bugcheckRecord,
    256                                             &VBoxGuestBugCheckCallback,
    257                                             pDevExt->pcBugcheckBuffer,
    258                                             sizeof(&pDevExt->szDriverName),
    259                                             pDevExt->szDriverName))
    260     {
    261         dprintf(("VBoxGuest::VBoxGuestAddDevice: Could not register bugcheck callback routine!\n"));
    262     }
    263     else
    264     {
    265         dprintf(("VBoxGuest::VBoxGuestAddDevice: Bugcheck callback registered.\n"));
    266     }
     248#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
     249    rc = hlpRegisterBugCheckCallback(pDevExt);
    267250#endif
    268251
     
    309292    VBoxCleanupMemBalloon(pDevExt);
    310293
    311 #if 0 /** @todo r=bird: code temporarily disabled. Btw. it would be a good idea not to
    312        * try deregister it if we didn't successfully register it in the first place... */
     294#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
    313295    /* Unregister bugcheck callback. */
    314     if (FALSE == KeDeregisterBugCheckCallback(&pDevExt->bugcheckRecord))
    315         dprintf(("VBoxGuest::VBoxGuestUnload: Unregistering bugcheck callback routine failed!\n"));
     296    if (pDevExt->bBugcheckCallbackRegistered && pDevExt->bugcheckContext)
     297    {
     298        if (FALSE == KeDeregisterBugCheckCallback(&pDevExt->bugcheckContext->bugcheckRecord))
     299            dprintf(("VBoxGuest::VBoxGuestUnload: Unregistering bugcheck callback routine failed!\n"));
     300
     301        ExFreePool(&pDevExt->bugcheckContext);
     302        pDevExt->bBugcheckCallbackRegistered = FALSE;
     303    }
    316304#endif
    317305
     
    15431531}
    15441532
    1545 VOID VBoxGuestBugCheckCallback(PVOID pszBuffer, ULONG ulLength)
    1546 {
    1547 /** @todo r=bird: The buffer is the 3rd argument of the registration call
    1548  *        according to the spec and ulLength is the 4th... so either the spec
    1549  *        is wrong of this code dosn't make sense... */
    1550     LogRelBackdoor(("Windows bluescreen detected! "));
    1551     if (pszBuffer)
    1552     {
    1553         LogRelBackdoor(("Additional information: %s\n", (char*)pszBuffer));
    1554     }
    1555     else LogRelBackdoor(("No additional information given.\n"));
    1556 
    1557     /* @todo Notify the host somehow over DevVMM. */
    1558 }
    1559 
    15601533/**
    15611534 * Worker thread to do periodic things such as notify other
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest_Internal.h

    r17480 r18019  
    125125} BASE_ADDRESS, *PBASE_ADDRESS;
    126126
     127typedef struct
     128{
     129    KBUGCHECK_CALLBACK_RECORD bugcheckRecord;
     130} VBOXBUGCHECKCONTEXT, *PVBOXBUGCHECKCONTEXT;
    127131
    128132/**
     
    216220    VMMDevPowerStateRequest *powerStateRequest;
    217221
    218     /* Record for bugcheck callback routine. */
    219     KBUGCHECK_CALLBACK_RECORD bugcheckRecord;
    220     CHAR* pcBugcheckBuffer;
     222    /* Bugcheck context. */
     223    BOOLEAN bBugcheckCallbackRegistered;
     224    PVBOXBUGCHECKCONTEXT bugcheckContext;
    221225
    222226} VBOXGUESTDEVEXT, *PVBOXGUESTDEVEXT;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette