Changeset 37221 in vbox for trunk/src/VBox/Additions/common/VBoxGuest
- Timestamp:
- May 26, 2011 10:33:21 AM (14 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxGuest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r36060 r37221 51 51 static NTSTATUS vboxguestwinClose(PDEVICE_OBJECT pDevObj, PIRP pIrp); 52 52 static NTSTATUS vboxguestwinIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp); 53 static NTSTATUS vboxguestwinInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp); 53 54 static NTSTATUS vboxguestwinSystemControl(PDEVICE_OBJECT pDevObj, PIRP pIrp); 54 55 static NTSTATUS vboxguestwinShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp); … … 88 89 /** The detected Windows version. */ 89 90 winVersion_t g_winVersion; 90 91 91 92 92 /** … … 166 166 pDrvObj->MajorFunction[IRP_MJ_CLOSE] = vboxguestwinClose; 167 167 pDrvObj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = vboxguestwinIOCtl; 168 pDrvObj->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = vboxguestwinI OCtl;168 pDrvObj->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = vboxguestwinInternalIOCtl; 169 169 pDrvObj->MajorFunction[IRP_MJ_SHUTDOWN] = vboxguestwinShutdown; 170 170 pDrvObj->MajorFunction[IRP_MJ_READ] = vboxguestwinNotSupportedStub; … … 221 221 pDevExt = (PVBOXGUESTDEVEXT)pDeviceObject->DeviceExtension; 222 222 RtlZeroMemory(pDevExt, sizeof(VBOXGUESTDEVEXT)); 223 224 KeInitializeSpinLock(&pDevExt->win.s.MouseEventAccessLock); 223 225 224 226 pDevExt->win.s.pDeviceObject = pDeviceObject; … … 795 797 } 796 798 799 /* we do not want to allow some IOCTLs to be originated from user mode, 800 * this is why we have a separate vboxguestwinInternalIOCtl for internal IOCTLs */ 801 NTSTATUS vboxguestwinInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp) 802 { 803 NTSTATUS Status = STATUS_SUCCESS; 804 PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension; 805 PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp); 806 unsigned int uCmd = (unsigned int)pStack->Parameters.DeviceIoControl.IoControlCode; 807 BOOLEAN fProcessed = FALSE; 808 unsigned Info = 0; 809 810 switch (uCmd) 811 { 812 case VBOXGUEST_IOCTL_INTERNAL_SET_MOUSE_NOTIFY_EVENT: 813 { 814 PVOID pvBuf = pStack->Parameters.Others.Argument1; 815 size_t cbData = (size_t)pStack->Parameters.Others.Argument2; 816 fProcessed = true; 817 if (cbData != sizeof (PKEVENT)) 818 { 819 AssertFailed(); 820 Status = STATUS_INVALID_PARAMETER; 821 break; 822 } 823 824 KIRQL OldIrql; 825 /* we need a lock here to avoid concurrency with the set event functionality */ 826 KeAcquireSpinLock(&pDevExt->win.s.MouseEventAccessLock, &OldIrql); 827 pDevExt->win.s.pMouseEvent = (PKEVENT)pvBuf; 828 KeReleaseSpinLock(&pDevExt->win.s.MouseEventAccessLock, OldIrql); 829 830 Status = STATUS_SUCCESS; 831 break; 832 } 833 834 default: 835 break; 836 } 837 838 839 if (fProcessed) 840 { 841 pIrp->IoStatus.Status = Status; 842 pIrp->IoStatus.Information = Info; 843 844 IoCompleteRequest(pIrp, IO_NO_INCREMENT); 845 return Status; 846 } 847 848 return vboxguestwinIOCtl(pDevObj, pIrp); 849 } 850 797 851 798 852 /** … … 879 933 Log(("VBoxGuest::vboxguestwinGuestDpcHandler: pDevExt=0x%p\n", pDevExt)); 880 934 935 /* test & reset the counter */ 936 if (ASMAtomicXchgU32(&pDevExt->u32MousePosChangedSeq, 0)) 937 { 938 Assert(KeGetCurrentIrql() == DISPATCH_LEVEL); 939 /* we need a lock here to avoid concurrency with the set event ioctl handler thread, 940 * i.e. to prevent the event from destroyed while we're using it */ 941 KeAcquireSpinLockAtDpcLevel(&pDevExt->win.s.MouseEventAccessLock); 942 PKEVENT pEvent = pDevExt->win.s.pMouseEvent; 943 if (pEvent) 944 { 945 KeSetEvent(pEvent, 0, FALSE); 946 } 947 KeReleaseSpinLockFromDpcLevel(&pDevExt->win.s.MouseEventAccessLock); 948 } 949 881 950 /* Process the wake-up list we were asked by the scheduling a DPC 882 951 * in vboxguestwinIsrHandler(). */ … … 910 979 Log(("VBoxGuest::vboxguestwinGuestIsrHandler: IRQ was taken! pInterrupt = 0x%p, pDevExt = 0x%p\n", 911 980 pInterrupt, pDevExt)); 912 if ( !RTListIsEmpty(&pDevExt->WakeUpList))981 if (ASMAtomicUoReadU32(&pDevExt->u32MousePosChangedSeq) || !RTListIsEmpty(&pDevExt->WakeUpList)) 913 982 { 914 983 Log(("VBoxGuest::vboxguestwinGuestIsrHandler: Requesting DPC ...\n")); … … 921 990 922 991 /* 923 * Overridden routine for mouse polling events. Not 924 * used at the moment on Windows. 992 * Overridden routine for mouse polling events. 925 993 * 926 994 * @param pDevExt Device extension structure. … … 929 997 { 930 998 NOREF(pDevExt); 999 /* nothing to do here - i.e. since we can not KeSetEvent from ISR level, 1000 * we rely on the pDevExt->u32MousePosChangedSeq to be set to a non-zero value on a mouse event 1001 * and queue the DPC in our ISR routine in that case doing KeSetEvent from the DPC routine */ 931 1002 } 932 1003 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.h
r36060 r37221 116 116 * for handling kernel IOCtls. */ 117 117 PVBOXGUESTSESSION pKernelSession; 118 119 120 KSPIN_LOCK MouseEventAccessLock; 121 /* event to be signalled on mouse event arrival from host */ 122 PKEVENT pMouseEvent; 118 123 } VBOXGUESTDEVEXTWIN, *PVBOXGUESTDEVEXTWIN; 119 124
Note:
See TracChangeset
for help on using the changeset viewer.