Kernel+中驱动挂载

IoGetDeviceObjectPointer
IoAttachDeviceToDeviceStack
IoDetachDevice


UNICODE_STRING DeviceName;
RtlInitUnicodeString(&DeviceName, L"\\Device\\MyDDKA");
PDEVICE_OBJECT DeviceObject = NULL;
PFILE_OBJECT FileObject = NULL;
status = IoGetDeviceObjectPointer(&DeviceName,FILE_ALL_ACCESS, &FileObject, &DeviceObject);

    PDEVICE_OBJECT TargetDevice = IoAttachDeviceToDeviceStack(
                    FilterDeviceObject,DeviceObject);
    pDevExt->TargetDevice = TargetDevice;
    if (!TargetDevice)
    {
        ObDereferenceObject(FileObject);
        IoDeleteDevice(FilterDeviceObject);
        KdPrint(("IoAttachDeviceToDeviceStack() error\n"));
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    FilterDeviceObject->DeviceType = TargetDevice->DeviceType;
    FilterDeviceObject->Characteristics = TargetDevice->Characteristics;
    FilterDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
    FilterDeviceObject->Flags |= (TargetDevice->Flags &(DO_BUFFERED_IO |
                                                        DO_DIRECT_IO));
    ObDereferenceObject(FileObject);

//调用下一层设备
    PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION)
        pDevObj->DeviceExtension;
    IoSkipCurrentIrpStackLocation(pIrp);
   IoCallDriver(pdx->TargetDevice, pIrp);



阅读更多
想对作者说点什么? 我来说一句

安卓uvc的driver

2014年12月11日 64KB 下载

Ext2IFS windows

2010年08月07日 1.39MB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭