阅读:1620回复:2
IRP首部FileObject中的FileName域是用来做什么的?
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是做什么的,何时添加,如何使用? |
|
沙发#
发布于:2002-04-16 16:18
用户被禁言,该主题自动屏蔽! |
|
板凳#
发布于: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; } |
|