Changeset 3739 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Jul 20, 2007 2:28:38 PM (18 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxService
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxClipboard.cpp
r3198 r3739 24 24 #include "VBoxService.h" 25 25 #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" 60 27 61 28 typedef struct _VBOXCLIPBOARDCONTEXT -
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxSeamless.cpp
r3735 r3739 39 39 *pfStartThread = false; 40 40 41 dprintf(("VBoxSeamlessInit\n")); 42 41 43 /* Will fail if SetWinEventHook is not present (version < NT4 SP6 apparently) */ 42 44 hModule = LoadLibrary(VBOXHOOK_DLL_NAME); … … 46 48 *(uintptr_t *)&pfnVBoxRemoveHook = (uintptr_t)GetProcAddress(hModule, "VBoxRemoveHook"); 47 49 } 50 else 51 dprintf(("VBoxSeamlessInit LoadLibrary failed with %d\n", GetLastError())); 52 48 53 if (pfnVBoxInstallHook) 49 54 { … … 57 62 &vmmreqGuestCaps, sizeof(vmmreqGuestCaps), &cbReturned, NULL)) 58 63 { 59 SvcDebugOut2("VMMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError());64 dprintf(("VMMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError())); 60 65 return VERR_INVALID_PARAMETER; 61 66 } … … 67 72 68 73 69 void VBoxSeamlessDestroy 74 void VBoxSeamlessDestroy(const VBOXSERVICEENV *pEnv, void *pInstance) 70 75 { 76 dprintf(("VBoxSeamlessDestroy\n")); 71 77 /* inform the host that we no longer support the seamless window mode */ 72 78 VMMDevReqGuestCapabilities vmmreqGuestCaps = {0}; … … 78 84 &vmmreqGuestCaps, sizeof(vmmreqGuestCaps), &cbReturned, NULL)) 79 85 { 80 SvcDebugOut2("VMMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError());86 dprintf(("VMMDevReq_ReportGuestCapabilities: error doing IOCTL, last error: %d\n", GetLastError())); 81 87 } 82 88 if (pfnVBoxRemoveHook) … … 86 92 return; 87 93 } 88 89 #if 090 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 40 40 41 41 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 */ 48 void WriteLog(char *String, ...) 43 49 { 44 50 DWORD cbReturned; … … 52 58 vmmdevInitRequest(&pReq->header, VMMDevReq_LogString); 53 59 vsprintf(pReq->szString, String, va); 60 OutputDebugStringA(pReq->szString); 54 61 pReq->header.size += strlen(pReq->szString); 55 62 … … 60 67 return; 61 68 } 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 74 72 75 73 /* The shared clipboard service prototypes. */ … … 113 111 while (pTable->pszName) 114 112 { 115 SvcDebugOut2 ("Starting %s...\n", pTable->pszName);113 dprintf(("Starting %s...\n", pTable->pszName)); 116 114 117 115 int rc = VINF_SUCCESS; … … 130 128 if (VBOX_FAILURE (rc)) 131 129 { 132 SvcDebugOut2 ("Failed to initialize rc = %Vrc.\n", rc);130 dprintf(("Failed to initialize rc = %Vrc.\n", rc)); 133 131 } 134 132 else … … 153 151 if (VBOX_FAILURE (rc)) 154 152 { 155 SvcDebugOut2 ("Failed to start the thread.\n");153 dprintf(("Failed to start the thread.\n")); 156 154 157 155 if (pTable->pfnDestroy) … … 214 212 void WINAPI VBoxServiceStart(void) 215 213 { 216 SvcDebugOut2("VBoxService: Start\n");214 dprintf(("VBoxService: Start\n")); 217 215 218 216 VBOXSERVICEENV svcEnv; … … 230 228 if (gVBoxDriver == INVALID_HANDLE_VALUE) 231 229 { 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())); 233 231 status = ERROR_GEN_FAILURE; 234 232 } 235 233 236 SvcDebugOut2("VBoxService: Driver h %p, st %p\n", gVBoxDriver, status);234 dprintf(("VBoxService: Driver h %p, st %p\n", gVBoxDriver, status)); 237 235 238 236 if (status == NO_ERROR) … … 249 247 } 250 248 251 SvcDebugOut2("VBoxService: Class st %p\n", status);249 dprintf(("VBoxService: Class st %p\n", status)); 252 250 253 251 if (status == NO_ERROR) … … 276 274 } 277 275 278 SvcDebugOut2("VBoxService: Window h %p, st %p\n", gToolWindow, status);276 dprintf(("VBoxService: Window h %p, st %p\n", gToolWindow, status)); 279 277 280 278 if (status == NO_ERROR) … … 283 281 if (gStopSem == NULL) 284 282 { 285 SvcDebugOut("VBoxService: CreateEvent failed: rc = %d\n", GetLastError());283 dprintf(("VBoxService: CreateEvent failed: rc = %d\n", GetLastError())); 286 284 return; 287 285 } … … 313 311 } 314 312 315 SvcDebugOut2("VBoxService: hDisplayChangeThread h %p, st %p\n", hDisplayChangeThread, status);313 dprintf(("VBoxService: hDisplayChangeThread h %p, st %p\n", hDisplayChangeThread, status)); 316 314 317 315 /* terminate service if something went wrong */ … … 335 333 sprintf(ndata.szTip, "innotek VirtualBox Guest Additions %d.%d.%d", VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD); 336 334 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)); 338 336 339 337 /* … … 346 344 if (waitResult == WAIT_OBJECT_0) 347 345 { 348 SvcDebugOut2("VBoxService: exit\n");346 dprintf(("VBoxService: exit\n")); 349 347 /* exit */ 350 348 break; … … 356 354 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 357 355 { 358 SvcDebugOut2("VBoxService: msg %p\n", msg.message);356 dprintf(("VBoxService: msg %p\n", msg.message)); 359 357 if (msg.message == WM_QUIT) 360 358 { 361 SvcDebugOut2("VBoxService: WM_QUIT!\n");359 dprintf(("VBoxService: WM_QUIT!\n")); 362 360 SetEvent(gStopSem); 363 361 continue; … … 370 368 { 371 369 #ifndef DEBUG_sandervl 372 SvcDebugOut2("VBoxService: timed out\n");370 dprintf(("VBoxService: timed out\n")); 373 371 #endif 374 372 /* we might have to repeat this operation because the shell might not be loaded yet */ … … 376 374 { 377 375 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")); 384 382 385 383 /* remove the system tray icon */ 386 384 Shell_NotifyIcon(NIM_DELETE, &ndata); 387 385 388 SvcDebugOut("VBoxService: waiting for display change thread...\n", 0);386 dprintf(("VBoxService: waiting for display change thread...\n")); 389 387 390 388 /* wait for the display change thread to terminate */ … … 393 391 vboxStopServices (&svcEnv, vboxServiceTable); 394 392 395 SvcDebugOut("VBoxService: destroying tool window...\n", 0);393 dprintf(("VBoxService: destroying tool window...\n")); 396 394 397 395 /* destroy the tool window */ … … 403 401 CloseHandle(gStopSem); 404 402 405 SvcDebugOut("VBoxService: leaving service main function\n", 0);403 dprintf(("VBoxService: leaving service main function\n")); 406 404 407 405 return; … … 414 412 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) 415 413 { 416 SvcDebugOut2("VBoxService: WinMain\n");414 dprintf(("VBoxService: WinMain\n")); 417 415 gInstance = hInstance; 418 416 VBoxServiceStart (); … … 682 680 else 683 681 { 684 SvcDebugOut2("VBoxService: DeviceIOControl(CtlMask) failed, DisplayChangeThread exited\n");682 dprintf(("VBoxService: DeviceIOControl(CtlMask) failed, DisplayChangeThread exited\n")); 685 683 return; 686 684 } … … 766 764 if (EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &devMode)) 767 765 { 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)); 769 767 770 768 /* Check whether a mode reset or a change is requested. */ … … 791 789 && devMode.dmBitsPerPel == displayChangeRequest.bpp) 792 790 { 793 SvcDebugOut2("VBoxService: already at desired resolution.\n");791 dprintf(("VBoxService: already at desired resolution.\n")); 794 792 break; 795 793 } … … 815 813 if (status != DISP_CHANGE_SUCCESSFUL) 816 814 { 817 SvcDebugOut("VBoxService: error from ChangeDisplaySettings: %d\n", status);815 dprintf(("VBoxService: error from ChangeDisplaySettings: %d\n", status)); 818 816 819 817 if (status == DISP_CHANGE_BADMODE) … … 831 829 else 832 830 { 833 SvcDebugOut2("VBoxService: error from EnumDisplaySettings: %d\n", GetLastError ());831 dprintf(("VBoxService: error from EnumDisplaySettings: %d\n", GetLastError ())); 834 832 break; 835 833 } … … 838 836 else 839 837 { 840 SvcDebugOut2("VBoxService: vboxDisplayDriver is not active.\n", 0);838 dprintf(("VBoxService: vboxDisplayDriver is not active.\n")); 841 839 } 842 840 … … 851 849 else 852 850 { 853 SvcDebugOut("VBoxService: error from DeviceIoControl IOCTL_VBOXGUEST_VMMREQUEST\n", 0);851 dprintf(("VBoxService: error from DeviceIoControl IOCTL_VBOXGUEST_VMMREQUEST\n")); 854 852 /* sleep a bit to not eat too much CPU while retrying */ 855 853 /* are we supposed to stop? */ … … 864 862 } else 865 863 { 866 SvcDebugOut("VBoxService: error from DeviceIoControl IOCTL_VBOXGUEST_WAITEVENT\n", 0);864 dprintf(("VBoxService: error 0 from DeviceIoControl IOCTL_VBOXGUEST_WAITEVENT\n")); 867 865 /* sleep a bit to not eat too much CPU in case the above call always fails */ 868 866 if (WaitForSingleObject(gStopSem, 10) == WAIT_OBJECT_0) … … 882 880 else 883 881 { 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")); 888 886 } 889 887 -
trunk/src/VBox/Additions/WINNT/VBoxService/helpers.h
r3260 r3739 28 28 void SvcDebugOut2(char *String, ...); 29 29 # ifdef DEBUG_DISPLAY_CHANGE 30 # define DDCLOG(a) d o { SvcDebugOut2 a; } while (0)30 # define DDCLOG(a) dprintf(a) 31 31 # else 32 32 # define DDCLOG(a) do {} while (0) … … 34 34 #endif /* DDCLOG */ 35 35 36 #ifdef DEBUG 37 void 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 36 43 void resizeRect(RECTL *paRects, unsigned nRects, unsigned iPrimary, unsigned iResized, int NewWidth, int NewHeight); 37 44
Note:
See TracChangeset
for help on using the changeset viewer.