Changeset 4461 in vbox for trunk/src/VBox
- Timestamp:
- Aug 31, 2007 8:41:54 AM (17 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxHook/VBoxHook.cpp
r4457 r4461 19 19 #pragma data_seg("SHARED") 20 20 static HWINEVENTHOOK hEventHook[2] = {0}; 21 static HWND hwndNotification = 0;22 21 #pragma data_seg() 23 22 #pragma comment(linker, "/section:SHARED,RWS") 23 24 static HANDLE hNotifyEvent = 0; 24 25 25 26 #ifdef DEBUG … … 74 75 } 75 76 #endif 76 BOOL ret = PostMessage(hwndNotification, WM_VBOX_SEAMLESS_UPDATE, 0, 0); 77 dprintf(("PostMessage %x returned %d (last error %x)\n", hwndNotification, ret, GetLastError())); 77 if (!hNotifyEvent) 78 { 79 hNotifyEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE, VBOXHOOK_GLOBAL_EVENT_NAME); 80 dprintf(("OpenEvent returned %x (last err=%x)\n", hNotifyEvent, GetLastError())); 81 } 82 BOOL ret = SetEvent(hNotifyEvent); 83 dprintf(("SetEvent %x returned %d (last error %x)\n", hNotifyEvent, ret, GetLastError())); 78 84 break; 79 85 } … … 82 88 83 89 /* Install the global message hook */ 84 BOOL VBoxInstallHook(HMODULE hDll , HWND hwndPostWindow)90 BOOL VBoxInstallHook(HMODULE hDll) 85 91 { 86 92 if (hEventHook[0] || hEventHook[1]) 87 93 return TRUE; 88 94 89 hwndNotification = hwndPostWindow;90 91 dprintf(("VBoxInstallHook hwnd=%x\n", hwndPostWindow));92 95 CoInitialize(NULL); 93 96 hEventHook[0] = SetWinEventHook(EVENT_OBJECT_LOCATIONCHANGE, EVENT_OBJECT_LOCATIONCHANGE, … … 115 118 } 116 119 hEventHook[0] = hEventHook[1] = 0; 117 hwndNotification = 0;118 120 return true; 119 121 } -
trunk/src/VBox/Additions/WINNT/VBoxHook/testcase/tstHook.cpp
r4071 r4461 21 21 { 22 22 printf("Enabling global hook\n"); 23 VBoxInstallHook(GetModuleHandle("VBoxHook.dll"), 0); 23 24 HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, VBOXHOOK_GLOBAL_EVENT_NAME); 25 26 VBoxInstallHook(GetModuleHandle("VBoxHook.dll")); 24 27 getchar(); 25 28 -
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxSeamless.cpp
r4071 r4461 32 32 HMODULE hModule; 33 33 34 BOOL (* pfnVBoxInstallHook)(HMODULE hDll , HWND hwndPostWindow);34 BOOL (* pfnVBoxInstallHook)(HMODULE hDll); 35 35 BOOL (* pfnVBoxRemoveHook)(); 36 36 … … 120 120 VBoxSeamlessCheckWindows(); 121 121 122 gCtx.pfnVBoxInstallHook(gCtx.hModule , gToolWindow);122 gCtx.pfnVBoxInstallHook(gCtx.hModule); 123 123 } 124 124 } -
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxService.cpp
r4453 r4461 30 30 HANDLE gVBoxDriver; 31 31 HANDLE gStopSem; 32 HANDLE ghSeamlessNotifyEvent = 0; 32 33 SERVICE_STATUS gVBoxServiceStatus; 33 34 SERVICE_STATUS_HANDLE gVBoxServiceStatusHandle; … … 291 292 return; 292 293 } 294 ghSeamlessNotifyEvent = CreateEvent(NULL, FALSE, FALSE, VBOXHOOK_GLOBAL_EVENT_NAME); 295 if (ghSeamlessNotifyEvent == NULL) 296 { 297 dprintf(("VBoxService: CreateEvent failed: rc = %d\n", GetLastError())); 298 return; 299 } 293 300 } 294 301 … … 335 342 * Wait for the stop semaphore to be posted or a window event to arrive 336 343 */ 344 HANDLE hWaitEvent[2] = {gStopSem, ghSeamlessNotifyEvent}; 337 345 while(true) 338 346 { 339 DWORD waitResult = MsgWaitForMultipleObjectsEx( 1, &gStopSem, 250, QS_ALLINPUT, 0);347 DWORD waitResult = MsgWaitForMultipleObjectsEx(2, hWaitEvent, 500, QS_ALLINPUT, 0); 340 348 if (waitResult == WAIT_OBJECT_0) 341 349 { … … 344 352 break; 345 353 } 346 /* timeout or a window message, handle it */ 347 MSG msg; 348 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 349 { 350 dprintf(("VBoxService: msg %p\n", msg.message)); 351 if (msg.message == WM_QUIT) 352 { 353 dprintf(("VBoxService: WM_QUIT!\n")); 354 SetEvent(gStopSem); 355 continue; 356 } 357 TranslateMessage(&msg); 358 DispatchMessage(&msg); 359 } 360 /* we might have to repeat this operation because the shell might not be loaded yet */ 361 if (!fTrayIconCreated) 362 { 363 fTrayIconCreated = Shell_NotifyIcon(NIM_ADD, &ndata); 364 dprintf(("VBoxService: fTrayIconCreated = %d, err %08X\n", fTrayIconCreated, GetLastError ())); 354 else 355 if (waitResult == WAIT_OBJECT_0+1) 356 { 357 /* seamless window notification */ 358 VBoxSeamlessCheckWindows(); 359 } 360 else 361 { 362 /* timeout or a window message, handle it */ 363 MSG msg; 364 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 365 { 366 dprintf(("VBoxService: msg %p\n", msg.message)); 367 if (msg.message == WM_QUIT) 368 { 369 dprintf(("VBoxService: WM_QUIT!\n")); 370 SetEvent(gStopSem); 371 continue; 372 } 373 TranslateMessage(&msg); 374 DispatchMessage(&msg); 375 } 376 /* we might have to repeat this operation because the shell might not be loaded yet */ 377 if (!fTrayIconCreated) 378 { 379 fTrayIconCreated = Shell_NotifyIcon(NIM_ADD, &ndata); 380 dprintf(("VBoxService: fTrayIconCreated = %d, err %08X\n", fTrayIconCreated, GetLastError ())); 381 } 365 382 } 366 383 } -
trunk/src/VBox/Additions/WINNT/include/VBoxGuestInternal.h
r4301 r4461 12 12 13 13 /** Uncomment to enable VRDP status checks */ 14 //#define VBOX_WITH_VRDP_SESSION_HANDLING14 #define VBOX_WITH_VRDP_SESSION_HANDLING 15 15 16 16 /** IOCTL for VBoxGuest to enable a VRDP session */ -
trunk/src/VBox/Additions/WINNT/include/VBoxHook.h
r4278 r4461 18 18 19 19 #define VBOXHOOK_DLL_NAME "VBoxHook.dll" 20 #define VBOXHOOK_GLOBAL_EVENT_NAME "Local\\VBoxHookNotifyEvent" 20 21 21 22 /* Install the global message hook */ 22 BOOL VBoxInstallHook(HMODULE hDll , HWND hwndPostWindow);23 BOOL VBoxInstallHook(HMODULE hDll); 23 24 24 25 /* Remove the global message hook */
Note:
See TracChangeset
for help on using the changeset viewer.