Changeset 21888 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jul 30, 2009 1:51:20 PM (15 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest.cpp
r21703 r21888 77 77 #endif 78 78 79 #ifdef DEBUG 80 static VOID testVBoxGuest(VOID); 81 #endif 82 79 83 /******************************************************************************* 80 84 * Exported Functions * … … 123 127 PsGetVersion(&majorVersion, &minorVersion, &buildNumber, NULL); 124 128 dprintf(("VBoxGuest::DriverEntry: running on Windows NT version %d.%d, build %d\n", majorVersion, minorVersion, buildNumber)); 129 #ifdef DEBUG 130 testVBoxGuest(); 131 #endif 125 132 switch (majorVersion) 126 133 { … … 783 790 } 784 791 792 /** A quick implementation of AtomicTestAndClear for uint32_t and multiple 793 * bits. 794 */ 795 static uint32_t guestAtomicBitsTestAndClear(void *pu32Bits, uint32_t u32Mask) 796 { 797 AssertPtrReturn(pu32Bits, 0); 798 LogFlowFunc(("*pu32Bits=0x%x, u32Mask=0x%x\n", *(long *)pu32Bits, 799 u32Mask)); 800 uint32_t u32Result = 0; 801 uint32_t u32WorkingMask = u32Mask; 802 int iBitOffset = ASMBitFirstSetU32 (u32WorkingMask); 803 804 while (iBitOffset > 0) 805 { 806 bool fSet = ASMAtomicBitTestAndClear(pu32Bits, iBitOffset - 1); 807 if (fSet) 808 u32Result |= 1 << (iBitOffset - 1); 809 u32WorkingMask &= ~(1 << (iBitOffset - 1)); 810 iBitOffset = ASMBitFirstSetU32 (u32WorkingMask); 811 } 812 LogFlowFunc(("Returning 0x%x\n", u32Result)); 813 return u32Result; 814 } 815 785 816 /** 786 817 * Device I/O Control entry point. … … 850 881 VBoxGuestWaitEventInfo *eventInfo = (VBoxGuestWaitEventInfo *)pBuf; 851 882 852 if (!eventInfo->u32EventMaskIn || !IsPowerOfTwo (eventInfo->u32EventMaskIn)) {883 if (!eventInfo->u32EventMaskIn) { 853 884 dprintf (("VBoxGuest::VBoxGuestDeviceControl: Invalid input mask %#x\n", 854 885 eventInfo->u32EventMaskIn)); … … 858 889 859 890 eventInfo->u32EventFlagsOut = 0; 860 int iBitOffset = ASMBitFirstSetU32 (eventInfo->u32EventMaskIn) - 1;861 891 bool fTimeout = (eventInfo->u32TimeoutIn != ~0L); 862 863 dprintf (("mask = %d, iBitOffset = %d\n", iBitOffset, eventInfo->u32EventMaskIn));864 892 865 893 /* Possible problem with request completion right between the pending event check and KeWaitForSingleObject … … 874 902 for (;;) 875 903 { 876 bool fEventPending = ASMAtomicBitTestAndClear(&pDevExt->u32Events, iBitOffset); 877 if (fEventPending) 904 uint32_t u32EventsPending = 905 guestAtomicBitsTestAndClear(&pDevExt->u32Events, 906 eventInfo->u32EventMaskIn); 907 dprintf (("mask = 0x%x, pending = 0x%x\n", 908 eventInfo->u32EventMaskIn, u32EventsPending)); 909 910 if (u32EventsPending) 878 911 { 879 eventInfo->u32EventFlagsOut = 1 << iBitOffset;912 eventInfo->u32EventFlagsOut = u32EventsPending; 880 913 break; 881 914 } … … 1882 1915 dprintf(("VBoxGuest::vboxIdleThread leaving\n")); 1883 1916 } 1917 1918 #ifdef DEBUG 1919 static VOID testAtomicTestAndClearBitsU32(uint32_t u32Mask, uint32_t u32Bits, 1920 uint32_t u32Exp) 1921 { 1922 ULONG u32Bits2 = u32Bits; 1923 uint32_t u32Result = guestAtomicBitsTestAndClear(&u32Bits2, u32Mask); 1924 if ( u32Result != u32Exp 1925 || (u32Bits2 & u32Mask) 1926 || (u32Bits2 & u32Result) 1927 || ((u32Bits2 | u32Result) != u32Bits) 1928 ) 1929 AssertLogRelMsgFailed(("%s: TEST FAILED: u32Mask=0x%x, u32Bits (before)=0x%x, u32Bits (after)=0x%x, u32Result=0x%x, u32Exp=ox%x\n", 1930 __PRETTY_FUNCTION__, u32Mask, u32Bits, u32Bits2, 1931 u32Result)); 1932 } 1933 1934 static VOID testVBoxGuest(VOID) 1935 { 1936 testAtomicTestAndClearBitsU32(0x00, 0x23, 0); 1937 testAtomicTestAndClearBitsU32(0x11, 0, 0); 1938 testAtomicTestAndClearBitsU32(0x11, 0x22, 0); 1939 testAtomicTestAndClearBitsU32(0x11, 0x23, 0x1); 1940 testAtomicTestAndClearBitsU32(0x11, 0x32, 0x10); 1941 testAtomicTestAndClearBitsU32(0x22, 0x23, 0x22); 1942 } 1943 #endif -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
r21219 r21888 386 386 DWORD cbReturned; 387 387 388 maskInfo.u32OrMask = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST ;388 maskInfo.u32OrMask = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED; 389 389 maskInfo.u32NotMask = 0; 390 390 if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL)) … … 403 403 VBoxGuestWaitEventInfo waitEvent; 404 404 waitEvent.u32TimeoutIn = 1000; 405 waitEvent.u32EventMaskIn = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST ;405 waitEvent.u32EventMaskIn = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED; 406 406 if (DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent), &waitEvent, sizeof(waitEvent), &cbReturned, NULL)) 407 407 { … … 591 591 } 592 592 } 593 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED) 594 VBoxServiceReloadCursor(); 593 595 } else 594 596 { … … 604 606 605 607 maskInfo.u32OrMask = 0; 606 maskInfo.u32NotMask = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST ;608 maskInfo.u32NotMask = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED; 607 609 if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL)) 608 610 { -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp
r18265 r21888 215 215 216 216 217 /** Attempt to force Windows to reload the cursor image by attaching to the 218 * thread of the window currently under the mouse, hiding the cursor and 219 * showing it again. This could fail to work in any number of ways (no 220 * window under the cursor, the cursor has moved to a different window while 221 * we are processing), but we just accept this, as the cursor will be reloaded 222 * at some point anyway. */ 223 void VBoxServiceReloadCursor(void) 224 { 225 LogFlowFunc(("\n")); 226 POINT mousePos; 227 HWND hWin; 228 DWORD hThread, hCurrentThread; 229 230 GetCursorPos(&mousePos); 231 hWin = WindowFromPoint(mousePos); 232 if (hWin) 233 { 234 hThread = GetWindowThreadProcessId(hWin, NULL); 235 hCurrentThread = GetCurrentThreadId(); 236 if (hCurrentThread != hThread) 237 AttachThreadInput(hCurrentThread, hThread, TRUE); 238 } 239 ShowCursor(false); 240 ShowCursor(true); 241 if (hWin && (hCurrentThread != hThread)) 242 AttachThreadInput(hCurrentThread, hThread, FALSE); 243 LogFlowFunc(("exiting\n")); 244 } 245 246 217 247 void WINAPI VBoxServiceStart(void) 218 248 { … … 264 294 status = GetLastError(); 265 295 else 266 { 267 /* move the window beneach the mouse pointer so that we get access to it */ 268 POINT mousePos; 269 GetCursorPos(&mousePos); 270 SetWindowPos(gToolWindow, HWND_TOPMOST, mousePos.x - 10, mousePos.y - 10, 0, 0, 271 SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOSIZE); 272 /* change the mouse pointer so that we can go for a hardware shape */ 273 SetCursor(LoadCursor(NULL, IDC_APPSTARTING)); 274 SetCursor(LoadCursor(NULL, IDC_ARROW)); 275 /* move back our tool window */ 276 SetWindowPos(gToolWindow, HWND_TOPMOST, -200, -200, 0, 0, 277 SWP_NOACTIVATE | SWP_HIDEWINDOW | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOSIZE); 278 } 296 VBoxServiceReloadCursor(); 279 297 } 280 298 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.h
r21229 r21888 67 67 extern HWND gToolWindow; 68 68 69 extern void VBoxServiceReloadCursor(void); 70 69 71 #endif /* !___VBOXTRAY_H */ 70 72
Note:
See TracChangeset
for help on using the changeset viewer.