博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CM_RESOURCE_LIST structure 分类: wind...
阅读量:5024 次
发布时间:2019-06-12

本文共 4635 字,大约阅读时间需要 15 分钟。

The CM_RESOURCE_LIST structure specifies all of the system hardware resources assigned to a device.

Syntax

C++
typedef struct _CM_RESOURCE_LIST {  ULONG                       Count;  CM_FULL_RESOURCE_DESCRIPTOR List[1];} CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;

Members

Count

The number of full resource descriptors that are specified by this CM_RESOURCE_LIST structure. The List member is the header for the first full resource descriptor. For WDM drivers, Count is always 1.

List

The structure that serves as the header for the first full resource descriptor. If the CM_RESOURCE_LIST structure contains more than one full resource descriptor, the second full resource descriptor immediately follows the first in memory, and so on. The size of each full resource descriptor depends on the length of the array that it contains. For more information, see the following Remarks section.

Remarks

This structure describes the assignment of hardware resources to a device. An IRP uses this structure to specify the resources that the Plug and Play manager assigns to a device. Drivers for legacy devices use this structure to pass their resource requirements to the routine. For more information about hardware resource allocation, see .

The CM_RESOURCE_LIST structure is a header for a larger data structure, of variable size, that contains one or more full resource descriptors. All of the data in this larger structure occupies a contiguous block of memory. Each full resource descriptor occupies a subblock within the larger block.

A full resource descriptor begins with a structure, which serves as a header for an array of structures. The length of this array determines the size of the full resource descriptor. The last member in the CM_FULL_RESOURCE_DESCRIPTOR structure is a structure that contains, as its last member, the first element in this array. If the array contains more than one element, the remaining elements immediately follow, in memory, the end of the CM_PARTIAL_RESOURCE_LIST structure, which is also the end of the CM_FULL_RESOURCE_DESCRIPTOR structure.

Driver code can use pointer arithmetic to step from one full resource descriptor to the next. For example, if a parameter named list is a pointer to the CM_FULL_RESOURCE_DESCRIPTOR structure at the start of one full resource descriptor, list can be updated to point to the start of the next full resource descriptor as follows:

list = (PCM_FULL_RESOURCE_DESCRIPTOR)(list->PartialResourceList.PartialDescriptors +                                          list->PartialResourceList.Count);

In this example, list->PartialResourceList.PartialDescriptors is a pointer to the start of the CM_PARTIAL_RESOURCE_DESCRIPTOR array, and list->PartialResourceList.Count is the number of elements in the array. For more information about the PartialDescriptors and Count members, see .

Examples

All PnP drivers must handle IRPs. Typically, a driver's handler for this IRP walks the lists of assigned resources that are pointed to by the Parameters.StartDevice.AllocatedResources and Parameters.StartDevice.AllocatedResourcesTranslated members of the structure in the IRP. The following code example contains a function—named GetAssignedResources—that is called in the handler to walk each list. This function verifies that the required resources are specified in the list, and configures the device to use the resources.

The GetAssignedResources function returns TRUE if it succeeds. Otherwise, it returns FALSE (probably from the switch statement, although the details are omitted to simplify the code example).

/* Process the assigned hardware resources. */BOOLEAN GetAssignedResources(PCM_RESOURCE_LIST reslist){    PCM_FULL_RESOURCE_DESCRIPTOR list;    list = reslist->List;    for (int ix = 0; ix < reslist->Count; ++ix)    {        /* Process resources in CM_FULL_RESOURCE_DESCRIPTOR block number ix. */        for (int jx = 0; jx < list->PartialResourceList.Count; ++jx)        {            PCM_PARTIAL_RESOURCE_DESCRIPTOR desc;            desc = list->PartialResourceList.PartialDescriptors + jx;            switch (desc->Type)            {                /* Process element jx in PartialDescriptors array. */                ...            }        }        /* Advance to next CM_FULL_RESOURCE_DESCRIPTOR block in memory. */        list = (PCM_FULL_RESOURCE_DESCRIPTOR)(list->PartialResourceList.PartialDescriptors +                                               list->PartialResourceList.Count);    }    return TRUE;}

Requirements

Header

Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)

See also

版权声明:本文为博主原创文章,未经博主允许不得转载。

转载于:https://www.cnblogs.com/mao0504/p/4706878.html

你可能感兴趣的文章
版本更新
查看>>
SQL 单引号转义
查看>>
start
查看>>
实现手机扫描二维码页面登录,类似web微信-第三篇,手机客户端
查看>>
PHP socket客户端长连接
查看>>
7、shell函数
查看>>
【转】Apache Jmeter发送post请求
查看>>
Nginx 基本 安装..
查看>>
【凸优化】保留凸性的几个方式(交集、仿射变换、投影、线性分式变换)
查看>>
NYOJ-613//HDU-1176-免费馅饼,数字三角形的兄弟~~
查看>>
TFS --- GrantBackup Plan Permissions Error
查看>>
傅里叶级数与积分方程
查看>>
软工作业3:用户体验分析——以“南通大学教务管理系统微信公众号”为例
查看>>
Css:背景色透明,内容不透明之终极方法!兼容所有浏览器
查看>>
我们前端跟后端是怎么合作的
查看>>
mysql存储过程
查看>>
洛谷P2556 [AHOI2002] 黑白图像压缩 [模拟]
查看>>
letecode [136] - Single Number
查看>>
linux下设置固定IP的方法
查看>>
VMware虚拟机下Linux系统的全屏显示
查看>>