ReactOS  0.4.14-dev-57-g333b8f1
strucsup.c File Reference
#include "cdprocs.h"
Include dependency graph for strucsup.c:

Go to the source code of this file.

Classes

struct  _FCB_TABLE_ELEMENT
 

Macros

#define BugCheckFileId   (CDFS_BUG_CHECK_STRUCSUP)
 
#define CdAllocateFcbData(IC)   FsRtlAllocatePoolWithTag( CdPagedPool, SIZEOF_FCB_DATA, TAG_FCB_DATA )
 
#define CdDeallocateFcbData(IC, F)   CdFreePool( &(F) )
 
#define CdAllocateFcbIndex(IC)   FsRtlAllocatePoolWithTag( CdPagedPool, SIZEOF_FCB_INDEX, TAG_FCB_INDEX )
 
#define CdDeallocateFcbIndex(IC, F)   CdFreePool( &(F) )
 
#define CdAllocateFcbNonpaged(IC)   ExAllocatePoolWithTag( CdNonPagedPool, sizeof( FCB_NONPAGED ), TAG_FCB_NONPAGED )
 
#define CdDeallocateFcbNonpaged(IC, FNP)   CdFreePool( &(FNP) )
 
#define CdAllocateCcb(IC)   FsRtlAllocatePoolWithTag( CdPagedPool, sizeof( CCB ), TAG_CCB )
 
#define CdDeallocateCcb(IC, C)   CdFreePool( &(C) )
 
#define CdInsertFcbTable(IC, F)
 
#define CdDeleteFcbTable(IC, F)
 

Typedefs

typedef struct _FCB_TABLE_ELEMENT FCB_TABLE_ELEMENT
 
typedef struct _FCB_TABLE_ELEMENTPFCB_TABLE_ELEMENT
 

Functions

VOID CdDeleteFcb (_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb)
 
PFCB_NONPAGED CdCreateFcbNonpaged (_In_ PIRP_CONTEXT IrpContext)
 
VOID CdDeleteFcbNonpaged (_In_ PIRP_CONTEXT IrpContext, _In_ PFCB_NONPAGED FcbNonpaged)
 
RTL_GENERIC_COMPARE_RESULTS NTAPI CdFcbTableCompare (_In_ PRTL_GENERIC_TABLE FcbTable, _In_ PVOID Fid1, _In_ PVOID Fid2)
 
PVOID NTAPI CdAllocateFcbTable (_In_ PRTL_GENERIC_TABLE FcbTable, _In_ CLONG ByteSize)
 
VOID NTAPI CdDeallocateFcbTable (_In_ PRTL_GENERIC_TABLE FcbTable, _In_ __drv_freesMem(Mem) _Post_invalid_ PVOID Buffer)
 
ULONG CdTocSerial (_In_ PIRP_CONTEXT IrpContext, _In_ PCDROM_TOC_LARGE CdromToc)
 
VOID CdInitializeVcb (_In_ PIRP_CONTEXT IrpContext, _Inout_ PVCB Vcb, _In_ __drv_aliasesMem PDEVICE_OBJECT TargetDeviceObject, _In_ __drv_aliasesMem PVPB Vpb, _In_ __drv_aliasesMem PCDROM_TOC_LARGE CdromToc, _In_ ULONG TocLength, _In_ ULONG TocTrackCount, _In_ ULONG TocDiskFlags, _In_ ULONG BlockFactor, _In_ ULONG MediaChangeCount)
 
VOID CdUpdateVcbFromVolDescriptor (_In_ PIRP_CONTEXT IrpContext, _Inout_ PVCB Vcb, _In_reads_bytes_opt_(SECTOR_SIZE) PCHAR RawIsoVd)
 
VOID CdDeleteVcb (_In_ PIRP_CONTEXT IrpContext, _Inout_ PVCB Vcb)
 
PFCB CdCreateFcb (_In_ PIRP_CONTEXT IrpContext, _In_ FILE_ID FileId, _In_ NODE_TYPE_CODE NodeTypeCode, _Out_opt_ PBOOLEAN FcbExisted)
 
VOID CdInitializeFcbFromPathEntry (_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_opt_ PFCB ParentFcb, _In_ PPATH_ENTRY PathEntry)
 
VOID CdInitializeFcbFromFileContext (_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_ PFCB ParentFcb, _In_ PFILE_ENUM_CONTEXT FileContext)
 
PCCB CdCreateCcb (_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _In_ ULONG Flags)
 
VOID CdDeleteCcb (_In_ PIRP_CONTEXT IrpContext, _In_ __drv_freesMem(Pool) PCCB Ccb)
 
 _When_ (RaiseOnError||return, _At_(Fcb->FileLock, _Post_notnull_)) _When_(RaiseOnError
 
 _At_ (BOOLEANCdCreateFileLock(_In_opt_ PIRP_CONTEXT IrpContext, _Pre_notnull_)
 
_Ret_valid_ PIRP_CONTEXT CdCreateIrpContext (_In_ PIRP Irp, _In_ BOOLEAN Wait)
 
VOID CdCleanupIrpContext (_In_ PIRP_CONTEXT IrpContext, _In_ BOOLEAN Post)
 
VOID CdInitializeStackIrpContext (_Out_ PIRP_CONTEXT IrpContext, _In_ PIRP_CONTEXT_LITE IrpContextLite)
 
 _Requires_lock_held_ (_Global_critical_region_)
 
PFCB CdLookupFcbTable (_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _In_ FILE_ID FileId)
 
PFCB CdGetNextFcb (_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _In_ PVOID *RestartKey)
 
NTSTATUS CdProcessToc (_In_ PIRP_CONTEXT IrpContext, _In_ PDEVICE_OBJECT TargetDeviceObject, _In_ PCDROM_TOC_LARGE CdromToc, _Inout_ PULONG Length, _Out_ PULONG TrackCount, _Inout_ PULONG DiskFlags)
 

Variables

RTL_GENERIC_COMPARE_ROUTINE CdFcbTableCompare
 
RTL_GENERIC_ALLOCATE_ROUTINE CdAllocateFcbTable
 
RTL_GENERIC_FREE_ROUTINE CdDeallocateFcbTable
 
UNICODE_STRING CdInternalStreamNames []
 

Macro Definition Documentation

◆ BugCheckFileId

#define BugCheckFileId   (CDFS_BUG_CHECK_STRUCSUP)

Definition at line 23 of file strucsup.c.

◆ CdAllocateCcb

#define CdAllocateCcb (   IC)    FsRtlAllocatePoolWithTag( CdPagedPool, sizeof( CCB ), TAG_CCB )

Definition at line 93 of file strucsup.c.

◆ CdAllocateFcbData

Definition at line 75 of file strucsup.c.

◆ CdAllocateFcbIndex

Definition at line 81 of file strucsup.c.

◆ CdAllocateFcbNonpaged

#define CdAllocateFcbNonpaged (   IC)    ExAllocatePoolWithTag( CdNonPagedPool, sizeof( FCB_NONPAGED ), TAG_FCB_NONPAGED )

Definition at line 87 of file strucsup.c.

◆ CdDeallocateCcb

#define CdDeallocateCcb (   IC,
  C 
)    CdFreePool( &(C) )

Definition at line 96 of file strucsup.c.

◆ CdDeallocateFcbData

#define CdDeallocateFcbData (   IC,
  F 
)    CdFreePool( &(F) )

Definition at line 78 of file strucsup.c.

◆ CdDeallocateFcbIndex

#define CdDeallocateFcbIndex (   IC,
  F 
)    CdFreePool( &(F) )

Definition at line 84 of file strucsup.c.

◆ CdDeallocateFcbNonpaged

#define CdDeallocateFcbNonpaged (   IC,
  FNP 
)    CdFreePool( &(FNP) )

Definition at line 90 of file strucsup.c.

◆ CdDeleteFcbTable

#define CdDeleteFcbTable (   IC,
  F 
)
Value:
{ \
FCB_TABLE_ELEMENT _Key; \
_Key.FileId = (F)->FileId; \
RtlDeleteElementGenericTable( &(F)->Vcb->FcbTable, &_Key ); \
}
#define Vcb
Definition: cdprocs.h:1425
#define F(x, y, z)
Definition: md5.c:51

Definition at line 139 of file strucsup.c.

◆ CdInsertFcbTable

#define CdInsertFcbTable (   IC,
  F 
)
Value:
{ \
FCB_TABLE_ELEMENT _Key; \
_Key.Fcb = (F); \
_Key.FileId = (F)->FileId; \
RtlInsertElementGenericTable( &(F)->Vcb->FcbTable, \
&_Key, \
sizeof( FCB_TABLE_ELEMENT ), \
NULL ); \
}
smooth NULL
Definition: ftsmooth.c:416
#define Vcb
Definition: cdprocs.h:1425
#define F(x, y, z)
Definition: md5.c:51

Definition at line 129 of file strucsup.c.

Typedef Documentation

◆ FCB_TABLE_ELEMENT

◆ PFCB_TABLE_ELEMENT

Function Documentation

◆ _At_()

_At_ ( BOOLEANCdCreateFileLock ( _In_opt_ PIRP_CONTEXT  IrpContext,
_Pre_notnull_   
)

Definition at line 1498 of file strucsup.c.

1529 {
1530  BOOLEAN Result = TRUE;
1531  PFILE_LOCK FileLock;
1532 
1533  PAGED_CODE();
1534 
1535  //
1536  // Lock the Fcb and check if there is really any work to do.
1537  //
1538 
1539  CdLockFcb( IrpContext, Fcb );
1540 
1541  if (Fcb->FileLock != NULL) {
1542 
1543  CdUnlockFcb( IrpContext, Fcb );
1544  return TRUE;
1545  }
1546 
1547  Fcb->FileLock = FileLock =
1549 
1550  CdUnlockFcb( IrpContext, Fcb );
1551 
1552  //
1553  // Return or raise as appropriate.
1554  //
1555 
1556  if (FileLock == NULL) {
1557 
1558  if (RaiseOnError) {
1559 
1560  NT_ASSERT( ARGUMENT_PRESENT( IrpContext ));
1561 
1563  }
1564 
1565  Result = FALSE;
1566  }
1567 
1568  return Result;
1569 }
FILE_LOCK FileLock
Definition: fatstruc.h:1070
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PFILE_LOCK NTAPI FsRtlAllocateFileLock(IN PCOMPLETE_LOCK_IRP_ROUTINE CompleteLockIrpRoutine OPTIONAL, IN PUNLOCK_ROUTINE UnlockRoutine OPTIONAL)
Definition: filelock.c:1314
#define PAGED_CODE()
Definition: video.h:57
#define CdUnlockFcb(IC, F)
Definition: cdprocs.h:1065
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define ARGUMENT_PRESENT(ArgumentPointer)
#define CdLockFcb(IC, F)
Definition: cdprocs.h:1049
#define CdRaiseStatus(IC, S)
Definition: cdprocs.h:1869
_Inout_ PFCB _In_ BOOLEAN RaiseOnError
Definition: cdprocs.h:1214
_In_ PFCB Fcb
Definition: cdprocs.h:151
#define NT_ASSERT
Definition: rtlfuncs.h:3312

◆ _Requires_lock_held_()

_Requires_lock_held_ ( _Global_critical_region_  )

Definition at line 1915 of file strucsup.c.

1953 {
1954  PVCB Vcb = StartingFcb->Vcb;
1956  BOOLEAN AcquiredCurrentFcb = FALSE;
1957  PFCB ParentFcb;
1958 
1959  PAGED_CODE();
1960 
1962 
1963  //
1964  // If this is a recursive call to TearDownStructures we return immediately
1965  // doing no operation.
1966  //
1967 
1968  if (FlagOn( IrpContext->TopLevel->Flags, IRP_CONTEXT_FLAG_IN_TEARDOWN )) {
1969 
1970  return;
1971  }
1972 
1973  SetFlag( IrpContext->TopLevel->Flags, IRP_CONTEXT_FLAG_IN_TEARDOWN );
1974 
1975  //
1976  // Use a try-finally to safely clear the top-level field.
1977  //
1978 
1979  _SEH2_TRY {
1980 
1981  //
1982  // Loop until we find an Fcb we can't remove.
1983  //
1984 
1985  do {
1986 
1987  //
1988  // See if there is an internal stream we should delete.
1989  // Only do this if it is the last reference on the Fcb.
1990  //
1991 
1993  (CurrentFcb->FcbUserReference == 0) &&
1994  (CurrentFcb->FileObject != NULL)) {
1995 
1996  //
1997  // Go ahead and delete the stream file object.
1998  //
1999 
2000  CdDeleteInternalStream( IrpContext, CurrentFcb );
2001  }
2002 
2003  //
2004  // If the reference count is non-zero then break.
2005  //
2006 
2007  if (CurrentFcb->FcbReference != 0) {
2008 
2009  break;
2010  }
2011 
2012  //
2013  // It looks like we have a candidate for removal here. We
2014  // will need to acquire the parent, if present, in order to
2015  // remove this from the parent prefix table.
2016  //
2017 
2019 
2020  if (ParentFcb != NULL) {
2021 
2022  CdAcquireFcbExclusive( IrpContext, ParentFcb, FALSE );
2023  }
2024 
2025  //
2026  // Now lock the vcb.
2027  //
2028 
2029  CdLockVcb( IrpContext, Vcb );
2030 
2031  //
2032  // Final check to see if the reference count is still zero.
2033  //
2034 
2035  if (CurrentFcb->FcbReference != 0) {
2036 
2037  CdUnlockVcb( IrpContext, Vcb );
2038 
2039  if (ParentFcb != NULL) {
2040 
2041  CdReleaseFcb( IrpContext, ParentFcb );
2042  }
2043 
2044  break;
2045  }
2046 
2047  //
2048  // If there is a parent then do the necessary cleanup for the parent.
2049  //
2050 
2051  if (ParentFcb != NULL) {
2052 
2053  CdRemovePrefix( IrpContext, CurrentFcb );
2055 
2056  CdDecrementReferenceCounts( IrpContext, ParentFcb, 1, 1 );
2057  }
2058 
2060 
2061  CdDeleteFcbTable( IrpContext, CurrentFcb );
2063 
2064  }
2065 
2066  //
2067  // Unlock the Vcb but hold the parent in order to walk up
2068  // the tree.
2069  //
2070 
2071  CdUnlockVcb( IrpContext, Vcb );
2072  CdDeleteFcb( IrpContext, CurrentFcb );
2073 
2074  //
2075  // Move to the parent Fcb.
2076  //
2077 
2079  AcquiredCurrentFcb = TRUE;
2080 
2081  } while (CurrentFcb != NULL);
2082 
2083  } _SEH2_FINALLY {
2084 
2085  //
2086  // Release the current Fcb if we have acquired it.
2087  //
2088 
2089  if (AcquiredCurrentFcb && (CurrentFcb != NULL)) {
2090 
2091  CdReleaseFcb( IrpContext, CurrentFcb );
2092  }
2093 
2094  //
2095  // Clear the teardown flag.
2096  //
2097 
2098  ClearFlag( IrpContext->TopLevel->Flags, IRP_CONTEXT_FLAG_IN_TEARDOWN );
2099  } _SEH2_END;
2100 
2102  return;
2103 }
_Inout_ PFCB _Out_ PBOOLEAN RemovedStartingFcb
Definition: cdprocs.h:1264
#define TRUE
Definition: types.h:120
_Inout_ PFCB * CurrentFcb
Definition: cdprocs.h:806
PFILE_OBJECT FileObject
Definition: ntfs.h:516
Definition: cdstruc.h:908
#define SafeNodeType(Ptr)
Definition: nodetype.h:54
#define CdReleaseFcb(IC, F)
Definition: cdprocs.h:1017
Definition: cdstruc.h:504
#define CdAcquireFcbExclusive(IC, F, I)
Definition: cdprocs.h:1011
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
VOID CdDeleteInternalStream(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb)
Definition: cachesup.c:333
#define CDFS_NTC_FCB_DATA
Definition: nodetype.h:31
#define FCB_STATE_IN_FCB_TABLE
Definition: cdstruc.h:1049
__volatile LONG FcbReference
Definition: cdstruc.h:970
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define CdDecrementReferenceCounts(IC, F, C, UC)
Definition: cdprocs.h:1330
_Inout_ PFCB StartingFcb
Definition: cdprocs.h:1264
#define CdUnlockVcb(IC, V)
Definition: cdprocs.h:1033
#define Vcb
Definition: cdprocs.h:1425
_In_ PFCB ParentFcb
Definition: cdprocs.h:741
#define CdLockVcb(IC, V)
Definition: cdprocs.h:1028
VOID CdDeleteFcb(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb)
Definition: strucsup.c:2424
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
ULONG FcbUserReference
Definition: cdstruc.h:971
LIST_ENTRY FcbLinks
Definition: cdstruc.h:952
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
VOID CdRemovePrefix(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb)
Definition: prefxsup.c:207
PVCB Vcb
Definition: cdstruc.h:939
struct _FCB * ParentFcb
Definition: cdstruc.h:946
#define CdDeleteFcbTable(IC, F)
Definition: strucsup.c:139
ULONG FcbState
Definition: cdstruc.h:977
#define IRP_CONTEXT_FLAG_IN_TEARDOWN
Definition: cdstruc.h:1226

◆ _When_()

_When_ ( RaiseOnError||  return,
_At_(Fcb->FileLock, _Post_notnull_  
)

◆ CdAllocateFcbTable()

PVOID NTAPI CdAllocateFcbTable ( _In_ PRTL_GENERIC_TABLE  FcbTable,
_In_ CLONG  ByteSize 
)

Definition at line 2706 of file strucsup.c.

2729 {
2730  PAGED_CODE();
2731 
2732  UNREFERENCED_PARAMETER( FcbTable );
2733 
2735 }
PVOID NTAPI FsRtlAllocatePoolWithTag(IN POOL_TYPE PoolType, IN ULONG NumberOfBytes, IN ULONG Tag)
Definition: filter.c:229
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define PAGED_CODE()
Definition: video.h:57
#define CdPagedPool
Definition: cdprocs.h:1385
#define TAG_FCB_TABLE
Definition: cdprocs.h:84
_IRQL_requires_same_ _In_ CLONG ByteSize
Definition: rtltypes.h:389

◆ CdCleanupIrpContext()

VOID CdCleanupIrpContext ( _In_ PIRP_CONTEXT  IrpContext,
_In_ BOOLEAN  Post 
)

Definition at line 1733 of file strucsup.c.

1757 {
1758  PAGED_CODE();
1759 
1760  //
1761  // If we aren't doing more processing then deallocate this as appropriate.
1762  //
1763 
1764  if (!FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_MORE_PROCESSING)) {
1765 
1766  //
1767  // If this context is the top level CDFS context then we need to
1768  // restore the top level thread context.
1769  //
1770 
1771  if (IrpContext->ThreadContext != NULL) {
1772 
1773  CdRestoreThreadContext( IrpContext );
1774  }
1775 
1776  //
1777  // Deallocate the Io context if allocated.
1778  //
1779 
1780  if (FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_ALLOC_IO )) {
1781 
1782  CdFreeIoContext( IrpContext->IoContext );
1783  }
1784 
1785  //
1786  // Deallocate the IrpContext if not from the stack.
1787  //
1788 
1789  if (!FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_ON_STACK )) {
1790 
1792 
1793  CdLockCdData();
1794 
1797 
1798  CdUnlockCdData();
1799 
1800  } else {
1801 
1802  //
1803  // We couldn't add this to our lookaside list so free it to
1804  // pool.
1805  //
1806 
1807  CdFreePool( &IrpContext );
1808  }
1809  }
1810 
1811  //
1812  // Clear the appropriate flags.
1813  //
1814 
1815  } else if (Post) {
1816 
1817  //
1818  // If this context is the top level CDFS context then we need to
1819  // restore the top level thread context.
1820  //
1821 
1822  if (IrpContext->ThreadContext != NULL) {
1823 
1824  CdRestoreThreadContext( IrpContext );
1825  }
1826 
1827  ClearFlag( IrpContext->Flags, IRP_CONTEXT_FLAGS_CLEAR_ON_POST );
1828 
1829  } else {
1830 
1831  ClearFlag( IrpContext->Flags, IRP_CONTEXT_FLAGS_CLEAR_ON_RETRY );
1832  }
1833 
1834  return;
1835 }
#define IRP_CONTEXT_FLAG_ALLOC_IO
Definition: cdstruc.h:1227
Definition: ntbasedef.h:635
#define IRP_CONTEXT_FLAG_MORE_PROCESSING
Definition: cdstruc.h:1220
#define PAGED_CODE()
Definition: video.h:57
#define CdRestoreThreadContext(IC)
Definition: cdprocs.h:1993
FORCEINLINE VOID PushEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY Entry)
Definition: rtlfuncs.h:253
smooth NULL
Definition: ftsmooth.c:416
SINGLE_LIST_ENTRY IrpContextList
Definition: cdstruc.h:350
#define IRP_CONTEXT_FLAGS_CLEAR_ON_RETRY
Definition: cdstruc.h:1257
CD_DATA CdData
Definition: cddata.c:42
#define IRP_CONTEXT_FLAG_ON_STACK
Definition: cdstruc.h:1219
#define CdLockCdData()
Definition: cdprocs.h:1020
#define CdFreeIoContext(IO)
Definition: cdprocs.h:1354
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
ULONG IrpContextDepth
Definition: cdstruc.h:348
#define CdFreePool(x)
Definition: cdprocs.h:2200
ULONG IrpContextMaxDepth
Definition: cdstruc.h:349
#define IRP_CONTEXT_FLAGS_CLEAR_ON_POST
Definition: cdstruc.h:1242
#define CdUnlockCdData()
Definition: cdprocs.h:1024

Referenced by _IRQL_requires_max_(), CdCompleteRequest(), CdFspDispatch(), and CdQueueClose().

◆ CdCreateCcb()

PCCB CdCreateCcb ( _In_ PIRP_CONTEXT  IrpContext,
_In_ PFCB  Fcb,
_In_ ULONG  Flags 
)

Definition at line 1405 of file strucsup.c.

1429 {
1430  PCCB NewCcb;
1431  PAGED_CODE();
1432 
1433  UNREFERENCED_PARAMETER( IrpContext );
1434 
1435  //
1436  // Allocate and initialize the structure.
1437  //
1438 
1439  NewCcb = CdAllocateCcb( IrpContext );
1440 
1441  RtlZeroMemory( NewCcb, sizeof( CCB ));
1442 
1443  //
1444  // Set the proper node type code and node byte size
1445  //
1446 
1447  NewCcb->NodeTypeCode = CDFS_NTC_CCB;
1448  NewCcb->NodeByteSize = sizeof( CCB );
1449 
1450  //
1451  // Set the initial value for the flags and Fcb
1452  //
1453 
1454  NewCcb->Flags = Flags;
1455  NewCcb->Fcb = Fcb;
1456 
1457  return NewCcb;
1458 }
#define CDFS_NTC_CCB
Definition: nodetype.h:33
#define CdAllocateCcb(IC)
Definition: strucsup.c:93
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
Definition: cdstruc.h:1073
#define PAGED_CODE()
Definition: video.h:57
NODE_TYPE_CODE NodeTypeCode
Definition: fatstruc.h:1365
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
ULONG Flags
Definition: cdstruc.h:1086
struct _CCB CCB
NODE_BYTE_SIZE NodeByteSize
Definition: cdstruc.h:1080
PFCB Fcb
Definition: cdstruc.h:1092
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ PFCB Fcb
Definition: cdprocs.h:151

◆ CdCreateFcb()

PFCB CdCreateFcb ( _In_ PIRP_CONTEXT  IrpContext,
_In_ FILE_ID  FileId,
_In_ NODE_TYPE_CODE  NodeTypeCode,
_Out_opt_ PBOOLEAN  FcbExisted 
)

Definition at line 986 of file strucsup.c.

1018 {
1019  PFCB NewFcb;
1020  BOOLEAN LocalFcbExisted;
1021 
1022  PAGED_CODE();
1023 
1024  //
1025  // Use the local boolean if one was not passed in.
1026  //
1027 
1028  if (!ARGUMENT_PRESENT( FcbExisted )) {
1029 
1030  FcbExisted = &LocalFcbExisted;
1031  }
1032 
1033  //
1034  // Maybe this is already in the table.
1035  //
1036 
1037  NewFcb = CdLookupFcbTable( IrpContext, IrpContext->Vcb, FileId );
1038 
1039  //
1040  // If not then create the Fcb is requested by our caller.
1041  //
1042 
1043  if (NewFcb == NULL) {
1044 
1045  //
1046  // Allocate and initialize the structure depending on the
1047  // type code.
1048  //
1049 
1050  switch (NodeTypeCode) {
1051 
1053  case CDFS_NTC_FCB_INDEX:
1054 
1055  NewFcb = CdAllocateFcbIndex( IrpContext );
1056 
1057  RtlZeroMemory( NewFcb, SIZEOF_FCB_INDEX );
1058 
1059  NewFcb->NodeByteSize = SIZEOF_FCB_INDEX;
1060 
1061  InitializeListHead( &NewFcb->FcbQueue );
1062 
1063  break;
1064 
1065  case CDFS_NTC_FCB_DATA :
1066 
1067  NewFcb = CdAllocateFcbData( IrpContext );
1068 
1069  RtlZeroMemory( NewFcb, SIZEOF_FCB_DATA );
1070 
1071  NewFcb->NodeByteSize = SIZEOF_FCB_DATA;
1072 
1073  break;
1074 
1075  default:
1076 
1077 #ifdef _MSC_VER
1078 #pragma prefast( suppress: __WARNING_USE_OTHER_FUNCTION, "This is a bug." )
1079 #endif
1080  CdBugCheck( 0, 0, 0 );
1081  }
1082 
1083  //
1084  // Now do the common initialization.
1085  //
1086 
1087  NewFcb->NodeTypeCode = NodeTypeCode;
1088 
1089  NewFcb->Vcb = IrpContext->Vcb;
1090  NewFcb->FileId = FileId;
1091 
1092  CdInitializeMcb( IrpContext, NewFcb );
1093 
1094  //
1095  // Now create the non-paged section object.
1096  //
1097 
1098  NewFcb->FcbNonpaged = CdCreateFcbNonpaged( IrpContext );
1099 
1100  //
1101  // Deallocate the Fcb and raise if the allocation failed.
1102  //
1103 
1104  if (NewFcb->FcbNonpaged == NULL) {
1105 
1106  CdFreePool( &NewFcb );
1107 
1109  }
1110 
1111  *FcbExisted = FALSE;
1112 
1113  //
1114  // Initialize Advanced FCB Header fields
1115  //
1116 
1118  FsRtlSetupAdvancedHeader( &NewFcb->Header,
1119  &NewFcb->FcbNonpaged->AdvancedFcbHeaderMutex );
1120 
1121  if (NodeTypeCode == CDFS_NTC_FCB_DATA) {
1122 
1124  }
1125 
1126  } else {
1127 
1128  *FcbExisted = TRUE;
1129  }
1130 
1131  return NewFcb;
1132 }
#define SIZEOF_FCB_INDEX
Definition: cdstruc.h:1065
#define SIZEOF_FCB_DATA
Definition: cdstruc.h:1062
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
Definition: cdstruc.h:908
PFCB CdLookupFcbTable(_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _In_ FILE_ID FileId)
Definition: strucsup.c:2107
#define CdAllocateFcbData(IC)
Definition: strucsup.c:75
#define CDFS_NTC_FCB_PATH_TABLE
Definition: nodetype.h:29
#define CDFS_NTC_FCB_INDEX
Definition: nodetype.h:30
#define PAGED_CODE()
Definition: video.h:57
#define CdBugCheck(A, B, C)
Definition: nodetype.h:103
FAST_MUTEX AdvancedFcbHeaderMutex
Definition: cdstruc.h:898
#define CdGetFcbOplock(F)
Definition: cdprocs.h:1086
#define CDFS_NTC_FCB_DATA
Definition: nodetype.h:31
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define ARGUMENT_PRESENT(ArgumentPointer)
VOID NTAPI FsRtlInitializeOplock(IN OUT POPLOCK Oplock)
Definition: oplock.c:1402
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
#define CdFreePool(x)
Definition: cdprocs.h:2200
PFCB_NONPAGED CdCreateFcbNonpaged(_In_ PIRP_CONTEXT IrpContext)
Definition: strucsup.c:2555
#define CdRaiseStatus(IC, S)
Definition: cdprocs.h:1869
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
FILE_ID FileId
Definition: cdstruc.h:958
#define CdAllocateFcbIndex(IC)
Definition: strucsup.c:81
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PVCB Vcb
Definition: cdstruc.h:939
PFCB_NONPAGED FcbNonpaged
Definition: cdstruc.h:1009

Referenced by _Requires_lock_held_(), and CdUpdateVcbFromVolDescriptor().

◆ CdCreateFcbNonpaged()

PFCB_NONPAGED CdCreateFcbNonpaged ( _In_ PIRP_CONTEXT  IrpContext)

Definition at line 2555 of file strucsup.c.

2574 {
2575  PFCB_NONPAGED FcbNonpaged;
2576 
2577  PAGED_CODE();
2578 
2579  UNREFERENCED_PARAMETER( IrpContext );
2580 
2581  //
2582  // Allocate the non-paged pool and initialize the various
2583  // synchronization objects.
2584  //
2585 
2586  FcbNonpaged = CdAllocateFcbNonpaged( IrpContext );
2587 
2588  if (FcbNonpaged != NULL) {
2589 
2590  RtlZeroMemory( FcbNonpaged, sizeof( FCB_NONPAGED ));
2591 
2592  FcbNonpaged->NodeTypeCode = CDFS_NTC_FCB_NONPAGED;
2593  FcbNonpaged->NodeByteSize = sizeof( FCB_NONPAGED );
2594 
2595  ExInitializeResourceLite( &FcbNonpaged->FcbResource );
2596  ExInitializeFastMutex( &FcbNonpaged->FcbMutex );
2597  }
2598 
2599  return FcbNonpaged;
2600 }
struct _FCB_NONPAGED FCB_NONPAGED
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
#define PAGED_CODE()
Definition: video.h:57
NODE_BYTE_SIZE NodeByteSize
Definition: cdstruc.h:869
smooth NULL
Definition: ftsmooth.c:416
#define CdAllocateFcbNonpaged(IC)
Definition: strucsup.c:87
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
FAST_MUTEX FcbMutex
Definition: cdstruc.h:891
ERESOURCE FcbResource
Definition: cdstruc.h:885
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define CDFS_NTC_FCB_NONPAGED
Definition: nodetype.h:32

Referenced by CdCreateFcb().

◆ CdCreateIrpContext()

_Ret_valid_ PIRP_CONTEXT CdCreateIrpContext ( _In_ PIRP  Irp,
_In_ BOOLEAN  Wait 
)

Definition at line 1573 of file strucsup.c.

1598 {
1599  PIRP_CONTEXT NewIrpContext = NULL;
1601 
1602  PAGED_CODE();
1603 
1604  //
1605  // The only operations a filesystem device object should ever receive
1606  // are create/teardown of fsdo handles and operations which do not
1607  // occur in the context of fileobjects (i.e., mount).
1608  //
1609 
1610 #ifndef __REACTOS__
1612 #else
1614  IrpSp->DeviceObject == CdData.HddFileSystemDeviceObject) {
1615 #endif
1616 
1617  if (IrpSp->FileObject != NULL &&
1621 
1623  }
1624 
1625  NT_ASSERT( IrpSp->FileObject != NULL ||
1626 
1629  IrpSp->Parameters.FileSystemControl.FsControlCode == FSCTL_INVALIDATE_VOLUMES) ||
1630 
1633 
1635  }
1636 
1637  //
1638  // Look in our lookaside list for an IrpContext.
1639  //
1640 
1641  if (CdData.IrpContextDepth) {
1642 
1643  CdLockCdData();
1644  NewIrpContext = (PIRP_CONTEXT) PopEntryList( &CdData.IrpContextList );
1645  if (NewIrpContext != NULL) {
1646 
1648  }
1649 
1650  CdUnlockCdData();
1651  }
1652 
1653  if (NewIrpContext == NULL) {
1654 
1655  //
1656  // We didn't get it from our private list so allocate it from pool.
1657  //
1658 
1659  NewIrpContext = FsRtlAllocatePoolWithTag( CdNonPagedPool, sizeof( IRP_CONTEXT ), TAG_IRP_CONTEXT );
1660  }
1661 
1662  RtlZeroMemory( NewIrpContext, sizeof( IRP_CONTEXT ));
1663 
1664  //
1665  // Set the proper node type code and node byte size
1666  //
1667 
1668  NewIrpContext->NodeTypeCode = CDFS_NTC_IRP_CONTEXT;
1669  NewIrpContext->NodeByteSize = sizeof( IRP_CONTEXT );
1670 
1671  //
1672  // Set the originating Irp field
1673  //
1674 
1675  NewIrpContext->Irp = Irp;
1676 
1677  //
1678  // Copy RealDevice for workque algorithms. We will update this in the Mount or
1679  // Verify since they have no file objects to use here.
1680  //
1681 
1682  if (IrpSp->FileObject != NULL) {
1683 
1684  NewIrpContext->RealDevice = IrpSp->FileObject->DeviceObject;
1685  }
1686 
1687  //
1688  // Locate the volume device object and Vcb that we are trying to access.
1689  // This may be our filesystem device object. In that case don't initialize
1690  // the Vcb field.
1691  //
1692 
1693 #ifndef __REACTOS__
1695 #else
1697  IrpSp->DeviceObject != CdData.HddFileSystemDeviceObject) {
1698 #endif
1699 
1700  NewIrpContext->Vcb = &((PVOLUME_DEVICE_OBJECT) IrpSp->DeviceObject)->Vcb;
1701 
1702  }
1703 
1704  //
1705  // Major/Minor Function codes
1706  //
1707 
1708  NewIrpContext->MajorFunction = IrpSp->MajorFunction;
1709  NewIrpContext->MinorFunction = IrpSp->MinorFunction;
1710 
1711  //
1712  // Set the wait parameter
1713  //
1714 
1715  if (Wait) {
1716 
1717  SetFlag( NewIrpContext->Flags, IRP_CONTEXT_FLAG_WAIT );
1718 
1719  } else {
1720 
1721  SetFlag( NewIrpContext->Flags, IRP_CONTEXT_FLAG_FORCE_POST );
1722  }
1723 
1724  //
1725  // return and tell the caller
1726  //
1727 
1728  return NewIrpContext;
1729 }
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1221
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
PDEVICE_OBJECT FileSystemDeviceObject
Definition: cdstruc.h:356
PVOID NTAPI FsRtlAllocatePoolWithTag(IN POOL_TYPE PoolType, IN ULONG NumberOfBytes, IN ULONG Tag)
Definition: filter.c:229
PIRP Irp
Definition: usbstor.h:298
IRP_CONTEXT * PIRP_CONTEXT
Definition: cdstruc.h:1217
#define IRP_CONTEXT_FLAG_FORCE_POST
Definition: cdstruc.h:1222
#define IRP_MJ_SHUTDOWN
_In_ PIRP Irp
Definition: csq.h:116
#define ExRaiseStatus
Definition: ntoskrnl.h:95
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
VOLUME_DEVICE_OBJECT * PVOLUME_DEVICE_OBJECT
Definition: cdstruc.h:775
#define PAGED_CODE()
Definition: video.h:57
#define FSCTL_INVALIDATE_VOLUMES
Definition: nt_native.h:847
smooth NULL
Definition: ftsmooth.c:416
SINGLE_LIST_ENTRY IrpContextList
Definition: cdstruc.h:350
FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead)
Definition: rtlfuncs.h:240
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4048
#define IRP_MN_USER_FS_REQUEST
Definition: iotypes.h:4047
CD_DATA CdData
Definition: cddata.c:42
#define CdNonPagedPool
Definition: cdprocs.h:1387
#define IRP_MJ_FILE_SYSTEM_CONTROL
#define CdLockCdData()
Definition: cdprocs.h:1020
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2867
struct _IRP_CONTEXT IRP_CONTEXT
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define TAG_IRP_CONTEXT
Definition: cdprocs.h:89
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
ULONG IrpContextDepth
Definition: cdstruc.h:348
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
#define CDFS_NTC_IRP_CONTEXT
Definition: nodetype.h:34
#define IRP_MJ_CLEANUP
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
#define CdUnlockCdData()
Definition: cdprocs.h:1024
IN BOOLEAN Wait
Definition: fatprocs.h:1529
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by _IRQL_requires_max_().

◆ CdDeallocateFcbTable()

VOID NTAPI CdDeallocateFcbTable ( _In_ PRTL_GENERIC_TABLE  FcbTable,
_In_ __drv_freesMem(Mem) _Post_invalid_ PVOID  Buffer 
)

Definition at line 2743 of file strucsup.c.

2765 {
2766  PAGED_CODE();
2767 
2768  CdFreePool( &Buffer );
2769 
2770  UNREFERENCED_PARAMETER( FcbTable );
2771 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define PAGED_CODE()
Definition: video.h:57
Definition: bufpool.h:45
#define CdFreePool(x)
Definition: cdprocs.h:2200

◆ CdDeleteCcb()

VOID CdDeleteCcb ( _In_ PIRP_CONTEXT  IrpContext,
_In_ __drv_freesMem(Pool) PCCB  Ccb 
)

Definition at line 1462 of file strucsup.c.

1482 {
1483  PAGED_CODE();
1484 
1485  UNREFERENCED_PARAMETER( IrpContext );
1486 
1487  if (Ccb->SearchExpression.FileName.Buffer != NULL) {
1488 
1489  CdFreePool( &Ccb->SearchExpression.FileName.Buffer );
1490  }
1491 
1492  CdDeallocateCcb( IrpContext, Ccb );
1493  return;
1494 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
#define CdFreePool(x)
Definition: cdprocs.h:2200
#define CdDeallocateCcb(IC, C)
Definition: strucsup.c:96

◆ CdDeleteFcb()

VOID CdDeleteFcb ( _In_ PIRP_CONTEXT  IrpContext,
_In_ PFCB  Fcb 
)

Definition at line 2424 of file strucsup.c.

2447 {
2448  PVCB Vcb = NULL;
2449  PAGED_CODE();
2450 
2451  //
2452  // Sanity check the counts.
2453  //
2454 
2455  NT_ASSERT( Fcb->FcbCleanup == 0 );
2456  NT_ASSERT( Fcb->FcbReference == 0 );
2457 
2458  //
2459  // Release any Filter Context structures associated with this FCB
2460  //
2461 
2463 
2464  //
2465  // Start with the common structures.
2466  //
2467 
2468  CdUninitializeMcb( IrpContext, Fcb );
2469 
2470  CdDeleteFcbNonpaged( IrpContext, Fcb->FcbNonpaged );
2471 
2472  //
2473  // Check if we need to deallocate the prefix name buffer.
2474  //
2475 
2478 
2480  }
2481 
2482  //
2483  // Now look at the short name prefix.
2484  //
2485 
2486  if (Fcb->ShortNamePrefix != NULL) {
2487 
2489  }
2490 
2491  //
2492  // Now do the type specific structures.
2493  //
2494 
2495  switch (Fcb->NodeTypeCode) {
2496 
2498  case CDFS_NTC_FCB_INDEX:
2499 
2500  NT_ASSERT( Fcb->FileObject == NULL );
2501  NT_ASSERT( IsListEmpty( &Fcb->FcbQueue ));
2502 
2503  if (Fcb == Fcb->Vcb->RootIndexFcb) {
2504 
2505  Vcb = Fcb->Vcb;
2506  Vcb->RootIndexFcb = NULL;
2507 
2508  } else if (Fcb == Fcb->Vcb->PathTableFcb) {
2509 
2510  Vcb = Fcb->Vcb;
2511  Vcb->PathTableFcb = NULL;
2512  }
2513 
2514  CdDeallocateFcbIndex( IrpContext, *(PVOID*)&Fcb );/* ReactOS Change: GCC "passing argument 1 from incompatible pointer type" */
2515  break;
2516 
2517  case CDFS_NTC_FCB_DATA :
2518 
2519  if (Fcb->FileLock != NULL) {
2520 
2522  }
2523 
2525 
2526  if (Fcb == Fcb->Vcb->VolumeDasdFcb) {
2527 
2528  Vcb = Fcb->Vcb;
2529  Vcb->VolumeDasdFcb = NULL;
2530  }
2531 
2532  CdDeallocateFcbData( IrpContext, *(PVOID*)&Fcb );/* ReactOS Change: GCC "passing argument 1 from incompatible pointer type" */
2533  }
2534 
2535  //
2536  // Decrement the Vcb reference count if this is a system
2537  // Fcb.
2538  //
2539 
2540  if (Vcb != NULL) {
2541 
2542  InterlockedDecrement( (LONG*)&Vcb->VcbReference );
2543  InterlockedDecrement( (LONG*)&Vcb->VcbUserReference );
2544  }
2545 
2546  return;
2547 }
FILE_LOCK FileLock
Definition: fatstruc.h:1070
#define CdDeallocateFcbIndex(IC, F)
Definition: strucsup.c:84
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
PFILE_OBJECT FileObject
Definition: ntfs.h:516
Definition: cdstruc.h:504
struct _FCB * RootIndexFcb
Definition: cdstruc.h:566
VOID NTAPI FsRtlUninitializeOplock(IN POPLOCK Oplock)
Definition: oplock.c:1602
uint16_t * PWCHAR
Definition: typedefs.h:54
#define CDFS_NTC_FCB_PATH_TABLE
Definition: nodetype.h:29
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define CDFS_NTC_FCB_INDEX
Definition: nodetype.h:30
#define PAGED_CODE()
Definition: video.h:57
PREFIX_ENTRY FileNamePrefix
Definition: cdstruc.h:1030
#define CdGetFcbOplock(F)
Definition: cdprocs.h:1086
NAME_LINK ExactCaseName
Definition: cdstruc.h:299
long LONG
Definition: pedump.c:60
#define CDFS_NTC_FCB_DATA
Definition: nodetype.h:31
__volatile LONG FcbReference
Definition: cdstruc.h:970
struct _FCB * VolumeDasdFcb
Definition: cdstruc.h:565
smooth NULL
Definition: ftsmooth.c:416
struct _FCB * PathTableFcb
Definition: cdstruc.h:567
VOID NTAPI FsRtlTeardownPerStreamContexts(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader)
Definition: filtrctx.c:368
#define Vcb
Definition: cdprocs.h:1425
#define InterlockedDecrement
Definition: armddk.h:52
VOID CdDeleteFcbNonpaged(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB_NONPAGED FcbNonpaged)
Definition: strucsup.c:2608
#define CdFreePool(x)
Definition: cdprocs.h:2200
#define CdDeallocateFcbData(IC, F)
Definition: strucsup.c:78
PPREFIX_ENTRY ShortNamePrefix
Definition: cdstruc.h:1029
VOID NTAPI FsRtlFreeFileLock(IN PFILE_LOCK FileLock)
Definition: filelock.c:1338
PVCB Vcb
Definition: cdstruc.h:939
_In_ PFCB Fcb
Definition: cdprocs.h:151
PFCB_NONPAGED FcbNonpaged
Definition: cdstruc.h:1009
WCHAR FileNameBuffer[BYTE_COUNT_EMBEDDED_NAME]
Definition: cdstruc.h:307
ULONG FcbCleanup
Definition: cdstruc.h:969
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by _Requires_lock_held_().

◆ CdDeleteFcbNonpaged()

VOID CdDeleteFcbNonpaged ( _In_ PIRP_CONTEXT  IrpContext,
_In_ PFCB_NONPAGED  FcbNonpaged 
)

Definition at line 2608 of file strucsup.c.

2629 {
2630  PAGED_CODE();
2631 
2632  UNREFERENCED_PARAMETER( IrpContext );
2633 
2634  ExDeleteResourceLite( &FcbNonpaged->FcbResource );
2635 
2636  CdDeallocateFcbNonpaged( IrpContext, *(PVOID*)&FcbNonpaged );/* ReactOS Change: GCC "passing argument 1 from incompatible pointer type" */
2637 
2638  return;
2639 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
#define PAGED_CODE()
Definition: video.h:57
#define CdDeallocateFcbNonpaged(IC, FNP)
Definition: strucsup.c:90

Referenced by CdDeleteFcb().

◆ CdDeleteVcb()

VOID CdDeleteVcb ( _In_ PIRP_CONTEXT  IrpContext,
_Inout_ PVCB  Vcb 
)

Definition at line 876 of file strucsup.c.

899 {
900  PAGED_CODE();
901 
904 
905  UNREFERENCED_PARAMETER( IrpContext );
906 
907  //
908  // Chuck the backpocket Vpb we kept just in case.
909  //
910 
911  CdFreePool( &Vcb->SwapVpb );
912 
913  //
914  // If there is a Vpb then we must delete it ourselves.
915  //
916 
917  CdFreePool( &Vcb->Vpb );
918 
919  //
920  // Dereference our target if we haven't already done so.
921  //
922 
923  if (Vcb->TargetDeviceObject != NULL) {
924 
925  ObDereferenceObject( Vcb->TargetDeviceObject );
926  }
927 
928  //
929  // Delete the XA Sector and sector cache buffer if allocated.
930  //
931 
932  CdFreePool( &Vcb->XASector );
933  CdFreePool( &Vcb->SectorCacheBuffer);
934 
935  if (Vcb->SectorCacheIrp != NULL) {
936 
937  IoFreeIrp( Vcb->SectorCacheIrp);
938  Vcb->SectorCacheIrp = NULL;
939 
940  ExDeleteResourceLite( &Vcb->SectorCacheResource);
941  }
942 
943  //
944  // Remove this entry from the global queue.
945  //
946 
947  RemoveEntryList( &Vcb->VcbLinks );
948 
949  //
950  // Delete the Vcb and File resources.
951  //
952 
953  ExDeleteResourceLite( &Vcb->VcbResource );
954  ExDeleteResourceLite( &Vcb->FileResource );
955 
956  //
957  // Delete the TOC if present.
958  //
959 
960  CdFreePool( &Vcb->CdromToc );
961 
962  //
963  // Uninitialize the notify structures.
964  //
965 
966  if (Vcb->NotifySync != NULL) {
967 
968  FsRtlNotifyUninitializeSync( &Vcb->NotifySync );
969  }
970 
971  //
972  // Now delete the volume device object.
973  //
974 #ifdef _MSC_VER
975 #pragma prefast( suppress: __WARNING_BUFFER_UNDERFLOW, "This is ok, the Vcb is embedded in our volume device object, and that is what we are really deleting." )
976 #endif
979  Vcb ));
980 
981  return;
982 }
#define ASSERT_EXCLUSIVE_CDDATA
Definition: cddata.h:258
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define PAGED_CODE()
Definition: video.h:57
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define Vcb
Definition: cdprocs.h:1425
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define CdFreePool(x)
Definition: cdprocs.h:2200
#define ASSERT_EXCLUSIVE_VCB(V)
Definition: cddata.h:259
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
VOID NTAPI FsRtlNotifyUninitializeSync(IN PNOTIFY_SYNC *NotifySync)
Definition: notify.c:1639

◆ CdFcbTableCompare()

RTL_GENERIC_COMPARE_RESULTS NTAPI CdFcbTableCompare ( _In_ PRTL_GENERIC_TABLE  FcbTable,
_In_ PVOID  Fid1,
_In_ PVOID  Fid2 
)

Definition at line 2648 of file strucsup.c.

2676 {
2677  FILE_ID Id1, Id2;
2678  PAGED_CODE();
2679 
2680  Id1 = *((FILE_ID UNALIGNED *) Fid1);
2681  Id2 = *((FILE_ID UNALIGNED *) Fid2);
2682 
2683  if (Id1.QuadPart < Id2.QuadPart) {
2684 
2685  return GenericLessThan;
2686 
2687  } else if (Id1.QuadPart > Id2.QuadPart) {
2688 
2689  return GenericGreaterThan;
2690 
2691  } else {
2692 
2693  return GenericEqual;
2694  }
2695 
2696  UNREFERENCED_PARAMETER( FcbTable );
2697 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define PAGED_CODE()
Definition: video.h:57
#define UNALIGNED
Definition: crtdefs.h:132
LONGLONG QuadPart
Definition: typedefs.h:112

◆ CdGetNextFcb()

PFCB CdGetNextFcb ( _In_ PIRP_CONTEXT  IrpContext,
_In_ PVCB  Vcb,
_In_ PVOID RestartKey 
)

Definition at line 2155 of file strucsup.c.

2182 {
2183  PFCB Fcb;
2184 
2185  PAGED_CODE();
2186 
2187  UNREFERENCED_PARAMETER( IrpContext );
2188 
2189  Fcb = (PFCB) RtlEnumerateGenericTableWithoutSplaying( &Vcb->FcbTable, RestartKey );
2190 
2191  if (Fcb != NULL) {
2192 
2193  Fcb = ((PFCB_TABLE_ELEMENT)(Fcb))->Fcb;
2194  }
2195 
2196  return Fcb;
2197 }
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlEnumerateGenericTableWithoutSplaying(_In_ PRTL_GENERIC_TABLE Table, _Inout_ PVOID *RestartKey)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
Definition: cdstruc.h:908
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
FCB * PFCB
Definition: cdstruc.h:1046
#define Vcb
Definition: cdprocs.h:1425
struct _FCB_TABLE_ELEMENT * PFCB_TABLE_ELEMENT
_In_ PFCB Fcb
Definition: cdprocs.h:151

Referenced by _Requires_lock_held_().

◆ CdInitializeFcbFromFileContext()

VOID CdInitializeFcbFromFileContext ( _In_ PIRP_CONTEXT  IrpContext,
_Inout_ PFCB  Fcb,
_In_ PFCB  ParentFcb,
_In_ PFILE_ENUM_CONTEXT  FileContext 
)

Definition at line 1225 of file strucsup.c.

1257 {
1258  PDIRENT ThisDirent = &FileContext->InitialDirent->Dirent;
1259  PCOMPOUND_DIRENT CurrentCompoundDirent;
1260 
1261  LONGLONG CurrentFileOffset;
1262  ULONG CurrentMcbEntryOffset;
1263 
1264  PAGED_CODE();
1265 
1266  //
1267  // Use a try-finally to facilitate cleanup.
1268  //
1269 
1270  CdLockFcb( IrpContext, Fcb );
1271 
1272  _SEH2_TRY {
1273 
1274  //
1275  // Initialize the common header in the Fcb. The node type is already
1276  // present.
1277  //
1278 
1279  Fcb->Resource = &IrpContext->Vcb->FileResource;
1280 
1281  //
1282  // Allocation occurs in block-sized units.
1283  //
1284 
1285  Fcb->FileSize.QuadPart =
1286  Fcb->ValidDataLength.QuadPart = FileContext->FileSize;
1287 
1288  Fcb->AllocationSize.QuadPart = LlBlockAlign( Fcb->Vcb, FileContext->FileSize );
1289 
1290  //
1291  // Set the flags from the dirent. We always start with the read-only bit.
1292  //
1293 
1295  if (FlagOn( ThisDirent->DirentFlags, CD_ATTRIBUTE_HIDDEN )) {
1296 
1298  }
1299 
1300  //
1301  // Convert the time to NT time.
1302  //
1303 
1304  CdConvertCdTimeToNtTime( IrpContext,
1305  ThisDirent->CdTime,
1307 
1308  //
1309  // Set the flag indicating the type of extent.
1310  //
1311 
1312  if (ThisDirent->ExtentType != Form1Data) {
1313 
1314  if (ThisDirent->ExtentType == Mode2Form2Data) {
1315 
1317 
1318  } else {
1319 
1321  }
1322 
1323  Fcb->XAAttributes = ThisDirent->XAAttributes;
1324  Fcb->XAFileNumber = ThisDirent->XAFileNumber;
1325  }
1326 
1327  //
1328  // Read through all of the dirents for the file until we find the last
1329  // and add the allocation into the Mcb.
1330  //
1331 
1332  CurrentCompoundDirent = FileContext->InitialDirent;
1333  CurrentFileOffset = 0;
1334  CurrentMcbEntryOffset = 0;
1335 
1336  while (TRUE) {
1337 
1338  CdAddAllocationFromDirent( IrpContext,
1339  Fcb,
1340  CurrentMcbEntryOffset,
1341  CurrentFileOffset,
1342  &CurrentCompoundDirent->Dirent );
1343 
1344  //
1345  // Break out if we are at the last dirent.
1346  //
1347 
1348  if (!FlagOn( CurrentCompoundDirent->Dirent.DirentFlags, CD_ATTRIBUTE_MULTI )) {
1349 
1350  break;
1351  }
1352 
1353  CurrentFileOffset += CurrentCompoundDirent->Dirent.DataLength;
1354  CurrentMcbEntryOffset += 1;
1355 
1356  //
1357  // We better be able to find the next dirent.
1358  //
1359 
1360  if (!CdLookupNextDirent( IrpContext,
1361  ParentFcb,
1362  &CurrentCompoundDirent->DirContext,
1363  &FileContext->CurrentDirent->DirContext )) {
1364 
1366  }
1367 
1368  CurrentCompoundDirent = FileContext->CurrentDirent;
1369 
1370  CdUpdateDirentFromRawDirent( IrpContext,
1371  ParentFcb,
1372  &CurrentCompoundDirent->DirContext,
1373  &CurrentCompoundDirent->Dirent );
1374  }
1375 
1376  //
1377  // Show that the Fcb is initialized.
1378  //
1379 
1381 
1382  //
1383  // Link into the other in-memory structures and into the Fcb table.
1384  //
1385 
1386  Fcb->ParentFcb = ParentFcb;
1387 
1388  InsertTailList( &ParentFcb->FcbQueue, &Fcb->FcbLinks );
1389 
1390  CdIncrementReferenceCounts( IrpContext, ParentFcb, 1, 1 );
1391 
1392  CdInsertFcbTable( IrpContext, Fcb );
1394 
1395  } _SEH2_FINALLY {
1396 
1397  CdUnlockFcb( IrpContext, Fcb );
1398  } _SEH2_END;
1399 
1400  return;
1401 }
ULONG DataLength
Definition: cdstruc.h:1606
LONGLONG CreationTime
Definition: cdstruc.h:1036
#define CdInsertFcbTable(IC, F)
Definition: strucsup.c:129
#define FCB_STATE_INITIALIZED
Definition: cdstruc.h:1048
#define TRUE
Definition: types.h:120
#define CD_ATTRIBUTE_HIDDEN
Definition: cd.h:353
Definition: cd.h:524
PCHAR CdTime
Definition: cdstruc.h:1613
ULONG FileAttributes
Definition: cdstruc.h:983
DIRENT_ENUM_CONTEXT DirContext
Definition: cdstruc.h:1689
#define InsertTailList(ListHead, Entry)
ERESOURCE FileResource
Definition: cdstruc.h:596
#define PAGED_CODE()
Definition: video.h:57
#define CdUnlockFcb(IC, F)
Definition: cdprocs.h:1065
_SEH2_TRY
Definition: create.c:4250
#define STATUS_FILE_CORRUPT_ERROR
Definition: udferr_usr.h:168
VOID CdAddAllocationFromDirent(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_ ULONG McbEntryOffset, _In_ LONGLONG StartingFileOffset, _In_ PDIRENT Dirent)
Definition: allocsup.c:335
#define FCB_STATE_IN_FCB_TABLE
Definition: cdstruc.h:1049
BOOLEAN CdLookupNextDirent(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _In_ PDIRENT_ENUM_CONTEXT CurrentDirContext, _Inout_ PDIRENT_ENUM_CONTEXT NextDirContext)
Definition: dirsup.c:208
#define FCB_STATE_MODE2FORM2_FILE
Definition: cdstruc.h:1050
UCHAR DirentFlags
Definition: cdstruc.h:1619
_In_ PFCB _In_ PCD_NAME _In_ BOOLEAN _Inout_ PFILE_ENUM_CONTEXT FileContext
Definition: cdprocs.h:444
#define LlBlockAlign(V, L)
Definition: cdprocs.h:1656
int64_t LONGLONG
Definition: typedefs.h:66
#define CD_ATTRIBUTE_MULTI
Definition: cd.h:356
#define FCB_STATE_DA_FILE
Definition: cdstruc.h:1052
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
XA_EXTENT_TYPE ExtentType
Definition: cdstruc.h:1669
_In_ PFCB ParentFcb
Definition: cdprocs.h:741
USHORT XAAttributes
Definition: cdstruc.h:1645
#define CdConvertCdTimeToNtTime(IC, CD, NT)
Definition: cd.h:394
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
LIST_ENTRY FcbLinks
Definition: cdstruc.h:952
UCHAR XAFileNumber
Definition: cdstruc.h:995
#define CdLockFcb(IC, F)
Definition: cdprocs.h:1049
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
#define CdRaiseStatus(IC, S)
Definition: cdprocs.h:1869
_SEH2_FINALLY
Definition: create.c:4395
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
unsigned int ULONG
Definition: retypes.h:1
#define CdIncrementReferenceCounts(IC, F, C, UC)
Definition: cdprocs.h:1322
PVCB Vcb
Definition: cdstruc.h:939
struct _FCB * ParentFcb
Definition: cdstruc.h:946
_In_ PFCB Fcb
Definition: cdprocs.h:151
UCHAR XAFileNumber
Definition: cdstruc.h:1646
ULONG FcbState
Definition: cdstruc.h:977
USHORT XAAttributes
Definition: cdstruc.h:989

Referenced by _Requires_lock_held_().

◆ CdInitializeFcbFromPathEntry()

VOID CdInitializeFcbFromPathEntry ( _In_ PIRP_CONTEXT  IrpContext,
_Inout_ PFCB  Fcb,
_In_opt_ PFCB  ParentFcb,
_In_ PPATH_ENTRY  PathEntry 
)

Definition at line 1136 of file strucsup.c.

1167 {
1168  PAGED_CODE();
1169 
1170  //
1171  // Fill in the Index specific fields of the Fcb.
1172  //
1173 
1174  Fcb->StreamOffset = BytesFromBlocks( Fcb->Vcb,
1175  SectorBlockOffset( Fcb->Vcb, PathEntry->DiskOffset ));
1176 
1177  Fcb->Ordinal = PathEntry->Ordinal;
1178 
1179  //
1180  // Initialize the common header in the Fcb. The node type is already
1181  // present.
1182  //
1183 
1184  Fcb->Resource = &Fcb->Vcb->FileResource;
1185 
1186  //
1187  // Always set the sizes to one sector until we read the self-entry.
1188  //
1189 
1190  Fcb->AllocationSize.QuadPart =
1191  Fcb->FileSize.QuadPart =
1192  Fcb->ValidDataLength.QuadPart = SECTOR_SIZE;
1193 
1194  CdAddInitialAllocation( IrpContext,
1195  Fcb,
1196  PathEntry->DiskOffset,
1197  SECTOR_SIZE );
1198  //
1199  // State flags for this Fcb.
1200  //
1201 
1203 
1204  //
1205  // Link into the other in-memory structures and into the Fcb table.
1206  //
1207 
1208  if (ParentFcb != NULL) {
1209 
1210  Fcb->ParentFcb = ParentFcb;
1211 
1212  InsertTailList( &ParentFcb->FcbQueue, &Fcb->FcbLinks );
1213 
1214  CdIncrementReferenceCounts( IrpContext, ParentFcb, 1, 1 );
1215  }
1216 
1217  CdInsertFcbTable( IrpContext, Fcb );
1219 
1220  return;
1221 }
#define CdInsertFcbTable(IC, F)
Definition: strucsup.c:129
#define SectorBlockOffset(V, LB)
Definition: cdprocs.h:1636
ULONG FileAttributes
Definition: cdstruc.h:983
#define InsertTailList(ListHead, Entry)
ERESOURCE FileResource
Definition: cdstruc.h:596
#define PAGED_CODE()
Definition: video.h:57
#define FCB_STATE_IN_FCB_TABLE
Definition: cdstruc.h:1049
smooth NULL
Definition: ftsmooth.c:416
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define BytesFromBlocks(V, B)
Definition: cdprocs.h:1640
_In_ PFCB ParentFcb
Definition: cdprocs.h:741
LIST_ENTRY FcbLinks
Definition: cdstruc.h:952
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
VOID CdAddInitialAllocation(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_ ULONG StartingBlock, _In_ LONGLONG DataLength)
Definition: allocsup.c:484
#define CdIncrementReferenceCounts(IC, F, C, UC)
Definition: cdprocs.h:1322
PVCB Vcb
Definition: cdstruc.h:939
struct _FCB * ParentFcb
Definition: cdstruc.h:946
#define SECTOR_SIZE
Definition: fs.h:22
_In_ PFCB Fcb
Definition: cdprocs.h:151
ULONG FcbState
Definition: cdstruc.h:977

Referenced by _Requires_lock_held_(), and CdUpdateVcbFromVolDescriptor().

◆ CdInitializeStackIrpContext()

VOID CdInitializeStackIrpContext ( _Out_ PIRP_CONTEXT  IrpContext,
_In_ PIRP_CONTEXT_LITE  IrpContextLite 
)

Definition at line 1839 of file strucsup.c.

1864 {
1865  PAGED_CODE();
1866 
1867  //
1868  // Zero and then initialize the structure.
1869  //
1870 
1871  RtlZeroMemory( IrpContext, sizeof( IRP_CONTEXT ));
1872 
1873  //
1874  // Set the proper node type code and node byte size
1875  //
1876 
1877  IrpContext->NodeTypeCode = CDFS_NTC_IRP_CONTEXT;
1878  IrpContext->NodeByteSize = sizeof( IRP_CONTEXT );
1879 
1880  //
1881  // Note that this is from the stack.
1882  //
1883 
1884  SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_ON_STACK );
1885 
1886  //
1887  // Copy RealDevice for workque algorithms.
1888  //
1889 
1890  IrpContext->RealDevice = IrpContextLite->RealDevice;
1891 
1892  //
1893  // The Vcb is found in the Fcb.
1894  //
1895 
1896  IrpContext->Vcb = IrpContextLite->Fcb->Vcb;
1897 
1898  //
1899  // Major/Minor Function codes
1900  //
1901 
1902  IrpContext->MajorFunction = IRP_MJ_CLOSE;
1903 
1904  //
1905  // Set the wait parameter
1906  //
1907 
1908  SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT );
1909 
1910  return;
1911 }
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1221
#define PAGED_CODE()
Definition: video.h:57
#define IRP_CONTEXT_FLAG_ON_STACK
Definition: cdstruc.h:1219
struct _IRP_CONTEXT IRP_CONTEXT
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define CDFS_NTC_IRP_CONTEXT
Definition: nodetype.h:34
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

◆ CdInitializeVcb()

VOID CdInitializeVcb ( _In_ PIRP_CONTEXT  IrpContext,
_Inout_ PVCB  Vcb,
_In_ __drv_aliasesMem PDEVICE_OBJECT  TargetDeviceObject,
_In_ __drv_aliasesMem PVPB  Vpb,
_In_ __drv_aliasesMem PCDROM_TOC_LARGE  CdromToc,
_In_ ULONG  TocLength,
_In_ ULONG  TocTrackCount,
_In_ ULONG  TocDiskFlags,
_In_ ULONG  BlockFactor,
_In_ ULONG  MediaChangeCount 
)

Definition at line 241 of file strucsup.c.

292 {
293  PAGED_CODE();
294 
295  UNREFERENCED_PARAMETER( IrpContext );
296 
297  //
298  // We start by first zeroing out all of the VCB, this will guarantee
299  // that any stale data is wiped clean.
300  //
301 
302  RtlZeroMemory( Vcb, sizeof( VCB ));
303 
304  //
305  // Set the proper node type code and node byte size.
306  //
307 
308  Vcb->NodeTypeCode = CDFS_NTC_VCB;
309  Vcb->NodeByteSize = sizeof( VCB );
310 
311  //
312  // Initialize the DirNotify structs. FsRtlNotifyInitializeSync can raise.
313  //
314 
315  InitializeListHead( &Vcb->DirNotifyList );
316  FsRtlNotifyInitializeSync( &Vcb->NotifySync );
317 
318  //
319  // Pick up a VPB right now so we know we can pull this filesystem stack
320  // off of the storage stack on demand. This can raise - if it does,
321  // uninitialize the notify structures before returning.
322  //
323 
324  _SEH2_TRY {
325 
327  sizeof( VPB ),
328  TAG_VPB );
329  }
330  _SEH2_FINALLY {
331 
333 
334  FsRtlNotifyUninitializeSync( &Vcb->NotifySync );
335  }
336  } _SEH2_END;
337 
338  //
339  // Nothing beyond this point should raise.
340  //
341 
342  RtlZeroMemory( Vcb->SwapVpb, sizeof( VPB ) );
343 
344  //
345  // Initialize the resource variable for the Vcb and files.
346  //
347 
348  ExInitializeResourceLite( &Vcb->VcbResource );
349  ExInitializeResourceLite( &Vcb->FileResource );
350  ExInitializeFastMutex( &Vcb->VcbMutex );
351 
352  //
353  // Insert this Vcb record on the CdData.VcbQueue.
354  //
355 
356  InsertHeadList( &CdData.VcbQueue, &Vcb->VcbLinks );
357 
358  //
359  // Set the Target Device Object and Vpb fields, referencing the
360  // Target device for the mount.
361  //
362 
364  Vcb->TargetDeviceObject = TargetDeviceObject;
365  Vcb->Vpb = Vpb;
366 
367  //
368  // Set the removable media flag based on the real device's
369  // characteristics
370  //
371 
372  if (FlagOn( Vpb->RealDevice->Characteristics, FILE_REMOVABLE_MEDIA )) {
373 
374  SetFlag( Vcb->VcbState, VCB_STATE_REMOVABLE_MEDIA );
375  }
376 
377  //
378  // Initialize the generic Fcb Table.
379  //
380 
381  RtlInitializeGenericTable( &Vcb->FcbTable,
385  NULL );
386 
387  //
388  // Show that we have a mount in progress.
389  //
390 
392 
393  //
394  // Refererence the Vcb for two reasons. The first is a reference
395  // that prevents the Vcb from going away on the last close unless
396  // dismount has already occurred. The second is to make sure
397  // we don't go into the dismount path on any error during mount
398  // until we get to the Mount cleanup.
399  //
400 
401  Vcb->VcbReference = 1 + CDFS_RESIDUAL_REFERENCE;
402 
403  //
404  // Update the TOC information in the Vcb.
405  //
406 
407  Vcb->CdromToc = CdromToc;
408  Vcb->TocLength = TocLength;
409  Vcb->TrackCount = TocTrackCount;
410  Vcb->DiskFlags = TocDiskFlags;
411 
412  //
413  // If this disk contains audio tracks only then set the audio flag.
414  //
415 
416  if (TocDiskFlags == CDROM_DISK_AUDIO_TRACK) {
417 
419  }
420 
421  //
422  // Set the block factor.
423  //
424 
425  Vcb->BlockFactor = BlockFactor;
426 
427  //
428  // Set the media change count on the device
429  //
430 
431  CdUpdateMediaChangeCount( Vcb, MediaChangeCount);
432 }
RTL_GENERIC_COMPARE_ROUTINE * PRTL_GENERIC_COMPARE_ROUTINE
Definition: rtltypes.h:448
#define VCB_STATE_AUDIO_DISK
Definition: cdstruc.h:718
RTL_GENERIC_ALLOCATE_ROUTINE * PRTL_GENERIC_ALLOCATE_ROUTINE
Definition: rtltypes.h:457
PVOID NTAPI FsRtlAllocatePoolWithTag(IN POOL_TYPE PoolType, IN ULONG NumberOfBytes, IN ULONG Tag)
Definition: filter.c:229
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
Definition: cdstruc.h:504
#define TAG_VPB
Definition: cdprocs.h:98
VOID NTAPI RtlInitializeGenericTable(IN PRTL_GENERIC_TABLE Table, IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine, IN PVOID TableContext)
Definition: generictable.c:100
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
struct _VCB VCB
RTL_GENERIC_FREE_ROUTINE * PRTL_GENERIC_FREE_ROUTINE
Definition: rtltypes.h:465
#define FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
RTL_GENERIC_COMPARE_ROUTINE CdFcbTableCompare
Definition: strucsup.c:167
smooth NULL
Definition: ftsmooth.c:416
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:13
RTL_GENERIC_ALLOCATE_ROUTINE CdAllocateFcbTable
Definition: strucsup.c:178
CD_DATA CdData
Definition: cddata.c:42
#define CdNonPagedPool
Definition: cdprocs.h:1387
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
#define Vcb
Definition: cdprocs.h:1425
#define CDFS_NTC_VCB
Definition: nodetype.h:28
RTL_GENERIC_FREE_ROUTINE CdDeallocateFcbTable
Definition: strucsup.c:188
#define CDFS_RESIDUAL_REFERENCE
Definition: cddata.h:43
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define VCB_STATE_CDXA
Definition: cdstruc.h:717
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
#define VCB_STATE_REMOVABLE_MEDIA
Definition: cdstruc.h:716
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_SEH2_FINALLY
Definition: create.c:4395
LIST_ENTRY VcbQueue
Definition: cdstruc.h:340
VOID NTAPI FsRtlNotifyInitializeSync(IN PNOTIFY_SYNC *NotifySync)
Definition: notify.c:1561
Definition: iotypes.h:166
#define ObReferenceObject
Definition: obfuncs.h:204
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define CDROM_DISK_AUDIO_TRACK
Definition: ntddcdrm.h:112
VOID NTAPI FsRtlNotifyUninitializeSync(IN PNOTIFY_SYNC *NotifySync)
Definition: notify.c:1639
IN OUT PVCB IN PDEVICE_OBJECT TargetDeviceObject
Definition: fatprocs.h:1664
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664
#define CdUpdateMediaChangeCount(V, C)
Definition: cdprocs.h:1458
#define CdUpdateVcbCondition(V, C)
Definition: cdprocs.h:1459

◆ CdLookupFcbTable()

PFCB CdLookupFcbTable ( _In_ PIRP_CONTEXT  IrpContext,
_In_ PVCB  Vcb,
_In_ FILE_ID  FileId 
)

Definition at line 2107 of file strucsup.c.

2132 {
2134  PFCB_TABLE_ELEMENT Hit;
2135  PFCB ReturnFcb = NULL;
2136 
2137  PAGED_CODE();
2138 
2139  Key.FileId = FileId;
2140 
2141  Hit = (PFCB_TABLE_ELEMENT) RtlLookupElementGenericTable( &Vcb->FcbTable, &Key );
2142 
2143  if (Hit != NULL) {
2144 
2145  ReturnFcb = Hit->Fcb;
2146  }
2147 
2148  return ReturnFcb;
2149 
2150  UNREFERENCED_PARAMETER( IrpContext );
2151 }
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ULONG Key
Definition: fatprocs.h:2697
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
Definition: cdstruc.h:908
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlLookupElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ PVOID Buffer)
#define Vcb
Definition: cdprocs.h:1425
struct _FCB_TABLE_ELEMENT * PFCB_TABLE_ELEMENT

Referenced by _Requires_lock_held_(), and CdCreateFcb().

◆ CdProcessToc()

NTSTATUS CdProcessToc ( _In_ PIRP_CONTEXT  IrpContext,
_In_ PDEVICE_OBJECT  TargetDeviceObject,
_In_ PCDROM_TOC_LARGE  CdromToc,
_Inout_ PULONG  Length,
_Out_ PULONG  TrackCount,
_Inout_ PULONG  DiskFlags 
)

Definition at line 2201 of file strucsup.c.

2237 {
2238  NTSTATUS Status;
2241 
2242  ULONG CurrentTrack;
2243  ULONG LocalTrackCount;
2244  ULONG LocalTocLength;
2245  ULONG Address = 0;
2246  BOOLEAN UseReadToc = FALSE;
2247 
2248  union {
2249 
2250  UCHAR BigEndian[2];
2251  USHORT Length;
2252 
2253  } BiasedTocLength;
2254 
2256 
2257  PAGED_CODE();
2258 
2259  //
2260  // Zero the command block. This conveniently corresponds to an
2261  // LBA mode READ_TOC request.
2262  //
2263 
2264  RtlZeroMemory( &Command, sizeof( Command));
2265 
2266 RetryReadToc:
2267 
2268  //
2269  // Go ahead and read the table of contents
2270  //
2271 
2272  Status = CdPerformDevIoCtrlEx( IrpContext,
2275  &Command,
2276  sizeof( Command ),
2277  CdromToc,
2278  sizeof( CDROM_TOC_LARGE ),
2279  FALSE,
2280  TRUE,
2281  &Iosb );
2282 
2283  //
2284  // Nothing to process if this request fails.
2285  //
2286 
2287  if (!NT_SUCCESS( Status )) {
2288 
2289  //
2290  // If the underlying device does not support READ_TOC_EX, try the old method.
2291  //
2292 
2293  if (!UseReadToc &&
2295  (Status == STATUS_NOT_IMPLEMENTED) || /* ReactOS Change: we return STATUS_NOT_IMPLEMENTED for IOCTL_CDROM_READ_TOC_EX */
2297 
2298  UseReadToc = TRUE;
2299  goto RetryReadToc;
2300  }
2301 
2302  return Status;
2303  }
2304 
2305  //
2306  // Get the number of tracks and stated size of this structure.
2307  //
2308 
2309  CurrentTrack = 0;
2310  LocalTrackCount = CdromToc->LastTrack - CdromToc->FirstTrack + 1;
2311  LocalTocLength = PtrOffset( CdromToc, &CdromToc->TrackData[LocalTrackCount + 1] );
2312 
2313  //
2314  // Get out if there is an immediate problem with the TOC.
2315  //
2316 
2317  if ((LocalTocLength > Iosb.Information) ||
2318  (CdromToc->FirstTrack > CdromToc->LastTrack)) {
2319 
2321  return Status;
2322  }
2323 
2324  //
2325  // Walk through the individual tracks. Stop at the first data track after
2326  // any lead-in audio tracks.
2327  //
2328 
2329  do {
2330 
2331  //
2332  // Get the next track.
2333  //
2334 
2335  Track = &CdromToc->TrackData[CurrentTrack];
2336 
2337  //
2338  // If this is a data track then check if we have only seen audio tracks
2339  // to this point.
2340  //
2341 
2342  if (FlagOn( Track->Control, TOC_DATA_TRACK )) {
2343 
2344  //
2345  // If we have only seen audio tracks then assume this is a
2346  // CD+ disk. Hide the current data track and only return
2347  // the previous audio tracks. Set the disk type to be mixed
2348  // data/audio.
2349  //
2350 
2351  if (FlagOn( *DiskFlags, CDROM_DISK_AUDIO_TRACK ) &&
2352  !FlagOn( *DiskFlags, CDROM_DISK_DATA_TRACK )) {
2353 
2354  //
2355  // Remove one track from the TOC.
2356  //
2357 
2358  CdromToc->LastTrack -= 1;
2359 
2360  //
2361  // Knock 2.5 minutes off the current track to hide the final leadin.
2362  // 2.5 min = 150 sec = (x 75) 11250 frames (sectors).
2363  //
2364 
2365  SwapCopyUchar4( &Address, &Track->Address);
2366  Address -= 11250;
2367  SwapCopyUchar4( &Track->Address, &Address);
2368 
2369  Track->TrackNumber = TOC_LAST_TRACK;
2370 
2371  //
2372  // Set the disk type to mixed data/audio.
2373  //
2374 
2375  SetFlag( *DiskFlags, CDROM_DISK_DATA_TRACK );
2376 
2377  break;
2378  }
2379 
2380  //
2381  // Set the flag to indicate data tracks present.
2382  //
2383 
2384  SetFlag( *DiskFlags, CDROM_DISK_DATA_TRACK );
2385 
2386  //
2387  // If this is a audio track then set the flag indicating audio
2388  // tracks.
2389  //
2390 
2391  } else {
2392 
2393  SetFlag( *DiskFlags, CDROM_DISK_AUDIO_TRACK );
2394  }
2395 
2396  //
2397  // Set our index for the next track.
2398  //
2399 
2400  CurrentTrack += 1;
2401 
2402  } while (CurrentTrack < LocalTrackCount);
2403 
2404  //
2405  // Set the length to point just past the last track we looked at.
2406  //
2407 
2408  *TrackCount = CurrentTrack;
2409  *Length = PtrOffset( CdromToc, &CdromToc->TrackData[CurrentTrack + 1] );
2410  BiasedTocLength.Length = (USHORT) *Length - 2;
2411 
2412  CdromToc->Length[0] = BiasedTocLength.BigEndian[1];
2413  CdromToc->Length[1] = BiasedTocLength.BigEndian[0];
2414 
2415  return Status;
2416 }
#define TRUE
Definition: types.h:120
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define PtrOffset(BASE, OFFSET)
Definition: cdprocs.h:1557
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define Track(x, y)
Definition: memtrack.h:11
LONG NTSTATUS
Definition: precomp.h:26
#define SwapCopyUchar4(Dst, Src)
Definition: cdprocs.h:1729
NTSTATUS CdPerformDevIoCtrlEx(_In_ PIRP_CONTEXT IrpContext, _In_ ULONG IoControlCode, _In_ PDEVICE_OBJECT Device, _In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer, _In_ ULONG InputBufferLength, _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer, _In_ ULONG OutputBufferLength, _In_ BOOLEAN InternalDeviceIoControl, _In_ BOOLEAN OverrideVerify, _Out_opt_ PIO_STATUS_BLOCK Iosb)
Definition: deviosup.c:1329
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
Definition: shell.h:41
#define PAGED_CODE()
Definition: video.h:57
unsigned char BOOLEAN
static WCHAR Address[46]
Definition: ping.c:68
#define TOC_DATA_TRACK
Definition: cd.h:99
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct Command Command
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char UCHAR
Definition: xmlstorage.h:181
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
Status
Definition: gdiplustypes.h:24
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define TOC_LAST_TRACK
Definition: cd.h:100
unsigned short USHORT
Definition: pedump.c:61
#define IOCTL_CDROM_READ_TOC_EX
Definition: ntddcdrm.h:76
#define CDROM_DISK_DATA_TRACK
Definition: ntddcdrm.h:113
#define STATUS_DISK_CORRUPT_ERROR
Definition: udferr_usr.h:147
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define CDROM_DISK_AUDIO_TRACK
Definition: ntddcdrm.h:112
#define IOCTL_CDROM_READ_TOC
Definition: ntddcdrm.h:73
IN OUT PVCB IN PDEVICE_OBJECT TargetDeviceObject
Definition: fatprocs.h:1664

◆ CdTocSerial()

ULONG CdTocSerial ( _In_ PIRP_CONTEXT  IrpContext,
_In_ PCDROM_TOC_LARGE  CdromToc 
)

Definition at line 2779 of file strucsup.c.

2807 {
2808  ULONG SerialNumber = 0;
2809  PTRACK_DATA ThisTrack;
2810  PTRACK_DATA LastTrack;
2811  ULONG Address;
2812  ULONG MsfAddress = 0; // satisfy PREFIX
2813 
2814  PAGED_CODE();
2815 
2816  UNREFERENCED_PARAMETER( IrpContext );
2817 
2818  //
2819  // Check if there are two tracks or fewer.
2820  //
2821 
2822  LastTrack = &CdromToc->TrackData[ CdromToc->LastTrack - CdromToc->FirstTrack + 1];
2823  ThisTrack = &CdromToc->TrackData[0];
2824 
2825  if (CdromToc->LastTrack - CdromToc->FirstTrack <= 1) {
2826 
2827  SwapCopyUchar4( &Address, LastTrack->Address);
2829  }
2830  else {
2831 
2832  //
2833  // Add the starting offset of each track and add to the serial number.
2834  //
2835 
2836  while (ThisTrack != LastTrack) {
2837 
2838  SwapCopyUchar4( &Address, ThisTrack->Address);
2839  CdLbnToMmSsFf( Address, (PUCHAR)&MsfAddress);
2840 
2841  SerialNumber += MsfAddress;
2842  ThisTrack += 1;
2843  }
2844  }
2845 
2846  return SerialNumber;
2847 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
unsigned char * PUCHAR
Definition: retypes.h:3
#define SwapCopyUchar4(Dst, Src)
Definition: cdprocs.h:1729
UCHAR Address[4]
Definition: ntddcdrm.h:108
VOID CdLbnToMmSsFf(_In_ ULONG Blocks, _Out_writes_(3) PUCHAR Msf)
#define PAGED_CODE()
Definition: video.h:57
static WCHAR Address[46]
Definition: ping.c:68
ULONG SerialNumber
Definition: rxce.c:117
unsigned int ULONG
Definition: retypes.h:1

Referenced by CdUpdateVcbFromVolDescriptor().

◆ CdUpdateVcbFromVolDescriptor()

VOID CdUpdateVcbFromVolDescriptor ( _In_ PIRP_CONTEXT  IrpContext,
_Inout_ PVCB  Vcb,
_In_reads_bytes_opt_(SECTOR_SIZE) PCHAR  RawIsoVd 
)

Definition at line 436 of file strucsup.c.

463 {
464  ULONG StartingBlock;
466 
467  LONGLONG FileId = 0;
468 
469  PRAW_DIRENT RawDirent;
470  PATH_ENTRY PathEntry;
471  PCD_MCB_ENTRY McbEntry;
472 
473  BOOLEAN UnlockVcb = FALSE;
474 
475  PAGED_CODE();
476 
477  //
478  // Use a try-finally to facilitate cleanup.
479  //
480 
481  _SEH2_TRY {
482 
483  //
484  // Copy the block size and compute the various block masks.
485  // Block size must not be larger than the sector size. We will
486  // use a default of the CD physical sector size if we are not
487  // on a data-full disc.
488  //
489  // This must always be set.
490  //
491 
492  Vcb->BlockSize = ( ARGUMENT_PRESENT( RawIsoVd ) ?
493  CdRvdBlkSz( RawIsoVd, Vcb->VcbState ) :
494  SECTOR_SIZE );
495 
496  //
497  // We no longer accept media where blocksize != sector size.
498  //
499 
500  if (Vcb->BlockSize != SECTOR_SIZE) {
501 
503  }
504 
505  Vcb->BlocksPerSector = SECTOR_SIZE / Vcb->BlockSize;
506  Vcb->BlockMask = Vcb->BlockSize - 1;
507  Vcb->BlockInverseMask = ~Vcb->BlockMask;
508 
509  Vcb->BlockToSectorShift = 0;
510  Vcb->BlockToByteShift = SECTOR_SHIFT;
511 
512  //
513  // If there is a volume descriptor then do the internal Fcb's and
514  // other Vcb fields.
515  //
516 
517  if (ARGUMENT_PRESENT( RawIsoVd )) {
518 
519  //
520  // Create the path table Fcb and refererence it and the Vcb.
521  //
522 
523  CdLockVcb( IrpContext, Vcb );
524  UnlockVcb = TRUE;
525 
526  Vcb->PathTableFcb = CdCreateFcb( IrpContext,
527  *((PFILE_ID) &FileId),
529  NULL );
530 
531  CdIncrementReferenceCounts( IrpContext, Vcb->PathTableFcb, 1, 1 );
532  CdUnlockVcb( IrpContext, Vcb );
533  UnlockVcb = FALSE;
534 
535  //
536  // Compute the stream offset and size of this path table.
537  //
538 
539  StartingBlock = CdRvdPtLoc( RawIsoVd, Vcb->VcbState );
540 
541  ByteCount = CdRvdPtSz( RawIsoVd, Vcb->VcbState );
542 
543  Vcb->PathTableFcb->StreamOffset = BytesFromBlocks( Vcb,
544  SectorBlockOffset( Vcb, StartingBlock ));
545 
546  Vcb->PathTableFcb->FileSize.QuadPart = (LONGLONG) (Vcb->PathTableFcb->StreamOffset +
547  ByteCount);
548 
549  Vcb->PathTableFcb->ValidDataLength.QuadPart = Vcb->PathTableFcb->FileSize.QuadPart;
550 
551  Vcb->PathTableFcb->AllocationSize.QuadPart = LlSectorAlign( Vcb->PathTableFcb->FileSize.QuadPart );
552 
553  //
554  // Now add the mapping information.
555  //
556 
557  CdLockFcb( IrpContext, Vcb->PathTableFcb );
558 
559  CdAddInitialAllocation( IrpContext,
560  Vcb->PathTableFcb,
561  StartingBlock,
562  Vcb->PathTableFcb->AllocationSize.QuadPart );
563 
564  CdUnlockFcb( IrpContext, Vcb->PathTableFcb );
565 
566  //
567  // Point to the file resource.
568  //
569 
570  Vcb->PathTableFcb->Resource = &Vcb->FileResource;
571 
572  //
573  // Mark the Fcb as initialized and create the stream file for this.
574  //
575 
576  SetFlag( Vcb->PathTableFcb->FcbState, FCB_STATE_INITIALIZED );
577 
578  CdCreateInternalStream( IrpContext, Vcb, Vcb->PathTableFcb, &CdInternalStreamNames[0]);
579 
580  //
581  // Create the root index and reference it in the Vcb.
582  //
583 
584  CdLockVcb( IrpContext, Vcb );
585  UnlockVcb = TRUE;
586  Vcb->RootIndexFcb = CdCreateFcb( IrpContext,
587  *((PFILE_ID) &FileId),
589  NULL );
590 
591  CdIncrementReferenceCounts( IrpContext, Vcb->RootIndexFcb, 1, 1 );
592  CdUnlockVcb( IrpContext, Vcb );
593  UnlockVcb = FALSE;
594 
595  //
596  // Create the File id by hand for this Fcb.
597  //
598 
599  CdSetFidPathTableOffset( Vcb->RootIndexFcb->FileId, Vcb->PathTableFcb->StreamOffset );
600  CdFidSetDirectory( Vcb->RootIndexFcb->FileId );
601 
602  //
603  // Create a pseudo path table entry so we can call the initialization
604  // routine for the directory.
605  //
606 
607  RawDirent = (PRAW_DIRENT) CdRvdDirent( RawIsoVd, Vcb->VcbState );
608 
609  CopyUchar4( &PathEntry.DiskOffset, RawDirent->FileLoc );
610 
611  PathEntry.DiskOffset += RawDirent->XarLen;
612  PathEntry.Ordinal = 1;
613  PathEntry.PathTableOffset = Vcb->PathTableFcb->StreamOffset;
614 
615  CdInitializeFcbFromPathEntry( IrpContext,
616  Vcb->RootIndexFcb,
617  NULL,
618  &PathEntry );
619 
620  //
621  // Create the stream file for the root directory.
622  //
623 
624  CdCreateInternalStream( IrpContext, Vcb, Vcb->RootIndexFcb, &CdInternalStreamNames[1] );
625 
626  //
627  // Now do the volume dasd Fcb. Create this and reference it in the
628  // Vcb.
629  //
630 
631  CdLockVcb( IrpContext, Vcb );
632  UnlockVcb = TRUE;
633 
634  Vcb->VolumeDasdFcb = CdCreateFcb( IrpContext,
635  *((PFILE_ID) &FileId),
637  NULL );
638 
639  CdIncrementReferenceCounts( IrpContext, Vcb->VolumeDasdFcb, 1, 1 );
640  CdUnlockVcb( IrpContext, Vcb );
641  UnlockVcb = FALSE;
642 
643  //
644  // The file size is the full disk.
645  //
646 
647  StartingBlock = CdRvdVolSz( RawIsoVd, Vcb->VcbState );
648 
649  Vcb->VolumeDasdFcb->FileSize.QuadPart = LlBytesFromBlocks( Vcb, StartingBlock );
650 
651  Vcb->VolumeDasdFcb->AllocationSize.QuadPart =
652  Vcb->VolumeDasdFcb->ValidDataLength.QuadPart = Vcb->VolumeDasdFcb->FileSize.QuadPart;
653 
654  //
655  // Now add the extent representing the volume 'by hand'.
656  //
657 
658  CdLockFcb( IrpContext, Vcb->VolumeDasdFcb );
659 
660  McbEntry = Vcb->VolumeDasdFcb->Mcb.McbArray;
661 
662  McbEntry->FileOffset =
663  McbEntry->DiskOffset = 0;
664 
665  McbEntry->ByteCount = Vcb->VolumeDasdFcb->AllocationSize.QuadPart;
666 
667  McbEntry->DataBlockByteCount =
668  McbEntry->TotalBlockByteCount = McbEntry->ByteCount;
669 
670  Vcb->VolumeDasdFcb->Mcb.CurrentEntryCount = 1;
671 
672  CdUnlockFcb( IrpContext, Vcb->VolumeDasdFcb );
673 
674  //
675  // Point to the file resource.
676  //
677 
678  Vcb->VolumeDasdFcb->Resource = &Vcb->FileResource;
679 
680  Vcb->VolumeDasdFcb->FileAttributes = FILE_ATTRIBUTE_READONLY;
681 
682  //
683  // Mark the Fcb as initialized.
684  //
685 
686  SetFlag( Vcb->VolumeDasdFcb->FcbState, FCB_STATE_INITIALIZED );
687 
688  //
689  // Check and see if this is an XA disk.
690  //
691 
692  if (FlagOn( Vcb->VcbState, VCB_STATE_ISO | VCB_STATE_JOLIET)
694  Add2Ptr( RawIsoVd, 0x400, PCHAR ),
695  8 )) {
696 
697  SetFlag( Vcb->VcbState, VCB_STATE_CDXA );
698  }
699 
700  //
701  // If this is a music disk then we want to mock this disk to make it
702  // look like ISO disk. We will create a pseudo root directory in
703  // that case.
704  //
705 
706  } else if (FlagOn( Vcb->VcbState, VCB_STATE_AUDIO_DISK )) {
707 
708  ULONG RootDirectorySize;
709 
710  //
711  // Create the path table Fcb and refererence it and the Vcb.
712  //
713 
714  CdLockVcb( IrpContext, Vcb );
715  UnlockVcb = TRUE;
716 
717  Vcb->PathTableFcb = CdCreateFcb( IrpContext,
718  *((PFILE_ID) &FileId),
720  NULL );
721 
722  CdIncrementReferenceCounts( IrpContext, Vcb->PathTableFcb, 1, 1 );
723  CdUnlockVcb( IrpContext, Vcb );
724  UnlockVcb = FALSE;
725 
726  //
727  // We only create a pseudo entry for the root.
728  //
729 
730  Vcb->PathTableFcb->FileSize.QuadPart = (LONGLONG) (FIELD_OFFSET( RAW_PATH_ISO, DirId ) + 2);
731 
732  Vcb->PathTableFcb->ValidDataLength.QuadPart = Vcb->PathTableFcb->FileSize.QuadPart;
733 
734  Vcb->PathTableFcb->AllocationSize.QuadPart = LlSectorAlign( Vcb->PathTableFcb->FileSize.QuadPart );
735 
736  //
737  // Point to the file resource.
738  //
739 
740  Vcb->PathTableFcb->Resource = &Vcb->FileResource;
741 
742  //
743  // Mark the Fcb as initialized and create the stream file for this.
744  //
745 
746  SetFlag( Vcb->PathTableFcb->FcbState, FCB_STATE_INITIALIZED );
747 
748  CdCreateInternalStream( IrpContext, Vcb, Vcb->PathTableFcb, &CdInternalStreamNames[0]);
749 
750  //
751  // Create the root index and reference it in the Vcb.
752  //
753 
754  CdLockVcb( IrpContext, Vcb );
755  UnlockVcb = TRUE;
756  Vcb->RootIndexFcb = CdCreateFcb( IrpContext,
757  *((PFILE_ID) &FileId),
759  NULL );
760 
761  CdIncrementReferenceCounts( IrpContext, Vcb->RootIndexFcb, 1, 1 );
762  CdUnlockVcb( IrpContext, Vcb );
763  UnlockVcb = FALSE;
764 
765  //
766  // Create the File id by hand for this Fcb.
767  //
768 
769  CdSetFidPathTableOffset( Vcb->RootIndexFcb->FileId, Vcb->PathTableFcb->StreamOffset );
770  CdFidSetDirectory( Vcb->RootIndexFcb->FileId );
771 
772  //
773  // Create a pseudo path table entry so we can call the initialization
774  // routine for the directory.
775  //
776 
777  RtlZeroMemory( &PathEntry, sizeof( PATH_ENTRY ));
778 
779 
780  PathEntry.Ordinal = 1;
781  PathEntry.PathTableOffset = Vcb->PathTableFcb->StreamOffset;
782 
783  CdInitializeFcbFromPathEntry( IrpContext,
784  Vcb->RootIndexFcb,
785  NULL,
786  &PathEntry );
787 
788  //
789  // Set the sizes by hand for this Fcb. It should have an entry for each track plus an
790  // entry for the root and parent.
791  //
792 
793  RootDirectorySize = (Vcb->TrackCount + 2) * CdAudioDirentSize;
794  RootDirectorySize = SectorAlign( RootDirectorySize );
795 
796  Vcb->RootIndexFcb->AllocationSize.QuadPart =
797  Vcb->RootIndexFcb->ValidDataLength.QuadPart =
798  Vcb->RootIndexFcb->FileSize.QuadPart = RootDirectorySize;
799 
800  SetFlag( Vcb->RootIndexFcb->FcbState, FCB_STATE_INITIALIZED );
801 
802  //
803  // Create the stream file for the root directory.
804  //
805 
806  CdCreateInternalStream( IrpContext, Vcb, Vcb->RootIndexFcb, &CdInternalStreamNames[1] );
807 
808  //
809  // Now do the volume dasd Fcb. Create this and reference it in the
810  // Vcb.
811  //
812 
813  CdLockVcb( IrpContext, Vcb );
814  UnlockVcb = TRUE;
815 
816  Vcb->VolumeDasdFcb = CdCreateFcb( IrpContext,
817  *((PFILE_ID) &FileId),
819  NULL );
820 
821  CdIncrementReferenceCounts( IrpContext, Vcb->VolumeDasdFcb, 1, 1 );
822  CdUnlockVcb( IrpContext, Vcb );
823  UnlockVcb = FALSE;
824 
825  //
826  // We won't allow raw reads on this Fcb so leave the size at
827  // zero.
828  //
829 
830  //
831  // Point to the file resource.
832  //
833 
834  Vcb->VolumeDasdFcb->Resource = &Vcb->FileResource;
835 
836  Vcb->VolumeDasdFcb->FileAttributes = FILE_ATTRIBUTE_READONLY;
837 
838  //
839  // Mark the Fcb as initialized.
840  //
841 
842  SetFlag( Vcb->VolumeDasdFcb->FcbState, FCB_STATE_INITIALIZED );
843 
844  //
845  // We will store a hard-coded name in the Vpb and use the toc as
846  // the serial number.
847  //
848 
849  Vcb->Vpb->VolumeLabelLength = CdAudioLabelLength;
850 
851  RtlCopyMemory( Vcb->Vpb->VolumeLabel,
852  CdAudioLabel,
854 
855  //
856  // Find the serial number for the audio disk.
857  //
858 
859  Vcb->Vpb->SerialNumber = CdTocSerial( IrpContext, Vcb->CdromToc );
860 
861  //
862  // Set the ISO bit so we know how to treat the names.
863  //
864 
865  SetFlag( Vcb->VcbState, VCB_STATE_ISO );
866  }
867 
868  } _SEH2_FINALLY {
869 
870  if (UnlockVcb) { CdUnlockVcb( IrpContext, Vcb ); }
871  } _SEH2_END;
872 }
signed char * PCHAR
Definition: retypes.h:7
#define VCB_STATE_JOLIET
Definition: cdstruc.h:714
PFCB CdCreateFcb(_In_ PIRP_CONTEXT IrpContext, _In_ FILE_ID FileId, _In_ NODE_TYPE_CODE NodeTypeCode, _Out_opt_ PBOOLEAN FcbExisted)
Definition: strucsup.c:986
#define VCB_STATE_AUDIO_DISK
Definition: cdstruc.h:718
#define FCB_STATE_INITIALIZED
Definition: cdstruc.h:1048
#define SectorAlign(L)
Definition: cdprocs.h:1590
#define CdRvdVolSz(R, F)
Definition: cd.h:313
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define Add2Ptr(PTR, INC)
#define SectorBlockOffset(V, LB)
Definition: cdprocs.h:1636
#define SECTOR_SHIFT
Definition: cd.h:32
ULONG CdTocSerial(_In_ PIRP_CONTEXT IrpContext, _In_ PCDROM_TOC_LARGE CdromToc)
Definition: strucsup.c:2779
ULONG CdAudioDirentSize
Definition: cddata.c:78
#define CdFidSetDirectory(I)
Definition: cdstruc.h:1842
#define CDFS_NTC_FCB_PATH_TABLE
Definition: nodetype.h:29
#define CDFS_NTC_FCB_INDEX
Definition: nodetype.h:30
#define PAGED_CODE()
Definition: video.h:57
#define CdUnlockFcb(IC, F)
Definition: cdprocs.h:1065
_SEH2_TRY
Definition: create.c:4250
ULONG PathTableOffset
Definition: cdstruc.h:1475
#define CdRvdPtSz(R, F)
Definition: cd.h:301
#define CDFS_NTC_FCB_DATA
Definition: nodetype.h:31
VOID CdCreateInternalStream(_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _Inout_ PFCB Fcb, _In_ PUNICODE_STRING Name)
Definition: cachesup.c:38
#define LlBytesFromBlocks(V, B)
Definition: cdprocs.h:1644
LONGLONG TotalBlockByteCount
Definition: cdstruc.h:230
unsigned char BOOLEAN
LONGLONG DataBlockByteCount
Definition: cdstruc.h:229
smooth NULL
Definition: ftsmooth.c:416
UCHAR FileLoc[4]
Definition: cd.h:334
int64_t LONGLONG
Definition: typedefs.h:66
#define CopyUchar4(Dst, Src)
Definition: cdprocs.h:1711
NTSYSAPI ULONG NTAPI RtlEqualMemory(CONST VOID *Source1, CONST VOID *Source2, ULONG Length)
#define VCB_STATE_ISO
Definition: cdstruc.h:713
#define CdRvdBlkSz(R, F)
Definition: cd.h:289
#define CdUnlockVcb(IC, V)
Definition: cdprocs.h:1033
#define ARGUMENT_PRESENT(ArgumentPointer)
#define Vcb
Definition: cdprocs.h:1425
UCHAR XarLen
Definition: cd.h:333
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define BytesFromBlocks(V, B)
Definition: cdprocs.h:1640
#define CdLockVcb(IC, V)
Definition: cdprocs.h:1028
#define LlSectorAlign(L)
Definition: cdprocs.h:1594
LONGLONG ByteCount
Definition: cdstruc.h:215
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
USHORT CdAudioLabelLength
Definition: cddata.c:70
ULONG Ordinal
Definition: cdstruc.h:1474
#define VCB_STATE_CDXA
Definition: cdstruc.h:717
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _In_ LARGE_INTEGER ByteCount
Definition: iotypes.h:1061
UNICODE_STRING CdInternalStreamNames[]
Definition: strucsup.c:234
#define CdLockFcb(IC, F)
Definition: cdprocs.h:1049
Definition: cdstruc.h:1466
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
#define CdSetFidPathTableOffset(I, P)
Definition: cdstruc.h:1840
#define CdRaiseStatus(IC, S)
Definition: cdprocs.h:1869
RAW_DIRENT * PRAW_DIRENT
Definition: cd.h:351
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
_SEH2_FINALLY
Definition: create.c:4395
VOID CdAddInitialAllocation(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_ ULONG StartingBlock, _In_ LONGLONG DataLength)
Definition: allocsup.c:484
VOID CdInitializeFcbFromPathEntry(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_opt_ PFCB ParentFcb, _In_ PPATH_ENTRY PathEntry)
Definition: strucsup.c:1136
WCHAR CdAudioLabel[]
Definition: cddata.c:69
#define STATUS_DISK_CORRUPT_ERROR
Definition: udferr_usr.h:147
ULONG DiskOffset
Definition: cdstruc.h:1482
Definition: cdstruc.h:206
unsigned int ULONG
Definition: retypes.h:1
#define CdIncrementReferenceCounts(IC, F, C, UC)
Definition: cdprocs.h:1322
#define CdRvdDirent(R, F)
Definition: cd.h:307
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define SECTOR_SIZE
Definition: fs.h:22
LONGLONG DiskOffset
Definition: cdstruc.h:214
CHAR CdXaId[]
Definition: cddata.c:63
#define CdRvdPtLoc(R, F)
Definition: cd.h:295
LONGLONG FileOffset
Definition: cdstruc.h:221

Variable Documentation

◆ CdAllocateFcbTable

PVOID NTAPI CdAllocateFcbTable

Definition at line 178 of file strucsup.c.

Referenced by CdInitializeVcb().

◆ CdDeallocateFcbTable

VOID NTAPI CdDeallocateFcbTable

Definition at line 188 of file strucsup.c.

Referenced by CdInitializeVcb().

◆ CdFcbTableCompare

Definition at line 167 of file strucsup.c.

Referenced by CdInitializeVcb().

◆ CdInternalStreamNames

UNICODE_STRING CdInternalStreamNames[]
Initial value:
= {
{ 24, 24, L"$PATH_TABLE$"},
{ 2, 2, L"\\"}
}
static const WCHAR L[]
Definition: oid.c:1250

Definition at line 234 of file strucsup.c.

Referenced by CdUpdateVcbFromVolDescriptor().