NPI_PROVIDER_ATTACH_CLIENT_FN callback function

A provider module's ProviderAttachClient callback function attaches the provider module to a client module.

Syntax

NPI_PROVIDER_ATTACH_CLIENT_FN NpiProviderAttachClientFn;

NTSTATUS NpiProviderAttachClientFn(
  HANDLE NmrBindingHandle,
  PVOID ProviderContext,
  PNPI_REGISTRATION_INSTANCE ClientRegistrationInstance,
  PVOID ClientBindingContext,
  const VOID *ClientDispatch,
  PVOID *ProviderBindingContext,
  const VOID **ProviderDispatch
)
{...}

Parameters

NmrBindingHandle

A handle used by the NMR to represent the binding between the client module and the provider module.

ProviderContext

A pointer to the provider module's registration context. The provider module passes this pointer to the NMR when it calls the NmrRegisterProvider function to register itself with the NMR.

ClientRegistrationInstance

A pointer to an NPI_REGISTRATION_INSTANCE structure. This structure contains the client module's registration data.

ClientBindingContext

A pointer to the client module's context for the binding between the client module and the provider module. The client module uses this context to keep track of the state of the binding. The contents of the client module's binding context are opaque to the provider module. The provider module passes this pointer to the client module whenever it calls any of the client module's NPI callback functions that require the client module's binding context.

ClientDispatch

ProviderBindingContext

*ProviderDispatch

Return Value

A provider module's ProviderAttachClient callback function returns one of the following NTSTATUS codes:

Return code Description
STATUS_SUCCESS
The provider module successfully attached to the client module.
STATUS_NOINTERFACE
The provider module did not attach to the client module.
Other status codes
An error occurred.

Remarks

The NMR calls a provider module's ProviderAttachClient callback function whenever a client module calls the NmrClientAttachProvider function with a handle that represents a binding between the client module and the provider module.

A provider module can examine the client module's registration data. This data is in the structure pointed to by the ClientRegistrationInstance parameter. The provider module uses this data to determine whether it will attach to the client module:

  • If the provider module determines that it will attach to the client module, then the ProviderAttachClient callback function must do the following:
    1. Save the pointers passed in the ClientBindingContext and ClientDispatch parameters so that the provider module can make calls to the client module's NPI functions.
    2. Save the handle passed in the NmrBindingHandle parameter. The provider module passes this handle as a parameter to the NmrProviderDetachClientComplete function when it detaches from the client module.
    3. Set the ProviderBindingContext parameter to point to the provider module's binding context structure for the binding between the client module and the provider module.
    4. Set the ProviderDispatch parameter to point to a structure that contains the provider module's dispatch table of NPI functions.
    5. Return STATUS_SUCCESS.
  • If the provider module determines that it will not attach to the client module, then the ProviderAttachClient callback function must return STATUS_NOINTERFACE.
If the provider module attaches to the client module and it dynamically allocated memory for its binding context, it should free that allocated memory when the NMR calls the provider module's ProviderCleanupBindingContext callback function after the client module and provider module are detached from each other.

The NMR calls a provider module's ProviderAttachClient callback function at IRQL = PASSIVE_LEVEL.

Requirements

   
Minimum supported client Available in Windows Vista and later versions of the Windows operating systems.
Target Platform Windows
Header netioddk.h (include Wsk.h)
IRQL PASSIVE_LEVEL

See Also

NPI_PROVIDER_CHARACTERISTICS

NPI_REGISTRATION_INSTANCE

NmrClientAttachProvider

NmrProviderDetachClientComplete

NmrRegisterProvider

ProviderCleanupBindingContext

ProviderDetachClient