Implemented timer

This commit is contained in:
Benjamin Höglinger
2018-05-13 21:43:25 +02:00
parent 299f9b6d5c
commit d16f9f5832
3 changed files with 40 additions and 0 deletions

View File

@@ -143,6 +143,11 @@ typedef struct _FDO_DEVICE_DATA
//
WDFSPINLOCK PendingPluginRequestsLock;
//
// Periodic timer sweeping up orphaned requests
//
WDFTIMER PendingPluginRequestsCleanupTimer;
} FDO_DEVICE_DATA, *PFDO_DEVICE_DATA;
#define FDO_FIRST_SESSION_ID 100

View File

@@ -93,9 +93,11 @@ NTSTATUS Bus_EvtDeviceAdd(IN WDFDRIVER Driver, IN PWDFDEVICE_INIT DeviceInit)
WDF_OBJECT_ATTRIBUTES fdoAttributes;
WDF_OBJECT_ATTRIBUTES fileHandleAttributes;
WDF_OBJECT_ATTRIBUTES collectionAttributes;
WDF_OBJECT_ATTRIBUTES timerAttributes;
PFDO_DEVICE_DATA pFDOData;
VIGEM_BUS_INTERFACE busInterface;
PINTERFACE interfaceHeader;
WDF_TIMER_CONFIG reqTimerCfg;
UNREFERENCED_PARAMETER(Driver);
@@ -188,6 +190,25 @@ NTSTATUS Bus_EvtDeviceAdd(IN WDFDRIVER Driver, IN PWDFDEVICE_INIT DeviceInit)
#pragma endregion
#pragma region Create timer for sweeping up orphaned requests
WDF_TIMER_CONFIG_INIT_PERIODIC(&reqTimerCfg, Bus_PlugInRequestCleanUpEvtTimerFunc, 500);
WDF_OBJECT_ATTRIBUTES_INIT(&timerAttributes);
timerAttributes.ParentObject = device;
status = WdfTimerCreate(&reqTimerCfg, &timerAttributes, &pFDOData->PendingPluginRequestsCleanupTimer);
if (!NT_SUCCESS(status)) {
TraceEvents(TRACE_LEVEL_ERROR,
TRACE_DRIVER,
"WdfTimerCreate failed with status %!STATUS!",
status);
return status;
}
WdfTimerStart(pFDOData->PendingPluginRequestsCleanupTimer, WDF_REL_TIMEOUT_IN_SEC(1));
#pragma endregion
#pragma region Add query interface
//
@@ -559,3 +580,15 @@ Bus_PdoStageResult(
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit");
}
_Use_decl_annotations_
VOID
Bus_PlugInRequestCleanUpEvtTimerFunc(
WDFTIMER Timer
)
{
UNREFERENCED_PARAMETER(Timer);
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
}

View File

@@ -102,6 +102,8 @@ EVT_WDF_TIMER Xgip_SysInitTimerFunc;
EVT_WDF_OBJECT_CONTEXT_CLEANUP Bus_EvtDriverContextCleanup;
EVT_WDF_TIMER Bus_PlugInRequestCleanUpEvtTimerFunc;
#pragma endregion
#pragma region Bus enumeration-specific functions