即插即用的INF问题(使用IoRegisterPlugPlayNotification)
|
您好想使用IoRegisterPlugPlayNotification通知新的USB获取插件!我的代码不起作用(我没有得到通知)
可以在DriverEntry中使用IoRegisterPlugPlayNotification?
没有使用Adddevice我可以得到通知吗?
我必须使用INF文件来获得通知吗?为什么呢?
我必须使用什么GUID?在代码和INF文件中?
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
{
NTSTATUS status;
int i;
//{a5dcbf10-6530-11d2-901f-00c04fb951ed}
DriverObject->DriverUnload=usblockerUnload;
for (i=0;i<IRP_MJ_MAXIMUM_FUNCTION;i++)
DriverObject->MajorFunction[i] = Driver_PNP;
DriverObject->MajorFunction[IRP_MJ_PNP] = Driver_PNP;
status=IoRegisterPlugPlayNotification( EventCategoryDeviceInterfaceChange,
PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES,
(PVOID)&GUID_CLASS_USB_DEVICE,
DriverObject,
(PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)PnpNotifyInterfaceChange,
(PVOID)DriverObject,
&NotificationHandle);
if(!NT_SUCCESS(status))
{
DbgPrint(\"error in IoRegisterPlugPlayNotification \\n\");
return status;
}
DbgPrint(\" Driver Entry oK *** \\n\");
return STATUS_SUCCESS;
}
void usblockerUnload(IN PDRIVER_OBJECT DriverObject)
{
NTSTATUS status;
DbgPrint(\" Unload \\r\");
status=IoUnregisterPlugPlayNotification(NotificationHandle);
if(!NT_SUCCESS(status))
{
DbgPrint(\"error in IoUnregisterPlugPlayNotification \\n\");
}
}
#pragma PAGEDCODE
NTSTATUS PnpNotifyInterfaceChange( PVOID pNotifyContext, PVOID pContext )
{
PDEVICE_INTERFACE_CHANGE_NOTIFICATION pNotifyData = (PDEVICE_INTERFACE_CHANGE_NOTIFICATION)pNotifyContext;
DbgPrint(\"symbolic name: %wZ\\n\", pNotifyData->SymbolicLinkName);
return STATUS_SUCCESS;
}
没有找到相关结果
已邀请:
1 个回复
械怒等