Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

sessnirp.h File Reference

Go to the source code of this file.

Functions

PIOV_SESSION_DATA FASTCALL IovpSessionDataCreate (IN PDEVICE_OBJECT DeviceObject, IN OUT PIOV_REQUEST_PACKET *IovPacketPointer, OUT PBOOLEAN SurrogateSpawned)
VOID FASTCALL IovpSessionDataAdvance (IN PDEVICE_OBJECT DeviceObject, IN PIOV_SESSION_DATA IovSessionData, IN OUT PIOV_REQUEST_PACKET *IovPacketPointer, OUT PBOOLEAN SurrogateSpawned)
VOID FASTCALL IovpSessionDataReference (IN PIOV_SESSION_DATA IovSessionData)
VOID FASTCALL IovpSessionDataDereference (IN PIOV_SESSION_DATA IovSessionData)
VOID FASTCALL IovpSessionDataClose (IN PIOV_SESSION_DATA IovSessionData)
VOID IovpSessionDataDeterminePolicy (IN PIOV_REQUEST_PACKET IovRequestPacket, IN PDEVICE_OBJECT DeviceObject, OUT PBOOLEAN Trackable, OUT PBOOLEAN UseSurrogateIrp)
BOOLEAN FASTCALL IovpSessionDataAttachSurrogate (IN OUT PIOV_REQUEST_PACKET *IovPacketPointer, IN PIOV_SESSION_DATA IovSessionData)
VOID FASTCALL IovpSessionDataFinalizeSurrogate (IN PIOV_SESSION_DATA IovSessionData, IN OUT PIOV_REQUEST_PACKET IovPacket, IN PIRP Irp)


Function Documentation

VOID FASTCALL IovpSessionDataAdvance IN PDEVICE_OBJECT  DeviceObject,
IN PIOV_SESSION_DATA  IovSessionData,
IN OUT PIOV_REQUEST_PACKET IovPacketPointer,
OUT PBOOLEAN  SurrogateSpawned
 

Definition at line 140 of file sessnirp.c.

References FALSE.

Referenced by IovpCallDriver1().

00146 { 00147 *SurrogateSpawned = FALSE; 00148 }

BOOLEAN FASTCALL IovpSessionDataAttachSurrogate IN OUT PIOV_REQUEST_PACKET IovPacketPointer,
IN PIOV_SESSION_DATA  IovSessionData
 

Definition at line 314 of file sessnirp.c.

References _IRP::AllocationFlags, ASSERT, ASSERT_SPINLOCK_HELD, _IOV_REQUEST_PACKET::AssertFlags, _IOV_REQUEST_PACKET::CallerIrql, _IRP::CancelRoutine, _IRP::CurrentLocation, DISPATCH_LEVEL, FALSE, _IRP::Flags, _IO_STACK_LOCATION::Flags, _IOV_REQUEST_PACKET::Flags, _IOV_REQUEST_PACKET::HeadPacket, IO_STACK_LOCATION, IoGetCurrentIrpStackLocation, IoGetNextIrpStackLocation, IopIsMemoryRangeReadable(), _IRP::IoStatus, IOV_REQUEST_PACKET, IovpProtectedIrpAllocate(), IovpProtectedIrpFree(), IovpProtectedIrpMakeUntouchable(), IovpTrackingDataCreateAndLock(), IovpTrackingDataReference(), IOVREFTYPE_POINTER, IRP_DIAG_HAS_SURROGATE, IRP_DIAG_IS_SURROGATE, IRP_MJ_SCSI, IRP_QUOTA_CHARGED, _IOV_REQUEST_PACKET::IrpLock, _IOV_REQUEST_PACKET::LastLocation, _IO_STACK_LOCATION::MajorFunction, NULL, _IO_STACK_LOCATION::Parameters, _IOV_REQUEST_PACKET::pIovSessionData, _IRP::StackCount, _IOV_REQUEST_PACKET::SurrogateLink, _IRP::Tail, _IRP::ThreadListEntry, _IOV_REQUEST_PACKET::TopStackLocation, _IOV_REQUEST_PACKET::TrackedIrp, TRACKFLAG_ACTIVE, TRACKFLAG_HAS_SURROGATE, TRACKFLAG_SRB_MUNGED, TRACKFLAG_SURROGATE, TRUE, _IRP::UserEvent, and _IRP::UserIosb.

Referenced by IovpSessionDataCreate().

00320 : 00321 00322 This routine creates tracking data for a new IRP. It must be called on the 00323 thread the IRP was originally sent down... 00324 00325 Arguments: 00326 00327 IovPacketPointer - Pointer to IRP packet to attach surrogate to. If 00328 a surrogate can be attached the packet will be 00329 updated to track the surrogate. 00330 00331 SurrogateIrp - Prepared surrogate IRP to attach. 00332 00333 Return Value: 00334 00335 iovPacket block, NULL if no memory. 00336 00337 --*/ 00338 { 00339 00340 PIOV_REQUEST_PACKET iovSurrogatePacket, iovPacket, headPacket; 00341 PIRP surrogateIrp, irp; 00342 PIO_STACK_LOCATION irpSp; 00343 PSCSI_REQUEST_BLOCK srb; 00344 PVOID restoreHandle; 00345 CCHAR activeSize; 00346 00347 iovPacket = *IovPacketPointer; 00348 ASSERT_SPINLOCK_HELD(&iovPacket->IrpLock); 00349 ASSERT(!(CONTAINING_RECORD( 00350 iovPacket->SurrogateLink.Flink, 00351 IOV_REQUEST_PACKET, 00352 SurrogateLink)->Flags&TRACKFLAG_SURROGATE 00353 )); 00354 00355 ASSERT(iovPacket->Flags & TRACKFLAG_ACTIVE); 00356 00357 irp = iovPacket->TrackedIrp; 00358 activeSize = (irp->CurrentLocation-1); 00359 ASSERT(activeSize); 00360 00361 // 00362 // We now try to make a copy of this new IRP which we will track. We 00363 // do this so that we may free *every* tracked IRP immediately upon 00364 // completion. 00365 // Technically speaking, we only need to allocate what's left of the 00366 // stack, not the entire thing. But using the entire stack makes our 00367 // work much much easier. Specifically the session stack array may depend 00368 // on this. 00369 // 00370 // ADRIAO BUGBUG 03/04/1999 - Make this work only copying a portion of the 00371 // IRP. 00372 // 00373 surrogateIrp = IovpProtectedIrpAllocate( 00374 irp->StackCount, // activeSize 00375 (BOOLEAN) ((irp->AllocationFlags&IRP_QUOTA_CHARGED) ? TRUE : FALSE), 00376 NULL 00377 ); 00378 00379 if (surrogateIrp == NULL) { 00380 00381 return FALSE; 00382 } 00383 00384 // 00385 // Now set up the new IRP - we do this here so IovpTrackingDataCreateAndLock 00386 // can peek at it's fields. Start with the IRP header. 00387 // 00388 RtlCopyMemory(surrogateIrp, irp, sizeof(IRP)); 00389 00390 // 00391 // Adjust StackCount and CurrentLocation 00392 // 00393 surrogateIrp->StackCount = irp->StackCount; // activeSize 00394 surrogateIrp->Tail.Overlay.CurrentStackLocation = 00395 ((PIO_STACK_LOCATION) (surrogateIrp+1))+activeSize; 00396 00397 // 00398 // Our new IRP "floats", and is not attached to any thread. 00399 // Note that all cancels due to thread death will come through the 00400 // original IRP. 00401 // 00402 InitializeListHead(&surrogateIrp->ThreadListEntry); 00403 00404 // 00405 // Our new IRP also is not connected to user mode. 00406 // 00407 surrogateIrp->UserEvent = NULL; 00408 surrogateIrp->UserIosb = NULL; 00409 00410 // 00411 // Now copy over only the active portions of IRP. Be very careful to not 00412 // assume that the last stack location is right after the end of the IRP, 00413 // as we may change this someday! 00414 // 00415 irpSp = (IoGetCurrentIrpStackLocation(irp)-activeSize); 00416 RtlCopyMemory(surrogateIrp+1, irpSp, sizeof(IO_STACK_LOCATION)*activeSize); 00417 00418 // 00419 // Zero the portion of the new IRP we won't be using (this should 00420 // eventually go away). 00421 // 00422 RtlZeroMemory( 00423 ((PIO_STACK_LOCATION) (surrogateIrp+1))+activeSize, 00424 sizeof(IO_STACK_LOCATION)*(surrogateIrp->StackCount - activeSize) 00425 ); 00426 00427 // 00428 // Now create a surrogate packet to track the new IRP. 00429 // 00430 iovSurrogatePacket = IovpTrackingDataCreateAndLock(surrogateIrp); 00431 if (iovSurrogatePacket == NULL) { 00432 00433 // 00434 // ADRIAO BUGBUG 02/11/1999 - Need to free IRP 00435 // 00436 restoreHandle = IovpProtectedIrpMakeUntouchable(surrogateIrp, TRUE); 00437 IovpProtectedIrpFree(surrogateIrp, restoreHandle); 00438 return FALSE; 00439 } 00440 00441 headPacket = iovPacket->HeadPacket; 00442 00443 ASSERT(iovSurrogatePacket->CallerIrql == DISPATCH_LEVEL); 00444 irpSp = IoGetNextIrpStackLocation(irp); 00445 00446 // 00447 // We will flag this bug later. 00448 // 00449 irp->CancelRoutine = NULL; 00450 00451 // 00452 // Let's take advantage of the original IRP not being the thing partied on 00453 // now; store a pointer to our tracking data in the information field. We 00454 // don't use this, but it's nice when debugging... 00455 // 00456 irp->IoStatus.Information = (ULONG_PTR) iovPacket; 00457 00458 // 00459 // ADRIAO BUGBUG #28 06/10/98 - This is absolutely *gross*, and not 00460 // deterministic enough for my tastes. 00461 // 00462 // For IRP_MJ_SCSI (ie, IRP_MJ_INTERNAL_DEVICE_CONTROL), look and see 00463 // if we have an SRB coming through. If so, fake out the OriginalRequest 00464 // IRP pointer as appropriate. 00465 // 00466 if (irpSp->MajorFunction == IRP_MJ_SCSI) { 00467 srb = irpSp->Parameters.Others.Argument1 ; 00468 if (IopIsMemoryRangeReadable(srb, SCSI_REQUEST_BLOCK_SIZE)) { 00469 if ((srb->Length == SCSI_REQUEST_BLOCK_SIZE)&&(srb->OriginalRequest == irp)) { 00470 srb->OriginalRequest = surrogateIrp ; 00471 headPacket->Flags |= TRACKFLAG_SRB_MUNGED ; 00472 } 00473 } 00474 } 00475 00476 // 00477 // Since the replacement will never make it back to user mode (the real 00478 // IRP shall of course), we will steal a field or two for debugging info. 00479 // 00480 surrogateIrp->UserIosb = (PIO_STATUS_BLOCK) iovPacket ; 00481 00482 // 00483 // Now that everything is built correctly, attach the surrogate. The 00484 // surrogate holds down the packet we are attaching to. When the surrogate 00485 // dies we will remove this reference. 00486 // 00487 IovpTrackingDataReference(iovPacket, IOVREFTYPE_POINTER); 00488 00489 // 00490 // Stamp IRPs appropriately. 00491 // 00492 surrogateIrp->Flags |= IRP_DIAG_IS_SURROGATE; 00493 irp->Flags |= IRP_DIAG_HAS_SURROGATE; 00494 00495 // 00496 // Mark packet as surrogate and inherit appropriate fields from iovPacket. 00497 // 00498 iovSurrogatePacket->Flags |= TRACKFLAG_SURROGATE | TRACKFLAG_ACTIVE; 00499 iovSurrogatePacket->pIovSessionData = iovPacket->pIovSessionData; 00500 iovSurrogatePacket->AssertFlags = iovPacket->AssertFlags; 00501 iovSurrogatePacket->HeadPacket = iovPacket->HeadPacket; 00502 iovSurrogatePacket->LastLocation = iovPacket->LastLocation; 00503 iovSurrogatePacket->TopStackLocation = irp->CurrentLocation; 00504 00505 iovPacket->Flags |= TRACKFLAG_HAS_SURROGATE; 00506 00507 // 00508 // Fix up IRQL's so spinlocks are released in the right order. Link'm. 00509 // 00510 iovSurrogatePacket->CallerIrql = iovPacket->CallerIrql; 00511 iovPacket->CallerIrql = DISPATCH_LEVEL; 00512 InsertTailList( 00513 &iovPacket->HeadPacket->SurrogateLink, 00514 &iovSurrogatePacket->SurrogateLink 00515 ); 00516 00517 *IovPacketPointer = iovSurrogatePacket; 00518 return TRUE; 00519 }

VOID FASTCALL IovpSessionDataClose IN PIOV_SESSION_DATA  IovSessionData  ) 
 

Definition at line 220 of file sessnirp.c.

References ASSERT, ASSERT_SPINLOCK_HELD, _IOV_REQUEST_PACKET::Flags, _IOV_REQUEST_PACKET::HeadPacket, _IOV_REQUEST_PACKET::IrpLock, NULL, _IOV_REQUEST_PACKET::pIovSessionData, and TRACKIRP_DBGPRINT.

Referenced by IovpCompleteRequest2(), and IovpSwapSurrogateIrp().

00223 { 00224 PIOV_REQUEST_PACKET iovPacket = IovSessionData->IovRequestPacket; 00225 00226 ASSERT_SPINLOCK_HELD(&iovPacket->IrpLock); 00227 00228 ASSERT(iovPacket == iovPacket->HeadPacket); 00229 ASSERT(iovPacket->pIovSessionData == IovSessionData); 00230 00231 TRACKIRP_DBGPRINT(( 00232 " SSN CLOSE(%x)\n" 00233 ), 3) ; 00234 00235 iovPacket->Flags &=~ TRACKFLAG_ACTIVE; 00236 iovPacket->pIovSessionData = NULL; 00237 }

PIOV_SESSION_DATA FASTCALL IovpSessionDataCreate IN PDEVICE_OBJECT  DeviceObject,
IN OUT PIOV_REQUEST_PACKET IovPacketPointer,
OUT PBOOLEAN  SurrogateSpawned
 

Definition at line 27 of file sessnirp.c.

References ASSERT, ASSERTFLAG_COMPLETEATPASSIVE, ASSERTFLAG_DEFERCOMPLETION, ASSERTFLAG_FORCEPENDING, _IOV_SESSION_DATA::AssertFlags, _IOV_SESSION_DATA::BestVisibleIrp, _IRP::CurrentLocation, ExAllocatePoolWithTag, FALSE, _IOV_REQUEST_PACKET::Flags, _IOV_REQUEST_PACKET::HeadPacket, IOV_SESSION_DATA, IOV_STACK_LOCATION, IovpSessionDataAttachSurrogate(), IovpSessionDataDeterminePolicy(), IovpTrackingFlags, _IOV_SESSION_DATA::IovRequestPacket, NonPagedPool, NULL, PIOV_REQUEST_PACKET, _IOV_REQUEST_PACKET::pIovSessionData, POOL_TAG_SESSION_DATA, _IOV_REQUEST_PACKET::SessionHead, _IOV_SESSION_DATA::SessionLink, _IRP::StackCount, _IOV_REQUEST_PACKET::TopStackLocation, _IOV_REQUEST_PACKET::TrackedIrp, TRACKFLAG_ACTIVE, TRACKFLAG_PASSED_FAILURE, TRACKFLAG_QUEUED_INTERNALLY, TRACKFLAG_RELEASED, TRACKFLAG_SRB_MUNGED, TRACKFLAG_SWAPPED_BACK, and TRACKIRP_DBGPRINT.

Referenced by IovpCallDriver1().

00034 : 00035 00036 This routine creates tracking data for a new IRP. It must be called on the 00037 thread the IRP was originally sent down... 00038 00039 Arguments: 00040 00041 Irp - Irp to track. 00042 00043 Return Value: 00044 00045 iovPacket block, NULL if no memory. 00046 00047 --*/ 00048 { 00049 PIRP irp, surrogateIrp; 00050 PIOV_SESSION_DATA iovSessionData; 00051 PIOV_REQUEST_PACKET headPacket; 00052 ULONG sessionDataSize; 00053 BOOLEAN trackable, useSurrogateIrp; 00054 00055 *SurrogateSpawned = FALSE; 00056 00057 headPacket = (*IovPacketPointer)->HeadPacket; 00058 ASSERT(headPacket == (*IovPacketPointer)); 00059 irp = headPacket->TrackedIrp; 00060 00061 // 00062 // Check the IRP appropriately 00063 // 00064 IovpSessionDataDeterminePolicy( 00065 headPacket, 00066 DeviceObject, 00067 &trackable, 00068 &useSurrogateIrp 00069 ); 00070 00071 if (!trackable) { 00072 00073 return NULL; 00074 } 00075 00076 // 00077 // One extra stack location is allocated as the "zero'th" is used to 00078 // simplify some logic... 00079 // 00080 sessionDataSize = 00081 sizeof(IOV_SESSION_DATA)+ 00082 irp->StackCount*sizeof(IOV_STACK_LOCATION); 00083 00084 iovSessionData = ExAllocatePoolWithTag( 00085 NonPagedPool, 00086 sessionDataSize, 00087 POOL_TAG_SESSION_DATA 00088 ); 00089 00090 if (iovSessionData == NULL) { 00091 00092 return NULL; 00093 } 00094 00095 RtlZeroMemory(iovSessionData, sessionDataSize); 00096 00097 iovSessionData->AssertFlags = IovpTrackingFlags; 00098 iovSessionData->IovRequestPacket = headPacket; 00099 InsertHeadList(&headPacket->SessionHead, &iovSessionData->SessionLink); 00100 00101 if ((iovSessionData->AssertFlags&ASSERTFLAG_COMPLETEATPASSIVE) || 00102 (iovSessionData->AssertFlags&ASSERTFLAG_DEFERCOMPLETION)) { 00103 00104 iovSessionData->AssertFlags |= ASSERTFLAG_FORCEPENDING; 00105 } 00106 00107 headPacket->pIovSessionData = iovSessionData; 00108 headPacket->TopStackLocation = irp->CurrentLocation; 00109 headPacket->Flags |= TRACKFLAG_ACTIVE; 00110 headPacket->Flags &=~ ( 00111 TRACKFLAG_QUEUED_INTERNALLY| 00112 TRACKFLAG_RELEASED| 00113 TRACKFLAG_SRB_MUNGED| 00114 TRACKFLAG_SWAPPED_BACK| 00115 TRACKFLAG_PASSED_FAILURE 00116 ); 00117 00118 iovSessionData->BestVisibleIrp = irp; 00119 if (useSurrogateIrp) { 00120 00121 // 00122 // We will track the IRP using a surrogate. 00123 // 00124 *SurrogateSpawned = IovpSessionDataAttachSurrogate( 00125 IovPacketPointer, 00126 iovSessionData 00127 ); 00128 } 00129 00130 TRACKIRP_DBGPRINT(( 00131 " SSN CREATE(%x)->%x\n", 00132 headPacket, 00133 iovSessionData 00134 ), 3) ; 00135 return iovSessionData; 00136 }

VOID FASTCALL IovpSessionDataDereference IN PIOV_SESSION_DATA  IovSessionData  ) 
 

Definition at line 152 of file sessnirp.c.

References ASSERT, ASSERT_SPINLOCK_HELD, ExFreePool(), _IOV_REQUEST_PACKET::HeadPacket, IovpTrackingDataDereference(), IOVREFTYPE_PACKET, _IOV_REQUEST_PACKET::IrpLock, _IOV_REQUEST_PACKET::pIovSessionData, _IOV_REQUEST_PACKET::PointerCount, _IOV_REQUEST_PACKET::ReferenceCount, and TRACKIRP_DBGPRINT.

Referenced by IovpCallDriver2(), IovpCompleteRequest2(), IovpCompleteRequest5(), and IovpSwapSurrogateIrp().

00155 { 00156 PIOV_REQUEST_PACKET iovPacket, headPacket; 00157 00158 iovPacket = IovSessionData->IovRequestPacket; 00159 headPacket = iovPacket->HeadPacket; 00160 00161 ASSERT_SPINLOCK_HELD(&headPacket->IrpLock); 00162 ASSERT_SPINLOCK_HELD(&iovPacket->IrpLock); 00163 ASSERT(IovSessionData->SessionRefCount > 0); 00164 ASSERT(headPacket->ReferenceCount > 0); 00165 ASSERT(iovPacket->ReferenceCount >= 0); 00166 00167 TRACKIRP_DBGPRINT(( 00168 " SSN DEREF(%x) %x--\n", 00169 IovSessionData, 00170 IovSessionData->SessionRefCount 00171 ), 3) ; 00172 00173 IovSessionData->SessionRefCount--; 00174 if (!IovSessionData->SessionRefCount) { 00175 00176 ASSERT(headPacket->pIovSessionData != IovSessionData); 00177 ASSERT(iovPacket->ReferenceCount > iovPacket->PointerCount); 00178 //ASSERT(IsListEmpty(&IovSessionData->SessionLink)); 00179 RemoveEntryList(&IovSessionData->SessionLink); 00180 InitializeListHead(&IovSessionData->SessionLink); 00181 00182 IovpTrackingDataDereference(iovPacket, IOVREFTYPE_PACKET); 00183 00184 ExFreePool(IovSessionData); 00185 } 00186 }

VOID IovpSessionDataDeterminePolicy IN PIOV_REQUEST_PACKET  IovRequestPacket,
IN PDEVICE_OBJECT  DeviceObject,
OUT PBOOLEAN  Trackable,
OUT PBOOLEAN  UseSurrogateIrp
 

Definition at line 240 of file sessnirp.c.

References ASSERTFLAG_POLICEIRPS, ASSERTFLAG_SMASH_SRBS, ASSERTFLAG_SURROGATE, ASSERTFLAG_TRACKIRPS, FALSE, HACKFLAG_FOR_MUP, IoGetNextIrpStackLocation, IovpHackFlags, IovpIsInterestingStack(), IovpTrackingFlags, IRP_MJ_CREATE, IRP_MJ_SCSI, and _IO_STACK_LOCATION::MajorFunction.

Referenced by IovpSessionDataCreate().

00248 : 00249 00250 This routine is called by IovpCallDriver1 to determine which IRPs should 00251 be tracked and how that tracking should be done. 00252 00253 Arguments: 00254 00255 ADRIAO BUGBUG 12/31/1998 - Fill this out. 00256 00257 Return Value: 00258 00259 None. 00260 00261 --*/ 00262 { 00263 PIO_STACK_LOCATION irpSp; 00264 PIRP irp; 00265 00266 irp = IovRequestPacket->TrackedIrp; 00267 00268 if (!(IovpTrackingFlags&ASSERTFLAG_TRACKIRPS)) { 00269 00270 // 00271 // No IRPs are to be tracked. Exit now. 00272 // 00273 *Trackable = FALSE; 00274 return; 00275 } 00276 00277 // 00278 // Determine whether we are to monitor this IRP. If we are going to test 00279 // any one driver in a stack, then we must unfortunately monitor the IRP's 00280 // progress through the *entire* stack. Thus our granularity here is stack 00281 // based, not device based! We will compensate for this somewhat in the 00282 // driver check code, which will attempt to ignore asserts from those 00283 // "non-targetted" drivers who happen to have screwed up in our stack... 00284 // 00285 *Trackable = IovpIsInterestingStack(DeviceObject); 00286 00287 irpSp = IoGetNextIrpStackLocation( irp ); 00288 00289 if (IovpTrackingFlags&ASSERTFLAG_POLICEIRPS) { 00290 00291 *UseSurrogateIrp = ((IovpTrackingFlags&ASSERTFLAG_SURROGATE)!=0) ; 00292 *UseSurrogateIrp &= ((irpSp->MajorFunction != IRP_MJ_SCSI) || 00293 ((IovpTrackingFlags&ASSERTFLAG_SMASH_SRBS)!=0)) ; 00294 00295 #ifdef HACKHACKS_ENABLED 00296 00297 // 00298 // ADRIAO HACKHACK #05 05/30/98 - 00299 // We don't surrogate creates right now because MUP touches IRPs 00300 // after they are completed. 00301 // 00302 if (IovpHackFlags&HACKFLAG_FOR_MUP) { 00303 *UseSurrogateIrp &= (irpSp->MajorFunction != IRP_MJ_CREATE) ; 00304 } 00305 #endif 00306 } else { 00307 00308 *UseSurrogateIrp = FALSE; 00309 } 00310 }

VOID FASTCALL IovpSessionDataFinalizeSurrogate IN PIOV_SESSION_DATA  IovSessionData,
IN OUT PIOV_REQUEST_PACKET  IovPacket,
IN PIRP  Irp
 

Definition at line 523 of file sessnirp.c.

References _IRP::AllocationFlags, _IRP::ApcEnvironment, ASSERT, _IRP::AssociatedIrp, _IRP::Cancel, _IOV_REQUEST_PACKET::Flags, _IRP::Flags, IoMarkIrpPending, _IRP::IoStatus, IovpProtectedIrpFree(), IovpProtectedIrpMakeUntouchable(), IovpTrackingDataDereference(), IovpTrackingDataGetCurrentSessionData(), IOVREFTYPE_POINTER, IRP_DEALLOCATE_BUFFER, IRP_DIAG_HAS_SURROGATE, IRP_DIAG_IS_SURROGATE, IRPFLAG_EXAMINE_MASK, _IRP::MdlAddress, NTSTATUS(), NULL, _IRP::Overlay, _IRP::PendingReturned, _IRP::RequestorMode, _IRP::StackCount, _IRP::Tail, _IOV_REQUEST_PACKET::TrackedIrp, TRACKFLAG_SURROGATE, TRUE, _IRP::Type, and _IRP::UserBuffer.

Referenced by IovpSwapSurrogateIrp().

00530 : 00531 00532 This routine removes the flags from both the real and 00533 surrogate IRP and records the final IRP settings. Finally, 00534 the surrogate IRP is made "untouchable" (decommitted). 00535 00536 Arguments: 00537 00538 iovPacket - Pointer to the IRP tracking data. 00539 00540 Return Value: 00541 00542 None. 00543 --*/ 00544 { 00545 PIOV_REQUEST_PACKET iovPrevPacket; 00546 NTSTATUS status, lockedStatus; 00547 ULONG nonInterestingFlags; 00548 PIO_STACK_LOCATION irpSp; 00549 PVOID restoreHandle; 00550 PIRP irp; 00551 00552 ASSERT(IovPacket->Flags&TRACKFLAG_SURROGATE); 00553 00554 ASSERT(IovpTrackingDataGetCurrentSessionData(IovPacket) == IovSessionData); 00555 00556 // 00557 // It's a surrogate, do as appropriate. 00558 // 00559 ASSERT(IovPacket->TopStackLocation == SurrogateIrp->CurrentLocation+1) ; 00560 00561 iovPrevPacket = CONTAINING_RECORD( 00562 IovPacket->SurrogateLink.Blink, 00563 IOV_REQUEST_PACKET, 00564 SurrogateLink 00565 ); 00566 00567 irp = iovPrevPacket->TrackedIrp; 00568 00569 // 00570 // Carry the pending bit over. 00571 // 00572 if (SurrogateIrp->PendingReturned) { 00573 IoMarkIrpPending(irp); 00574 } 00575 00576 nonInterestingFlags = ( 00577 IRPFLAG_EXAMINE_MASK | 00578 IRP_DIAG_IS_SURROGATE| 00579 IRP_DIAG_HAS_SURROGATE 00580 ); 00581 00582 // 00583 // Wipe the flags nice and clean 00584 // 00585 SurrogateIrp->Flags &=~ IRP_DIAG_IS_SURROGATE; 00586 irp->Flags &=~ IRP_DIAG_HAS_SURROGATE; 00587 00588 // 00589 // ASSERT portions of the IRP header have not changed. 00590 // 00591 ASSERT(irp->StackCount == SurrogateIrp->StackCount); // Later to be removed 00592 00593 ASSERT(irp->Type == SurrogateIrp->Type); 00594 ASSERT(irp->RequestorMode == SurrogateIrp->RequestorMode); 00595 ASSERT(irp->ApcEnvironment == SurrogateIrp->ApcEnvironment); 00596 ASSERT(irp->AllocationFlags == SurrogateIrp->AllocationFlags); 00597 ASSERT(irp->UserBuffer == SurrogateIrp->UserBuffer); 00598 ASSERT(irp->Tail.Overlay.Thread == SurrogateIrp->Tail.Overlay.Thread); 00599 00600 ASSERT( 00601 irp->Overlay.AsynchronousParameters.UserApcRoutine == 00602 SurrogateIrp->Overlay.AsynchronousParameters.UserApcRoutine 00603 ); 00604 00605 ASSERT( 00606 irp->Overlay.AsynchronousParameters.UserApcContext == 00607 SurrogateIrp->Overlay.AsynchronousParameters.UserApcContext 00608 ); 00609 00610 ASSERT( 00611 irp->Tail.Overlay.OriginalFileObject == 00612 SurrogateIrp->Tail.Overlay.OriginalFileObject 00613 ); 00614 00615 ASSERT( 00616 irp->Tail.Overlay.AuxiliaryBuffer == 00617 SurrogateIrp->Tail.Overlay.AuxiliaryBuffer 00618 ); 00619 00620 /* 00621 ASSERT( 00622 irp->AssociatedIrp.SystemBuffer == 00623 SurrogateIrp->AssociatedIrp.SystemBuffer 00624 ); 00625 00626 ASSERT( 00627 (irp->Flags & ~nonInterestingFlags) == 00628 (SurrogateIrp->Flags & ~nonInterestingFlags) 00629 ); 00630 00631 ASSERT(irp->MdlAddress == SurrogateIrp->MdlAddress); 00632 */ 00633 // 00634 // ADRIAO BUGBUG 02/28/1999 - 00635 // How do these change as an IRP progresses? 00636 // 00637 irp->Flags |= SurrogateIrp->Flags; 00638 irp->MdlAddress = SurrogateIrp->MdlAddress; 00639 irp->AssociatedIrp.SystemBuffer = SurrogateIrp->AssociatedIrp.SystemBuffer; 00640 00641 if ((irp->Flags&IRP_DEALLOCATE_BUFFER)&& 00642 (irp->AssociatedIrp.SystemBuffer == NULL)) { 00643 00644 irp->Flags &=~ IRP_DEALLOCATE_BUFFER; 00645 } 00646 00647 // 00648 // Copy the salient fields back. We only need to touch certain areas of the 00649 // header. 00650 // 00651 irp->IoStatus = SurrogateIrp->IoStatus; 00652 irp->PendingReturned = SurrogateIrp->PendingReturned; 00653 irp->Cancel = SurrogateIrp->Cancel; 00654 00655 iovPrevPacket->Flags &=~ TRACKFLAG_HAS_SURROGATE; 00656 00657 // 00658 // Record data from it and make the system fault if the IRP is touched 00659 // after this completion routine. 00660 // 00661 IovSessionData->BestVisibleIrp = irp; 00662 00663 IovpTrackingDataDereference(iovPrevPacket, IOVREFTYPE_POINTER); 00664 00665 ASSERT(IovPacket->PointerCount == 0); 00666 00667 restoreHandle = IovpProtectedIrpMakeUntouchable(SurrogateIrp, TRUE); 00668 IovpProtectedIrpFree(SurrogateIrp, &restoreHandle); 00669 } #endif // NO_SPECIAL_IRP

VOID FASTCALL IovpSessionDataReference IN PIOV_SESSION_DATA  IovSessionData  ) 
 

Definition at line 190 of file sessnirp.c.

References ASSERT, ASSERT_SPINLOCK_HELD, _IOV_REQUEST_PACKET::HeadPacket, IovpTrackingDataReference(), IOVREFTYPE_PACKET, _IOV_REQUEST_PACKET::IrpLock, _IOV_REQUEST_PACKET::ReferenceCount, and TRACKIRP_DBGPRINT.

Referenced by IovpCallDriver1(), and IovpCompleteRequest2().

00193 { 00194 PIOV_REQUEST_PACKET iovPacket, headPacket; 00195 00196 iovPacket = IovSessionData->IovRequestPacket; 00197 headPacket = iovPacket->HeadPacket; 00198 00199 ASSERT_SPINLOCK_HELD(&headPacket->IrpLock); 00200 ASSERT_SPINLOCK_HELD(&iovPacket->IrpLock); 00201 ASSERT(IovSessionData->SessionRefCount >= 0); 00202 ASSERT(headPacket->ReferenceCount >= 0); 00203 ASSERT(iovPacket->ReferenceCount >= 0); 00204 00205 TRACKIRP_DBGPRINT(( 00206 " SSN REF(%x) %x++\n", 00207 IovSessionData, 00208 IovSessionData->SessionRefCount 00209 ), 3) ; 00210 00211 if (!IovSessionData->SessionRefCount) { 00212 00213 IovpTrackingDataReference(iovPacket, IOVREFTYPE_PACKET); 00214 } 00215 IovSessionData->SessionRefCount++; 00216 }


Generated on Sat May 15 19:45:38 2004 for test by doxygen 1.3.7