VirtualBox

Changeset 3739 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Jul 20, 2007 2:28:38 PM (18 years ago)
Author:
vboxsync
Message:

cleaned up logging

Location:
trunk/src/VBox/Additions/WINNT/VBoxService
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxService/VBoxClipboard.cpp

    r3198 r3739  
    2424#include "VBoxService.h"
    2525#include <VBox/HostServices/VBoxClipboardSvc.h>
    26 
    27 // #include <iprt/crc64.h>
    28 
    29 // #define LOG_ENABLED
    30 
    31 #ifdef LOG_ENABLED
    32 #include <stdio.h>
    33 
    34 static void _dprintf(LPSTR String, ...)
    35 {
    36    va_list va;
    37 
    38    va_start(va, String);
    39 
    40    CHAR  Buffer[1024];
    41    if (strlen(String) < 1000)
    42    {
    43       _vsntprintf (Buffer, sizeof(Buffer), String, va);
    44 
    45       FILE *f = fopen ("c:\\inst\\clip.log", "ab");
    46       if (f)
    47       {
    48           fprintf (f, "%s", Buffer);
    49           fclose (f);
    50       }
    51    }
    52 
    53    va_end (va);
    54 }
    55 #define dprintf(a) _dprintf a
    56 #else
    57 #define dprintf(a) do {} while (0)
    58 #endif /* LOG_ENABLED */
    59 
     26#include "helpers.h"
    6027
    6128typedef struct _VBOXCLIPBOARDCONTEXT
  • trunk/src/VBox/Additions/WINNT/VBoxService/VBoxSeamless.cpp

    r3735 r3739  
    3939    *pfStartThread = false;
    4040
     41    dprintf(("VBoxSeamlessInit\n"));
     42
    4143    /* Will fail if SetWinEventHook is not present (version < NT4 SP6 apparently) */
    4244    hModule = LoadLibrary(VBOXHOOK_DLL_NAME);
     
    4648        *(uintptr_t *)&pfnVBoxRemoveHook  = (uintptr_t)GetProcAddress(hModule, "VBoxRemoveHook");
    4749    }
     50    else
     51        dprintf(("VBoxSeamlessInit LoadLibrary failed with %d\n", GetLastError()));
     52
    4853    if (pfnVBoxInstallHook)
    4954    {
     
    5762                             &vmmreqGuestCaps, sizeof(vmmreqGuestCaps), &cbReturned, NULL))
    5863        {
    59             SvcDebugOut2("VMMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError());
     64            dprintf(("VMMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError()));
    6065            return VERR_INVALID_PARAMETER;
    6166        }
     
    6772
    6873
    69 void VBoxSeamlessDestroy  (const VBOXSERVICEENV *pEnv, void *pInstance)
     74void VBoxSeamlessDestroy(const VBOXSERVICEENV *pEnv, void *pInstance)
    7075{
     76    dprintf(("VBoxSeamlessDestroy\n"));
    7177    /* inform the host that we no longer support the seamless window mode */
    7278    VMMDevReqGuestCapabilities vmmreqGuestCaps = {0};
     
    7884                         &vmmreqGuestCaps, sizeof(vmmreqGuestCaps), &cbReturned, NULL))
    7985    {
    80         SvcDebugOut2("VMMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError());
     86        dprintf(("VMMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError()));
    8187    }
    8288    if (pfnVBoxRemoveHook)
     
    8692    return;
    8793}
    88 
    89 #if 0
    90 
    91 static char LogBuffer[1024];
    92 
    93 
    94 VBGLR3DECL(int) VbglR3GRPerform(HANDLE hDriver, VMMDevRequestHeader *pReq)
    95 {
    96     DWORD cbReturned;
    97     if (!DeviceIoControl(hDriver, IOCTL_VBOXGUEST_VMMREQUEST, pReq, pReq->size,
    98                          pReq, pReq->size, &cbReturned, NULL))
    99     {
    100         SvcDebugOut2("error doing IOCTL, last error: %d\n", GetLastError());
    101     }
    102     return VINF_SUCCESS;
    103 }
    104 
    105 void VBoxLogString(HANDLE hDriver, char *pszStr)
    106 {
    107     VMMDevReqLogString *pReq = (VMMDevReqLogString *)LogBuffer;
    108     int rc;
    109 
    110     vmmdevInitRequest(&pReq->header, VMMDevReq_LogString);
    111     strcpy(pReq->szString, pszStr);
    112     pReq->header.size += strlen(pszStr);
    113     rc = VbglR3GRPerform(hDriver, &pReq->header);
    114     return;
    115 }
    116 
    117 #endif
  • trunk/src/VBox/Additions/WINNT/VBoxService/VBoxService.cpp

    r3737 r3739  
    4040
    4141
    42 void SvcDebugOut2(char *String, ...)
     42#ifdef DEBUG
     43/**
     44 * Helper function to send a message to WinDbg
     45 *
     46 * @param String message string
     47 */
     48void WriteLog(char *String, ...)
    4349{
    4450    DWORD cbReturned;
     
    5258    vmmdevInitRequest(&pReq->header, VMMDevReq_LogString);
    5359    vsprintf(pReq->szString, String, va);
     60    OutputDebugStringA(pReq->szString);
    5461    pReq->header.size += strlen(pReq->szString);
    5562
     
    6067    return;
    6168}
    62 
    63 
    64 /**
    65  * Helper function to send a message to WinDbg
    66  *
    67  * @param String message string
    68  * @param Status error code, will be inserted into String's placeholder
    69  */
    70 VOID SvcDebugOut(LPSTR String, DWORD Status)
    71 {
    72     SvcDebugOut2(String, Status);
    73 }
     69#endif
     70
     71
    7472
    7573/* The shared clipboard service prototypes. */
     
    113111    while (pTable->pszName)
    114112    {
    115         SvcDebugOut2 ("Starting %s...\n", pTable->pszName);
     113        dprintf(("Starting %s...\n", pTable->pszName));
    116114
    117115        int rc = VINF_SUCCESS;
     
    130128        if (VBOX_FAILURE (rc))
    131129        {
    132             SvcDebugOut2 ("Failed to initialize rc = %Vrc.\n", rc);
     130            dprintf(("Failed to initialize rc = %Vrc.\n", rc));
    133131        }
    134132        else
     
    153151            if (VBOX_FAILURE (rc))
    154152            {
    155                 SvcDebugOut2 ("Failed to start the thread.\n");
     153                dprintf(("Failed to start the thread.\n"));
    156154
    157155                if (pTable->pfnDestroy)
     
    214212void WINAPI VBoxServiceStart(void)
    215213{
    216     SvcDebugOut2("VBoxService: Start\n");
     214    dprintf(("VBoxService: Start\n"));
    217215
    218216    VBOXSERVICEENV svcEnv;
     
    230228    if (gVBoxDriver == INVALID_HANDLE_VALUE)
    231229    {
    232         SvcDebugOut("VBoxService: could not open VBox Guest Additions driver! rc = %d\n", GetLastError());
     230        dprintf(("VBoxService: could not open VBox Guest Additions driver! rc = %d\n", GetLastError()));
    233231        status = ERROR_GEN_FAILURE;
    234232    }
    235233
    236     SvcDebugOut2("VBoxService: Driver h %p, st %p\n", gVBoxDriver, status);
     234    dprintf(("VBoxService: Driver h %p, st %p\n", gVBoxDriver, status));
    237235
    238236    if (status == NO_ERROR)
     
    249247    }
    250248
    251     SvcDebugOut2("VBoxService: Class st %p\n", status);
     249    dprintf(("VBoxService: Class st %p\n", status));
    252250
    253251    if (status == NO_ERROR)
     
    276274    }
    277275
    278     SvcDebugOut2("VBoxService: Window h %p, st %p\n", gToolWindow, status);
     276    dprintf(("VBoxService: Window h %p, st %p\n", gToolWindow, status));
    279277
    280278    if (status == NO_ERROR)
     
    283281        if (gStopSem == NULL)
    284282        {
    285             SvcDebugOut("VBoxService: CreateEvent failed: rc = %d\n", GetLastError());
     283            dprintf(("VBoxService: CreateEvent failed: rc = %d\n", GetLastError()));
    286284            return;
    287285        }
     
    313311    }
    314312
    315     SvcDebugOut2("VBoxService: hDisplayChangeThread h %p, st %p\n", hDisplayChangeThread, status);
     313    dprintf(("VBoxService: hDisplayChangeThread h %p, st %p\n", hDisplayChangeThread, status));
    316314
    317315    /* terminate service if something went wrong */
     
    335333    sprintf(ndata.szTip, "innotek VirtualBox Guest Additions %d.%d.%d", VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD);
    336334
    337     SvcDebugOut2("VBoxService: ndata.hWnd %08X, ndata.hIcon = %p\n", ndata.hWnd, ndata.hIcon);
     335    dprintf(("VBoxService: ndata.hWnd %08X, ndata.hIcon = %p\n", ndata.hWnd, ndata.hIcon));
    338336
    339337    /*
     
    346344        if (waitResult == WAIT_OBJECT_0)
    347345        {
    348             SvcDebugOut2("VBoxService: exit\n");
     346            dprintf(("VBoxService: exit\n"));
    349347            /* exit */
    350348            break;
     
    356354            while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
    357355            {
    358                 SvcDebugOut2("VBoxService: msg %p\n", msg.message);
     356                dprintf(("VBoxService: msg %p\n", msg.message));
    359357                if (msg.message == WM_QUIT)
    360358                {
    361                     SvcDebugOut2("VBoxService: WM_QUIT!\n");
     359                    dprintf(("VBoxService: WM_QUIT!\n"));
    362360                    SetEvent(gStopSem);
    363361                    continue;
     
    370368        {
    371369#ifndef DEBUG_sandervl
    372             SvcDebugOut2("VBoxService: timed out\n");
     370            dprintf(("VBoxService: timed out\n"));
    373371#endif
    374372            /* we might have to repeat this operation because the shell might not be loaded yet */
     
    376374            {
    377375                fTrayIconCreated = Shell_NotifyIcon(NIM_ADD, &ndata);
    378                 SvcDebugOut2("VBoxService: fTrayIconCreated = %d, err %08X\n", fTrayIconCreated, GetLastError ());
    379             }
    380         }
    381     }
    382 
    383     SvcDebugOut("VBoxService: returned from main loop, exiting...\n", 0);
     376                dprintf(("VBoxService: fTrayIconCreated = %d, err %08X\n", fTrayIconCreated, GetLastError ()));
     377            }
     378        }
     379    }
     380
     381    dprintf(("VBoxService: returned from main loop, exiting...\n"));
    384382
    385383    /* remove the system tray icon */
    386384    Shell_NotifyIcon(NIM_DELETE, &ndata);
    387385
    388     SvcDebugOut("VBoxService: waiting for display change thread...\n", 0);
     386    dprintf(("VBoxService: waiting for display change thread...\n"));
    389387
    390388    /* wait for the display change thread to terminate */
     
    393391    vboxStopServices (&svcEnv, vboxServiceTable);
    394392
    395     SvcDebugOut("VBoxService: destroying tool window...\n", 0);
     393    dprintf(("VBoxService: destroying tool window...\n"));
    396394
    397395    /* destroy the tool window */
     
    403401    CloseHandle(gStopSem);
    404402
    405     SvcDebugOut("VBoxService: leaving service main function\n", 0);
     403    dprintf(("VBoxService: leaving service main function\n"));
    406404
    407405    return;
     
    414412int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    415413{
    416     SvcDebugOut2("VBoxService: WinMain\n");
     414    dprintf(("VBoxService: WinMain\n"));
    417415    gInstance = hInstance;
    418416    VBoxServiceStart ();
     
    682680    else
    683681    {
    684         SvcDebugOut2("VBoxService: DeviceIOControl(CtlMask) failed, DisplayChangeThread exited\n");
     682        dprintf(("VBoxService: DeviceIOControl(CtlMask) failed, DisplayChangeThread exited\n"));
    685683        return;
    686684    }
     
    766764                                if (EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &devMode))
    767765                                {
    768                                     SvcDebugOut2("VBoxService: Current mode: %dx%dx%d at %d,%d\n", devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel, devMode.dmPosition.x, devMode.dmPosition.y);
     766                                    dprintf(("VBoxService: Current mode: %dx%dx%d at %d,%d\n", devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel, devMode.dmPosition.x, devMode.dmPosition.y));
    769767
    770768                                    /* Check whether a mode reset or a change is requested. */
     
    791789                                        && devMode.dmBitsPerPel == displayChangeRequest.bpp)
    792790                                    {
    793                                         SvcDebugOut2("VBoxService: already at desired resolution.\n");
     791                                        dprintf(("VBoxService: already at desired resolution.\n"));
    794792                                        break;
    795793                                    }
     
    815813                                    if (status != DISP_CHANGE_SUCCESSFUL)
    816814                                    {
    817                                         SvcDebugOut("VBoxService: error from ChangeDisplaySettings: %d\n", status);
     815                                        dprintf(("VBoxService: error from ChangeDisplaySettings: %d\n", status));
    818816
    819817                                        if (status == DISP_CHANGE_BADMODE)
     
    831829                                else
    832830                                {
    833                                     SvcDebugOut2("VBoxService: error from EnumDisplaySettings: %d\n", GetLastError ());
     831                                    dprintf(("VBoxService: error from EnumDisplaySettings: %d\n", GetLastError ()));
    834832                                    break;
    835833                                }
     
    838836                        else
    839837                        {
    840                             SvcDebugOut2("VBoxService: vboxDisplayDriver is not active.\n", 0);
     838                            dprintf(("VBoxService: vboxDisplayDriver is not active.\n"));
    841839                        }
    842840
     
    851849                    else
    852850                    {
    853                         SvcDebugOut("VBoxService: error from DeviceIoControl IOCTL_VBOXGUEST_VMMREQUEST\n", 0);
     851                        dprintf(("VBoxService: error from DeviceIoControl IOCTL_VBOXGUEST_VMMREQUEST\n"));
    854852                        /* sleep a bit to not eat too much CPU while retrying */
    855853                        /* are we supposed to stop? */
     
    864862        } else
    865863        {
    866             SvcDebugOut("VBoxService: error from DeviceIoControl IOCTL_VBOXGUEST_WAITEVENT\n", 0);
     864            dprintf(("VBoxService: error 0 from DeviceIoControl IOCTL_VBOXGUEST_WAITEVENT\n"));
    867865            /* sleep a bit to not eat too much CPU in case the above call always fails */
    868866            if (WaitForSingleObject(gStopSem, 10) == WAIT_OBJECT_0)
     
    882880    else
    883881    {
    884         SvcDebugOut2 ("VBoxService: DeviceIOControl(CtlMask) failed\n");
    885     }
    886 
    887     SvcDebugOut2("VBoxService: finished display change request thread\n");
     882        dprintf(("VBoxService: DeviceIOControl(CtlMask) failed\n"));
     883    }
     884
     885    dprintf(("VBoxService: finished display change request thread\n"));
    888886}
    889887
  • trunk/src/VBox/Additions/WINNT/VBoxService/helpers.h

    r3260 r3739  
    2828void SvcDebugOut2(char *String, ...);
    2929# ifdef DEBUG_DISPLAY_CHANGE
    30 #  define DDCLOG(a) do { SvcDebugOut2 a; } while (0)
     30#  define DDCLOG(a) dprintf(a)
    3131# else
    3232#  define DDCLOG(a) do {} while (0)
     
    3434#endif /* DDCLOG */
    3535
     36#ifdef DEBUG
     37void WriteLog(char *String, ...);
     38#define dprintf(a) do { WriteLog a; } while (0)
     39#else
     40#define dprintf(a) do {} while (0)
     41#endif /* DEBUG */
     42
    3643void resizeRect(RECTL *paRects, unsigned nRects, unsigned iPrimary, unsigned iResized, int NewWidth, int NewHeight);
    3744
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