Bewerken

Delen via


WdfCmResourceListInsertDescriptor function (wdfresource.h)

[Applies to KMDF only]

The WdfCmResourceListInsertDescriptor method inserts a resource descriptor into a specified resource list.

Syntax

NTSTATUS WdfCmResourceListInsertDescriptor(
  [in] WDFCMRESLIST                    List,
  [in] PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor,
  [in] ULONG                           Index
);

Parameters

[in] List

A handle to a framework resource-list object that represents a list of hardware resources for a device.

[in] Descriptor

A pointer to an CM_PARTIAL_RESOURCE_DESCRIPTOR structure that describes a hardware resource.

[in] Index

A zero-based value that is used as an index into the logical configuration that List specifies. To add a resource descriptor to the end of the resource list, specify WDF_INSERT_AT_END or the return value from WdfCmResourceListGetCount.

Return value

WdfCmResourceListInsertDescriptor returns STATUS_SUCCESS if the operation succeeds. Otherwise, this method might return one of the following values:

Return code Description
STATUS_INVALID_PARAMETER
An invalid parameter was specified.
STATUS_ACCESS_DENIED
The driver was not allowed to add descriptors to the logical configuration that the List parameter specified. For example, the driver could not modify the logical configuration that its EvtDevicePrepareHardware or EvtDeviceReleaseHardware callback function received.
STATUS_INSUFFICIENT_RESOURCES
The framework could not allocate space to store the descriptor that the Descriptor parameter points to.
STATUS_ARRAY_BOUNDS_EXCEEDED
The value that the Index parameter specified was too large.
 

A system bug check occurs if the driver supplies an invalid object handle.

Remarks

The WdfCmResourceListInsertDescriptor method inserts the resource descriptor that Descriptor specifies into the resource list that List specifies, in front of the resource descriptor that Index value identifies.

To add a resource descriptor to the end of a resource list, specify WDF_INSERT_AT_END or the return value from WdfCmResourceListGetCount as the Index value. Alternatively, use the WdfCmResourceListAppendDescriptor method.

The framework copies the contents of the CM_PARTIAL_RESOURCE_DESCRIPTOR structure into internal storage, so the driver routine that calls WdfCmResourceListInsertDescriptor can allocate the structure locally. After the driver calls WdfCmResourceListInsertDescriptor, it can reuse the CM_PARTIAL_RESOURCE_DESCRIPTOR structure.

For more information about resource lists, see Hardware Resources for Framework-Based Drivers.

Examples

The following code example adds a resource descriptor to the end of the resource list that an EvtDeviceResourcesQuery callback function receives.

NTSTATUS
PdoEvtDeviceResourcesQuery(
    IN WDFDEVICE  Device,
    IN WDFCMRESLIST  Resources
    )
{
    CM_PARTIAL_RESOURCE_DESCRIPTOR newDescriptor;
...
    newDescriptor.Type = CmResourceTypePort;
    newDescriptor.ShareDisposition = CmResourceShareDeviceExclusive;
    newDescriptor.Flags = CM_RESOURCE_PORT_IO|CM_RESOURCE_PORT_16_BIT_DECODE;
    newDescriptor.u.Port.Length = 1;
    newDescriptor.u.Port.Start = 0;

    status = WdfCmResourceListInsertDescriptor(
                                               Resources,
                                               &newDescriptor,
                                               WDF_INSERT_AT_END
                                               );
...

}

Requirements

Requirement Value
Target Platform Universal
Minimum KMDF version 1.0
Header wdfresource.h (include Wdf.h)
Library Wdf01000.sys (see Framework Library Versioning.)
IRQL <=DISPATCH_LEVEL
DDI compliance rules DriverCreate(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf)

See also

CM_PARTIAL_RESOURCE_DESCRIPTOR

EvtDevicePrepareHardware

EvtDeviceReleaseHardware

EvtDeviceResourcesQuery

WdfCmResourceListAppendDescriptor