19#define IsFileObjectReadOnly(FO) (!((FO)->WriteAccess | (FO)->DeleteAccess))
22#define UDF_BUG_CHECK_ID UDF_FILE_CREATE
24#define MEM_USABS_TAG "US_Abs"
25#define MEM_USLOC_TAG "US_Loc"
26#define MEM_USOBJ_TAG "US_Obj"
28#define UDF_LOG_CREATE_DISPOSITION
74 Irp->IoStatus.Status = RC;
93 Irp->IoStatus.Status = RC;
94 Irp->IoStatus.Information = 0;
110 AdPrint((
"UDFCreate: %x\n", RC));
130 (*PagingIoRes) =
NULL;
152 if(RelatedFileInfo->Fcb &&
153 RelatedFileInfo->Fcb->ParentFcb) {
165 ASSERT_REF(RelatedFileInfo->Fcb->ReferenceCount >= RelatedFileInfo->RefCount);
198 ULONG RequestedOptions;
199 ULONG RequestedDisposition;
203 ULONG ExtAttrLength = 0;
218 BOOLEAN DeleteOnCloseSpecified;
234 ULONG ReturnedInformation = 0;
252 ULONG TreeLength = 0;
260 ULONG SNameIndex = 0;
262 TmPrint((
"UDFCommonCreate:\n"));
300 TargetObjectName = PtrNewFileObject->FileName;
301 PtrRelatedFileObject = PtrNewFileObject->RelatedFileObject;
305 if (PtrRelatedFileObject) {
306 PtrRelatedCCB = (
PtrUDFCCB)(PtrRelatedFileObject->FsContext2);
310 PtrRelatedFCB = PtrRelatedCCB->
Fcb;
314 RelatedObjectName = PtrRelatedFileObject->FileName;
315 if (!(RelatedObjectName.
Length) || (RelatedObjectName.
Buffer[0] !=
L'\\')) {
342 switch(RequestedDisposition) {
344 AdPrint((
" Dispos: FILE_SUPERSEDE\n"));
347 AdPrint((
" Dispos: FILE_OPEN\n"));
350 AdPrint((
" Dispos: FILE_CREATE\n"));
353 AdPrint((
" Dispos: FILE_OPEN_IF\n"));
356 AdPrint((
" Dispos: FILE_OVERWRITE\n"));
359 AdPrint((
" Dispos: FILE_OVERWRITE_IF\n"));
362 AdPrint((
" Dispos: *** Unknown ***\n"));
386#define OpenForBackup (RequestedOptions & FILE_OPEN_FOR_BACKUP_INTENT)
393#define DirectoryOnlyRequested (RequestedOptions & FILE_DIRECTORY_FILE)
401#define FileOnlyRequested (RequestedOptions & FILE_NON_DIRECTORY_FILE)
408#define NoBufferingSpecified (RequestedOptions & FILE_NO_INTERMEDIATE_BUFFERING)
416#define SequentialIoRequested (RequestedOptions & FILE_SEQUENTIAL_ONLY ? TRUE : FALSE)
429 if(DeleteOnCloseSpecified) {
433#define NoExtAttrKnowledge TRUE
448#define OpenByFileId (RequestedOptions & FILE_OPEN_BY_FILE_ID)
468 WriteThroughRequested = WriteThroughRequested ||
475 if(PageFileManipulation) {
476 ReturnedInformation = 0;
477 AdPrint((
"Can't create a page file\n"));
481 ReturnedInformation = 0;
482 AdPrint((
"Can't create file with EAs\n"));
488 if (
Vcb->SoftEjectReq) {
489 AdPrint((
" Eject requested\n"));
497 AdPrint((
" Volume is locked\n"));
522#ifndef UDF_READ_ONLY_BUILD
526 (DeleteOnCloseSpecified ||
527 OpenTargetDirectory ||
533 ReturnedInformation = 0;
534 AdPrint((
" Write protected or dirty\n"));
547 if (!(PtrNewFileObject->FileName.Length) && (!PtrRelatedFileObject ||
552 AdPrint((
" Opening Volume\n"));
567 if ((OpenTargetDirectory) || (PtrExtAttrBuffer)) {
576#ifndef UDF_READ_ONLY_BUILD
577 if (DeleteOnCloseSpecified) {
618 UDFPrint((
" set UDF_IRP_CONTEXT_FLUSH2_REQUIRED\n"));
644 if ((
Vcb->VCBHandleCount) &&
647 UDFPrint((
" !FILE_SHARE_READ + open handles (%d)\n",
Vcb->VCBHandleCount));
662#ifdef UDF_DELAYED_CLOSE
674 UDFPrint((
" FILE_SHARE_READ + R/W handles: %d(%d) -> STATUS_SHARING_VIOLATION ?\n",
676 Vcb->VCBOpenCountRO));
685 Vcb->VolumeLockFileObject = PtrNewFileObject;
689 UDFPrint((
" set UDF_IRP_CONTEXT_FLUSH_REQUIRED\n"));
699 goto op_vol_accs_dnd;
701 PtrNewCcb = (
PtrUDFCCB)(PtrNewFileObject->FsContext2);
706 AdPrint((
" Access violation (Volume)\n"));
707 goto op_vol_accs_dnd;
712 AdPrint((
" Sharing violation (Volume)\n"));
715 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_VOLUME_LOCKED;
716 Vcb->VolumeLockFileObject =
NULL;
731 ReturnedInformation = 0;
732 AdPrint((
" Can't open anything on blank volume ;)\n"));
737 ReturnedInformation = 0;
738 AdPrint((
" Illegal share access\n"));
772 ReturnedInformation = 0;
773 AdPrint((
" Can't open by FileID on blank volume ;)\n"));
778 AdPrint((
" Invalid file ID\n"));
783 if ((RequestedDisposition !=
FILE_OPEN) &&
785 AdPrint((
" Illegal disposition for ID open\n"));
791 AdPrint((
" ID open failed\n"));
798 AdPrint((
" Init String failed\n"));
802 AbsolutePathName = TargetObjectName;
803 PtrRelatedFileObject =
NULL;
809 if (PtrRelatedFileObject) {
814 UDFPrint((
" PtrRelatedFileObject %x, FCB %x\n", PtrRelatedFileObject, PtrRelatedFCB));
823 AdPrint((
" Related object must be a directory\n"));
829 AdPrint((
" exception when printing name\n"));
841 if (!(RelatedObjectName.
Length) || (RelatedObjectName.
Buffer[0] !=
L'\\')) {
842 AdPrint((
" Wrong pathname (1)\n"));
849 if (TargetObjectName.
Length && (TargetObjectName.
Buffer[0] ==
L'\\')) {
850 AdPrint((
" Wrong pathname (2)\n"));
861 if(RelatedObjectName.
Length &&
862 (RelatedObjectName.
Buffer[ (RelatedObjectName.
Length/
sizeof(
WCHAR)) - 1 ] !=
L'\\')) {
863 RC = MyAppendUnicodeToString(&AbsolutePathName,
L"\\");
866 if(!AbsolutePathName.
Length ||
869 if(TargetObjectName.
Length && TargetObjectName.
Buffer[0] !=
L'\\') {
870 RC = MyAppendUnicodeToString(&AbsolutePathName,
L"\\");
875 RC = MyAppendUnicodeStringToStringTag(&AbsolutePathName, &TargetObjectName,
MEM_USABS_TAG);
887 if (!TargetObjectName.
Length || TargetObjectName.
Buffer[0] !=
L'\\') {
888 AdPrint((
" Wrong target name (1)\n"));
898 if ((AbsolutePathName.
Length >=
sizeof(
WCHAR)*2) &&
899 (AbsolutePathName.
Buffer[1] ==
L'\\') &&
900 (AbsolutePathName.
Buffer[0] ==
L'\\')) {
904 (AbsolutePathName.
Buffer[2] ==
L'\\')) {
905 AdPrint((
" Wrong target name (2)\n"));
910 AbsolutePathName.
Buffer + 1,
911 AbsolutePathName.
Length );
926 if(!TargetObjectName.
Length) {
927 TargetObjectName = AbsolutePathName;
937 AdPrint((
" Opening RootDir\n"));
943 AdPrint((
" Can't overwrite RootDir\n"));
952 if (DeleteOnCloseSpecified) {
954 AdPrint((
" Can't delete RootDir\n"));
958 PtrNewFcb =
Vcb->RootDirFCB;
963 PtrNewCcb = (
PtrUDFCCB)(PtrNewFileObject->FsContext2);
968 AdPrint((
" Access/Sharing violation (RootDir)\n"));
978 AdPrint((
" Opening file %ws %8.8x\n",AbsolutePathName.
Buffer, PtrNewFileObject));
980 AdPrint((
" Exception when printing FN\n"));
989 if(OpenTargetDirectory)
1000 RelatedFileInfo = PtrRelatedFCB->
FileInfo;
1004 LastGoodFileInfo = RelatedFileInfo;
1007 OldRelatedFileInfo = RelatedFileInfo->
ParentFile;
1008 PtrRelatedFCB = PtrRelatedFCB->
ParentFcb;
1018 PtrNewFcb = NewFileInfo->
Fcb;
1029 ReturnedInformation = 0;
1030 AdPrint((
" Can't open File on blank volume ;)\n"));
1043 if(!
UDFIsNameValid(&AbsolutePathName, &StreamOpen, &SNameIndex)) {
1044 AdPrint((
" Absolute path is not valid\n"));
1055 if (PtrRelatedFileObject) {
1058 RelatedFileInfo = PtrRelatedFCB->
FileInfo;
1059 if(RelatedFileInfo !=
Vcb->RootDirFCB->FileInfo) {
1064 if(TargetObjectName.
Buffer != AbsolutePathName.
Buffer) {
1067 AdPrint((
" Init String 'TargetObjectName' failed\n"));
1070 TailNameBuffer = TailName.
Buffer;
1072 TailName = AbsolutePathName;
1076 RelatedFileInfo =
Vcb->RootDirFCB->FileInfo;
1077 TailName = AbsolutePathName;
1093 LastGoodFileInfo = RelatedFileInfo;
1114 LastGoodTail = TailName;
1115 while(LastGoodTail.
Buffer[0] ==
L'\\') {
1121 TmpBuffer = TailName.
Buffer;
1143 AdPrint((
" Error opening path component\n"));
1156 if(RelatedFileInfo && (TreeLength>1)) {
1164 AdPrint((
" Path component is too long\n"));
1183 AdPrint((
" Traverse check failed\n"));
1184 goto Skip_open_attempt;
1187 if(CurName.
Buffer[0] !=
':') {
1191 RelatedFileInfo,&NewFileInfo,
NULL);
1200 AdPrint((
" Not a directory\n"));
1204 AdPrint((
" Dloc is being initialized\n"));
1214 StreamExists =
TRUE;
1221#ifndef UDF_READ_ONLY_BUILD
1227 OpenTargetDirectory ) {
1230 goto SuccessOpen_SDir;
1247 if (!(PtrNewFcb = NewFileInfo->
Fcb)) {
1253 NULL, &PtrNewFcb, RelatedFileInfo, NewFileInfo,
1254 &LocalPath, &CurName);
1258 AdPrint((
" Can't perform FirstOpen\n"));
1275 AdPrint((
" Fcb not valid\n"));
1295 LastGoodFileInfo = NewFileInfo;
1296 LastGoodName = CurName;
1300 ((CurName.
Buffer[0] !=
L':') &&
1305 RC = MyAppendUnicodeToString(&LocalPath,
L"\\");
1308 RC = MyAppendUnicodeStringToStringTag(&LocalPath, &CurName,
MEM_USLOC_TAG);
1313 AdPrint((
" Can't open file\n"));
1319 PtrNewFcb = NewFileInfo->
Fcb;
1322 PtrNewFcb->NTRequiredFCB) {
1323 NtReqFcb = PtrNewFcb->NTRequiredFCB;
1332 !PtrNewFcb->ReferenceCount &&
1333 !PtrNewFcb->OpenHandleCount) {
1339 if(NewFileInfo->
Dloc &&
1341 (!PtrNewFcb || !PtrNewFcb->ReferenceCount)) {
1356 NewFileInfo->
Fcb = PtrNewFcb;
1372 AdPrint((
" Return DeletePending (no err)\n"));
1376 OldRelatedFileInfo = RelatedFileInfo;
1377 RelatedFileInfo = NewFileInfo;
1395 AdPrint((
" Hard error or damaged data structures\n"));
1405 ASSERT(!OpenTargetDirectory);
1415 if(OpenTargetDirectory) {
1418 AdPrint((
" Not a directory (2)\n"));
1423 AdPrint((
" Target name should not contain (back)slashes\n"));
1428 NewFileInfo = LastGoodFileInfo;
1433 &CurName, RelatedFileInfo))) {
1436 AdPrint((
" Open Target: FILE_EXISTS\n"));
1442 for(TmpBuffer = LastGoodTail.
Buffer; *TmpBuffer; TmpBuffer++) {
1443 if((*TmpBuffer) ==
L'\\') {
1445 AdPrint((
" Target name should not contain (back)slashes\n"));
1452 AdPrint((
" Open Target: FILE_DOES_NOT_EXIST\n"));
1455 AdPrint((
" Open Target: unexpected error\n"));
1466 PtrNewFcb = NewFileInfo->
Fcb;
1472 AdPrint((
" Can't perform OpenFile operation for target\n"));
1475 PtrNewCcb = (
PtrUDFCCB)(PtrNewFileObject->FsContext2);
1480 AdPrint((
" Access/Share access check failed (Open Target)\n"));
1492 if( ((RequestedDisposition ==
FILE_OPEN) ||
1496 AdPrint((
" File doesn't exist\n"));
1501 AdPrint((
" Can't create due to unexpected error\n"));
1507 AdPrint((
" File doesn't exist (2)\n"));
1512#ifndef UDF_READ_ONLY_BUILD
1515 ReturnedInformation = 0;
1516 AdPrint((
" Write protected\n"));
1518#ifndef UDF_READ_ONLY_BUILD
1521 if(DeleteOnCloseSpecified &&
1523 AdPrint((
" Can't create r/o file marked for deletion\n"));
1530 for(TmpBuffer = LastGoodTail.
Buffer; *TmpBuffer; TmpBuffer++) {
1531 if((*TmpBuffer) ==
L'\\') {
1532 AdPrint((
" Target name should not contain (back)slashes\n"));
1538 StreamOpen ||
FALSE)) {
1539 AdPrint((
" Creation of _temporary_ directory not permited\n"));
1546 AdPrint((
" Creation of File/Dir not permitted\n"));
1554 RelatedFileInfo = OldRelatedFileInfo;
1557 Vcb->UseExtendedFE || (StreamOpen && !StreamExists),
1558 (RequestedDisposition ==
FILE_CREATE), RelatedFileInfo, &NewFileInfo);
1560 AdPrint((
" Creation error\n"));
1563 PtrNewFcb = NewFileInfo->
Fcb;
1566 !PtrNewFcb->ReferenceCount &&
1567 !PtrNewFcb->OpenHandleCount) {
1570 if(NewFileInfo->
Dloc &&
1580 PtrNewFcb = PtrNewFcb;
1582 NewFileInfo->
Fcb = PtrNewFcb;
1591 PtrRelatedFileObject &&
1603 AdPrint((
" Can't transform to directory\n"));
1613 goto Creation_Err_1;
1627 if(StreamOpen && !StreamExists) {
1632 if (!(PtrNewFcb = NewFileInfo->
Fcb)) {
1638 NULL, &PtrNewFcb, RelatedFileInfo, NewFileInfo,
1639 &LocalPath, &LastGoodTail);
1641 AdPrint((
" Can't perform FirstOpenFile operation for file to contain stream\n"));
1645 goto Creation_Err_1;
1653 LastGoodFileInfo = NewFileInfo;
1655 RC = MyAppendUnicodeToString(&LocalPath,
L"\\");
1657 RC = MyAppendUnicodeStringToStringTag(&LocalPath, &LastGoodTail,
MEM_USLOC_TAG);
1659 goto Creation_Err_1;
1673 RelatedFileInfo = NewFileInfo;
1676 AdPrint((
" Can't create SDir\n"));
1678 goto Creation_Err_1;
1688 if (!(PtrNewFcb = NewFileInfo->
Fcb)) {
1694 NULL, &PtrNewFcb, RelatedFileInfo, NewFileInfo,
1700 AdPrint((
" Can't perform OpenFile operation for SDir\n"));
1702 goto Creation_Err_1;
1707 LastGoodFileInfo = NewFileInfo;
1711 AdPrint((
" Can't append UNC str\n"));
1713 goto Creation_Err_1;
1724 RelatedFileInfo = NewFileInfo;
1727 RelatedFileInfo, &NewFileInfo);
1729 AdPrint((
" Can't create Stream\n"));
1731 goto Creation_Err_1;
1744 if (!(PtrNewFcb = NewFileInfo->
Fcb)) {
1755 PtrNewFileObject, &PtrNewFcb, RelatedFileInfo, NewFileInfo,
1756 &LocalPath, &LastGoodTail);
1762 AdPrint((
" Can't perform OpenFile operation for file or stream\n"));
1767 PtrNewFcb->NTRequiredFCB->CommonFCBHeader.FileSize.QuadPart =
1768 PtrNewFcb->NTRequiredFCB->CommonFCBHeader.ValidDataLength.QuadPart = 0;
1771 PtrNewFcb->NTRequiredFCB->CommonFCBHeader.AllocationSize.QuadPart =
AllocationSize;
1772 MmPrint((
" CcIsFileCached()\n"));
1774 MmPrint((
" CcSetFileSizes()\n"));
1783 LastGoodFileInfo = NewFileInfo;
1787 PtrNewCcb = (
PtrUDFCCB)(PtrNewFileObject->FsContext2);
1791 AdPrint((
" Can't set Access Rights on Create\n"));
1843 ASSERT(NewFileInfo != OldRelatedFileInfo);
1848 PtrNewCcb = (
PtrUDFCCB)(PtrNewFileObject->FsContext2);
1852 AdPrint((
" Object name collision\n"));
1856 NtReqFcb = PtrNewFcb->NTRequiredFCB;
1866 AdPrint((
" Can't open directory as a plain file\n"));
1868 AdPrint((
" Can't supersede directory\n"));
1875 AdPrint((
" This is not a directory\n"));
1881 AdPrint((
" Can't delete Read-Only file\n"));
1891 AdPrint((
" Access/Share access check failed\n"));
1895 RestoreShareAccess =
TRUE;
1905 MmPrint((
" MmFlushImageSection();\n"));
1908 MmFlushForWrite )) {
1913 AdPrint((
" File is mapped or deletion in progress\n"));
1920 !(PtrNewFcb->CachedOpenHandleCount) &&
1921 (
NtReqFcb->SectionObject.DataSectionObject) ) {
1926 MmPrint((
" CcFlushCache()\n"));
1928 MmPrint((
" CcPurgeCacheSection()\n"));
1934 AdPrint((
" Directory in not empry\n"));
1943 if(DeleteOnCloseSpecified &&
1949 AdPrint((
" Read-only. DeleteOnClose attempt failed\n"));
1960#ifndef UDF_READ_ONLY_BUILD
1972 PtrNewFcb->FCBFlags &= ~UDF_FCB_READ_ONLY;
1980 AdPrint((
" Can't supersede. DELETE permission required\n"));
1989 AdPrint((
" Can't overwrite. Permission denied\n"));
1996 AdPrint((
" The Hidden and/or System bits do not match\n"));
2002 MmPrint((
" MmCanFileBeTruncated()\n"));
2005 AdPrint((
" Can't truncate. File is mapped\n"));
2019 AdPrint((
" Error during resize operation\n"));
2029 NtReqFcb->CommonFCBHeader.FileSize.QuadPart =
2030 NtReqFcb->CommonFCBHeader.ValidDataLength.QuadPart = 0 ;
2031 PtrNewFcb->FCBFlags &= ~UDF_FCB_DELAY_CLOSE;
2032 MmPrint((
" CcSetFileSizes()\n"));
2063 PtrRelatedFileObject &&
2077 PtrRelatedFileObject &&
2089 if(RestoreVCBOpenCounter) {
2091 RestoreVCBOpenCounter =
FALSE;
2120#ifndef UDF_READ_ONLY_BUILD
2121 if(WriteThroughRequested) {
2124 MmPrint((
" FO_WRITE_THROUGH\n"));
2130 MmPrint((
" FO_SEQUENTIAL_ONLY\n"));
2131#ifndef UDF_READ_ONLY_BUILD
2133 PtrNewFileObject->Flags &= ~FO_WRITE_THROUGH;
2134 PtrNewFcb->FCBFlags &= ~UDF_FCB_WRITE_THROUGH;
2135 MmPrint((
" FILE_REMOVABLE_MEDIA + FO_SEQUENTIAL_ONLY => ~FO_WRITE_THROUGH\n"));
2138 if(PtrNewFcb->FileInfo) {
2144 MmPrint((
" FO_NO_INTERMEDIATE_BUFFERING\n"));
2147 MmPrint((
" FO_CACHE_SUPPORTED\n"));
2153 MmPrint((
" FO_FILE_FAST_IO_READ\n"));
2164 PtrNewCcb->TreeLength = TreeLength;
2166#ifndef UDF_READ_ONLY_BUILD
2167 if(DeleteOnCloseSpecified) {
2196 if(PtrNewFcb->FileInfo) {
2197 ASSERT_REF(PtrNewFcb->ReferenceCount >= PtrNewFcb->FileInfo->RefCount);
2200 AdPrint((
" FCB %x, CCB %x, FO %x, Flags %x\n", PtrNewFcb, PtrNewCcb, PtrNewFileObject, PtrNewFcb->FCBFlags));
2206 if(RestoreShareAccess &&
NtReqFcb && PtrNewFileObject) {
2210 if(PtrNewFileObject) {
2211 PtrNewFileObject->FsContext2 =
NULL;
2215 if(LastGoodFileInfo && LastGoodFileInfo->
Fcb) {
2217 if(LastGoodFileInfo->
Fcb->NTRequiredFCB) {
2227 if(
Vcb && (PtrNewFcb !=
Vcb->RootDirFCB) &&
2228 LastGoodFileInfo ) {
2231 ASSERT(!LastGoodFileInfo);
2239 Irp->IoStatus.Status = RC;
2240 Irp->IoStatus.Information = ReturnedInformation;
2255 if(AbsolutePathName.
Buffer)
2299 AdPrint((
"UDFFirstOpenFile\n"));
2302 AdPrint((
"Can't allocate FCB\n"));
2309 if(RelatedFileInfo && RelatedFileInfo->Fcb &&
2317 if( (CurName->Buffer[0] !=
L':') &&
2318 (!LocalPath->Length ||
2319 ((LocalPath->Buffer[LocalPath->Length/
sizeof(
WCHAR)-1] !=
L':')
2321 RC = MyAppendUnicodeToString(&(NewFCBName->
ObjectName),
L"\\");
2329 (*PtrNewFcb)->FileInfo = NewFileInfo;
2330 NewFileInfo->Fcb = (*PtrNewFcb);
2331 (*PtrNewFcb)->ParentFcb = RelatedFileInfo->Fcb;
2333 if(!((*PtrNewFcb)->NTRequiredFCB = NewFileInfo->Dloc->CommonFcb)) {
2335 if(!((*PtrNewFcb)->NTRequiredFCB)) {
2340 UDFPrint((
"UDFAllocateNtReqFCB: %x\n", (*PtrNewFcb)->NTRequiredFCB));
2342 (*PtrNewFcb)->FileInfo->Dloc->CommonFcb = (*PtrNewFcb)->NTRequiredFCB;
2346 (*PtrNewFcb)->NTRequiredFCB =
NULL;
2353 NtReqFcb = (*PtrNewFcb)->NTRequiredFCB;
2357 &(
NtReqFcb->CreationTime.QuadPart),
2358 &(
NtReqFcb->LastAccessTime.QuadPart),
2360 &(
NtReqFcb->LastWriteTime.QuadPart) );
2363 NtReqFcb->CommonFCBHeader.AllocationSize.QuadPart =
2364 UDFSysGetAllocSize(
Vcb, NewFileInfo->Dloc->DataLoc.Length);
2366 NtReqFcb->CommonFCBHeader.FileSize.QuadPart =
2367 NtReqFcb->CommonFCBHeader.ValidDataLength.QuadPart = NewFileInfo->Dloc->DataLoc.Length;
2377 (*PtrNewFcb)->NTRequiredFCB =
NULL;
2397 }
else if (RelatedFileInfo->ParentFile) {
2408 if(PtrNewFileObject) {
2458 AdPrint((
"Can't allocate CCB\n"));
2459 PtrNewFileObject->FsContext2 =
NULL;
2472 PtrNewFileObject->FsContext2 = (
PVOID)(
Ccb);
2473 PtrNewFileObject->Vpb =
Vcb->Vpb;
2475 PtrNewFileObject->SectionObjectPointer = &(
NtReqFcb->SectionObject);
2480#ifdef UDF_DELAYED_CLOSE
2481 PtrNewFcb->
FCBFlags &= ~UDF_FCB_DELAY_CLOSE;
2524 AdPrint((
"UDFInitializeFCB\n"));
2528 if(!PtrNewFcb->NTRequiredFCB->CommonFCBHeader.Resource) {
2531 PtrNewFcb->NTRequiredFCB->CommonFCBHeader.NodeByteSize =
sizeof(
UDFNTRequiredFCB);
2534 AdPrint((
" Can't init resource\n"));
2538 AdPrint((
" Can't init resource (2)\n"));
2543 PtrNewFcb->NTRequiredFCB->CommonFCBHeader.Resource = &(PtrNewFcb->NTRequiredFCB->MainResource);
2544 PtrNewFcb->NTRequiredFCB->CommonFCBHeader.PagingIoResource = &(PtrNewFcb->NTRequiredFCB->PagingIoResource);
2548 PtrNewFcb->NTRequiredFCB->CommonRefCount = 0;
2554 AdPrint((
" Can't init resource (3)\n"));
2559 PtrNewFcb->NTRequiredFCB->CommonFCBHeader.Resource =
2560 PtrNewFcb->NTRequiredFCB->CommonFCBHeader.PagingIoResource =
NULL;
2572 PtrNewFcb->ReferenceCount = 0;
2573 PtrNewFcb->OpenHandleCount = 0;
2577 PtrNewFcb->FCBName = PtrObjectName;
2579 PtrNewFcb->Vcb =
Vcb;
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define STATUS_PRIVILEGE_NOT_HELD
VOID UDFAttributesToUDF(IN PDIR_INDEX_ITEM FileDirNdx, IN tag *FileEntry, IN ULONG NTAttr)
ULONG UDFAttributesToNT(IN PDIR_INDEX_ITEM FileDirNdx, IN tag *FileEntry)
NTSTATUS MyCloneUnicodeString(IN PUNICODE_STRING Str1, IN PUNICODE_STRING Str2)
VOID UDFGetFileXTime(IN PUDF_FILE_INFO FileInfo, OUT LONGLONG *CrtTime, OUT LONGLONG *AccTime, OUT LONGLONG *AttrTime, OUT LONGLONG *ChgTime)
#define FILE_DELETE_ON_CLOSE
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
#define CcIsFileCached(FO)
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
NTSTATUS UDFCloseFileInfoChain(IN PVCB Vcb, IN PUDF_FILE_INFO fi, IN ULONG TreeLength, IN BOOLEAN VcbAcquired)
VOID UDFCloseAllDelayed(IN PVCB Vcb)
ULONG UDFCleanUpFcbChain(IN PVCB Vcb, IN PUDF_FILE_INFO fi, IN ULONG TreeLength, IN BOOLEAN VcbAcquired)
PDIR_INDEX_HDR UDFGetDirIndexByFileInfo(IN PUDF_FILE_INFO FileInfo)
#define NT_SUCCESS(StatCode)
static const WCHAR Linked[]
_In_ PIO_STACK_LOCATION IrpSp
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT ShareAccess
NTSTATUS NTAPI UDFCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
VOID __fastcall UDFReleaseResFromCreate(IN PERESOURCE *PagingIoRes, IN PERESOURCE *Res1, IN PERESOURCE *Res2)
#define IsFileObjectReadOnly(FO)
#define FileOnlyRequested
VOID __fastcall UDFAcquireParent(IN PUDF_FILE_INFO RelatedFileInfo, IN PERESOURCE *Res1, IN PERESOURCE *Res2)
#define NoBufferingSpecified
#define SequentialIoRequested
#define DirectoryOnlyRequested
NTSTATUS UDFCommonCreate(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
NTSTATUS UDFOpenFile(PVCB Vcb, PFILE_OBJECT PtrNewFileObject, PtrUDFFCB PtrNewFcb)
NTSTATUS UDFInitializeFCB(IN PtrUDFFCB PtrNewFcb, IN PVCB Vcb, IN PtrUDFObjectName PtrObjectName, IN ULONG Flags, IN PFILE_OBJECT FileObject)
NTSTATUS UDFFirstOpenFile(IN PVCB Vcb, IN PFILE_OBJECT PtrNewFileObject, OUT PtrUDFFCB *PtrNewFcb, IN PUDF_FILE_INFO RelatedFileInfo, IN PUDF_FILE_INFO NewFileInfo, IN PUNICODE_STRING LocalPath, IN PUNICODE_STRING CurName)
NTSTATUS UDFExceptionHandler(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
VOID __fastcall UDFCleanUpFCB(PtrUDFFCB Fcb)
BOOLEAN __fastcall UDFIsIrpTopLevel(PIRP Irp)
VOID UDFLogEvent(NTSTATUS UDFEventLogId, NTSTATUS RC)
PtrUDFCCB UDFAllocateCCB(VOID)
NTSTATUS UDFPostRequest(IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp)
PtrUDFIrpContext UDFAllocateIrpContext(PIRP Irp, PDEVICE_OBJECT PtrTargetDeviceObject)
VOID UDFReleaseIrpContext(PtrUDFIrpContext PtrIrpContext)
VOID __fastcall UDFCleanUpCCB(PtrUDFCCB Ccb)
VOID __fastcall UDFReleaseObjectName(PtrUDFObjectName PtrObjectName)
long UDFExceptionFilter(PtrUDFIrpContext PtrIrpContext, PEXCEPTION_POINTERS PtrExceptionPointers)
PtrUDFObjectName UDFAllocateObjectName(VOID)
PtrUDFFCB UDFAllocateFCB(VOID)
#define INTEGRITY_TYPE_OPEN
#define UDFNotifyVolumeEvent(FileObject, EventCode)
#define CollectStatistics(VCB, Field)
__inline VOID UDFNotifyFullReportChange(PVCB V, PUDF_FILE_INFO FI, ULONG E, ULONG A)
#define CollectStatistics2(VCB, Field)
#define InsertTailList(ListHead, Entry)
#define UDFReleaseResource(Resource)
#define UDFDeleteResource(Resource)
NTSTATUS MyInitUnicodeString(IN PUNICODE_STRING Str1, IN PCWSTR Str2)
#define UDFConvertExclusiveToSharedLite(Resource)
#define UDFAcquireResourceExclusive(Resource, CanWait)
#define UDFInterlockedDecrement(addr)
#define UDFInitializeResourceLite(Resource)
#define InitializeListHead(ListHead)
#define UDFInterlockedIncrement(addr)
#define UDF_ERROR_INTERNAL_ERROR
FAST_IO_POSSIBLE NTAPI UDFIsFastIoPossible(IN PtrUDFFCB Fcb)
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
NTSTATUS UDFGetOpenParamsByFileId(IN PVCB Vcb, IN LONGLONG Id, OUT PUNICODE_STRING *FName, OUT BOOLEAN *CaseSens)
VOID NTAPI FsRtlInitializeFileLock(IN PFILE_LOCK FileLock, IN PCOMPLETE_LOCK_IRP_ROUTINE CompleteLockIrpRoutine OPTIONAL, IN PUNLOCK_ROUTINE UnlockRoutine OPTIONAL)
VOID NTAPI FsRtlUninitializeFileLock(IN PFILE_LOCK FileLock)
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG FileAttributes
VOID UDFFlushTryBreak(IN PVCB Vcb)
ULONG UDFFlushLogicalVolume(IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp, IN PVCB Vcb, IN ULONG FlushFlags)
#define FILE_OVERWRITE_IF
#define FILE_NO_INTERMEDIATE_BUFFERING
#define FILE_WRITE_THROUGH
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING StreamName
VOID NTAPI CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
#define EXCEPTION_EXECUTE_HANDLER
BOOLEAN __fastcall UDFIsNameValid(IN PUNICODE_STRING SearchPattern, OUT BOOLEAN *StreamOpen, OUT ULONG *SNameIndex)
PWCHAR __fastcall UDFDissectName(IN PWCHAR Buffer, OUT PUSHORT Length)
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define FILE_DOES_NOT_EXIST
#define FILE_ATTRIBUTE_VALID_FLAGS
#define FILE_ATTRIBUTE_READONLY
#define FILE_ATTRIBUTE_HIDDEN
#define FILE_ATTRIBUTE_SYSTEM
#define FILE_DELETE_CHILD
#define FILE_SHARE_DELETE
#define FILE_WRITE_ATTRIBUTES
#define FILE_VALID_OPTION_FLAGS
#define FILE_ATTRIBUTE_ARCHIVE
#define FILE_ADD_SUBDIRECTORY
#define FILE_REMOVABLE_MEDIA
#define FILE_GENERIC_WRITE
#define FILE_ATTRIBUTE_TEMPORARY
#define FSRTL_VOLUME_LOCK
VOID NTAPI IoRemoveShareAccess(IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess)
#define IoCompleteRequest
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
BOOLEAN NTAPI SeSinglePrivilegeCheck(_In_ LUID PrivilegeValue, _In_ KPROCESSOR_MODE PreviousMode)
Checks if a single privilege is present in the context of the calling thread.
#define STATUS_DELETE_PENDING
#define STATUS_USER_MAPPED_FILE
#define STATUS_FILE_INVALID
#define STATUS_EAS_NOT_SUPPORTED
NTSTATUS UDFVerifyVcb(IN PtrUDFIrpContext IrpContext, IN PVCB Vcb)
NTSTATUS UDFSetAccessRights(PFILE_OBJECT FileObject, PACCESS_STATE AccessState, PtrUDFFCB Fcb, PtrUDFCCB Ccb, ACCESS_MASK DesiredAccess, USHORT ShareAccess)
NTSTATUS UDFCheckAccessRights(PFILE_OBJECT FileObject, PACCESS_STATE AccessState, PtrUDFFCB Fcb, PtrUDFCCB Ccb, ACCESS_MASK DesiredAccess, USHORT ShareAccess)
#define UDFCloseAllSystemDelayedInDir(Vcb, FI)
#define _SEH2_AbnormalTermination()
#define _SEH2_EXCEPT(...)
#define _SEH2_GetExceptionInformation()
BOOLEAN NTAPI MmCanFileBeTruncated(_In_ PSECTION_OBJECT_POINTERS SectionObjectPointer, _In_opt_ PLARGE_INTEGER NewFileSize)
BOOLEAN NTAPI MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
#define STATUS_CANNOT_DELETE
#define UDF_NODE_TYPE_NT_REQ_FCB
#define UDF_FCB_READ_ONLY
struct _UDFFileControlBlock * PtrUDFFCB
#define UDF_IRP_CONTEXT_FLUSH2_REQUIRED
#define UDF_IRP_CONTEXT_FLUSH_REQUIRED
#define UDF_CCB_READ_ONLY
#define UDF_NTREQ_FCB_VALID
#define UDF_IRP_CONTEXT_CAN_BLOCK
#define UDF_CCB_VOLUME_OPEN
struct _UDFNTRequiredFCB * PtrUDFNTRequiredFCB
#define UDF_NODE_TYPE_CCB
#define UDF_FCB_POSTED_RENAME
struct _UDFContextControlBlock * PtrUDFCCB
#define UDF_CCB_CASE_SENSETIVE
#define UDF_FCB_ROOT_DIRECTORY
#define UDF_RESIDUAL_REFERENCE
#define UDF_FCB_INITIALIZED_CCB_LIST_RESOURCE
#define UDF_NODE_TYPE_FCB
#define UDF_NTREQ_FCB_MODIFIED
#define UDF_NODE_TYPE_VCB
#define UDF_FCB_DELETE_ON_CLOSE
#define UDF_FCB_DIRECTORY
struct _UDFNTRequiredFCB UDFNTRequiredFCB
#define UDF_FCB_WRITE_THROUGH
#define UDF_CCB_DELETE_ON_CLOSE
struct _FCB::@729::@732 Fcb
PACCESS_STATE AccessState
ACCESS_MASK DesiredAccess
struct _IO_STACK_LOCATION::@3974::@3975 Create
union _IO_STACK_LOCATION::@1575 Parameters
UDFIdentifier NodeIdentifier
struct _UDFFileControlBlock * Fcb
UNICODE_STRING UnicodeStrSDir
ERESOURCE CcbListResource
struct _UDFFileControlBlock * ParentFcb
PtrUDFNTRequiredFCB NTRequiredFCB
UDFIdentifier NodeIdentifier
PDEVICE_OBJECT TargetDeviceObject
UNICODE_STRING ObjectName
struct _UDFNTRequiredFCB * CommonFcb
struct _UDFFileControlBlock * Fcb
struct _UDF_FILE_INFO * ParentFile
#define RtlZeroMemory(Destination, Length)
#define RtlMoveMemory(Destination, Source, Length)
#define UDF_VCB_IC_DIRTY_RO
#define UDF_VCB_IC_IGNORE_SEQUENTIAL_IO
#define UDF_VCB_FLAGS_VOLUME_MOUNTED
#define UDF_VCB_FLAGS_VOLUME_LOCKED
#define UDF_VCB_FLAGS_VOLUME_READ_ONLY
#define UDF_VCB_FLAGS_RAW_DISK
#define UDF_VCB_FLAGS_MEDIA_READ_ONLY
#define UDF_VCB_IC_UPDATE_DIR_READ
#define UDF_VCB_IC_UPDATE_DIR_WRITE
#define UDF_VCB_IC_SHOW_BLANK_CD
#define UDF_VCB_IC_FORCE_WRITE_THROUGH
OSSTATUS UDFRecordDirectory__(IN PVCB Vcb, IN OUT PUDF_FILE_INFO DirInfo)
OSSTATUS UDFCloseFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
OSSTATUS UDFFlushFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN ULONG FlushFlags)
uint32 UDFCleanUpFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
OSSTATUS UDFUnlinkFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN BOOLEAN FreeSpace)
OSSTATUS UDFOpenStreamDir__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, OUT PUDF_FILE_INFO *_SDirInfo)
OSSTATUS UDFResizeFile__(IN PVCB Vcb, IN OUT PUDF_FILE_INFO FileInfo, IN int64 NewLength)
OSSTATUS UDFCreateFile__(IN PVCB Vcb, IN BOOLEAN IgnoreCase, IN PUNICODE_STRING _fn, IN uint32 ExtAttrSz, IN uint32 ImpUseLen, IN BOOLEAN Extended, IN BOOLEAN CreateNew, IN OUT PUDF_FILE_INFO DirInfo, OUT PUDF_FILE_INFO *_FileInfo)
OSSTATUS UDFCreateStreamDir__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, OUT PUDF_FILE_INFO *_SDirInfo)
OSSTATUS UDFOpenFile__(IN PVCB Vcb, IN BOOLEAN IgnoreCase, IN BOOLEAN NotDeleted, IN PUNICODE_STRING fn, IN PUDF_FILE_INFO DirInfo, OUT PUDF_FILE_INFO *_FileInfo, IN uint_di *IndexToOpen)
#define UDFStreamsSupported(Vcb)
#define UDFReferenceFile__(fi)
#define UDFIsDirEmpty__(fi)
__inline PDIR_INDEX_ITEM UDFDirIndex(IN PDIR_INDEX_HDR hDirNdx, IN uint_di i)
__inline OSSTATUS UDFFindFile__(IN PVCB Vcb, IN BOOLEAN IgnoreCase, IN PUNICODE_STRING Name, IN PUDF_FILE_INFO DirInfo)
#define UDFIsAStreamDir(FI)
#define UDFIsADirectory(FileInfo)
#define UDFSetFileAllocMode__(fi, mode)
#define EXTENT_FLAG_ALLOC_SEQUENTIAL
#define STATUS_DIRECTORY_NOT_EMPTY
#define STATUS_FILE_IS_A_DIRECTORY
#define STATUS_NOT_A_DIRECTORY
#define STATUS_MEDIA_WRITE_PROTECTED
#define STATUS_ACCESS_DENIED
#define STATUS_OBJECT_PATH_NOT_FOUND
#define STATUS_INVALID_PARAMETER
#define STATUS_OBJECT_NAME_COLLISION
#define STATUS_SHARING_PAUSED
#define STATUS_FILE_DELETED
#define STATUS_SHARING_VIOLATION
#define STATUS_OBJECT_NAME_INVALID
#define STATUS_INSUFFICIENT_RESOURCES
#define STATUS_OBJECT_NAME_NOT_FOUND
#define UDFQuadAlign(Value)
#define UdfIllegalFcbAccess(Vcb, DesiredAccess)
#define UDF_CHECK_PAGING_IO_RESOURCE(NTReqFCB)
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_Must_inspect_result_ _In_ ULONG Flags
#define SL_OPEN_PAGING_FILE
#define FO_SEQUENTIAL_ONLY
#define FILE_NOTIFY_CHANGE_SIZE
#define FILE_ACTION_MODIFIED
#define FO_OPENED_CASE_SENSITIVE
#define FO_FILE_FAST_IO_READ
#define FILE_NOTIFY_CHANGE_STREAM_NAME
#define FILE_NOTIFY_CHANGE_ATTRIBUTES
#define FILE_NOTIFY_CHANGE_FILE_NAME
#define FO_FILE_SIZE_CHANGED
#define IO_DISK_INCREMENT
#define FO_NO_INTERMEDIATE_BUFFERING
#define FO_CACHE_SUPPORTED
#define FILE_ACTION_ADDED_STREAM
#define FILE_NOTIFY_CHANGE_LAST_WRITE
#define SL_OPEN_TARGET_DIRECTORY
#define FILE_ACTION_ADDED
#define FILE_NOTIFY_CHANGE_DIR_NAME
#define SL_CASE_SENSITIVE
_In_opt_ PVOID _In_opt_ PUNICODE_STRING _In_ PSECURITY_DESCRIPTOR _In_ PACCESS_STATE AccessState