VirtualBox

Changeset 40198 in vbox for trunk/src/VBox/Additions/common


Ignore:
Timestamp:
Feb 21, 2012 2:02:26 PM (13 years ago)
Author:
vboxsync
Message:

VBoxGuest: Implemented (optional) ability to print debug guest output to the release log (Windows guest only atm).

Location:
trunk/src/VBox/Additions/common/VBoxGuest
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp

    r40195 r40198  
    4545static NTSTATUS vboxguestwinIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    4646static NTSTATUS vboxguestwinInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     47static NTSTATUS vboxguestwinRegistryReadDWORD(ULONG ulRoot, PCWSTR pwszPath, PWSTR pwszName, PULONG puValue);
    4748static NTSTATUS vboxguestwinSystemControl(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    4849static NTSTATUS vboxguestwinShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     
    491492    if (RT_SUCCESS(rc))
    492493    {
     494        ULONG ulValue = 0;
     495        NTSTATUS s = vboxguestwinRegistryReadDWORD(RTL_REGISTRY_SERVICES, L"VBoxGuest", L"LoggingEnabled",
     496                                                   &ulValue);
     497        if (NT_SUCCESS(s))
     498        {
     499            pDevExt->fLoggingEnabled = ulValue >= 0xFF;
     500            if (pDevExt->fLoggingEnabled)
     501                Log(("Logging to release log enabled (0x%x)", ulValue));
     502        }
     503
    493504        /* Ready to rumble! */
    494505        Log(("VBoxGuest::vboxguestwinInit: Device is ready!\n"));
     
    10231034     * we rely on the pDevExt->u32MousePosChangedSeq to be set to a non-zero value on a mouse event
    10241035     * and queue the DPC in our ISR routine in that case doing KeSetEvent from the DPC routine */
     1036}
     1037
     1038
     1039/**
     1040 * Queries (gets) a DWORD value from the registry.
     1041 *
     1042 * @return  NTSTATUS
     1043 * @param   ulRoot      Relative path root. See RTL_REGISTRY_SERVICES or RTL_REGISTRY_ABSOLUTE.
     1044 * @param   pwszPath    Path inside path root.
     1045 * @param   pwszName    Actual value name to look up.
     1046 * @param   puValue     On input this can specify the default value (if RTL_REGISTRY_OPTIONAL is
     1047 *                      not specified in ulRoot), on output this will retrieve the looked up
     1048 *                      registry value if found.
     1049 */
     1050NTSTATUS vboxguestwinRegistryReadDWORD(ULONG ulRoot, PCWSTR pwszPath, PWSTR pwszName,
     1051                                       PULONG puValue)
     1052{
     1053    if (!pwszPath || !pwszName || !puValue)
     1054        return STATUS_INVALID_PARAMETER;
     1055
     1056    ULONG ulDefault = *puValue;
     1057
     1058    RTL_QUERY_REGISTRY_TABLE  tblQuery[2];
     1059    RtlZeroMemory(tblQuery, sizeof(tblQuery));
     1060    /** @todo Add RTL_QUERY_REGISTRY_TYPECHECK! */
     1061    tblQuery[0].Flags         = RTL_QUERY_REGISTRY_DIRECT;
     1062    tblQuery[0].Name          = pwszName;
     1063    tblQuery[0].EntryContext  = puValue;
     1064    tblQuery[0].DefaultType   = REG_DWORD;
     1065    tblQuery[0].DefaultData   = &ulDefault;
     1066    tblQuery[0].DefaultLength = sizeof(ULONG);
     1067
     1068    return RtlQueryRegistryValues(ulRoot,
     1069                                  pwszPath,
     1070                                  &tblQuery[0],
     1071                                  NULL /* Context */,
     1072                                  NULL /* Environment */);
    10251073}
    10261074
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp

    r40197 r40198  
    713713    pDevExt->fVRDPEnabled = false;
    714714#endif
     715    pDevExt->fLoggingEnabled = false;
    715716    pDevExt->f32PendingEvents = 0;
    716717    pDevExt->u32MousePosChangedSeq = 0;
     
    23412342 * @returns VBox status code.
    23422343 *
     2344 * @param   pDevExt             The device extension.
    23432345 * @param   pch                 The log message (need not be NULL terminated).
    23442346 * @param   cbData              Size of the buffer.
    23452347 * @param   pcbDataReturned     Where to store the amount of returned data. Can be NULL.
    23462348 */
    2347 static int VBoxGuestCommonIOCtl_Log(const char *pch, size_t cbData, size_t *pcbDataReturned)
     2349static int VBoxGuestCommonIOCtl_Log(PVBOXGUESTDEVEXT pDevExt, const char *pch, size_t cbData, size_t *pcbDataReturned)
    23482350{
    23492351    NOREF(pch);
    23502352    NOREF(cbData);
    2351     Log(("%.*s", cbData, pch));
     2353    if (pDevExt->fLoggingEnabled)
     2354        RTLogBackdoorPrintf("%.*s", cbData, pch);
     2355    else
     2356        Log(("%.*s", cbData, pch));
    23522357    if (pcbDataReturned)
    23532358        *pcbDataReturned = 0;
     
    24792484    {
    24802485        CHECKRET_MIN_SIZE("LOG", 1);
    2481         rc = VBoxGuestCommonIOCtl_Log((char *)pvData, cbData, pcbDataReturned);
     2486        rc = VBoxGuestCommonIOCtl_Log(pDevExt, (char *)pvData, cbData, pcbDataReturned);
    24822487    }
    24832488    else
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h

    r40195 r40198  
    153153    bool                        fVRDPEnabled;
    154154#endif
     155    /** Flag indicating whether logging to the release log
     156     *  is enabled. */
     157    bool                        fLoggingEnabled;
    155158    /** Memory balloon information for RTR0MemObjAllocPhysNC(). */
    156159    VBOXGUESTMEMBALLOON         MemBalloon;
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