阅读:3428回复:1
何时PNP管理器调用AddDevice?(《Programming the Microsoft Windows Driver Model》)
《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,我删除不了 |
|
沙发#
发布于: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. 唯一可见的... |
|
|