Condividi tramite


Registrazione dei callout con il motore di filtro

Dopo che un driver callout ha creato un oggetto dispositivo, può quindi registrare i propri callout con il motore di filtraggio. Un driver di callout può registrare i propri callout con il motore di filtro in qualsiasi momento, anche se il motore di filtro non è attualmente in esecuzione. Per registrare un callout con il motore di filtro, un driver callout chiama la funzione FwpsCalloutRegister0. Per esempio:

// Prototypes for the callout's callout functions
VOID NTAPI
 ClassifyFn(
    IN const FWPS_INCOMING_VALUES0  *inFixedValues,
    IN const FWPS_INCOMING_METADATA_VALUES0  *inMetaValues,
    IN OUT VOID  *layerData,
    IN const FWPS_FILTER0  *filter,
    IN UINT64  flowContext,
    IN OUT FWPS_CLASSIFY_OUT0  *classifyOut
    );

NTSTATUS NTAPI
 NotifyFn(
 IN FWPS_CALLOUT_NOTIFY_TYPE notifyType,
    IN const GUID  *filterKey,
    IN const FWPS_FILTER0  *filter
    );

VOID NTAPI
 FlowDeleteFn(
    IN UINT16  layerId,
    IN UINT32  calloutId,
    IN UINT64  flowContext
    );

// Callout registration structure
const FWPS_CALLOUT0 Callout =
{
 { ... }, // GUID key identifying the callout
  0,       // Callout-specific flags (none set here)
 ClassifyFn,
 NotifyFn,
 FlowDeleteFn
};

// Variable for the run-time callout identifier
UINT32 CalloutId;

NTSTATUS
 DriverEntry(
    IN PDRIVER_OBJECT DriverObject,
    IN PUNICODE_STRING RegistryPath
    )
{
  PDEVICE_OBJECT deviceObject;
  NTSTATUS status;

  ...

 status =
 FwpsCalloutRegister0(
 deviceObject,
      &Callout,
      &CalloutId
      );

  ...

 return status;
}

Se la chiamata alla funzioneFwpsCalloutRegister0ha esito positivo, la variabile a cui punta l'ultimo parametro contiene l'identificatore di runtime per il callout. Questo identificatore di runtime corrisponde al GUID specificato per la chiave di callout.

Un singolo driver callout può implementare più callout. Se un driver callout implementa più callout, invoca la funzione FwpsCalloutRegister0 una volta per ciascun callout supportato per registrare ogni callout con il motore di filtro.

classifyFn