阅读:751回复:1
CacheControlRequest代码分析
谁能帮我分析这断代码? 刚开始写Driver的。 10分
NTSTATUS CacheControlRequest(PDEVICE_EXTENSION pdx, PIRP Irp, PIRP* pIrp) { ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); KIRQL oldirql; KeAcquireSpinLock(&pdx->IoctlListLock, &oldirql); NTSTATUS status; if (*pIrp) { status = STATUS_UNSUCCESSFUL; // Something already cached here } else if (pdx->IoctlAbortStatus) { status = pdx->IoctlAbortStatus; // Rejecting new IRPs for some reason } else { // Try to cache IRP IoSetCancelRoutine(Irp, OnCancelPendingIoctl); if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL)) { status = STATUS_CANCELLED; // Already cancelled } else { // If to cache it IoMarkIrpPending(Irp); status = STATUS_PENDING; PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp); stack->Parameters.Others.Argument1 = (PVOID) pIrp; IoSetCompletionRoutine(Irp, (PIO_COMPLETION_ROUTINE) OnCompletePendingIoctl, (PVOID) pdx, TRUE, TRUE, TRUE); IoSetNextIrpStackLocation(Irp); // So our completion routine will get called PFILE_OBJECT fop = stack->FileObject; stack = IoGetCurrentIrpStackLocation(Irp); stack->DeviceObject = pdx->DeviceObject; // So IoCancelIrp can give us right ptr stack->FileObject = fop; // For cleanup *pIrp = Irp; InsertTailList(&pdx->PendingIoctlList, &Irp->Tail.Overlay.ListEntry); } } KeReleaseSpinLock(&pdx->IoctlListLock, oldirql); return status; } |
|
沙发#
发布于:2004-07-09 11:47
分析个什么?????????????????????????
|
|
|