NdisAllocateSharedMemory function (ndis.h)

The NdisAllocateSharedMemory function allocates shared memory from a shared memory provider.

Syntax

NDIS_STATUS NdisAllocateSharedMemory(
  [in]      NDIS_HANDLE                    NdisHandle,
  [in]      PNDIS_SHARED_MEMORY_PARAMETERS SharedMemoryParameters,
  [in, out] PNDIS_HANDLE                   pAllocationHandle
);

Parameters

[in] NdisHandle

An NDIS driver or instance handle that was obtained during caller initialization. For example, a miniport driver can use the NDIS handle that it obtained from the NdisMRegisterMiniportDriver or MiniportInitializeEx function. Other NDIS drivers can use the handles from the following functions:

NdisRegisterProtocolDriver

NdisOpenAdapterEx

[in] SharedMemoryParameters

A pointer to an NDIS_SHARED_MEMORY_PARAMETERS structure that defines the requested attributes for the shared memory.

[in, out] pAllocationHandle

A pointer to a location for a handle that identifies the shared memory that was allocated. The handle is available when the function returns or it is NULL if the function fails. The caller must use this handle to free the shared memory that was allocated successfully.

Return value

NdisAllocateSharedMemory can return the following status values:

Return code Description
NDIS_STATUS_SUCCESS
The operation completed successfully.
NDIS_STATUS_RESOURCES
The operation failed because there were insufficient resources to complete the operation.
NDIS_STATUS_INVALID_PARAMETER
The operation failed because of an invalid input parameter.
NDIS_STATUS_FAILURE
The operation failed for unspecified reasons.

Remarks

Note  A miniport driver must have already called NdisMRegisterScatterGatherDma or NdisMRegisterDmaChannel to initialize a scatter/gather DMA channel before calling NdisAllocateSharedMemory.
 
NDIS drivers call the NdisAllocateSharedMemory function to allocate a block of shared memory from an NDIS shared memory provider.

The SharedMemoryParameters parameter contains a pointer to an NDIS_SHARED_MEMORY_PARAMETERS structure that defines the requested attributes for the shared memory. If the NDIS_SHARED_MEM_PARAMETERS_CONTIGUOUS flag is not set in the Flags member, shared memory can be specified in a scatter-gather list that is contained in non-contiguous memory.

NDIS calls the NetAllocateSharedMemory function of a shared memory provider from the context of the call to NdisAllocateSharedMemory.

The driver must call the NdisFreeSharedMemory function to free the shared memory that it allocates with NdisAllocateSharedMemory.

Requirements

Requirement Value
Minimum supported client Supported in NDIS 6.20 and later.
Target Platform Universal
Header ndis.h (include Ndis.h)
Library Ndis.lib
IRQL PASSIVE_LEVEL

See also

FilterAttach

MiniportInitializeEx

NDIS_SHARED_MEMORY_PARAMETERS

NdisFRegisterFilterDriver

NdisFreeSharedMemory

NdisMRegisterDmaChannel

NdisMRegisterMiniportDriver

NdisMRegisterScatterGatherDma

NdisOpenAdapterEx

NdisRegisterProtocolDriver

NetAllocateSharedMemory