VOID MouFilter_ServiceCallback( IN PDEVICE_OBJECT DeviceObject, IN PMOUSE_INPUT_DATA InputDataStart, IN PMOUSE_INPUT_DATA InputDataEnd, IN OUT PULONG InputDataConsumed ) /*++ Routine Description: Called when there are mouse packets to report to the RIT. You can do anything you like to the packets. For instance: o Drop a packet altogether o Mutate the contents of a packet o Insert packets into the stream Arguments: DeviceObject - Context passed during the connect IOCTL InputDataStart - First packet to be reported InputDataEnd - One past the last packet to be reported. Total number of packets is equal to InputDataEnd - InputDataStart InputDataConsumed - Set to the total number of packets consumed by the RIT (via the function pointer we replaced in the connect IOCTL) Return Value: Status is returned. --*/ { PDEVICE_EXTENSION devExt; WDFDEVICE hDevice; hDevice = WdfWdmDeviceGetWdfDeviceHandle(DeviceObject); devExt = FilterGetData(hDevice); // // UpperConnectData must be called at DISPATCH // (*(PSERVICE_CALLBACK_ROUTINE) devExt->UpperConnectData.ClassService)( devExt->UpperConnectData.ClassDeviceObject, InputDataStart, InputDataEnd, InputDataConsumed ); }
void MouseTrapServiceCallback(DEVICE_OBJECT* deviceObject, MOUSE_INPUT_DATA* inputDataStart, MOUSE_INPUT_DATA* inputDataEnd, ULONG* inputDataConsumed) { // Get context data WDFDEVICE hDevice = WdfWdmDeviceGetWdfDeviceHandle(deviceObject); PDEVICE_CONTEXT context = DeviceGetContext(hDevice); // Invert all scroll actions for(PMOUSE_INPUT_DATA current = inputDataStart; current != inputDataEnd; current++) { if(current->ButtonFlags & MOUSE_WHEEL) { short value = (short)current->ButtonData; current->ButtonData = (USHORT)(-value); } } // Call parent #pragma warning(push) #pragma warning(disable:4055) (*(PSERVICE_CALLBACK_ROUTINE)context->UpperConnectData.ClassService)(context->UpperConnectData.ClassDeviceObject, inputDataStart, inputDataEnd, inputDataConsumed); #pragma warning(pop) }
VOID CBUpdateCardState( PSMARTCARD_EXTENSION SmartcardExtension, UCHAR IccState, BOOLEAN SystemWakeUp ) { ULONG oldState; NTSTATUS status; KIRQL irql; WDFREQUEST request; PDEVICE_EXTENSION DeviceExtension; KeAcquireSpinLock( &SmartcardExtension->OsData->SpinLock, &irql ); SmartcardDebug( DEBUG_TRACE, ( "PSCR!CBUpdateCardState: Enter \n" ) ); oldState = (SmartcardExtension->ReaderCapabilities.CurrentState > SCARD_ABSENT ? SCARD_PRESENT : SCARD_ABSENT); SmartcardExtension->ReaderCapabilities.CurrentState = (IccState == PSCR_ICC_PRESENT ? SCARD_PRESENT : SCARD_ABSENT); SmartcardDebug( DEBUG_DRIVER, ( "PSCR!CBUpdateCardState: Smart card %s\n", IccState == PSCR_ICC_PRESENT ? "inserted" : "removed") ); if ( SmartcardExtension->OsData->NotificationIrp != NULL && (SystemWakeUp && (oldState == SCARD_PRESENT || SmartcardExtension->ReaderCapabilities.CurrentState == SCARD_PRESENT) || SmartcardExtension->ReaderCapabilities.CurrentState != oldState)) { PIRP notificationIrp ; notificationIrp = InterlockedExchangePointer( &(SmartcardExtension->OsData->NotificationIrp), NULL ); DeviceExtension = GetDeviceExtension(WdfWdmDeviceGetWdfDeviceHandle(SmartcardExtension->OsData->DeviceObject)); KeReleaseSpinLock( &SmartcardExtension->OsData->SpinLock, irql ); status = WdfIoQueueRetrieveNextRequest( DeviceExtension->NotificationQueue, &request); if (NT_SUCCESS(status)) { SmartcardDebug( DEBUG_DRIVER, ( "PSCR!CBUpdateCardState: Completing Irp %p\n", notificationIrp) ); WdfRequestCompleteWithInformation(request, status, 0); } else { NT_ASSERTMSG("WdfIoQueueRetrieveNextRequest failed", status == STATUS_NO_MORE_ENTRIES); } } else { KeReleaseSpinLock( &SmartcardExtension->OsData->SpinLock, irql ); } SmartcardDebug( DEBUG_TRACE, ( "PSCR!CBUpdateCardState: Exit \n" ) ); }