當由插入程式處理的資料流停止時,如果插入程式驅動程式先前已將上下文與資料流相關聯,篩選引擎會呼叫插入程式的 flowDeleteFn 插入程式函式。 回呼的 flowDeleteFn 回呼函式會在數據流停止之前執行與數據流相關聯的驅動程式必要的清理工作。
例如:
// Context structure to be associated with data flows
typedef struct FLOW_CONTEXT_ {
...
} FLOW_CONTEXT, *PFLOW_CONTEXT;
#define FLOW_CONTEXT_POOL_TAG 'fcpt'
// flowDeleteFn callout function
VOID NTAPI
FlowDeleteFn(
IN UINT16 layerId,
IN UINT32 calloutId,
IN UINT64 flowContext
)
{
PFLOW_CONTEXT context;
// Get the flow context structure
context = (PFLOW_CONTEXT)flowContext;
// Cleanup the flow context structure
...
// Free the memory for the flow context structure
ExFreePoolWithTag(
context,
FLOW_CONTEXT_POOL_TAG
);
}
篩選引擎會在資料流停止時,自動移除與資料流相關聯的註釋。 因此,不需要 callout,即可從 flowDeleteFn 呼叫函式呼叫 FwpsFlowRemoveContext0 函式,以從數據流中移除上下文。