yy1125322
驱动牛犊
驱动牛犊
  • 注册日期2002-03-06
  • 最后登录2004-10-13
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1620回复:2

IRP首部FileObject中的FileName域是用来做什么的?

楼主#
更多 发布于:2002-04-13 21:43
HANDLE pDevicefile = CreateFile( ifDetail->DevicePath,  
      GENERIC_READ | GENERIC_WRITE,
      FILE_SHARE_READ | FILE_SHARE_WRITE,
      NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
CreateFile创建设备后,Win32例程访问。不知道,这个FileName是做什么的,何时添加,如何使用?
Tom.Cat
禁止发言
禁止发言
  • 注册日期2001-10-10
  • 最后登录2019-07-29
  • 粉丝1
  • 关注0
  • 积分-53792分
  • 威望197411点
  • 贡献值0点
  • 好评度5点
  • 原创分0分
  • 专家分0分
  • 社区居民
沙发#
发布于:2002-04-16 16:18
用户被禁言,该主题自动屏蔽!
yy1125322
驱动牛犊
驱动牛犊
  • 注册日期2002-03-06
  • 最后登录2004-10-13
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2002-04-17 21:38
那为什么D12驱动程序中D12_Create用到了这个域,另外,FileObject的FsContext 有什么用,请指教。下面是D12_Create的源码:
NTSTATUS
D12_Create(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    )
/*++
Routine Description:
    // Entry point for CreateFile calls
    // user mode apps may open \"\\\\.\\D12-x\\yy\"
    // where yy is the internal pipe id
    Arguments:
    DeviceObject - pointer to the device object for this instance of the 82930
                    devcice.
Return Value:
    NT status code
--*/
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    PD12_PIPE pipeHandle = NULL;
    PFILE_OBJECT fileObject;
    PIO_STACK_LOCATION irpStack;
    PDEVICE_EXTENSION deviceExtension;
    ULONG i;

    KdPrint ((\"Ocrw.c: 进入例程D12_Create\\n\"));

    D12_IncrementIoCount(DeviceObject);

    deviceExtension = DeviceObject->DeviceExtension;

    if (deviceExtension->AcceptingRequests == FALSE) {
        ntStatus = STATUS_DELETE_PENDING;
        Irp->IoStatus.Status = ntStatus;
        Irp->IoStatus.Information = 0;

        IoCompleteRequest (Irp,
                           IO_NO_INCREMENT
                          );

        D12_DecrementIoCount(DeviceObject);                          
        
        return ntStatus;
    }
    
    irpStack = IoGetCurrentIrpStackLocation (Irp);
    fileObject = irpStack->FileObject;

    // fscontext is null for device
    fileObject->FsContext = NULL;

    if (fileObject->FileName.Length != 0) {

        ntStatus = STATUS_INSUFFICIENT_RESOURCES;

        //
        // a name was specified, convert it to a pipe id
        //

        for (i=0; i<D12_MAX_PIPES; i++) {
            if (RtlCompareMemory (fileObject->FileName.Buffer,
                                  deviceExtension->PipeList.Name,
                                  fileObject->FileName.Length)
                    == fileObject->FileName.Length &&
                !deviceExtension->PipeList.Opened) {
                //
                // found a match
                //
                pipeHandle = &deviceExtension->PipeList;
                //D12_ResetPipe(DeviceObject, pipeHandle);
                break;
            }
        }
    }

// if we are opening a pipe set stuff up and set FsContext
    if (pipeHandle) {
        KdPrint ((\"Ocrw.c: 打开管道: %x\\n\", pipeHandle));
        fileObject->FsContext = pipeHandle;//*****按FILE_OBJECT查询 *******************************
        pipeHandle->Opened = TRUE;
pipeHandle->bPerfTimerEnabled = FALSE;
        ntStatus = STATUS_SUCCESS;
    }

    Irp->IoStatus.Status = ntStatus;
    Irp->IoStatus.Information = 0;

    IoCompleteRequest (Irp,
                       IO_NO_INCREMENT
                       );

    D12_DecrementIoCount(DeviceObject);                              

    KdPrint ((\"Ocrw.c: 结束例程D12_Create %x\\n\", ntStatus));

    return ntStatus;
}
游客

返回顶部