看雪论坛
发新帖

[求助]关于卷挂载

kisaLee 2017-6-27 20:33 703

在挂载设备时,向"\\Device\\MountPointManager" 发送  IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION 和 IOCTL_MOUNTMGR_CREATE_POINT 控制码 IoCallDriver 返回STATUS_INVALID_DEVICE_REQUEST 
请指教···· 谢谢大家了

ntUnicodeString =  \\device\\demo
	ntStatus = IoCreateDevice(
		DriverObject,
		sizeof(uint8_t),
		&ntUnicodeString,
		FILE_DEVICE_UNKNOWN,
		FILE_DEVICE_SECURE_OPEN,
		/*TRUE*/FALSE,
		&DeviceObject);
设备和符号创建成功
IoControlCode = IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION
deviceName = MOUNTMGR_DEVICE_NAME
PMOUNTMGR_TARGET_NAME InputBuffer= (PMOUNTMGR_TARGET_NAME)buf
InputBuffer.DeviceName = \\device\\demo
IO_STATUS_BLOCK ioStatusBlock = { 0 };
	NTSTATUS ntStatus = STATUS_SUCCESS;
	PIRP irp = NULL;
	PFILE_OBJECT fileObject = NULL;
	PDEVICE_OBJECT deviceObject = NULL;
	KEVENT event = { 0 };
	UNICODE_STRING name = { 0 };
	RtlInitUnicodeString(&name, deviceName);
	ntStatus = IoGetDeviceObjectPointer(&name, FILE_READ_ATTRIBUTES, &fileObject, &deviceObject);
	if (!NT_SUCCESS(ntStatus))
		return ntStatus;
	KeInitializeEvent(&event, NotificationEvent, FALSE);
	irp = IoBuildDeviceIoControlRequest(IoControlCode,
		deviceObject,
		InputBuffer, InputBufferSize,
		OutputBuffer, OutputBufferSize,
		FALSE,
		&event,
		&ioStatusBlock);
	if (irp == NULL)
	{
		Dump("IRP allocation failed\n");
		ntStatus = STATUS_INSUFFICIENT_RESOURCES;
		goto ret;
	}
	IoGetNextIrpStackLocation(irp)->FileObject = fileObject;
	ntStatus = IoCallDriver(deviceObject, irp);// 返回值为STATUS_INVALID_DEVICE_REQUEST 搞不懂?
	if (ntStatus == STATUS_PENDING)
	{
		KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
		ntStatus = ioStatusBlock.Status;
	}
ret:
	ObDereferenceObject(fileObject);
	return ntStatus;

本主题帖已收到 0 次赞赏,累计¥0.00
最新回复 (0)
返回



©2000-2017 看雪学院 | Based on Xiuno BBS | 微信公众号:ikanxue
Time: 0.011, SQL: 8 / 京ICP备10040895号-17