--*/
-#include "cdprocs.h"
+#include "CdProcs.h"
//
// The Bug check file id for this module
\f
VOID
CdCreateInternalStream (
- IN PIRP_CONTEXT IrpContext,
- IN PVCB Vcb,
- IN PFCB Fcb
+ _In_ PIRP_CONTEXT IrpContext,
+ _In_ PVCB Vcb,
+ _Inout_ PFCB Fcb,
+ _In_ PUNICODE_STRING Name
)
/*++
BOOLEAN CleanupDirContext = FALSE;
BOOLEAN UpdateFcbSizes = FALSE;
- DIRENT Dirent;
- DIRENT_ENUM_CONTEXT DirContext;
+ DIRENT Dirent = {0};
+ DIRENT_ENUM_CONTEXT DirContext = {0};
PAGED_CODE();
// Use a try-finally to facilitate cleanup.
//
- _SEH2_TRY {
+ try {
//
// Create the internal stream. The Vpb should be pointing at our volume
// device object at this point.
//
- StreamFile = IoCreateStreamFileObject( NULL, Vcb->Vpb->RealDevice );
+ StreamFile = IoCreateStreamFileObjectLite( NULL, Vcb->Vpb->RealDevice );
if (StreamFile == NULL) {
StreamFileOpen,
Fcb,
NULL );
+
+ //
+ // We'll give stream file objects a name to aid IO profiling etc. We
+ // NULL this in CdDeleteInternalStream before OB deletes the file object,
+ // and before CdRemovePrefix is called (which frees Fcb names).
+ //
+
+ StreamFile->FileName = *Name;
//
// We will reference the current Fcb twice to keep it from going
}
}
- } _SEH2_FINALLY {
+ } finally {
//
// Cleanup any dirent structures we may have used.
if (StreamFile != NULL) {
+ //
+ // Null the name pointer, since the stream file object never actually
+ // 'owns' the names, we just point it to existing ones.
+ //
+
+ StreamFile->FileName.Buffer = NULL;
+ StreamFile->FileName.MaximumLength = StreamFile->FileName.Length = 0;
+
ObDereferenceObject( StreamFile );
Fcb->FileObject = NULL;
}
}
CdUnlockFcb( IrpContext, Fcb );
- } _SEH2_END;
+ }
return;
}
\f
VOID
CdDeleteInternalStream (
- IN PIRP_CONTEXT IrpContext,
- IN PFCB Fcb
+ _In_ PIRP_CONTEXT IrpContext,
+ _Inout_ PFCB Fcb
)
/*++
PAGED_CODE();
+ UNREFERENCED_PARAMETER( IrpContext );
+
ASSERT_IRP_CONTEXT( IrpContext );
ASSERT_FCB( Fcb );
CcUninitializeCacheMap( FileObject, NULL, NULL );
}
+ //
+ // Null the name pointer, since the stream file object never actually
+ // 'owns' the names, we just point it to existing ones.
+ //
+
+ FileObject->FileName.Buffer = NULL;
+ FileObject->FileName.MaximumLength = FileObject->FileName.Length = 0;
+
ObDereferenceObject( FileObject );
}
-
- return;
}
\f
NTSTATUS
CdCompleteMdl (
- IN PIRP_CONTEXT IrpContext,
- IN PIRP Irp
+ _In_ PIRP_CONTEXT IrpContext,
+ _Inout_ PIRP Irp
)
/*++
}
\f
+
+_Requires_lock_held_(_Global_critical_region_)
NTSTATUS
CdPurgeVolume (
- IN PIRP_CONTEXT IrpContext,
- IN PVCB Vcb,
- IN BOOLEAN DismountUnderway
+ _In_ PIRP_CONTEXT IrpContext,
+ _In_ PVCB Vcb,
+ _In_ BOOLEAN DismountUnderway
)
/*++
if (Vcb->PathTableFcb != NULL) {
ThisFcb = Vcb->PathTableFcb;
- InterlockedIncrement( &Vcb->PathTableFcb->FcbReference );
+ InterlockedIncrement( (LONG*)&Vcb->PathTableFcb->FcbReference );
if ((ThisFcb->FcbNonpaged->SegmentObject.DataSectionObject != NULL) &&
!CcPurgeCacheSection( &ThisFcb->FcbNonpaged->SegmentObject,
CdDeleteInternalStream( IrpContext, ThisFcb );
- InterlockedDecrement( &ThisFcb->FcbReference );
+ InterlockedDecrement( (LONG*)&ThisFcb->FcbReference );
CdTeardownStructures( IrpContext, ThisFcb, &RemovedFcb );
}
if (Vcb->VolumeDasdFcb != NULL) {
ThisFcb = Vcb->VolumeDasdFcb;
- InterlockedIncrement( &ThisFcb->FcbReference );
+ InterlockedIncrement( (LONG*)&ThisFcb->FcbReference );
if ((ThisFcb->FcbNonpaged->SegmentObject.DataSectionObject != NULL) &&
!CcPurgeCacheSection( &ThisFcb->FcbNonpaged->SegmentObject,
Status = STATUS_UNABLE_TO_DELETE_SECTION;
}
- InterlockedDecrement( &ThisFcb->FcbReference );
+ InterlockedDecrement( (LONG*)&ThisFcb->FcbReference );
CdTeardownStructures( IrpContext, ThisFcb, &RemovedFcb );
}