ReactOS  0.4.15-dev-980-ge160524
cdprocs.h
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 1989-2000 Microsoft Corporation
4 
5 Module Name:
6 
7  CdProcs.h
8 
9 Abstract:
10 
11  This module defines all of the globally used procedures in the Cdfs
12  file system.
13 
14 
15 --*/
16 
17 #ifndef _CDPROCS_
18 #define _CDPROCS_
19 
20 #ifdef _MSC_VER
21 #pragma warning( disable: 4127 ) // conditional expression is constant
22 
23 #pragma warning( push )
24 #pragma warning( disable: 4201 ) // nonstandard extension used : nameless struct/union
25 #pragma warning( disable: 4214 ) // nonstandard extension used : bit field types
26 #endif
27 
28 #include <ntifs.h>
29 
30 #include <ntddcdrm.h>
31 #include <ntdddisk.h>
32 #include <ntddscsi.h>
33 #ifdef __REACTOS__
34 #include <pseh/pseh2.h>
35 #endif
36 
37 #ifndef INLINE
38 #define INLINE __inline
39 #endif
40 
41 #include "nodetype.h"
42 #include "cd.h"
43 #include "cdstruc.h"
44 #include "cddata.h"
45 
46 #ifdef CDFS_TELEMETRY_DATA
47 
48 #include <winmeta.h>
49 #include <TraceLoggingProvider.h>
50 #include <telemetry\MicrosoftTelemetry.h>
51 
52 #endif // CDFS_TELEMETRY_DATA
53 
54 #ifdef _MSC_VER
55 #pragma warning( pop )
56 #endif
57 
58 #ifdef __REACTOS__
59 // Downgrade unsupported NT6.2+ features.
60 #undef MdlMappingNoExecute
61 #define MdlMappingNoExecute 0
62 #define NonPagedPoolNx NonPagedPool
63 #define NonPagedPoolNxCacheAligned NonPagedPoolCacheAligned
64 #endif
65 
66 //**** x86 compiler bug ****
67 
68 #if defined(_M_IX86)
69 #undef Int64ShraMod32
70 #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b))
71 #endif
72 
73 #ifndef Min
74 #define Min(a, b) ((a) < (b) ? (a) : (b))
75 #endif
76 
77 #ifndef Max
78 #define Max(a, b) ((a) > (b) ? (a) : (b))
79 #endif
80 
81 //
82 // Here are the different pool tags.
83 //
84 
85 #define TAG_CCB 'ccdC' // Ccb
86 #define TAG_CDROM_TOC 'ctdC' // TOC
87 #define TAG_DIRENT_NAME 'nddC' // CdName in dirent
88 #define TAG_ENUM_EXPRESSION 'eedC' // Search expression for enumeration
89 #define TAG_FCB_DATA 'dfdC' // Data Fcb
90 #define TAG_FCB_INDEX 'ifdC' // Index Fcb
91 #define TAG_FCB_NONPAGED 'nfdC' // Nonpaged Fcb
92 #define TAG_FCB_TABLE 'tfdC' // Fcb Table entry
93 #define TAG_FILE_NAME 'nFdC' // Filename buffer
94 #define TAG_GEN_SHORT_NAME 'sgdC' // Generated short name
95 #define TAG_IO_BUFFER 'fbdC' // Temporary IO buffer
96 #define TAG_IO_CONTEXT 'oidC' // Io context for async reads
97 #define TAG_IRP_CONTEXT 'cidC' // Irp Context
98 #define TAG_IRP_CONTEXT_LITE 'lidC' // Irp Context lite
99 #define TAG_MCB_ARRAY 'amdC' // Mcb array
100 #define TAG_PATH_ENTRY_NAME 'nPdC' // CdName in path entry
101 #define TAG_PREFIX_ENTRY 'epdC' // Prefix Entry
102 #define TAG_PREFIX_NAME 'npdC' // Prefix Entry name
103 #define TAG_SPANNING_PATH_TABLE 'psdC' // Buffer for spanning path table
104 #define TAG_UPCASE_NAME 'nudC' // Buffer for upcased name
105 #define TAG_VOL_DESC 'dvdC' // Buffer for volume descriptor
106 #define TAG_VPB 'pvdC' // Vpb allocated in filesystem
107 
108 //
109 // Tag all of our allocations if tagging is turned on
110 //
111 
112 #ifdef POOL_TAGGING
113 
114 #undef FsRtlAllocatePool
115 #undef FsRtlAllocatePoolWithQuota
116 #define FsRtlAllocatePool(a,b) FsRtlAllocatePoolWithTag(a,b,'sfdC')
117 #define FsRtlAllocatePoolWithQuota(a,b) FsRtlAllocatePoolWithQuotaTag(a,b,'sfdC')
118 
119 #endif // POOL_TAGGING
120 
121 
122 //
123 // File access check routine, implemented in AcChkSup.c
124 //
125 
126 //
127 // BOOLEAN
128 // CdIllegalFcbAccess (
129 // _In_ PIRP_CONTEXT IrpContext,
130 // _In_ TYPE_OF_OPEN TypeOfOpen,
131 // _In_ ACCESS_MASK DesiredAccess
132 // );
133 //
134 
135 #define CdIllegalFcbAccess(IC,T,DA) ( \
136  BooleanFlagOn( (DA), \
137  ((T) != UserVolumeOpen ? \
138  (FILE_WRITE_ATTRIBUTES | \
139  FILE_WRITE_DATA | \
140  FILE_WRITE_EA | \
141  FILE_ADD_FILE | \
142  FILE_ADD_SUBDIRECTORY | \
143  FILE_APPEND_DATA) : 0) | \
144  FILE_DELETE_CHILD | \
145  DELETE | \
146  WRITE_DAC ))
147 
148 
149 //
150 // Allocation support routines, implemented in AllocSup.c
151 //
152 // These routines are for querying allocation on individual streams.
153 //
154 
155 _Requires_lock_held_(_Global_critical_region_)
156 VOID
157 CdLookupAllocation (
158  _In_ PIRP_CONTEXT IrpContext,
163  );
164 
165 VOID
167  _In_ PIRP_CONTEXT IrpContext,
168  _Inout_ PFCB Fcb,
169  _In_ ULONG McbEntryOffset,
170  _In_ LONGLONG StartingFileOffset,
172  );
173 
174 VOID
176  _In_ PIRP_CONTEXT IrpContext,
177  _Inout_ PFCB Fcb,
178  _In_ ULONG StartingBlock,
180  );
181 
182 VOID
184  _In_ PIRP_CONTEXT IrpContext,
185  _Inout_ PFCB Fcb,
186  _In_ LONGLONG StartingFileOffset
187  );
188 
189 _At_(Fcb->NodeByteSize, _In_range_(>=, FIELD_OFFSET( FCB, FcbType )))
190 VOID
191 CdInitializeMcb (
192  _In_ PIRP_CONTEXT IrpContext,
193  _Inout_updates_bytes_(Fcb->NodeByteSize) PFCB Fcb
194  );
195 
196 _At_(Fcb->NodeByteSize, _In_range_(>=, FIELD_OFFSET( FCB, FcbType )))
197 _When_(Fcb->NodeTypeCode == CDFS_NTC_FCB_PATH_TABLE, _At_(Fcb->NodeByteSize, _In_range_(==, SIZEOF_FCB_INDEX)))
198 _When_(Fcb->NodeTypeCode == CDFS_NTC_FCB_INDEX, _At_(Fcb->NodeByteSize, _In_range_(==, SIZEOF_FCB_INDEX)))
199 _When_(Fcb->NodeTypeCode == CDFS_NTC_FCB_DATA, _At_(Fcb->NodeByteSize, _In_range_(==, SIZEOF_FCB_DATA)))
200 VOID
201 CdUninitializeMcb (
202  _In_ PIRP_CONTEXT IrpContext,
203  _Inout_updates_bytes_(Fcb->NodeByteSize) PFCB Fcb
204  );
205 
206 
207 //
208 // Buffer control routines for data caching, implemented in CacheSup.c
209 //
210 
211 VOID
213  _In_ PIRP_CONTEXT IrpContext,
214  _In_ PVCB Vcb,
215  _Inout_ PFCB Fcb,
217  );
218 
219 VOID
221  _In_ PIRP_CONTEXT IrpContext,
223  );
224 
225 NTSTATUS
227  _In_ PIRP_CONTEXT IrpContext,
229  );
230 
231 _Requires_lock_held_(_Global_critical_region_)
232 NTSTATUS
233 CdPurgeVolume (
234  _In_ PIRP_CONTEXT IrpContext,
237  );
238 
239 static /* ReactOS Change: GCC "multiple definition" */
240 INLINE /* GCC only accepts __inline as the first modifier */
241 VOID
243  _In_ PIRP_CONTEXT IrpContext,
244  _In_ PFCB Fcb
245  )
246 {
247  //
248  // Unsafe test to see if call / lock neccessary.
249  //
250 
251  if (NULL == Fcb->FileObject) {
252 
253  CdCreateInternalStream( IrpContext,
254  Fcb->Vcb,
255  Fcb,
257  }
258 }
259 
260 
261 //
262 // VOID
263 // CdUnpinData (
264 // _In_ PIRP_CONTEXT IrpContext,
265 // _Inout_ PBCB *Bcb
266 // );
267 //
268 
269 #define CdUnpinData(IC,B) \
270  if (*(B) != NULL) { CcUnpinData( *(B) ); *(B) = NULL; }
271 
272 
273 //
274 // Device I/O routines, implemented in DevIoSup.c
275 //
276 // These routines perform the actual device read and writes. They only affect
277 // the on disk structure and do not alter any other data structures.
278 //
279 
280 _Requires_lock_held_(_Global_critical_region_)
281 VOID
282 CdFreeDirCache (
283  _In_ PIRP_CONTEXT IrpContext
284  );
285 
286 _Requires_lock_held_(_Global_critical_region_)
287 NTSTATUS
288 CdNonCachedRead (
289  _In_ PIRP_CONTEXT IrpContext,
293  );
294 
295 _Requires_lock_held_(_Global_critical_region_)
296 NTSTATUS
297 CdNonCachedXARead (
298  _In_ PIRP_CONTEXT IrpContext,
299  _In_ PFCB Fcb,
302  );
303 
304 _Requires_lock_held_(_Global_critical_region_)
305 NTSTATUS
306 CdVolumeDasdWrite (
307  _In_ PIRP_CONTEXT IrpContext,
308  _In_ PFCB Fcb,
311  );
312 
313 BOOLEAN
315  _In_ PIRP_CONTEXT IrpContext,
318  _In_ BOOLEAN ReturnError,
321  );
322 
323 NTSTATUS
325  _In_ PIRP_CONTEXT IrpContext,
329  );
330 
331 NTSTATUS
332 FASTCALL
334  _In_ PIRP_CONTEXT IrpContext,
340  _In_ BOOLEAN OverrideVerify,
342  );
343 
344 NTSTATUS
346  _In_ PIRP_CONTEXT IrpContext,
354  _In_ BOOLEAN OverrideVerify,
356  );
357 
358 NTSTATUS
360  _In_ PIRP_CONTEXT IrpContext,
361  _Inout_ PIRP Irp,
363  );
364 
365 
366 //
367 // VOID
368 // CdMapUserBuffer (
369 // _In_ PIRP_CONTEXT IrpContext
370 // _Out_ PVOID UserBuffer
371 // );
372 //
373 // Returns pointer to sys address. Will raise on failure.
374 //
375 //
376 // VOID
377 // CdLockUserBuffer (
378 // _Inout_ PIRP_CONTEXT IrpContext,
379 // _In_ ULONG BufferLength
380 // );
381 //
382 
383 #define CdMapUserBuffer(IC, UB) { \
384  *(UB) = (PVOID) ( ((IC)->Irp->MdlAddress == NULL) ? \
385  (IC)->Irp->UserBuffer : \
386  (MmGetSystemAddressForMdlSafe( (IC)->Irp->MdlAddress, NormalPagePriority | MdlMappingNoExecute))); \
387  if (NULL == *(UB)) { \
388  CdRaiseStatus( (IC), STATUS_INSUFFICIENT_RESOURCES); \
389  } \
390  }
391 
392 
393 #define CdLockUserBuffer(IC,BL,OP) { \
394  if ((IC)->Irp->MdlAddress == NULL) { \
395  (VOID) CdCreateUserMdl( (IC), (BL), TRUE, (OP) ); \
396  } \
397 }
398 
399 
400 //
401 // Dirent support routines, implemented in DirSup.c
402 //
403 
404 VOID
406  _In_ PIRP_CONTEXT IrpContext,
407  _In_ PFCB Fcb,
410  );
411 
412 BOOLEAN
414  _In_ PIRP_CONTEXT IrpContext,
415  _In_ PFCB Fcb,
416  _In_ PDIRENT_ENUM_CONTEXT CurrentDirContext,
417  _Inout_ PDIRENT_ENUM_CONTEXT NextDirContext
418  );
419 
420 _At_(Dirent->CdTime, _Post_notnull_)
421 VOID
422 CdUpdateDirentFromRawDirent (
423  _In_ PIRP_CONTEXT IrpContext,
427  );
428 
429 VOID
431  _In_ PIRP_CONTEXT IrpContext,
434  );
435 
436 _Success_(return != FALSE) BOOLEAN
437 CdFindFile (
438  _In_ PIRP_CONTEXT IrpContext,
444  );
445 
446 BOOLEAN
448  _In_ PIRP_CONTEXT IrpContext,
449  _In_ PFCB Fcb,
453  );
454 
455 _At_(FileContext->ShortName.FileName.MaximumLength, _In_range_(>=, BYTE_COUNT_8_DOT_3))
456 BOOLEAN
457 CdFindFileByShortName (
458  _In_ PIRP_CONTEXT IrpContext,
464  );
465 
466 BOOLEAN
468  _In_ PIRP_CONTEXT IrpContext,
469  _In_ PFCB Fcb,
471  );
472 
473 VOID
475  _In_ PIRP_CONTEXT IrpContext,
476  _In_ PFCB Fcb,
478  );
479 
480 VOID
482  _In_ PIRP_CONTEXT IrpContext,
484  );
485 
486 //
487 // VOID
488 // CdInitializeFileContext (
489 // _In_ PIRP_CONTEXT IrpContext,
490 // _Out_ PFILE_ENUM_CONTEXT FileContext
491 // );
492 //
493 //
494 // VOID
495 // CdInitializeDirent (
496 // _In_ PIRP_CONTEXT IrpContext,
497 // _Out_ PDIRENT Dirent
498 // );
499 //
500 // VOID
501 // CdInitializeDirContext (
502 // _In_ PIRP_CONTEXT IrpContext,
503 // _Out_ PDIRENT_ENUM_CONTEXT DirContext
504 // );
505 //
506 // VOID
507 // CdCleanupDirent (
508 // _In_ PIRP_CONTEXT IrpContext,
509 // _Inout_ PDIRENT Dirent
510 // );
511 //
512 // VOID
513 // CdCleanupDirContext (
514 // _In_ PIRP_CONTEXT IrpContext,
515 // _Inout_ PDIRENT_ENUM_CONTEXT DirContext
516 // );
517 //
518 // VOID
519 // CdLookupInitialFileDirent (
520 // _In_ PIRP_CONTEXT IrpContext,
521 // _In_ PFCB Fcb,
522 // _Out_ PFILE_ENUM_CONTEXT FileContext,
523 // _In_ ULONG DirentOffset
524 // );
525 //
526 
527 #define CdInitializeFileContext(IC,FC) { \
528  RtlZeroMemory( FC, sizeof( FILE_ENUM_CONTEXT )); \
529  (FC)->PriorDirent = &(FC)->Dirents[0]; \
530  (FC)->InitialDirent = &(FC)->Dirents[1]; \
531  (FC)->CurrentDirent = &(FC)->Dirents[2]; \
532  (FC)->ShortName.FileName.MaximumLength = BYTE_COUNT_8_DOT_3; \
533  (FC)->ShortName.FileName.Buffer = (FC)->ShortNameBuffer; \
534 }
535 
536 #define CdInitializeDirent(IC,D) \
537  RtlZeroMemory( D, sizeof( DIRENT ))
538 
539 #define CdInitializeDirContext(IC,DC) \
540  RtlZeroMemory( DC, sizeof( DIRENT_ENUM_CONTEXT ))
541 
542 #define CdCleanupDirent(IC,D) { \
543  if (FlagOn( (D)->Flags, DIRENT_FLAG_ALLOC_BUFFER )) { \
544  CdFreePool( &(D)->CdFileName.FileName.Buffer ); \
545  } \
546 }
547 
548 #define CdCleanupDirContext(IC,DC) \
549  CdUnpinData( (IC), &(DC)->Bcb )
550 
551 #define CdLookupInitialFileDirent(IC,F,FC,DO) \
552  CdLookupDirent( IC, \
553  F, \
554  DO, \
555  &(FC)->InitialDirent->DirContext ); \
556  CdUpdateDirentFromRawDirent( IC, \
557  F, \
558  &(FC)->InitialDirent->DirContext, \
559  &(FC)->InitialDirent->Dirent )
560 
561 
562 //
563 // The following routines are used to manipulate the fscontext fields
564 // of the file object, implemented in FilObSup.c
565 //
566 
567 //
568 // Type of opens. FilObSup.c depends on this order.
569 //
570 
571 typedef enum _TYPE_OF_OPEN {
572 
579 
580 } TYPE_OF_OPEN;
582 
585 VOID
586 CdSetFileObject (
587  _In_ PIRP_CONTEXT IrpContext,
590  PFCB Fcb,
592  );
593 
599 CdDecodeFileObject (
600  _In_ PIRP_CONTEXT IrpContext,
602  PFCB *Fcb,
603  PCCB *Ccb
604  );
605 
609  _Out_ PFCB *Fcb
610  );
611 
612 
613 //
614 // Name support routines, implemented in NameSup.c
615 //
616 
619 VOID
620 CdConvertNameToCdName (
621  _In_ PIRP_CONTEXT IrpContext,
623  );
624 
625 VOID
627  _In_ PIRP_CONTEXT IrpContext,
628  _In_reads_bytes_(ByteCount) PCHAR BigEndian,
630  _Out_writes_bytes_(ByteCount) PCHAR LittleEndian
631  );
632 
633 VOID
634 CdUpcaseName (
635  _In_ PIRP_CONTEXT IrpContext,
637  _Inout_ PCD_NAME UpcaseName
638  );
639 
640 VOID
642  _In_ PIRP_CONTEXT IrpContext,
644  _Out_ PUNICODE_STRING FinalName
645  );
646 
647 BOOLEAN
649  _In_ PIRP_CONTEXT IrpContext,
651  );
652 
653 BOOLEAN
655  _In_ PIRP_CONTEXT IrpContext,
657  );
658 
659 VOID
661  _In_ PIRP_CONTEXT IrpContext,
664  _Out_writes_bytes_to_(BYTE_COUNT_8_DOT_3, *ShortByteCount) PWCHAR ShortFileName,
665  _Out_ PUSHORT ShortByteCount
666  );
667 
668 BOOLEAN
670  _In_ PIRP_CONTEXT IrpContext,
671  _In_ PCD_NAME CurrentName,
672  _In_ PCD_NAME SearchExpression,
673  _In_ ULONG WildcardFlags,
674  _In_ BOOLEAN CheckVersion
675  );
676 
677 ULONG
679  _In_ PIRP_CONTEXT IrpContext,
681  );
682 
685  _In_ PIRP_CONTEXT IrpContext,
686  _In_ PUNICODE_STRING NameA,
687  _In_ PUNICODE_STRING NameB
688  );
689 
690 
691 //
692 // Filesystem control operations. Implemented in Fsctrl.c
693 //
694 
695 _Requires_lock_held_(_Global_critical_region_)
696 _Requires_lock_held_(Vcb->VcbResource)
697 NTSTATUS
698 CdLockVolumeInternal (
699  _In_ PIRP_CONTEXT IrpContext,
700  _Inout_ PVCB Vcb,
702  );
703 
704 NTSTATUS
706  _In_ PIRP_CONTEXT IrpContext,
707  _Inout_ PVCB Vcb,
709  );
710 
711 
712 //
713 // Path table enumeration routines. Implemented in PathSup.c
714 //
715 
716 VOID
718  _In_ PIRP_CONTEXT IrpContext,
719  _In_ ULONG PathEntryOffset,
720  _In_ ULONG Ordinal,
721  _In_ BOOLEAN VerifyBounds,
723  );
724 
725 BOOLEAN
727  _In_ PIRP_CONTEXT IrpContext,
728  _Inout_ PPATH_ENUM_CONTEXT PathContext,
729  _Inout_ PPATH_ENTRY PathEntry
730  );
731 
733 BOOLEAN
734 CdFindPathEntry (
735  _In_ PIRP_CONTEXT IrpContext,
740  );
741 
742 VOID
744  _In_ PIRP_CONTEXT IrpContext,
745  _Inout_ PPATH_ENTRY PathEntry,
747  );
748 
749 //
750 // VOID
751 // CdInitializeCompoundPathEntry (
752 // _In_ PIRP_CONTEXT IrpContext,
753 // _Out_ PCOMPOUND_PATH_ENTRY CompoundPathEntry
754 // );
755 //
756 // VOID
757 // CdCleanupCompoundPathEntry (
758 // _In_ PIRP_CONTEXT IrpContext,
759 // _Out_ PCOMPOUND_PATH_ENTRY CompoundPathEntry
760 // );
761 //
762 
763 #define CdInitializeCompoundPathEntry(IC,CP) \
764  RtlZeroMemory( CP, sizeof( COMPOUND_PATH_ENTRY ))
765 
766 #define CdCleanupCompoundPathEntry(IC,CP) { \
767  CdUnpinData( (IC), &(CP)->PathContext.Bcb ); \
768  if ((CP)->PathContext.AllocatedData) { \
769  CdFreePool( &(CP)->PathContext.Data ); \
770  } \
771  if (FlagOn( (CP)->PathEntry.Flags, PATH_ENTRY_FLAG_ALLOC_BUFFER )) { \
772  CdFreePool( &(CP)->PathEntry.CdDirName.FileName.Buffer ); \
773  } \
774 }
775 
776 
777 //
778 // Largest matching prefix searching routines, implemented in PrefxSup.c
779 //
780 
781 VOID
783  _In_ PIRP_CONTEXT IrpContext,
784  _Inout_ PFCB Fcb,
787  _In_ BOOLEAN ShortNameMatch,
789  );
790 
791 VOID
793  _In_ PIRP_CONTEXT IrpContext,
795  );
796 
797 _Requires_lock_held_(_Global_critical_region_)
798 VOID
799 CdFindPrefix (
800  _In_ PIRP_CONTEXT IrpContext,
804  );
805 
806 
807 //
808 // Synchronization routines. Implemented in Resrcsup.c
809 //
810 // The following routines/macros are used to synchronize the in-memory structures.
811 //
812 // Routine/Macro Synchronizes Subsequent
813 //
814 // CdAcquireCdData Volume Mounts/Dismounts,Vcb Queue CdReleaseCdData
815 // CdAcquireVcbExclusive Vcb for open/close CdReleaseVcb
816 // CdAcquireVcbShared Vcb for open/close CdReleaseVcb
817 // CdAcquireAllFiles Locks out operations to all files CdReleaseAllFiles
818 // CdAcquireFileExclusive Locks out file operations CdReleaseFile
819 // CdAcquireFileShared Files for file operations CdReleaseFile
820 // CdAcquireFcbExclusive Fcb for open/close CdReleaseFcb
821 // CdAcquireFcbShared Fcb for open/close CdReleaseFcb
822 // CdLockCdData Fields in CdData CdUnlockCdData
823 // CdLockVcb Vcb fields, FcbReference, FcbTable CdUnlockVcb
824 // CdLockFcb Fcb fields, prefix table, Mcb CdUnlockFcb
825 //
826 
827 typedef enum _TYPE_OF_ACQUIRE {
828 
832 
834 
835 _Requires_lock_held_(_Global_critical_region_)
840 BOOLEAN
841 CdAcquireResource (
842  _In_ PIRP_CONTEXT IrpContext,
846  );
847 
848 //
849 // BOOLEAN
850 // CdAcquireCdData (
851 // _In_ PIRP_CONTEXT IrpContext
852 // );
853 //
854 // VOID
855 // CdReleaseCdData (
856 // _In_ PIRP_CONTEXT IrpContext
857 // );
858 //
859 // BOOLEAN
860 // CdAcquireVcbExclusive (
861 // _In_ PIRP_CONTEXT IrpContext,
862 // _Inout_ PVCB Vcb,
863 // _In_ BOOLEAN IgnoreWait
864 // );
865 //
866 // BOOLEAN
867 // CdAcquireVcbShared (
868 // _In_ PIRP_CONTEXT IrpContext,
869 // _Inout_ PVCB Vcb,
870 // _In_ BOOLEAN IgnoreWait
871 // );
872 //
873 // VOID
874 // CdReleaseVcb (
875 // _In_ PIRP_CONTEXT IrpContext,
876 // _Inout_ PVCB Vcb
877 // );
878 //
879 // VOID
880 // CdAcquireAllFiles (
881 // _In_ PIRP_CONTEXT,
882 // _In_ PVCB Vcb
883 // );
884 //
885 // VOID
886 // CdReleaseAllFiles (
887 // _In_ PIRP_CONTEXT,
888 // _In_ PVCB Vcb
889 // );
890 //
891 // VOID
892 // CdAcquireFileExclusive (
893 // _In_ PIRP_CONTEXT IrpContext,
894 // _Inout_ PFCB Fcb,
895 // );
896 //
897 // VOID
898 // CdAcquireFileShared (
899 // _In_ PIRP_CONTEXT IrpContext,
900 // _Inout_ PFCB Fcb
901 // );
902 //
903 // VOID
904 // CdReleaseFile (
905 // _In_ PIRP_CONTEXT IrpContext,
906 // _Inout_ PFCB Fcb
907 // );
908 //
909 // BOOLEAN
910 // CdAcquireFcbExclusive (
911 // _In_ PIRP_CONTEXT IrpContext,
912 // _Inout_ PFCB Fcb,
913 // _In_ BOOLEAN IgnoreWait
914 // );
915 //
916 // BOOLEAN
917 // CdAcquireFcbShared (
918 // _In_ PIRP_CONTEXT IrpContext,
919 // _Inout_ PFCB Fcb,
920 // _In_ BOOLEAN IgnoreWait
921 // );
922 //
923 // BOOLEAN
924 // CdReleaseFcb (
925 // _In_ PIRP_CONTEXT IrpContext,
926 // _Inout_ PFCB Fcb
927 // );
928 //
929 // VOID
930 // CdLockCdData (
931 // );
932 //
933 // VOID
934 // CdUnlockCdData (
935 // );
936 //
937 // VOID
938 // CdLockVcb (
939 // _In_ PIRP_CONTEXT IrpContext
940 // );
941 //
942 // VOID
943 // CdUnlockVcb (
944 // _In_ PIRP_CONTEXT IrpContext
945 // );
946 //
947 // VOID
948 // CdLockFcb (
949 // _In_ PIRP_CONTEXT IrpContext,
950 // _Inout_ PFCB Fcb
951 // );
952 //
953 // VOID
954 // CdUnlockFcb (
955 // _In_ PIRP_CONTEXT IrpContext,
956 // _Inout_ PFCB Fcb
957 // );
958 //
959 
960 
961 #define CdAcquireCacheForRead( IC) \
962  ExAcquireResourceSharedLite( &(IC)->Vcb->SectorCacheResource, TRUE)
963 
964 #define CdAcquireCacheForUpdate( IC) \
965  ExAcquireResourceExclusiveLite( &(IC)->Vcb->SectorCacheResource, TRUE)
966 
967 #define CdReleaseCache( IC) \
968  ExReleaseResourceLite( &(IC)->Vcb->SectorCacheResource);
969 
970 #define CdConvertCacheToShared( IC) \
971  ExConvertExclusiveToSharedLite( &(IC)->Vcb->SectorCacheResource);
972 
973 #define CdAcquireCdData(IC) \
974  ExAcquireResourceExclusiveLite( &CdData.DataResource, TRUE )
975 
976 #define CdReleaseCdData(IC) \
977  ExReleaseResourceLite( &CdData.DataResource )
978 
979 #define CdAcquireVcbExclusive(IC,V,I) \
980  CdAcquireResource( (IC), &(V)->VcbResource, (I), AcquireExclusive )
981 
982 #define CdAcquireVcbShared(IC,V,I) \
983  CdAcquireResource( (IC), &(V)->VcbResource, (I), AcquireShared )
984 
985 #define CdReleaseVcb(IC,V) \
986  ExReleaseResourceLite( &(V)->VcbResource )
987 
988 #define CdAcquireAllFiles(IC,V) \
989  CdAcquireResource( (IC), &(V)->FileResource, FALSE, AcquireExclusive )
990 
991 #define CdReleaseAllFiles(IC,V) \
992  ExReleaseResourceLite( &(V)->FileResource )
993 
994 #define CdAcquireFileExclusive(IC,F) \
995  CdAcquireResource( (IC), (F)->Resource, FALSE, AcquireExclusive )
996 
997 #define CdAcquireFileShared(IC,F) \
998  CdAcquireResource( (IC), (F)->Resource, FALSE, AcquireShared )
999 
1000 #define CdAcquireFileSharedStarveExclusive(IC,F) \
1001  CdAcquireResource( (IC), (F)->Resource, FALSE, AcquireSharedStarveExclusive )
1002 
1003 #define CdReleaseFile(IC,F) \
1004  ExReleaseResourceLite( (F)->Resource )
1005 
1006 #define CdAcquireFcbExclusive(IC,F,I) \
1007  CdAcquireResource( (IC), &(F)->FcbNonpaged->FcbResource, (I), AcquireExclusive )
1008 
1009 #define CdAcquireFcbShared(IC,F,I) \
1010  CdAcquireResource( (IC), &(F)->FcbNonpaged->FcbResource, (I), AcquireShared )
1011 
1012 #define CdReleaseFcb(IC,F) \
1013  ExReleaseResourceLite( &(F)->FcbNonpaged->FcbResource )
1014 
1015 #define CdLockCdData() \
1016  ExAcquireFastMutex( &CdData.CdDataMutex ); \
1017  CdData.CdDataLockThread = PsGetCurrentThread()
1018 
1019 #define CdUnlockCdData() \
1020  CdData.CdDataLockThread = NULL; \
1021  ExReleaseFastMutex( &CdData.CdDataMutex )
1022 
1023 #define CdLockVcb(IC,V) \
1024  ExAcquireFastMutex( &(V)->VcbMutex ); \
1025  NT_ASSERT( NULL == (V)->VcbLockThread); \
1026  (V)->VcbLockThread = PsGetCurrentThread()
1027 
1028 #define CdUnlockVcb(IC,V) \
1029  NT_ASSERT( NULL != (V)->VcbLockThread); \
1030  (V)->VcbLockThread = NULL; \
1031  ExReleaseFastMutex( &(V)->VcbMutex )
1032 
1033 #if defined(_PREFAST_)
1034 
1035 _Success_(return)
1036 _IRQL_saves_global_(OldIrql, FastMutex)
1037 BOOLEAN DummySaveIrql(_Inout_ PFAST_MUTEX FastMutex);
1038 
1039 _Success_(return)
1040 _IRQL_restores_global_(OldIrql, FastMutex)
1041 BOOLEAN DummyRestoreIrql(_Inout_ PFAST_MUTEX FastMutex);
1042 #endif // _PREFAST_
1043 
1044 #define CdLockFcb(IC,F) { \
1045  PVOID _CurrentThread = PsGetCurrentThread(); \
1046  if (_CurrentThread != (F)->FcbLockThread) { \
1047  ExAcquireFastMutex( &(F)->FcbNonpaged->FcbMutex ); \
1048  NT_ASSERT( (F)->FcbLockCount == 0 ); \
1049  _Analysis_assume_( (F)->FcbLockCount == 0 ); \
1050  (F)->FcbLockThread = _CurrentThread; \
1051  } \
1052  else \
1053  { \
1054  _Analysis_assume_lock_held_( (F)->FcbNonpaged->FcbMutex ); \
1055  _Analysis_assume_(FALSE != DummySaveIrql(&(F)->FcbNonpaged->FcbMutex)); \
1056  } \
1057  (F)->FcbLockCount += 1; \
1058 }
1059 
1060 #define CdUnlockFcb(IC,F) { \
1061  (F)->FcbLockCount -= 1; \
1062  if ((F)->FcbLockCount == 0) { \
1063  (F)->FcbLockThread = NULL; \
1064  ExReleaseFastMutex( &(F)->FcbNonpaged->FcbMutex ); \
1065  } \
1066  else \
1067  { \
1068  _Analysis_assume_lock_not_held_( (F)->FcbNonpaged->FcbMutex ); \
1069  _Analysis_assume_(FALSE != DummyRestoreIrql(&(F)->FcbNonpaged->FcbMutex)); \
1070  } \
1071 }
1072 
1073 //
1074 // The following macro is used to retrieve the oplock structure within
1075 // the Fcb. This structure was moved to the advanced Fcb header
1076 // in Win8.
1077 //
1078 
1079 #if (NTDDI_VERSION >= NTDDI_WIN8)
1080 
1081 #define CdGetFcbOplock(F) &(F)->Header.Oplock
1082 
1083 #else
1084 
1085 #define CdGetFcbOplock(F) &(F)->Oplock
1086 
1087 #endif
1088 
1089 BOOLEAN
1090 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
1091 CdNoopAcquire (
1092  _In_ PVOID Fcb,
1093  _In_ BOOLEAN Wait
1094  );
1095 
1096 VOID
1097 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
1098 CdNoopRelease (
1099  _In_ PVOID Fcb
1100  );
1101 
1102 _Requires_lock_held_(_Global_critical_region_)
1103 _When_(return!=0, _Acquires_shared_lock_(*Fcb->Resource))
1104 BOOLEAN
1105 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
1107  _Inout_ PFCB Fcb,
1108  _In_ BOOLEAN Wait
1109  );
1110 
1111 _Requires_lock_held_(_Global_critical_region_)
1113 VOID
1114 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
1115 CdReleaseFromCache (
1116  _Inout_ PFCB Fcb
1117  );
1118 
1119 _Requires_lock_held_(_Global_critical_region_)
1120 NTSTATUS
1121 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
1122 CdFilterCallbackAcquireForCreateSection (
1124  _Unreferenced_parameter_ PVOID *CompletionContext
1125  );
1126 
1127 _Function_class_(FAST_IO_RELEASE_FILE)
1128 _Requires_lock_held_(_Global_critical_region_)
1129 VOID
1130 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
1131 CdReleaseForCreateSection (
1133  );
1134 
1135 
1136 //
1137 // In-memory structure support routines. Implemented in StrucSup.c
1138 //
1139 
1140 VOID
1142  _In_ PIRP_CONTEXT IrpContext,
1143  _Inout_ PVCB Vcb,
1147  _In_ ULONG TocLength,
1148  _In_ ULONG TocTrackCount,
1149  _In_ ULONG TocDiskFlags,
1150  _In_ ULONG BlockFactor,
1151  _In_ ULONG MediaChangeCount
1152  );
1153 
1154 VOID
1156  _In_ PIRP_CONTEXT IrpContext,
1157  _Inout_ PVCB Vcb,
1159  );
1160 
1161 VOID
1162 CdDeleteVcb (
1163  _In_ PIRP_CONTEXT IrpContext,
1164  _Inout_ PVCB Vcb
1165  );
1166 
1167 PFCB
1168 CdCreateFcb (
1169  _In_ PIRP_CONTEXT IrpContext,
1170  _In_ FILE_ID FileId,
1171  _In_ NODE_TYPE_CODE NodeTypeCode,
1172  _Out_opt_ PBOOLEAN FcbExisted
1173  );
1174 
1175 VOID
1177  _In_ PIRP_CONTEXT IrpContext,
1178  _Inout_ PFCB Fcb,
1180  _In_ PPATH_ENTRY PathEntry
1181  );
1182 
1183 VOID
1185  _In_ PIRP_CONTEXT IrpContext,
1186  _Inout_ PFCB Fcb,
1189  );
1190 
1191 PCCB
1192 CdCreateCcb (
1193  _In_ PIRP_CONTEXT IrpContext,
1194  _In_ PFCB Fcb,
1195  _In_ ULONG Flags
1196  );
1197 
1198 VOID
1199 CdDeleteCcb (
1200  _In_ PIRP_CONTEXT IrpContext,
1202  );
1203 
1205 _When_(RaiseOnError, _At_(IrpContext, _Pre_notnull_))
1206 BOOLEAN
1207 CdCreateFileLock (
1208  _In_opt_ PIRP_CONTEXT IrpContext,
1211  );
1212 
1213 VOID
1215  _In_ PIRP_CONTEXT IrpContext,
1216  _Inout_ PFILE_LOCK FileLock
1217  );
1218 
1221  _In_ PIRP Irp,
1222  _In_ BOOLEAN Wait
1223  );
1224 
1225 VOID
1227  _In_ PIRP_CONTEXT IrpContext,
1228  _In_ BOOLEAN Post
1229  );
1230 
1231 VOID
1233  _Out_ PIRP_CONTEXT IrpContext,
1234  _In_ PIRP_CONTEXT_LITE IrpContextLite
1235  );
1236 
1237 //
1238 // PIRP_CONTEXT_LITE
1239 // CdCreateIrpContextLite (
1240 // _In_ PIRP_CONTEXT IrpContext
1241 // );
1242 //
1243 // VOID
1244 // CdFreeIrpContextLite (
1245 // _Inout_ PIRP_CONTEXT_LITE IrpContextLite
1246 // );
1247 //
1248 
1249 #define CdCreateIrpContextLite(IC) \
1250  ExAllocatePoolWithTag( CdNonPagedPool, sizeof( IRP_CONTEXT_LITE ), TAG_IRP_CONTEXT_LITE )
1251 
1252 #define CdFreeIrpContextLite(ICL) \
1253  CdFreePool( &(ICL) )
1254 
1255 _Requires_lock_held_(_Global_critical_region_)
1256 VOID
1257 CdTeardownStructures (
1258  _In_ PIRP_CONTEXT IrpContext,
1261  );
1262 
1263 //
1264 // VOID
1265 // CdIncrementCleanupCounts (
1266 // _In_ PIRP_CONTEXT IrpContext,
1267 // _Inout_ PFCB Fcb
1268 // );
1269 //
1270 // VOID
1271 // CdDecrementCleanupCounts (
1272 // _In_ PIRP_CONTEXT IrpContext,
1273 // _Inout_ PFCB Fcb
1274 // );
1275 //
1276 // VOID
1277 // CdIncrementReferenceCounts (
1278 // _In_ PIRP_CONTEXT IrpContext,
1279 // _Inout_ PFCB Fcb,
1280 // _In_ ULONG ReferenceCount
1281 // _In_ ULONG UserReferenceCount
1282 // );
1283 //
1284 // VOID
1285 // CdDecrementReferenceCounts (
1286 // _In_ PIRP_CONTEXT IrpContext,
1287 // _Inout_ PFCB Fcb,
1288 // _In_ ULONG ReferenceCount
1289 // _In_ ULONG UserReferenceCount
1290 // );
1291 //
1292 // VOID
1293 // CdIncrementFcbReference (
1294 // _In_ PIRP_CONTEXT IrpContext,
1295 // _Inout_ PFCB Fcb
1296 // );
1297 //
1298 // VOID
1299 // CdDecrementFcbReference (
1300 // _In_ PIRP_CONTEXT IrpContext,
1301 // _Inout_ PFCB Fcb
1302 // );
1303 //
1304 
1305 #define CdIncrementCleanupCounts(IC,F) { \
1306  ASSERT_LOCKED_VCB( (F)->Vcb ); \
1307  (F)->FcbCleanup += 1; \
1308  (F)->Vcb->VcbCleanup += 1; \
1309 }
1310 
1311 #define CdDecrementCleanupCounts(IC,F) { \
1312  ASSERT_LOCKED_VCB( (F)->Vcb ); \
1313  (F)->FcbCleanup -= 1; \
1314  (F)->Vcb->VcbCleanup -= 1; \
1315 }
1316 
1317 #define CdIncrementReferenceCounts(IC,F,C,UC) { \
1318  ASSERT_LOCKED_VCB( (F)->Vcb ); \
1319  (F)->FcbReference += (C); \
1320  (F)->FcbUserReference += (UC); \
1321  (F)->Vcb->VcbReference += (C); \
1322  (F)->Vcb->VcbUserReference += (UC); \
1323 }
1324 
1325 #define CdDecrementReferenceCounts(IC,F,C,UC) { \
1326  ASSERT_LOCKED_VCB( (F)->Vcb ); \
1327  (F)->FcbReference -= (C); \
1328  (F)->FcbUserReference -= (UC); \
1329  (F)->Vcb->VcbReference -= (C); \
1330  (F)->Vcb->VcbUserReference -= (UC); \
1331 }
1332 
1333 //
1334 // PCD_IO_CONTEXT
1335 // CdAllocateIoContext (
1336 // );
1337 //
1338 // VOID
1339 // CdFreeIoContext (
1340 // PCD_IO_CONTEXT IoContext
1341 // );
1342 //
1343 
1344 #define CdAllocateIoContext() \
1345  FsRtlAllocatePoolWithTag( CdNonPagedPool, \
1346  sizeof( CD_IO_CONTEXT ), \
1347  TAG_IO_CONTEXT )
1348 
1349 #define CdFreeIoContext(IO) CdFreePool( (PVOID) &(IO) ) /* ReactOS Change: GCC "passing argument 1 from incompatible pointer type" */
1350 
1351 PFCB
1353  _In_ PIRP_CONTEXT IrpContext,
1354  _In_ PVCB Vcb,
1355  _In_ FILE_ID FileId
1356  );
1357 
1358 PFCB
1359 CdGetNextFcb (
1360  _In_ PIRP_CONTEXT IrpContext,
1361  _In_ PVCB Vcb,
1362  _In_ PVOID *RestartKey
1363  );
1364 
1365 NTSTATUS
1366 CdProcessToc (
1367  _In_ PIRP_CONTEXT IrpContext,
1369  _In_ PCDROM_TOC_LARGE CdromToc,
1371  _Out_ PULONG TrackCount,
1372  _Inout_ PULONG DiskFlags
1373  );
1374 
1375 //
1376 // For debugging purposes we sometimes want to allocate our structures from nonpaged
1377 // pool so that in the kernel debugger we can walk all the structures.
1378 //
1379 
1380 #define CdPagedPool PagedPool
1381 #define CdNonPagedPool NonPagedPoolNx
1382 #define CdNonPagedPoolCacheAligned NonPagedPoolNxCacheAligned
1383 
1384 
1385 //
1386 // Verification support routines. Contained in verfysup.c
1387 //
1388 
1389 static /* ReactOS Change: GCC "multiple definition" */
1390 INLINE
1391 BOOLEAN
1393  _In_ PIRP_CONTEXT IrpContext
1394  )
1395 {
1397 
1398  return ((IrpContext->MajorFunction == IRP_MJ_CREATE) &&
1399  (IrpSp->FileObject->FileName.Length == 0) &&
1400  (IrpSp->FileObject->RelatedFileObject == NULL));
1401 }
1402 
1403 _Requires_lock_held_(_Global_critical_region_)
1404 NTSTATUS
1405 CdPerformVerify (
1406  _Inout_ PIRP_CONTEXT IrpContext,
1409  );
1410 
1411 _Requires_lock_held_(_Global_critical_region_)
1412 BOOLEAN
1413 CdCheckForDismount (
1414  _In_ PIRP_CONTEXT IrpContext,
1417  );
1418 
1419 BOOLEAN
1421  _Inout_ PVCB Vcb
1422  );
1423 
1424 VOID
1425 CdVerifyVcb (
1426  _In_ PIRP_CONTEXT IrpContext,
1427  _Inout_ PVCB Vcb
1428  );
1429 
1430 BOOLEAN
1432  _In_opt_ PIRP_CONTEXT IrpContext,
1433  _In_ PFCB Fcb
1434  );
1435 
1436 _Requires_lock_held_(_Global_critical_region_)
1437 BOOLEAN
1438 CdDismountVcb (
1439  _In_ PIRP_CONTEXT IrpContext,
1440  _Inout_ PVCB Vcb
1441  );
1442 
1443 
1444 //
1445 // Macros to abstract device verify flag changes.
1446 //
1447 
1448 #define CdUpdateMediaChangeCount( V, C) (V)->MediaChangeCount = (C)
1449 #define CdUpdateVcbCondition( V, C) (V)->VcbCondition = (C)
1450 
1451 #define CdMarkRealDevForVerify( DO) SetFlag( (DO)->Flags, DO_VERIFY_VOLUME)
1452 
1453 #define CdMarkRealDevVerifyOk( DO) ClearFlag( (DO)->Flags, DO_VERIFY_VOLUME)
1454 
1455 
1456 #define CdRealDevNeedsVerify( DO) BooleanFlagOn( (DO)->Flags, DO_VERIFY_VOLUME)
1457 
1458 //
1459 // BOOLEAN
1460 // CdIsRawDevice (
1461 // _In_ PIRP_CONTEXT IrpContext,
1462 // _In_ NTSTATUS Status
1463 // );
1464 //
1465 
1466 #define CdIsRawDevice(IC,S) ( \
1467  ((S) == STATUS_DEVICE_NOT_READY) || \
1468  ((S) == STATUS_NO_MEDIA_IN_DEVICE) \
1469 )
1470 
1471 
1472 //
1473 // Work queue routines for posting and retrieving an Irp, implemented in
1474 // workque.c
1475 //
1476 
1477 _Requires_lock_held_(_Global_critical_region_)
1478 NTSTATUS
1479 CdFsdPostRequest (
1480  _Inout_ PIRP_CONTEXT IrpContext,
1481  _Inout_ PIRP Irp
1482  );
1483 
1484 _Requires_lock_held_(_Global_critical_region_)
1485 VOID
1486 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
1487 CdPrePostIrp (
1488  _Inout_ PIRP_CONTEXT IrpContext,
1489  _Inout_ PIRP Irp
1490  );
1491 
1492 _Requires_lock_held_(_Global_critical_region_)
1493 VOID
1494 NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
1495 CdOplockComplete (
1496  _Inout_ PIRP_CONTEXT IrpContext,
1497  _Inout_ PIRP Irp
1498  );
1499 
1500 
1501 //
1502 // Miscellaneous support routines
1503 //
1504 
1505 //
1506 // This macro returns TRUE if a flag in a set of flags is on and FALSE
1507 // otherwise
1508 //
1509 
1510 /* GCC complains about multi-line comments.
1511 //#ifndef BooleanFlagOn
1512 //#define BooleanFlagOn(F,SF) ( \
1513 // (BOOLEAN)(((F) & (SF)) != 0) \
1514 //)
1515 //#endif
1516 
1517 //#ifndef SetFlag
1518 //#define SetFlag(Flags,SingleFlag) { \
1519 // (Flags) |= (SingleFlag); \
1520 //}
1521 //#endif
1522 
1523 //#ifndef ClearFlag
1524 //#define ClearFlag(Flags,SingleFlag) { \
1525 // (Flags) &= ~(SingleFlag); \
1526 //}
1527 //#endif
1528 */
1529 
1530 //
1531 // CAST
1532 // Add2Ptr (
1533 // _In_ PVOID Pointer,
1534 // _In_ ULONG Increment
1535 // _In_ (CAST)
1536 // );
1537 //
1538 // ULONG
1539 // PtrOffset (
1540 // _In_ PVOID BasePtr,
1541 // _In_ PVOID OffsetPtr
1542 // );
1543 //
1544 
1545 #define Add2Ptr(PTR,INC,CAST) ((CAST)((PUCHAR)(PTR) + (INC)))
1546 
1547 #define PtrOffset(BASE,OFFSET) ((ULONG)((ULONG_PTR)(OFFSET) - (ULONG_PTR)(BASE)))
1548 
1549 //
1550 // This macro takes a pointer (or ulong) and returns its rounded up word
1551 // value
1552 //
1553 
1554 #define WordAlign(Ptr) ( \
1555  ((((ULONG)(Ptr)) + 1) & 0xfffffffe) \
1556  )
1557 
1558 //
1559 // This macro takes a pointer (or ulong) and returns its rounded up longword
1560 // value
1561 //
1562 
1563 #define LongAlign(Ptr) ( \
1564  ((((ULONG)(Ptr)) + 3) & 0xfffffffc) \
1565  )
1566 
1567 //
1568 // This macro takes a pointer (or ulong) and returns its rounded up quadword
1569 // value
1570 //
1571 
1572 #define QuadAlign(Ptr) ( \
1573  ((((ULONG)(Ptr)) + 7) & 0xfffffff8) \
1574  )
1575 
1576 //
1577 // The following macros round up and down to sector boundaries.
1578 //
1579 
1580 #define SectorAlign(L) ( \
1581  ((((ULONG)(L)) + (SECTOR_SIZE - 1)) & ~(SECTOR_SIZE - 1)) \
1582 )
1583 
1584 #define LlSectorAlign(L) ( \
1585  ((((LONGLONG)(L)) + (SECTOR_SIZE - 1)) & ~(SECTOR_SIZE - 1)) \
1586 )
1587 
1588 #define SectorTruncate(L) ( \
1589  ((ULONG)(L)) & ~(SECTOR_SIZE - 1) \
1590 )
1591 
1592 #define LlSectorTruncate(L) ( \
1593  ((LONGLONG)(L)) & ~(SECTOR_SIZE - 1) \
1594 )
1595 
1596 #define BytesFromSectors(L) ( \
1597  ((ULONG) (L)) << SECTOR_SHIFT \
1598 )
1599 
1600 #define SectorsFromBytes(L) ( \
1601  ((ULONG) (L)) >> SECTOR_SHIFT \
1602 )
1603 
1604 static /* ReactOS Change: GCC "multiple definition" */
1605 INLINE
1606 ULONG
1609 ) {
1610 
1611  return (ULONG)(Bytes >> SECTOR_SHIFT);
1612 }
1613 
1614 #define LlBytesFromSectors(L) ( \
1615  Int64ShllMod32( (LONGLONG)(L), SECTOR_SHIFT ) \
1616 )
1617 
1618 #define LlSectorsFromBytes(L) ( \
1619  Int64ShraMod32( (LONGLONG)(L), SECTOR_SHIFT ) \
1620 )
1621 
1622 #define SectorOffset(L) ( \
1623  ((ULONG)(ULONG_PTR) (L)) & SECTOR_MASK \
1624 )
1625 
1626 #define SectorBlockOffset(V,LB) ( \
1627  ((ULONG) (LB)) & ((V)->BlocksPerSector - 1) \
1628 )
1629 
1630 #define BytesFromBlocks(V,B) ( \
1631  (ULONG) (B) << (V)->BlockToByteShift \
1632 )
1633 
1634 #define LlBytesFromBlocks(V,B) ( \
1635  Int64ShllMod32( (LONGLONG) (B), (V)->BlockToByteShift ) \
1636 )
1637 
1638 #define BlockAlign(V,L) ( \
1639  ((ULONG)(L) + (V)->BlockMask) & (V)->BlockInverseMask \
1640 )
1641 
1642 //
1643 // Carefully make sure the mask is sign extended to 64bits
1644 //
1645 
1646 #define LlBlockAlign(V,L) ( \
1647  ((LONGLONG)(L) + (V)->BlockMask) & (LONGLONG)((LONG)(V)->BlockInverseMask) \
1648 )
1649 
1650 #define BlockOffset(V,L) ( \
1651  ((ULONG) (L)) & (V)->BlockMask \
1652 )
1653 
1654 #define RawSectorAlign( B) ((((B)+(RAW_SECTOR_SIZE - 1)) / RAW_SECTOR_SIZE) * RAW_SECTOR_SIZE)
1655 
1656 //
1657 // The following types and macros are used to help unpack the packed and
1658 // misaligned fields found in the Bios parameter block
1659 //
1660 
1661 typedef union _UCHAR1 {
1664 } UCHAR1, *PUCHAR1;
1665 
1666 typedef union _UCHAR2 {
1669 } UCHAR2, *PUCHAR2;
1670 
1671 typedef union _UCHAR4 {
1674 } UCHAR4, *PUCHAR4;
1675 
1676 typedef union _USHORT2 {
1679 } USHORT2, *PUSHORT2;
1680 
1681 //
1682 // This macro copies an unaligned src byte to an aligned dst byte
1683 //
1684 
1685 #define CopyUchar1(Dst,Src) { \
1686  *((UCHAR1 *)(Dst)) = *((UNALIGNED UCHAR1 *)(Src)); \
1687  }
1688 
1689 //
1690 // This macro copies an unaligned src word to an aligned dst word
1691 //
1692 
1693 #define CopyUchar2(Dst,Src) { \
1694  *((UCHAR2 *)(Dst)) = *((UNALIGNED UCHAR2 *)(Src)); \
1695  }
1696 
1697 //
1698 // This macro copies an unaligned src longword to an aligned dsr longword
1699 //
1700 
1701 #define CopyUchar4(Dst,Src) { \
1702  *((UCHAR4 *)(Dst)) = *((UNALIGNED UCHAR4 *)(Src)); \
1703  }
1704 
1705 //
1706 // This macro copies an unaligned src longword to an aligned dsr longword
1707 // accessing the source on a word boundary.
1708 //
1709 
1710 #define CopyUshort2(Dst,Src) { \
1711  *((USHORT2 *)(Dst)) = *((UNALIGNED USHORT2 *)(Src));\
1712  }
1713 
1714 //
1715 // This macro copies an unaligned src longword to a dst longword,
1716 // performing an little/big endian swap.
1717 //
1718 
1719 #define SwapCopyUchar4(Dst,Src) { \
1720  *((UNALIGNED UCHAR1 *)(Dst)) = *((UNALIGNED UCHAR1 *)(Src) + 3); \
1721  *((UNALIGNED UCHAR1 *)(Dst) + 1) = *((UNALIGNED UCHAR1 *)(Src) + 2); \
1722  *((UNALIGNED UCHAR1 *)(Dst) + 2) = *((UNALIGNED UCHAR1 *)(Src) + 1); \
1723  *((UNALIGNED UCHAR1 *)(Dst) + 3) = *((UNALIGNED UCHAR1 *)(Src)); \
1724 }
1725 
1726 VOID
1727 CdLbnToMmSsFf (
1728  _In_ ULONG Blocks,
1729  _Out_writes_(3) PUCHAR Msf
1730  );
1731 
1732 //
1733 // Following routines handle entry in and out of the filesystem. They are
1734 // contained in CdData.c
1735 //
1736 
1753 NTSTATUS
1754 NTAPI
1755 CdFsdDispatch (
1757  _Inout_ PIRP Irp
1758  );
1759 
1760 // DRIVER_DISPATCH CdFsdDispatch;
1761 
1762 LONG
1764  _Inout_ PIRP_CONTEXT IrpContext,
1765  _In_ PEXCEPTION_POINTERS ExceptionPointer
1766  );
1767 
1768 _Requires_lock_held_(_Global_critical_region_)
1769 NTSTATUS
1770 CdProcessException (
1771  _In_opt_ PIRP_CONTEXT IrpContext,
1774  );
1775 
1776 VOID
1778  _Inout_opt_ PIRP_CONTEXT IrpContext,
1781  );
1782 
1783 //
1784 // VOID
1785 // CdRaiseStatus (
1786 // _In_ PRIP_CONTEXT IrpContext,
1787 // _In_ NT_STATUS Status
1788 // );
1789 //
1790 // VOID
1791 // CdNormalizeAndRaiseStatus (
1792 // _In_ PRIP_CONTEXT IrpContext,
1793 // _In_ NT_STATUS Status
1794 // );
1795 //
1796 
1797 #if 0
1798 #define AssertVerifyDevice(C, S) \
1799  NT_ASSERT( (C) == NULL || \
1800  FlagOn( (C)->Flags, IRP_CONTEXT_FLAG_IN_FSP ) || \
1801  !((S) == STATUS_VERIFY_REQUIRED && \
1802  IoGetDeviceToVerify( PsGetCurrentThread() ) == NULL ));
1803 
1804 #define AssertVerifyDeviceIrp(I) \
1805  NT_ASSERT( (I) == NULL || \
1806  !(((I)->IoStatus.Status) == STATUS_VERIFY_REQUIRED && \
1807  ((I)->Tail.Overlay.Thread == NULL || \
1808  IoGetDeviceToVerify( (I)->Tail.Overlay.Thread ) == NULL )));
1809 #else
1810 #define AssertVerifyDevice(C, S)
1811 #define AssertVerifyDeviceIrp(I)
1812 #endif
1813 
1814 
1815 #ifdef CD_SANITY
1816 
1818 VOID
1820  _In_ PIRP_CONTEXT IrpContext,
1822  _In_ BOOLEAN NormalizeStatus,
1823  _In_opt_ ULONG FileId,
1825  );
1826 
1827 #else
1828 
1829 #ifdef __REACTOS__
1830 static // make windows gcc release build compile
1831 #endif
1832 INLINE
1834 VOID
1836  _In_ PIRP_CONTEXT IrpContext,
1838  _In_ BOOLEAN NormalizeStatus,
1839  _In_ ULONG Fileid,
1840  _In_ ULONG Line
1841  )
1842 {
1843  if (NormalizeStatus) {
1844 
1845  IrpContext->ExceptionStatus = FsRtlNormalizeNtstatus( Status, STATUS_UNEXPECTED_IO_ERROR);
1846  }
1847  else {
1848 
1849  IrpContext->ExceptionStatus = Status;
1850  }
1851 
1852  IrpContext->RaisedAtLineFile = (Fileid << 16) | Line;
1853 
1854  ExRaiseStatus( IrpContext->ExceptionStatus );
1855 }
1856 
1857 #endif
1858 
1859 #define CdRaiseStatus( IC, S) CdRaiseStatusEx( (IC), (S), FALSE, BugCheckFileId, __LINE__);
1860 #define CdNormalizeAndRaiseStatus( IC, S) CdRaiseStatusEx( (IC), (S), TRUE, BugCheckFileId, __LINE__);
1861 
1862 //
1863 // Following are the fast entry points.
1864 //
1865 
1866 // _Success_(return != FALSE)
1867 // BOOLEAN
1868 // CdFastQueryBasicInfo (
1869 // _In_ PFILE_OBJECT FileObject,
1870 // _In_ BOOLEAN Wait,
1871 // _Out_ PFILE_BASIC_INFORMATION Buffer,
1872 // _Out_ PIO_STATUS_BLOCK IoStatus,
1873 // _In_ PDEVICE_OBJECT DeviceObject
1874 // );
1875 
1876 FAST_IO_QUERY_BASIC_INFO CdFastQueryBasicInfo;
1877 
1878 // _Success_(return != FALSE)
1879 // BOOLEAN
1880 // CdFastQueryStdInfo (
1881 // _In_ PFILE_OBJECT FileObject,
1882 // _In_ BOOLEAN Wait,
1883 // _Out_ PFILE_STANDARD_INFORMATION Buffer,
1884 // _Out_ PIO_STATUS_BLOCK IoStatus,
1885 // _In_ PDEVICE_OBJECT DeviceObject
1886 // );
1887 
1888 FAST_IO_QUERY_STANDARD_INFO CdFastQueryStdInfo;
1889 
1890 // BOOLEAN
1891 // CdFastLock (
1892 // _In_ PFILE_OBJECT FileObject,
1893 // _In_ PLARGE_INTEGER FileOffset,
1894 // _In_ PLARGE_INTEGER Length,
1895 // _In_ PEPROCESS ProcessId,
1896 // _In_ ULONG Key,
1897 // _In_ BOOLEAN FailImmediately,
1898 // _In_ BOOLEAN ExclusiveLock,
1899 // _Out_ PIO_STATUS_BLOCK IoStatus,
1900 // _In_ PDEVICE_OBJECT DeviceObject
1901 // );
1902 
1903 FAST_IO_LOCK CdFastLock;
1904 
1905 // BOOLEAN
1906 // CdFastUnlockSingle (
1907 // _In_ PFILE_OBJECT FileObject,
1908 // _In_ PLARGE_INTEGER FileOffset,
1909 // _In_ PLARGE_INTEGER Length,
1910 // _In_ PEPROCESS ProcessId,
1911 // _In_ ULONG Key,
1912 // _Out_ PIO_STATUS_BLOCK IoStatus,
1913 // _In_ PDEVICE_OBJECT DeviceObject
1914 // );
1915 
1916 FAST_IO_UNLOCK_SINGLE CdFastUnlockSingle;
1917 
1918 // BOOLEAN
1919 // CdFastUnlockAll (
1920 // _In_ PFILE_OBJECT FileObject,
1921 // _In_ PEPROCESS ProcessId,
1922 // _Out_ PIO_STATUS_BLOCK IoStatus,
1923 // _In_ PDEVICE_OBJECT DeviceObject
1924 // );
1925 
1926 FAST_IO_UNLOCK_ALL CdFastUnlockAll;
1927 
1928 // BOOLEAN
1929 // CdFastUnlockAllByKey (
1930 // _In_ PFILE_OBJECT FileObject,
1931 // _In_ PVOID ProcessId,
1932 // _In_ ULONG Key,
1933 // _Out_ PIO_STATUS_BLOCK IoStatus,
1934 // _In_ PDEVICE_OBJECT DeviceObject
1935 // );
1936 
1937 FAST_IO_UNLOCK_ALL_BY_KEY CdFastUnlockAllByKey;
1938 
1939 // BOOLEAN
1940 // CdFastIoCheckIfPossible (
1941 // _In_ PFILE_OBJECT FileObject,
1942 // _In_ PLARGE_INTEGER FileOffset,
1943 // _In_ ULONG Length,
1944 // _In_ BOOLEAN Wait,
1945 // _In_ ULONG LockKey,
1946 // _In_ BOOLEAN CheckForReadOperation,
1947 // _Out_ PIO_STATUS_BLOCK IoStatus,
1948 // _In_ PDEVICE_OBJECT DeviceObject
1949 // );
1950 
1951 FAST_IO_CHECK_IF_POSSIBLE CdFastIoCheckIfPossible;
1952 
1953 // _Success_(return != FALSE)
1954 // BOOLEAN
1955 // CdFastQueryNetworkInfo (
1956 // _In_ PFILE_OBJECT FileObject,
1957 // _In_ BOOLEAN Wait,
1958 // _Out_ PFILE_NETWORK_OPEN_INFORMATION Buffer,
1959 // _Out_ PIO_STATUS_BLOCK IoStatus,
1960 // _In_ PDEVICE_OBJECT DeviceObject
1961 // );
1962 
1963 FAST_IO_QUERY_NETWORK_OPEN_INFO CdFastQueryNetworkInfo;
1964 
1965 //
1966 // Following are the routines to handle the top level thread logic.
1967 //
1968 
1969 VOID
1971  _Inout_ PIRP_CONTEXT IrpContext,
1972  _In_ PTHREAD_CONTEXT ThreadContext
1973  );
1974 
1975 
1976 //
1977 // VOID
1978 // CdRestoreThreadContext (
1979 // _Inout_ PIRP_CONTEXT IrpContext
1980 // );
1981 //
1982 
1983 #define CdRestoreThreadContext(IC) \
1984  (IC)->ThreadContext->Cdfs = 0; \
1985  IoSetTopLevelIrp( (IC)->ThreadContext->SavedTopLevelIrp ); \
1986  (IC)->ThreadContext = NULL
1987 
1988 ULONG
1989 CdSerial32 (
1992  );
1993 
1994 //
1995 // The following macro is used to determine if an FSD thread can block
1996 // for I/O or wait for a resource. It returns TRUE if the thread can
1997 // block and FALSE otherwise. This attribute can then be used to call
1998 // the FSD & FSP common work routine with the proper wait value.
1999 //
2000 
2001 #define CanFsdWait(I) IoIsOperationSynchronous(I)
2002 
2003 //
2004 // The following macro is used to set the fast i/o possible bits in the
2005 // FsRtl header.
2006 //
2007 // FastIoIsNotPossible - If the Fcb is bad or there are oplocks on the file.
2008 //
2009 // FastIoIsQuestionable - If there are file locks.
2010 //
2011 // FastIoIsPossible - In all other cases.
2012 //
2013 //
2014 
2015 #define CdIsFastIoPossible(F) ((BOOLEAN) \
2016  ((((F)->Vcb->VcbCondition != VcbMounted ) || \
2017  !FsRtlOplockIsFastIoPossible( CdGetFcbOplock(F) )) ? \
2018  \
2019  FastIoIsNotPossible : \
2020  \
2021  ((((F)->FileLock != NULL) && FsRtlAreThereCurrentFileLocks( (F)->FileLock )) ? \
2022  \
2023  FastIoIsQuestionable : \
2024  \
2025  FastIoIsPossible)) \
2026 )
2027 
2028 
2029 //
2030 // The FSP level dispatch/main routine. This is the routine that takes
2031 // IRP's off of the work queue and calls the appropriate FSP level
2032 // work routine.
2033 //
2034 
2035 // VOID
2036 // CdFspDispatch ( // implemented in FspDisp.c
2037 // _Inout_ PIRP_CONTEXT IrpContext
2038 // );
2039 
2040 WORKER_THREAD_ROUTINE CdFspDispatch;
2041 
2042 VOID
2043 CdFspClose ( // implemented in Close.c
2044  _In_opt_ PVCB Vcb
2045  );
2046 
2047 //
2048 // The following routines are the entry points for the different operations
2049 // based on the IrpSp major functions.
2050 //
2051 
2052 _Requires_lock_held_(_Global_critical_region_)
2053 NTSTATUS
2054 CdCommonCreate ( // Implemented in Create.c
2055  _Inout_ PIRP_CONTEXT IrpContext,
2056  _Inout_ PIRP Irp
2057  );
2058 
2059 _Requires_lock_held_(_Global_critical_region_)
2060 NTSTATUS
2061 CdCommonClose ( // Implemented in Close.c
2062  _Inout_ PIRP_CONTEXT IrpContext,
2063  _Inout_ PIRP Irp
2064  );
2065 
2066 _Requires_lock_held_(_Global_critical_region_)
2067 NTSTATUS
2068 CdCommonRead ( // Implemented in Read.c
2069  _Inout_ PIRP_CONTEXT IrpContext,
2070  _Inout_ PIRP Irp
2071  );
2072 
2073 _Requires_lock_held_(_Global_critical_region_)
2074 NTSTATUS
2075 CdCommonWrite ( // Implemented in Write.c
2076  _Inout_ PIRP_CONTEXT IrpContext,
2077  _Inout_ PIRP Irp
2078  );
2079 
2080 _Requires_lock_held_(_Global_critical_region_)
2081 NTSTATUS
2082 CdCommonQueryInfo ( // Implemented in FileInfo.c
2083  _Inout_ PIRP_CONTEXT IrpContext,
2084  _Inout_ PIRP Irp
2085  );
2086 
2087 _Requires_lock_held_(_Global_critical_region_)
2088 NTSTATUS
2089 CdCommonSetInfo ( // Implemented in FileInfo.c
2090  _Inout_ PIRP_CONTEXT IrpContext,
2091  _Inout_ PIRP Irp
2092  );
2093 
2094 _Requires_lock_held_(_Global_critical_region_)
2095 NTSTATUS
2096 CdCommonQueryVolInfo ( // Implemented in VolInfo.c
2097  _Inout_ PIRP_CONTEXT IrpContext,
2098  _Inout_ PIRP Irp
2099  );
2100 
2101 _Requires_lock_held_(_Global_critical_region_)
2102 NTSTATUS
2103 CdCommonDirControl ( // Implemented in DirCtrl.c
2104  _Inout_ PIRP_CONTEXT IrpContext,
2105  _Inout_ PIRP Irp
2106  );
2107 
2108 _Requires_lock_held_(_Global_critical_region_)
2109 NTSTATUS
2110 CdCommonFsControl ( // Implemented in FsCtrl.c
2111  _Inout_ PIRP_CONTEXT IrpContext,
2112  _Inout_ PIRP Irp
2113  );
2114 
2115 NTSTATUS
2116 CdCommonDevControl ( // Implemented in DevCtrl.c
2117  _Inout_ PIRP_CONTEXT IrpContext,
2118  _Inout_ PIRP Irp
2119  );
2120 
2121 NTSTATUS
2122 CdCommonLockControl ( // Implemented in LockCtrl.c
2123  _Inout_ PIRP_CONTEXT IrpContext,
2124  _Inout_ PIRP Irp
2125  );
2126 
2127 _Requires_lock_held_(_Global_critical_region_)
2128 NTSTATUS
2129 CdCommonCleanup ( // Implemented in Cleanup.c
2130  _Inout_ PIRP_CONTEXT IrpContext,
2131  _Inout_ PIRP Irp
2132  );
2133 
2134 _Requires_lock_held_(_Global_critical_region_)
2135 NTSTATUS
2136 CdCommonPnp ( // Implemented in Pnp.c
2137  _Inout_ PIRP_CONTEXT IrpContext,
2138  _Inout_ PIRP Irp
2139  );
2140 
2141 _Requires_lock_held_(_Global_critical_region_)
2142 NTSTATUS
2143 CdCommonShutdown ( // Implemented in Shutdown.c
2144  _Inout_ PIRP_CONTEXT IrpContext,
2145  _Inout_ PIRP Irp
2146  );
2147 
2148 
2149 
2150 //
2151 // The following macros are used to establish the semantics needed
2152 // to do a return from within a try-finally clause. As a rule every
2153 // try clause must end with a label call try_exit. For example,
2154 //
2155 // try {
2156 // :
2157 // :
2158 //
2159 // try_exit: NOTHING;
2160 // } finally {
2161 //
2162 // :
2163 // :
2164 // }
2165 //
2166 // Every return statement executed inside of a try clause should use the
2167 // try_return macro. If the compiler fully supports the try-finally construct
2168 // then the macro should be
2169 //
2170 // #define try_return(S) { return(S); }
2171 //
2172 // If the compiler does not support the try-finally construct then the macro
2173 // should be
2174 //
2175 // #define try_return(S) { S; goto try_exit; }
2176 //
2177 
2178 #ifndef __REACTOS__
2179 #define try_return(S) { S; goto try_exit; }
2180 #define try_leave(S) { S; leave; }
2181 #else
2182 #define try_return(S) { S; goto try_exit; }
2183 #define try_leave(S) { S; _SEH2_LEAVE; }
2184 #endif
2185 
2186 //
2187 // Encapsulate safe pool freeing
2188 //
2189 /* ReactOS Change: GCC "passing argument 1 of CdFreePool from incompatible pointer type" */
2190 #define CdFreePool(x) _CdFreePool((PVOID*)(x))
2191 
2192 static /* ReactOS Change: GCC "multiple definition" */
2193 INLINE
2194 VOID
2197  )
2198 {
2199  if (*Pool != NULL) {
2200 
2201  ExFreePool(*Pool);
2202  *Pool = NULL;
2203  }
2204 }
2205 
2206 #ifdef CDFS_TELEMETRY_DATA
2207 
2208 //
2209 // CDFS Telemetry. Current implementation uses the Telemetry TraceLogging APIs.
2210 //
2211 // The Telemetry TraceLoggingWrite() routines use a lot of stack space. We must
2212 // therefor wrap all our telemetry points with our own routines, and add a guard to
2213 // make sure there's enough stack space to call these routines.
2214 //
2215 // These telemetry routines should not be called on high-performance code paths.
2216 //
2217 
2218 TRACELOGGING_DECLARE_PROVIDER( CdTelemetryProvider );
2219 
2220 VOID
2221 CdInitializeTelemetry (
2222  VOID
2223  );
2224 
2226 VOID
2227 CdTelemetryMount (
2228  __in PGUID VolumeGuid,
2230  __in PVCB Vcb
2231  );
2232 
2233 //
2234 // Every additional argument passed to TraceLoggingWrite() consumes an additional
2235 // 16 to 32 bytes extra stack space. Having 512 bytes reserved space should be
2236 // sufficient for up to 20 arguments or so. This will be less of course if our
2237 // wrapper routines also declare their own local variables.
2238 //
2239 
2240 #define CDFS_TELEMETRY_STACK_THRESHOLD_DEFAULT 512 // for "small" telemetry points
2241 #define CDFS_TELEMETRY_STACK_THRESHOLD_LARGE 2048 // for "large" telemetry points
2242 
2243 INLINE
2244 BOOLEAN
2245 CdTelemetryGuard (
2246  __in ULONG StackSpaceNeeded )
2247 /*++
2248 
2249 Routine Description:
2250 
2251  This routine returns TRUE only when:
2252 
2253  1) There is an ETW listener, AND
2254  2) There is enough free stack space to safely call the Telemetry TraceLogging APIs
2255 
2256  We'll also count how many times there wasn't enough stack space, and include this
2257  value as part of the periodic cdfs Telemetry.
2258 
2259 Arguments:
2260 
2261  StackSpaceNeeded - Stack space needed in bytes
2262 
2263 --*/
2264 {
2265  ASSERT( IoGetRemainingStackSize() >= StackSpaceNeeded );
2266 
2267  if (CdTelemetryProvider->LevelPlus1 <= 5) {
2268 
2269  //
2270  // Bail out early if there are no ETW listeners
2271  //
2272 
2273  return FALSE;
2274  }
2275 
2276  if (IoGetRemainingStackSize() < StackSpaceNeeded) {
2277 
2278  //
2279  // Count how many times it was unsafe to generate telemetry because of
2280  // not enough stack space.
2281  //
2282 
2283  InterlockedIncrement( &CdTelemetryData.MissedTelemetryPoints );
2284 
2285  return FALSE;
2286  }
2287 
2288  return TRUE;
2289 }
2290 
2291 #define CdTelemetryMountSafe( VolumeGuid, Status, Vcb ) \
2292  if (CdTelemetryGuard( CDFS_TELEMETRY_STACK_THRESHOLD_LARGE )) { \
2293  CdTelemetryMount( VolumeGuid, Status, Vcb ); \
2294  }
2295 
2296 #if DBG
2297 #define CDFS_TELEMETRY_PERIODIC_INTERVAL CdTelemetryData.PeriodicInterval
2298 #else
2299 #define CDFS_TELEMETRY_PERIODIC_INTERVAL INTERVAL_ONE_DAY
2300 #endif
2301 
2302 #else // CDFS_TELEMETRY_DATA
2303 
2304 //
2305 // When CDFS_TELEMETRY_DATA is not defined then the CdTelemetry___Safe() routines
2306 // expand to nothing. This minimizes the cdfs.sys binary footprint. This also
2307 // means that the places where these Safe() routines are called do not
2308 // have to have to be surrounded by #ifdef CDFS_TELEMETRY_DATA .. #endif
2309 //
2310 
2311 
2312 #define CdTelemetryMountSafe( ... ) NOTHING
2313 
2314 #endif // CDFS_TELEMETRY_DATA
2315 
2316 #endif // _CDPROCS_
2317 
2318 
static INLINE VOID _CdFreePool(_Inout_ _At_(*Pool, __drv_freesMem(Mem) _Post_null_) PVOID *Pool)
Definition: cdprocs.h:2195
UNICODE_STRING VersionString
Definition: cdstruc.h:256
union _USHORT2 USHORT2
VOID CdDeleteInternalStream(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb)
Definition: cachesup.c:333
signed char * PCHAR
Definition: retypes.h:7
ULONG ForceAlignment
Definition: cdprocs.h:1673
VOID CdCleanupFileContext(_In_ PIRP_CONTEXT IrpContext, _In_ PFILE_ENUM_CONTEXT FileContext)
Definition: dirsup.c:1636
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
Definition: cdprocs.h:1772
#define SIZEOF_FCB_INDEX
Definition: cdstruc.h:1065
#define SIZEOF_FCB_DATA
Definition: cdstruc.h:1062
WORKER_THREAD_ROUTINE CdFspDispatch
Definition: cdprocs.h:2040
_Inout_ PFCB _Out_ PBOOLEAN RemovedStartingFcb
Definition: cdprocs.h:1259
PFCB CdCreateFcb(_In_ PIRP_CONTEXT IrpContext, _In_ FILE_ID FileId, _In_ NODE_TYPE_CODE NodeTypeCode, _Out_opt_ PBOOLEAN FcbExisted)
Definition: strucsup.c:986
return
Definition: dirsup.c:529
_In_ PFCB _In_ LONGLONG _Out_ PLONGLONG DiskOffset
Definition: cdprocs.h:159
BOOLEAN CdIsNameInExpression(_In_ PIRP_CONTEXT IrpContext, _In_ PCD_NAME CurrentName, _In_ PCD_NAME SearchExpression, _In_ ULONG WildcardFlags, _In_ BOOLEAN CheckVersion)
Definition: namesup.c:844
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
_Inout_ PFCB * CurrentFcb
Definition: cdprocs.h:801
static INLINE BOOLEAN CdOperationIsDasdOpen(_In_ PIRP_CONTEXT IrpContext)
Definition: cdprocs.h:1392
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
Type
Definition: Type.h:6
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2029
_At_(Fcb->NodeByteSize, _In_range_(>=, FIELD_OFFSET(FCB, FcbType))) VOID CdInitializeMcb(_In_ PIRP_CONTEXT IrpContext
#define _Out_writes_bytes_to_(size, count)
Definition: no_sal2.h:374
_In_ PFCB _In_ LONGLONG StartingOffset
Definition: cdprocs.h:290
unsigned char Uchar
Definition: utypes.h:45
FSRTL_COMPARISON_RESULT CdFullCompareNames(_In_ PIRP_CONTEXT IrpContext, _In_ PUNICODE_STRING NameA, _In_ PUNICODE_STRING NameB)
Definition: namesup.c:1064
PFILE_OBJECT FileObject
Definition: ntfs.h:516
BOOLEAN CdIs8dot3Name(_In_ PIRP_CONTEXT IrpContext, _In_ UNICODE_STRING FileName)
Definition: namesup.c:429
#define IRP_MJ_SHUTDOWN
VOID CdSetThreadContext(_Inout_ PIRP_CONTEXT IrpContext, _In_ PTHREAD_CONTEXT ThreadContext)
Definition: cddata.c:981
FAST_IO_QUERY_BASIC_INFO CdFastQueryBasicInfo
Definition: cdprocs.h:1876
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
Definition: cdstruc.h:908
VOID CdAddAllocationFromDirent(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_ ULONG McbEntryOffset, _In_ LONGLONG StartingFileOffset, _In_ PDIRENT Dirent)
Definition: allocsup.c:335
Definition: cdstruc.h:1073
unsigned char * PUCHAR
Definition: retypes.h:3
ULONG CdSerial32(_In_reads_bytes_(ByteCount) PCHAR Buffer, _In_ ULONG ByteCount)
Definition: cddata.c:1185
#define SECTOR_SHIFT
Definition: cd.h:32
Dirent DirentOffset
Definition: dirsup.c:444
#define _In_reads_bytes_opt_(size)
Definition: no_sal2.h:230
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID _In_ ULONG _In_ BOOLEAN InternalDeviceIoControl
Definition: iofuncs.h:713
VOID CdUpcaseName(_In_ PIRP_CONTEXT IrpContext, _In_ PCD_NAME Name, _Inout_ PCD_NAME UpcaseName)
Definition: namesup.c:194
LONG NTSTATUS
Definition: precomp.h:26
FAST_IO_CHECK_IF_POSSIBLE CdFastIoCheckIfPossible
Definition: cdprocs.h:1951
_Inout_updates_bytes_(Fcb->NodeByteSize) PFCB Fcb)
Definition: allocsup.c:631
USHORT ForceAlignment
Definition: cdprocs.h:1668
BOOLEAN NTAPI CdNoopAcquire(_In_ PVOID Fcb, _In_ BOOLEAN Wait)
Definition: resrcsup.c:218
union _UCHAR2 UCHAR2
FAST_IO_QUERY_STANDARD_INFO CdFastQueryStdInfo
Definition: cdprocs.h:1888
NTSTATUS FASTCALL CdPerformDevIoCtrl(_In_ PIRP_CONTEXT IrpContext, _In_ ULONG IoControlCode, _In_ PDEVICE_OBJECT Device, _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:1446
ULONG CdShortNameDirentOffset(_In_ PIRP_CONTEXT IrpContext, _In_ PUNICODE_STRING Name)
Definition: namesup.c:955
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 _Outptr_
Definition: no_sal2.h:396
_In_ UINT Bytes
Definition: mmcopy.h:9
FAST_IO_QUERY_NETWORK_OPEN_INFO CdFastQueryNetworkInfo
Definition: cdprocs.h:1963
VOID CdUpdateDirentName(_In_ PIRP_CONTEXT IrpContext, _Inout_ PDIRENT Dirent, _In_ ULONG IgnoreCase)
Definition: dirsup.c:534
#define ExRaiseStatus
Definition: ntoskrnl.h:96
union _UCHAR4 * PUCHAR4
VOID CdInsertPrefix(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_ PCD_NAME Name, _In_ BOOLEAN IgnoreCase, _In_ BOOLEAN ShortNameMatch, _Inout_ PFCB ParentFcb)
Definition: prefxsup.c:52
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
_Acquires_shared_lock_(Vcb->Resource)) FINISHED FatAcquireSharedVcb(IN PIRP_CONTEXT IrpContext
Definition: cdstruc.h:504
_In_ PVCB _In_ BOOLEAN DismountUnderway
Definition: cdprocs.h:235
#define _Post_notnull_
Definition: no_sal2.h:460
#define _Ret_valid_
Definition: no_sal2.h:614
VOID CdDeleteFileLock(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFILE_LOCK FileLock)
_Acquires_exclusive_lock_(Vcb->Resource)) FINISHED FatAcquireExclusiveVcb_Real(IN PIRP_CONTEXT IrpContext
uint16_t * PWCHAR
Definition: typedefs.h:56
_In_ PFCB _In_ PCD_NAME _In_ BOOLEAN _Inout_ PFILE_ENUM_CONTEXT _Out_ PCD_NAME * MatchingName
Definition: cdprocs.h:439
#define CDFS_NTC_FCB_PATH_TABLE
Definition: nodetype.h:29
#define FASTCALL
Definition: nt_native.h:50
_When_(TypeOfOpen==UnopenedFileObject, _At_(Fcb, _In_opt_)) _When_(TypeOfOpen !
VOID CdInitializeStackIrpContext(_Out_ PIRP_CONTEXT IrpContext, _In_ PIRP_CONTEXT_LITE IrpContextLite)
Definition: strucsup.c:1839
VOID CdConvertBigToLittleEndian(_In_ PIRP_CONTEXT IrpContext, _In_reads_bytes_(ByteCount) PCHAR BigEndian, _In_ ULONG ByteCount, _Out_writes_bytes_(ByteCount) PCHAR LittleEndian)
Definition: namesup.c:110
union _UCHAR4 UCHAR4
#define DECLSPEC_NORETURN
Definition: ntbasedef.h:176
VOID CdLbnToMmSsFf(_In_ ULONG Blocks, _Out_writes_(3) PUCHAR Msf)
#define INLINE
Definition: cdprocs.h:38
#define CDFS_NTC_FCB_INDEX
Definition: nodetype.h:30
CHAR InputBuffer[80]
Definition: conmgr.c:33
#define _In_opt_
Definition: no_sal2.h:213
VOID CdFspClose(_In_opt_ PVCB Vcb)
_Post_satisfies_(_Old_(CdName->FileName.Length) >=CdName->FileName.Length+CdName->VersionString.Length) VOID CdConvertNameToCdName(_In_ PIRP_CONTEXT IrpContext
PREFIX_ENTRY FileNamePrefix
Definition: cdstruc.h:1030
union _UCHAR1 * PUCHAR1
#define _Out_writes_(size)
Definition: no_sal2.h:367
__GNU_EXTENSION typedef __int64 * PLONGLONG
Definition: ntbasedef.h:389
enum _TYPE_OF_ACQUIRE * PTYPE_OF_ACQUIRE
_In_ PFCB _In_ PCD_NAME _In_ BOOLEAN _In_ ULONG ShortNameDirentOffset
Definition: cdprocs.h:459
VOID CdTruncateAllocation(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_ LONGLONG StartingFileOffset)
Definition: allocsup.c:575
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN TypeOfOpen
Definition: cdprocs.h:588
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
ERESOURCE * PERESOURCE
Definition: env_spec_w32.h:595
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
TYPE_OF_OPEN CdFastDecodeFileObject(_In_ PFILE_OBJECT FileObject, _Out_ PFCB *Fcb)
Definition: filobsup.c:206
NAME_LINK ExactCaseName
Definition: cdstruc.h:299
VOID CdInitializeFcbFromPathEntry(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_opt_ PFCB ParentFcb, _In_ PPATH_ENTRY PathEntry)
Definition: strucsup.c:1136
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
#define CDFS_NTC_FCB_DATA
Definition: nodetype.h:31
#define _Releases_lock_(a)
Definition: btrfs_drv.h:208
_Unreferenced_parameter_ PVOID * CompletionContext
Definition: cdprocs.h:1125
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: strucsup.c:2201
#define __drv_aliasesMem
Definition: btrfs_drv.h:205
unsigned char BOOLEAN
VOID CdUpdatePathEntryName(_In_ PIRP_CONTEXT IrpContext, _Inout_ PPATH_ENTRY PathEntry, _In_ BOOLEAN IgnoreCase)
Definition: pathsup.c:781
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN CdReadSectors(_In_ PIRP_CONTEXT IrpContext, _In_ LONGLONG StartingOffset, _In_ ULONG ByteCount, _In_ BOOLEAN ReturnError, _Out_writes_bytes_(ByteCount) PVOID Buffer, _In_ PDEVICE_OBJECT TargetDeviceObject)
Definition: deviosup.c:1080
BOOLEAN CdLookupNextDirent(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _In_ PDIRENT_ENUM_CONTEXT CurrentDirContext, _Inout_ PDIRENT_ENUM_CONTEXT NextDirContext)
Definition: dirsup.c:208
NTSTATUS CdCompleteMdl(_In_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: cachesup.c:411
#define _Out_writes_bytes_(size)
Definition: no_sal2.h:370
VOID CdCreateInternalStream(_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _Inout_ PFCB Fcb, _In_ PUNICODE_STRING Name)
Definition: cachesup.c:38
#define _Out_
Definition: no_sal2.h:323
PFCB CdLookupFcbTable(_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _In_ FILE_ID FileId)
Definition: strucsup.c:2107
_In_ PFCB _In_ PCD_NAME _In_ BOOLEAN IgnoreCase
Definition: cdprocs.h:439
Definition: bufpool.h:45
_Inout_ PCD_NAME CdName
Definition: cdprocs.h:623
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
_In_ PFCB _In_ LONGLONG _Out_ PLONGLONG _Out_ PULONG ByteCount
Definition: cdprocs.h:159
_TYPE_OF_ACQUIRE
Definition: cdprocs.h:827
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
_Function_class_(FAST_IO_RELEASE_FILE) _Requires_lock_held_(_Global_critical_region_) VOID NTAPI CdReleaseForCreateSection(_In_ PFILE_OBJECT FileObject)
Definition: resrcsup.c:366
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:588
_In_ PFCB _In_ PCD_NAME _In_ BOOLEAN _Inout_ PFILE_ENUM_CONTEXT FileContext
Definition: cdprocs.h:439
_Success_(return !=FALSE) BOOLEAN CdFindFile(_In_ PIRP_CONTEXT IrpContext
Definition: fsctrl.c:3139
VOID CdLookupLastFileDirent(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _In_ PFILE_ENUM_CONTEXT FileContext)
Definition: dirsup.c:1426
BOOLEAN CdIsLegalName(_In_ PIRP_CONTEXT IrpContext, _In_ PUNICODE_STRING FileName)
Definition: namesup.c:377
_TYPE_OF_OPEN
Definition: cdprocs.h:571
_IRQL_requires_max_(APC_LEVEL) __drv_dispatchType(DRIVER_DISPATCH) __drv_dispatchType(IRP_MJ_CREATE) __drv_dispatchType(IRP_MJ_CLOSE) __drv_dispatchType(IRP_MJ_READ) __drv_dispatchType(IRP_MJ_WRITE) __drv_dispatchType(IRP_MJ_QUERY_INFORMATION) __drv_dispatchType(IRP_MJ_SET_INFORMATION) __drv_dispatchType(IRP_MJ_QUERY_VOLUME_INFORMATION) __drv_dispatchType(IRP_MJ_DIRECTORY_CONTROL) __drv_dispatchType(IRP_MJ_FILE_SYSTEM_CONTROL) __drv_dispatchType(IRP_MJ_DEVICE_CONTROL) __drv_dispatchType(IRP_MJ_LOCK_CONTROL) __drv_dispatchType(IRP_MJ_CLEANUP) __drv_dispatchType(IRP_MJ_PNP) __drv_dispatchType(IRP_MJ_SHUTDOWN) NTSTATUS NTAPI CdFsdDispatch(_In_ PDEVICE_OBJECT DeviceObject
int64_t LONGLONG
Definition: typedefs.h:68
#define _Out_opt_
Definition: no_sal2.h:339
PCCB CdCreateCcb(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _In_ ULONG Flags)
Definition: strucsup.c:1405
_Inout_ PFCB StartingFcb
Definition: cdprocs.h:1259
VOID CdGenerate8dot3Name(_In_ PIRP_CONTEXT IrpContext, _In_ PUNICODE_STRING FileName, _In_ ULONG DirentOffset, _Out_writes_bytes_to_(BYTE_COUNT_8_DOT_3, *ShortByteCount) PWCHAR ShortFileName, _Out_ PUSHORT ShortByteCount)
Definition: namesup.c:550
TYPE_OF_OPEN * PTYPE_OF_OPEN
Definition: cdprocs.h:581
return Iosb
Definition: create.c:4402
_In_ UCHAR BufferLength
Definition: scsi.h:4066
FAST_IO_UNLOCK_SINGLE CdFastUnlockSingle
Definition: cdprocs.h:1916
union _UCHAR2 * PUCHAR2
LONG CdExceptionFilter(_Inout_ PIRP_CONTEXT IrpContext, _In_ PEXCEPTION_POINTERS ExceptionPointer)
Definition: cddata.c:525
uint64_t ULONGLONG
Definition: typedefs.h:67
ULONG ForceAlignment
Definition: cdprocs.h:1678
#define IRP_MJ_FILE_SYSTEM_CONTROL
enum _TYPE_OF_ACQUIRE TYPE_OF_ACQUIRE
_In_ PFCB _In_ PDIRENT_ENUM_CONTEXT DirContext
Definition: cdprocs.h:424
Definition: bufpool.h:50
BOOLEAN CdLookupNextInitialFileDirent(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _Inout_ PFILE_ENUM_CONTEXT FileContext)
Definition: dirsup.c:1275
UCHAR ForceAlignment
Definition: cdprocs.h:1663
#define _Inout_
Definition: no_sal2.h:244
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
* PFILE_OBJECT
Definition: iotypes.h:1962
_In_ PFCB ParentFcb
Definition: cdprocs.h:736
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: strucsup.c:241
#define __drv_dispatchType(x)
Definition: driverspecs.h:249
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: ncftp.h:79
_Requires_lock_held_(_Global_critical_region_) VOID CdLookupAllocation(_In_ PIRP_CONTEXT IrpContext
VOID CdDeleteCcb(_In_ PIRP_CONTEXT IrpContext, _In_ __drv_freesMem(Pool) PCCB Ccb)
Definition: strucsup.c:1462
#define _Post_null_
Definition: no_sal2.h:461
unsigned char UCHAR
Definition: xmlstorage.h:181
char * PBOOLEAN
Definition: retypes.h:11
NTSTATUS CdCreateUserMdl(_In_ PIRP_CONTEXT IrpContext, _In_ ULONG BufferLength, _In_ BOOLEAN RaiseOnError, _In_ LOCK_OPERATION Operation)
Definition: deviosup.c:1221
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
Status
Definition: gdiplustypes.h:24
BOOLEAN CdLookupNextPathEntry(_In_ PIRP_CONTEXT IrpContext, _Inout_ PPATH_ENUM_CONTEXT PathContext, _Inout_ PPATH_ENTRY PathEntry)
Definition: pathsup.c:207
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
union _UCHAR1 UCHAR1
NTSTATUS CdCommonDevControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: devctrl.c:46
enum _TYPE_OF_OPEN TYPE_OF_OPEN
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:588
static INLINE VOID CdVerifyOrCreateDirStreamFile(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb)
Definition: cdprocs.h:242
#define _Pre_notnull_
Definition: no_sal2.h:496
BOOLEAN CdFindDirectory(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _In_ PCD_NAME Name, _In_ BOOLEAN IgnoreCase, _Inout_ PFILE_ENUM_CONTEXT FileContext)
Definition: dirsup.c:997
DRIVER_DISPATCH(nfs41_FsdDispatch)
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
#define _In_reads_bytes_(size)
Definition: no_sal2.h:229
FAST_IO_UNLOCK_ALL CdFastUnlockAll
Definition: cdprocs.h:1926
_Acquires_shared_lock_ Fcb BOOLEAN NTAPI CdAcquireForCache(_Inout_ PFCB Fcb, _In_ BOOLEAN Wait)
VOID CdDissectName(_In_ PIRP_CONTEXT IrpContext, _Inout_ PUNICODE_STRING RemainingName, _Out_ PUNICODE_STRING FinalName)
Definition: namesup.c:301
static INLINE ULONG SectorsFromLlBytes(ULONGLONG Bytes)
Definition: cdprocs.h:1607
#define _In_
Definition: no_sal2.h:204
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
VOID CdVerifyVcb(_In_ PIRP_CONTEXT IrpContext, _Inout_ PVCB Vcb)
Definition: verfysup.c:411
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
Definition: cdstruc.h:1466
VOID CdAddInitialAllocation(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_ ULONG StartingBlock, _In_ LONGLONG DataLength)
Definition: allocsup.c:484
#define _IRQL_restores_global_(kind, param)
Definition: no_sal2.h:654
PFILE_OBJECT FileObject
Definition: iotypes.h:2820
* PFAST_MUTEX
Definition: extypes.h:17
FAST_IO_UNLOCK_ALL_BY_KEY CdFastUnlockAllByKey
Definition: cdprocs.h:1937
#define InterlockedIncrement
Definition: armddk.h:53
Definition: cdstruc.h:1531
enum _LOCK_OPERATION LOCK_OPERATION
unsigned short Ushort
Definition: utypes.h:44
PFCB CdGetNextFcb(_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _In_ PVOID *RestartKey)
Definition: strucsup.c:2155
unsigned short USHORT
Definition: pedump.c:61
#define _IRQL_saves_global_(kind, param)
Definition: no_sal2.h:656
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned int * PULONG
Definition: retypes.h:1
BOOLEAN CdVerifyFcbOperation(_In_opt_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb)
Definition: verfysup.c:615
VOID CdCleanupIrpContext(_In_ PIRP_CONTEXT IrpContext, _In_ BOOLEAN Post)
Definition: strucsup.c:1733
#define __drv_freesMem(kind)
Definition: driverspecs.h:254
NTSTATUS CdCommonLockControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: lockctrl.c:35
#define BYTE_COUNT_8_DOT_3
Definition: cd.h:362
NTSTATUS CdHijackIrpAndFlushDevice(_In_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp, _In_ PDEVICE_OBJECT TargetDeviceObject)
Definition: deviosup.c:4105
#define STATUS_UNEXPECTED_IO_ERROR
Definition: ntstatus.h:469
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_READ
Definition: rdpdr.c:46
VOID NTAPI CdNoopRelease(_In_ PVOID Fcb)
Definition: resrcsup.c:254
enum _FSRTL_COMPARISON_RESULT FSRTL_COMPARISON_RESULT
#define IRP_MJ_CLEANUP
Definition: iotypes.h:168
_In_ PVCB Vcb
Definition: cdprocs.h:235
VOID CdLookupPathEntry(_In_ PIRP_CONTEXT IrpContext, _In_ ULONG PathEntryOffset, _In_ ULONG Ordinal, _In_ BOOLEAN VerifyBounds, _Inout_ PCOMPOUND_PATH_ENTRY CompoundPathEntry)
VOID CdRemovePrefix(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb)
Definition: prefxsup.c:207
VOID CdDeleteVcb(_In_ PIRP_CONTEXT IrpContext, _Inout_ PVCB Vcb)
Definition: strucsup.c:876
_Inout_ PFCB _In_ BOOLEAN RaiseOnError
Definition: cdprocs.h:1209
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
unsigned int ULONG
Definition: retypes.h:1
_In_ PFCB _In_ PDIRENT_ENUM_CONTEXT _Inout_ PDIRENT Dirent
Definition: cdprocs.h:424
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
INLINE DECLSPEC_NORETURN VOID CdRaiseStatusEx(_In_ PIRP_CONTEXT IrpContext, _In_ NTSTATUS Status, _In_ BOOLEAN NormalizeStatus, _In_ ULONG Fileid, _In_ ULONG Line)
Definition: cdprocs.h:1835
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
_In_ PFCB _In_ PCD_NAME DirName
Definition: cdprocs.h:736
PVCB Vcb
Definition: cdstruc.h:939
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define SECTOR_SIZE
Definition: fs.h:22
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
USHORT NODE_TYPE_CODE
Definition: nodetype.h:22
VOID CdInitializeFcbFromFileContext(_In_ PIRP_CONTEXT IrpContext, _Inout_ PFCB Fcb, _In_ PFCB ParentFcb, _In_ PFILE_ENUM_CONTEXT FileContext)
Definition: strucsup.c:1225
NTSTATUS NTAPI FsRtlNormalizeNtstatus(IN NTSTATUS NtStatusToNormalize, IN NTSTATUS NormalizedNtStatus)
Definition: filter.c:90
#define _In_range_(lb, ub)
Definition: no_sal2.h:227
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG DataLength
Definition: hidpi.h:333
_Ret_valid_ PIRP_CONTEXT CdCreateIrpContext(_In_ PIRP Irp, _In_ BOOLEAN Wait)
Definition: strucsup.c:1573
_In_ PFCB Fcb
Definition: cdprocs.h:159
IN OUT PVCB IN PDEVICE_OBJECT TargetDeviceObject
Definition: fatprocs.h:1673
BOOLEAN CdMarkDevForVerifyIfVcbMounted(_Inout_ PVCB Vcb)
Definition: verfysup.c:359
#define _Out_writes_bytes_opt_(size)
Definition: no_sal2.h:373
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE _In_ BOOLEAN IgnoreWait
Definition: cdprocs.h:843
#define __in
Definition: dbghelp.h:35
FILE_NAME_NODE ShortName
Definition: fatstruc.h:1114
#define DECLSPEC_NOINLINE
Definition: ntbasedef.h:231
UNICODE_STRING FileName
Definition: cdstruc.h:250
#define APC_LEVEL
Definition: env_spec_w32.h:695
FAST_IO_LOCK CdFastLock
Definition: cdprocs.h:1903
unsigned short * PUSHORT
Definition: retypes.h:2
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1673
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
_Inout_ PIRP _In_ PDEVICE_OBJECT DeviceToVerify
Definition: cdprocs.h:1407
_In_ PFCB _In_ PCD_NAME _In_ BOOLEAN _Inout_ PCOMPOUND_PATH_ENTRY CompoundPathEntry
Definition: cdprocs.h:736
VOID CdUpdateVcbFromVolDescriptor(_In_ PIRP_CONTEXT IrpContext, _Inout_ PVCB Vcb, _In_reads_bytes_opt_(SECTOR_SIZE) PCHAR RawIsoVd)
Definition: strucsup.c:436
#define _Inout_opt_
Definition: no_sal2.h:258
VOID CdLookupDirent(_In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, _In_ ULONG DirentOffset, _Out_ PDIRENT_ENUM_CONTEXT DirContext)
Definition: dirsup.c:125
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
_Inout_ PVCB _In_ BOOLEAN Force
Definition: cdprocs.h:1415
IN BOOLEAN Wait
Definition: fatprocs.h:1538
_Inout_ PFCB _Inout_ PUNICODE_STRING RemainingName
Definition: cdprocs.h:801
NTSTATUS CdUnlockVolumeInternal(_In_ PIRP_CONTEXT IrpContext, _Inout_ PVCB Vcb, _In_opt_ PFILE_OBJECT FileObject)
Definition: fsctrl.c:288
union _USHORT2 * PUSHORT2