ggamma
驱动小牛
驱动小牛
  • 注册日期2007-02-15
  • 最后登录2009-05-26
  • 粉丝0
  • 关注0
  • 积分11分
  • 威望180点
  • 贡献值0点
  • 好评度99点
  • 原创分0分
  • 专家分0分
阅读:3428回复:1

何时PNP管理器调用AddDevice?(《Programming the Microsoft Windows Driver Model》)

楼主#
更多 发布于:2008-04-08 14:40
          《Programming the Microsoft Windows Driver Model》中,第二章第二节〈DriverEntry例程〉中,说:
extern "C"
NTSTATUS
DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
{
DriverObject->DriverUnload = DriverUnload;
DriverObject->DriverExtension->AddDevice = AddDevice;
DriverObject->DriverStartIo = StartIo;
DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;
DriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower;
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = DispatchWmi;
servkey.Buffer = (PWSTR) ExAllocatePool(PagedPool, RegistryPath->Length + sizeof(WCHAR));
if (!servkey.Buffer)
return STATUS_INSUFFICIENT_RESOURCES;
servkey.MaximumLength = RegistryPath->Length + sizeof(WCHAR);
RtlCopyUnicodeString(&servkey, RegistryPath);
return STATUS_SUCCESS;
}

你应当就意到,AddDevice例程是通过DriverExtension被登记的。这样的话,AddDevice势必对于外部不可见。也就是说,PNP管理器不应当见到它。


但,后一节的开关(AddDevice例程)又说:
          在前一节中,我讲述了当WDM驱动程序被第一次装入时如何初始化。通常,一个驱动程序可以被多个设备利用。WDM驱动程序有一个特殊的AddDevice函数,PnP管理器为每个设备实例调用该函数。该函数的原型如下。。。

请问,PNP管理器如何看到AddDevice呢?真是奇怪。

------------------------------------------------------------------------------------------------------

仔细看了书,原来Extension不是自定义的结构,该 问题无效,请管理员DELETE,我删除不了
blimy.liu
驱动牛犊
驱动牛犊
  • 注册日期2008-04-15
  • 最后登录2008-06-03
  • 粉丝0
  • 关注0
  • 积分120分
  • 威望13点
  • 贡献值0点
  • 好评度12点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2008-05-28 09:50
PDRIVER_EXTENSION DriverExtension
Pointer to the driver extension. The only accessible member of the driver extension is DriverExtension->AddDevice, into which a driver's DriverEntry routine stores the driver's AddDevice routine.


唯一可见的...
驱网无线,快乐无限
游客

返回顶部