ReactOS 0.4.15-dev-8339-g4028de8
cddata.c File Reference
#include "cdprocs.h"
Include dependency graph for cddata.c:

Go to the source code of this file.

Macros

#define BugCheckFileId   (CDFS_BUG_CHECK_CDDATA)
 

Functions

 _IRQL_requires_max_ (APC_LEVEL)
 
LONG CdExceptionFilter (_Inout_ PIRP_CONTEXT IrpContext, _In_ PEXCEPTION_POINTERS ExceptionPointer)
 
 _Requires_lock_held_ (_Global_critical_region_)
 
VOID CdCompleteRequest (_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
 
VOID CdSetThreadContext (_Inout_ PIRP_CONTEXT IrpContext, _In_ PTHREAD_CONTEXT ThreadContext)
 
 _Function_class_ (FAST_IO_CHECK_IF_POSSIBLE)
 
ULONG CdSerial32 (_In_reads_bytes_(ByteCount) PCHAR Buffer, _In_ ULONG ByteCount)
 

Variables

CD_DATA CdData
 
FAST_IO_DISPATCH CdFastIoDispatch
 
WCHAR CdUnicodeSelfArray [] = { L'.' }
 
WCHAR CdUnicodeParentArray [] = { L'.', L'.' }
 
UNICODE_STRING CdUnicodeDirectoryNames []
 
CHAR CdHsgId [] = { 'C', 'D', 'R', 'O', 'M' }
 
CHAR CdIsoId [] = { 'C', 'D', '0', '0', '1' }
 
CHAR CdXaId [] = { 'C', 'D', '-', 'X', 'A', '0', '0', '1' }
 
WCHAR CdAudioLabel [] = { L'A', L'u', L'd', L'i', L'o', L' ', L'C', L'D' }
 
USHORT CdAudioLabelLength = sizeof( CdAudioLabel )
 
CHAR CdAudioFileName [] = { 'T', 'r', 'a', 'c', 'k', '0', '0', '.', 'c', 'd', 'a' }
 
UCHAR CdAudioFileNameLength = sizeof( CdAudioFileName )
 
ULONG CdAudioDirentSize = FIELD_OFFSET( RAW_DIRENT, FileId ) + sizeof( CdAudioFileName ) + sizeof( SYSTEM_USE_XA )
 
ULONG CdAudioDirentsPerSector = SECTOR_SIZE / (FIELD_OFFSET( RAW_DIRENT, FileId ) + sizeof( CdAudioFileName ) + sizeof( SYSTEM_USE_XA ))
 
ULONG CdAudioSystemUseOffset = FIELD_OFFSET( RAW_DIRENT, FileId ) + sizeof( CdAudioFileName )
 
PCHAR CdJolietEscape [] = { "%/@", "%/C", "%/E" }
 
LONG CdAudioPlayHeader []
 
LONG CdXAAudioPhileHeader []
 
LONG CdXAFileHeader []
 

Macro Definition Documentation

◆ BugCheckFileId

#define BugCheckFileId   (CDFS_BUG_CHECK_CDDATA)

Definition at line 36 of file cddata.c.

Function Documentation

◆ _Function_class_()

_Function_class_ ( FAST_IO_CHECK_IF_POSSIBLE  )

Definition at line 1090 of file cddata.c.

1140{
1141 PFCB Fcb;
1143 LARGE_INTEGER LargeLength;
1144
1145 PAGED_CODE();
1146
1149
1150 //
1151 // Decode the type of file object we're being asked to process and
1152 // make sure that is is only a user file open.
1153 //
1154
1156
1158
1160 return TRUE;
1161 }
1162
1163 LargeLength.QuadPart = Length;
1164
1165 //
1166 // Check whether the file locks will allow for fast io.
1167 //
1168
1169 if ((Fcb->FileLock == NULL) ||
1171 FileOffset,
1172 &LargeLength,
1173 LockKey,
1174 FileObject,
1175 PsGetCurrentProcess() )) {
1176
1177 return TRUE;
1178 }
1179
1180 return FALSE;
1181}
#define PAGED_CODE()
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN TypeOfOpen
Definition: cdprocs.h:589
@ UserFileOpen
Definition: cdprocs.h:577
TYPE_OF_OPEN CdFastDecodeFileObject(_In_ PFILE_OBJECT FileObject, _Out_ PFCB *Fcb)
Definition: filobsup.c:206
_In_ PFCB Fcb
Definition: cdprocs.h:159
enum _TYPE_OF_OPEN TYPE_OF_OPEN
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2665
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN CheckForReadOperation
Definition: fatprocs.h:2666
BOOLEAN NTAPI FsRtlFastCheckLockForRead(IN PFILE_LOCK FileLock, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN ULONG Key, IN PFILE_OBJECT FileObject, IN PVOID Process)
Definition: filelock.c:748
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
Definition: cdstruc.h:902
FILE_LOCK FileLock
Definition: fatstruc.h:1071
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
#define PsGetCurrentProcess
Definition: psfuncs.h:17

◆ _IRQL_requires_max_()

_IRQL_requires_max_ ( APC_LEVEL  )

Definition at line 197 of file cddata.c.

254{
255 THREAD_CONTEXT ThreadContext = {0};
256 PIRP_CONTEXT IrpContext = NULL;
258
259#ifdef CD_SANITY
260 PVOID PreviousTopLevel;
261#endif
262
264
265#if DBG
266
267 KIRQL SaveIrql = KeGetCurrentIrql();
268
269#endif
270
272
274
276
277#ifdef CD_SANITY
278 PreviousTopLevel = IoGetTopLevelIrp();
279#endif
280
281 //
282 // Loop until this request has been completed or posted.
283 //
284
285 do {
286
287 //
288 // Use a try-except to handle the exception cases.
289 //
290
291 _SEH2_TRY {
292
293 //
294 // If the IrpContext is NULL then this is the first pass through
295 // this loop.
296 //
297
298 if (IrpContext == NULL) {
299
300 //
301 // Decide if this request is waitable an allocate the IrpContext.
302 // If the file object in the stack location is NULL then this
303 // is a mount which is always waitable. Otherwise we look at
304 // the file object flags.
305 //
306
308
309 Wait = TRUE;
310
311 } else {
312
313 Wait = CanFsdWait( Irp );
314 }
315
316 IrpContext = CdCreateIrpContext( Irp, Wait );
317
318 //
319 // Update the thread context information.
320 //
321
322 CdSetThreadContext( IrpContext, &ThreadContext );
323
324#ifdef CD_SANITY
325 NT_ASSERT( !CdTestTopLevel ||
326 SafeNodeType( IrpContext->TopLevel ) == CDFS_NTC_IRP_CONTEXT );
327#endif
328
329 //
330 // Otherwise cleanup the IrpContext for the retry.
331 //
332
333 } else {
334
335 //
336 // Set the MORE_PROCESSING flag to make sure the IrpContext
337 // isn't inadvertently deleted here. Then cleanup the
338 // IrpContext to perform the retry.
339 //
340
341 SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_MORE_PROCESSING );
342 CdCleanupIrpContext( IrpContext, FALSE );
343 }
344
345 //
346 // Case on the major irp code.
347 //
348
349 switch (IrpContext->MajorFunction) {
350
351 case IRP_MJ_CREATE :
352
353 Status = CdCommonCreate( IrpContext, Irp );
354 break;
355
356 case IRP_MJ_CLOSE :
357
358 Status = CdCommonClose( IrpContext, Irp );
359 break;
360
361 case IRP_MJ_READ :
362
363 //
364 // If this is an Mdl complete request, don't go through
365 // common read.
366 //
367
368 if (FlagOn( IrpContext->MinorFunction, IRP_MN_COMPLETE )) {
369
370 Status = CdCompleteMdl( IrpContext, Irp );
371
372 } else {
373
374 Status = CdCommonRead( IrpContext, Irp );
375 }
376
377 break;
378
379 case IRP_MJ_WRITE :
380
381 Status = CdCommonWrite( IrpContext, Irp );
382 break;
383
385
386 Status = CdCommonQueryInfo( IrpContext, Irp );
387 break;
388
390
391 Status = CdCommonSetInfo( IrpContext, Irp );
392 break;
393
395
396 Status = CdCommonQueryVolInfo( IrpContext, Irp );
397 break;
398
400
401 Status = CdCommonDirControl( IrpContext, Irp );
402 break;
403
405
406 Status = CdCommonFsControl( IrpContext, Irp );
407 break;
408
410
411 Status = CdCommonDevControl( IrpContext, Irp );
412 break;
413
415
416 Status = CdCommonLockControl( IrpContext, Irp );
417 break;
418
419 case IRP_MJ_CLEANUP :
420
421 Status = CdCommonCleanup( IrpContext, Irp );
422 break;
423
424 case IRP_MJ_PNP :
425
426 Status = CdCommonPnp( IrpContext, Irp );
427 break;
428
429 case IRP_MJ_SHUTDOWN :
430
431 Status = CdCommonShutdown( IrpContext, Irp );
432 break;
433
434 default :
435
437 CdCompleteRequest( IrpContext, Irp, Status );
438 }
439
441
442 Status = CdProcessException( IrpContext, Irp, _SEH2_GetExceptionCode() );
443 } _SEH2_END;
444
445 } while (Status == STATUS_CANT_WAIT);
446
447#ifdef CD_SANITY
448 NT_ASSERT( !CdTestTopLevel ||
449 (PreviousTopLevel == IoGetTopLevelIrp()) );
450#endif
451
453
454 NT_ASSERT( SaveIrql == KeGetCurrentIrql( ));
455
456 return Status;
457}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
LONG CdExceptionFilter(_Inout_ PIRP_CONTEXT IrpContext, _In_ PEXCEPTION_POINTERS ExceptionPointer)
Definition: cddata.c:525
VOID CdSetThreadContext(_Inout_ PIRP_CONTEXT IrpContext, _In_ PTHREAD_CONTEXT ThreadContext)
Definition: cddata.c:981
#define ASSERT_OPTIONAL_IRP(I)
Definition: cddata.h:251
NTSTATUS CdCompleteMdl(_In_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: cachesup.c:411
VOID CdCleanupIrpContext(_In_ PIRP_CONTEXT IrpContext, _In_ BOOLEAN Post)
Definition: strucsup.c:1733
#define CanFsdWait(I)
Definition: cdprocs.h:2001
NTSTATUS CdCommonLockControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: lockctrl.c:35
NTSTATUS CdCommonDevControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: devctrl.c:46
_Ret_valid_ PIRP_CONTEXT CdCreateIrpContext(_In_ PIRP Irp, _In_ BOOLEAN Wait)
Definition: strucsup.c:1573
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define IRP_CONTEXT_FLAG_MORE_PROCESSING
Definition: cdstruc.h:1214
_In_ PIRP Irp
Definition: csq.h:116
#define CDFS_NTC_IRP_CONTEXT
Definition: nodetype.h:34
#define SafeNodeType(Ptr)
Definition: nodetype.h:54
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
Status
Definition: gdiplustypes.h:25
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
#define STATUS_CANT_WAIT
Definition: ntstatus.h:452
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:164
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define IRP_MN_COMPLETE
Definition: iotypes.h:4420
#define IRP_MJ_FILE_SYSTEM_CONTROL
#define IRP_MJ_SHUTDOWN
#define IRP_MJ_CLEANUP
#define NT_ASSERT
Definition: rtlfuncs.h:3310

◆ _Requires_lock_held_()

_Requires_lock_held_ ( _Global_critical_region_  )

Definition at line 615 of file cddata.c.

649{
651 PVPB Vpb;
653
654 ASSERT_OPTIONAL_IRP_CONTEXT( IrpContext );
655 ASSERT_IRP( Irp );
656
657 //
658 // If there is not an irp context, then complete the request with the
659 // current status code.
660 //
661
662 if (!ARGUMENT_PRESENT( IrpContext )) {
663
665 return ExceptionCode;
666 }
667
668 //
669 // Get the real exception status from the IrpContext.
670 //
671
672 ExceptionCode = IrpContext->ExceptionStatus;
673
674 //
675 // Check if we are posting this request. One of the following must be true
676 // if we are to post a request.
677 //
678 // - Status code is STATUS_CANT_WAIT and the request is asynchronous
679 // or we are forcing this to be posted.
680 //
681 // - Status code is STATUS_VERIFY_REQUIRED and we are at APC level
682 // or higher, or within a guarded region. Can't wait for IO in
683 // the verify path in this case.
684 //
685 // Set the MORE_PROCESSING flag in the IrpContext to keep if from being
686 // deleted if this is a retryable condition.
687 //
688 //
689 // Note that (children of) CdFsdPostRequest can raise (Mdl allocation).
690 //
691
692 _SEH2_TRY {
693
695
696 if (FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_FORCE_POST )) {
697
698 ExceptionCode = CdFsdPostRequest( IrpContext, Irp );
699 }
700 }
702 FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_TOP_LEVEL ) &&
704
705 ExceptionCode = CdFsdPostRequest( IrpContext, Irp );
706 }
707 }
709
711 } _SEH2_END;
712 //
713 // If we posted the request or our caller will retry then just return here.
714 //
715
716 if ((ExceptionCode == STATUS_PENDING) ||
718
719 return ExceptionCode;
720 }
721
722 ClearFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_MORE_PROCESSING );
723
724 //
725 // If we are not a top level request then we just complete the request
726 // with the current status code.
727 //
728
729 if (!FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_TOP_LEVEL )) {
730
731 CdCompleteRequest( IrpContext, Irp, ExceptionCode );
732 return ExceptionCode;
733 }
734
735 //
736 // Store this error into the Irp for posting back to the Io system.
737 //
738
740
742
743 //
744 // Check for the various error conditions that can be caused by,
745 // and possibly resolved my the user.
746 //
747
749
750 //
751 // Now we are at the top level file system entry point.
752 //
753 // If we have already posted this request then the device to
754 // verify is in the original thread. Find this via the Irp.
755 //
756
757 Device = IoGetDeviceToVerify( Irp->Tail.Overlay.Thread );
758 IoSetDeviceToVerify( Irp->Tail.Overlay.Thread, NULL );
759
760 //
761 // If there is no device in that location then check in the
762 // current thread.
763 //
764
765 if (Device == NULL) {
766
769
770 NT_ASSERT( Device != NULL );
771
772 }
773
774 //
775 // It turns out some storage drivers really do set invalid non-NULL device
776 // objects to verify.
777 //
778 // To work around this, completely ignore the device to verify in the thread,
779 // and just use our real device object instead.
780 //
781
782 if (IrpContext->Vcb) {
783
784 Device = IrpContext->Vcb->Vpb->RealDevice;
785 }
786
787 //
788 // Let's not BugCheck just because the device to verify is somehow still NULL.
789 //
790
791 if (Device == NULL) {
792
794
795 CdCompleteRequest( IrpContext, Irp, ExceptionCode );
796
797 return ExceptionCode;
798 }
799
800 //
801 // CdPerformVerify() will do the right thing with the Irp.
802 // If we return STATUS_CANT_WAIT then the current thread
803 // can retry the request.
804 //
805
806 return CdPerformVerify( IrpContext, Irp, Device );
807 }
808
809 //
810 // The other user induced conditions generate an error unless
811 // they have been disabled for this request.
812 //
813
814 if (FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_DISABLE_POPUPS )) {
815
816 CdCompleteRequest( IrpContext, Irp, ExceptionCode );
817
818 return ExceptionCode;
819
820 }
821 //
822 // Generate a pop-up.
823 //
824 else {
825
827
829
830 } else {
831
832 Vpb = NULL;
833 }
834
835
836 //
837 // The device to verify is either in my thread local storage
838 // or that of the thread that owns the Irp.
839 //
840
841 Thread = Irp->Tail.Overlay.Thread;
843
844 if (Device == NULL) {
845
848
849 NT_ASSERT( Device != NULL );
850 }
851
852 //
853 // It turns out some storage drivers really do set invalid non-NULL device
854 // objects to verify.
855 //
856 // To work around this, completely ignore the device to verify in the thread,
857 // and just use our real device object instead.
858 //
859
860 if (IrpContext->Vcb) {
861
862 Device = IrpContext->Vcb->Vpb->RealDevice;
863 }
864
865 //
866 // Let's not BugCheck just because the device to verify is somehow still NULL.
867 //
868
869 if (Device == NULL) {
870
871 CdCompleteRequest( IrpContext, Irp, ExceptionCode );
872
873 return ExceptionCode;
874 }
875
876 //
877 // This routine actually causes the pop-up. It usually
878 // does this by queuing an APC to the callers thread,
879 // but in some cases it will complete the request immediately,
880 // so it is very important to IoMarkIrpPending() first.
881 //
882
885
886 //
887 // We will be handing control back to the caller here, so
888 // reset the saved device object.
889 //
890
892
893 //
894 // The Irp will be completed by Io or resubmitted. In either
895 // case we must clean up the IrpContext here.
896 //
897
898 CdCompleteRequest( IrpContext, NULL, STATUS_SUCCESS );
899 return STATUS_PENDING;
900 }
901 }
902
903 //
904 // This is just a run of the mill error.
905 //
906
907 CdCompleteRequest( IrpContext, Irp, ExceptionCode );
908
909 return ExceptionCode;
910}
#define ASSERT_IRP(I)
Definition: cddata.h:250
#define ASSERT_OPTIONAL_IRP_CONTEXT(IC)
Definition: cddata.h:249
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
Definition: cdprocs.h:1774
#define IRP_CONTEXT_FLAG_FORCE_POST
Definition: cdstruc.h:1216
#define IRP_CONTEXT_FLAG_DISABLE_POPUPS
Definition: cdstruc.h:1222
#define IRP_CONTEXT_FLAG_TOP_LEVEL
Definition: cdstruc.h:1217
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define ClearFlag(_F, _SF)
Definition: ext2fs.h:191
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1675
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
IoMarkIrpPending(Irp)
#define ARGUMENT_PRESENT(ArgumentPointer)
VOID NTAPI IoRaiseHardError(IN PIRP Irp, IN PVPB Vpb, IN PDEVICE_OBJECT RealDeviceObject)
Definition: error.c:664
VOID NTAPI IoSetDeviceToVerify(IN PETHREAD Thread, IN PDEVICE_OBJECT DeviceObject)
Definition: util.c:304
PDEVICE_OBJECT NTAPI IoGetDeviceToVerify(IN PETHREAD Thread)
Definition: util.c:336
BOOLEAN NTAPI KeAreAllApcsDisabled(VOID)
Definition: apc.c:985
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_SUCCESS
Definition: shellext.h:65
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
IO_STATUS_BLOCK IoStatus
Definition: iotypes.h:189
#define STATUS_DRIVER_INTERNAL_ERROR
Definition: udferr_usr.h:177
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define IoIsErrorUserInduced(Status)
Definition: iofuncs.h:2817

◆ CdCompleteRequest()

VOID CdCompleteRequest ( _Inout_opt_ PIRP_CONTEXT  IrpContext,
_Inout_opt_ PIRP  Irp,
_In_ NTSTATUS  Status 
)

Definition at line 914 of file cddata.c.

939{
940 ASSERT_OPTIONAL_IRP_CONTEXT( IrpContext );
942
943 //
944 // Cleanup the IrpContext if passed in here.
945 //
946
947 if (ARGUMENT_PRESENT( IrpContext )) {
948
949 CdCleanupIrpContext( IrpContext, FALSE );
950 }
951
952 //
953 // If we have an Irp then complete the irp.
954 //
955
956 if (ARGUMENT_PRESENT( Irp )) {
957
958 //
959 // Clear the information field in case we have used this Irp
960 // internally.
961 //
962
963 if (NT_ERROR( Status ) &&
964 FlagOn( Irp->Flags, IRP_INPUT_OPERATION )) {
965
966 Irp->IoStatus.Information = 0;
967 }
968
969 Irp->IoStatus.Status = Status;
970
972
974 }
975
976 return;
977}
#define AssertVerifyDeviceIrp(I)
Definition: cdprocs.h:1811
#define IoCompleteRequest
Definition: irp.c:1240
#define NT_ERROR(Status)
Definition: umtypes.h:106
#define IRP_INPUT_OPERATION
#define IO_CD_ROM_INCREMENT
Definition: iotypes.h:599

Referenced by _IRQL_requires_max_(), _Requires_lock_held_(), _Success_(), CdAllowExtendedDasdIo(), CdCommonDevControl(), CdCommonLockControl(), CdCompleteMdl(), CdFspDispatch(), CdIsPathnameValid(), CdIsVolumeDirty(), CdIsVolumeMounted(), and CdQueueClose().

◆ CdExceptionFilter()

LONG CdExceptionFilter ( _Inout_ PIRP_CONTEXT  IrpContext,
_In_ PEXCEPTION_POINTERS  ExceptionPointer 
)

Definition at line 525 of file cddata.c.

549{
552
553 ASSERT_OPTIONAL_IRP_CONTEXT( IrpContext );
554
555 ExceptionCode = ExceptionPointer->ExceptionRecord->ExceptionCode;
556
557 //
558 // If the exception is STATUS_IN_PAGE_ERROR, get the I/O error code
559 // from the exception record.
560 //
561
563 (ExceptionPointer->ExceptionRecord->NumberParameters >= 3)) {
564
566 (NTSTATUS)ExceptionPointer->ExceptionRecord->ExceptionInformation[2];
567 }
568
569 //
570 // If there is an Irp context then check which status code to use.
571 //
572
573 if (ARGUMENT_PRESENT( IrpContext )) {
574
575 if (IrpContext->ExceptionStatus == STATUS_SUCCESS) {
576
577 //
578 // Store the real status into the IrpContext.
579 //
580
581 IrpContext->ExceptionStatus = ExceptionCode;
582
583 } else {
584
585 //
586 // No need to test the status code if we raised it ourselves.
587 //
588
590 }
591 }
592
593 AssertVerifyDevice( IrpContext, IrpContext->ExceptionStatus );
594
595 //
596 // Bug check if this status is not supported.
597 //
598
600
601#ifdef _MSC_VER
602#pragma prefast( suppress: __WARNING_USE_OTHER_FUNCTION, "We're corrupted." )
603#endif
604 CdBugCheck( (ULONG_PTR) ExceptionPointer->ExceptionRecord,
605 (ULONG_PTR) ExceptionPointer->ContextRecord,
606 (ULONG_PTR) ExceptionPointer->ExceptionRecord->ExceptionAddress );
607
608 }
609
611}
#define AssertVerifyDevice(C, S)
Definition: cdprocs.h:1810
#define NTSTATUS
Definition: precomp.h:21
#define CdBugCheck(A, B, C)
Definition: nodetype.h:103
TestStatus
Definition: global_mem.c:33
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
BOOLEAN NTAPI FsRtlIsNtstatusExpected(IN NTSTATUS NtStatus)
Definition: filter.c:61
#define STATUS_IN_PAGE_ERROR
Definition: ntstatus.h:243
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by _IRQL_requires_max_(), _Requires_lock_held_(), and CdFspDispatch().

◆ CdSerial32()

ULONG CdSerial32 ( _In_reads_bytes_(ByteCount) PCHAR  Buffer,
_In_ ULONG  ByteCount 
)

Definition at line 1185 of file cddata.c.

1209{
1210 union {
1211 UCHAR Bytes[4];
1212 ULONG SerialId;
1213 } Checksum;
1214
1215 PAGED_CODE();
1216
1217 //
1218 // Initialize the serial number.
1219 //
1220
1221 Checksum.SerialId = 0;
1222
1223 //
1224 // Continue while there are more bytes to use.
1225 //
1226
1227 while (ByteCount--) {
1228
1229 //
1230 // Increment this sub-checksum.
1231 //
1232
1233 Checksum.Bytes[ByteCount & 0x3] += *(Buffer++);
1234 }
1235
1236 //
1237 // Return the checksums as a ULONG.
1238 //
1239
1240 return Checksum.SerialId;
1241}
Definition: bufpool.h:45
_In_ UINT Bytes
Definition: mmcopy.h:9
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _In_ LARGE_INTEGER ByteCount
Definition: iotypes.h:1099
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by CdFindActiveVolDescriptor().

◆ CdSetThreadContext()

VOID CdSetThreadContext ( _Inout_ PIRP_CONTEXT  IrpContext,
_In_ PTHREAD_CONTEXT  ThreadContext 
)

Definition at line 981 of file cddata.c.

1012{
1013 PTHREAD_CONTEXT CurrentThreadContext;
1014#ifdef __REACTOS__
1015 ULONG_PTR StackTop;
1016 ULONG_PTR StackBottom;
1017#endif
1018
1019 PAGED_CODE();
1020
1021 ASSERT_IRP_CONTEXT( IrpContext );
1022
1023 //
1024 // Get the current top-level irp out of the thread storage.
1025 // If NULL then this is the top-level request.
1026 //
1027
1028 CurrentThreadContext = (PTHREAD_CONTEXT) IoGetTopLevelIrp();
1029
1030 if (CurrentThreadContext == NULL) {
1031
1032 SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_TOP_LEVEL );
1033 }
1034
1035 //
1036 // Initialize the input context unless we are using the current
1037 // thread context block. We use the new block if our caller
1038 // specified this or the existing block is invalid.
1039 //
1040 // The following must be true for the current to be a valid Cdfs context.
1041 //
1042 // Structure must lie within current stack.
1043 // Address must be ULONG aligned.
1044 // Cdfs signature must be present.
1045 //
1046 // If this is not a valid Cdfs context then use the input thread
1047 // context and store it in the top level context.
1048 //
1049
1050#ifdef __REACTOS__
1051 IoGetStackLimits( &StackTop, &StackBottom);
1052#endif
1053
1054#ifdef _MSC_VER
1055#pragma warning(suppress: 6011) // Bug in PREFast around bitflag operations
1056#endif
1057 if (FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_TOP_LEVEL ) ||
1058#ifndef __REACTOS__
1059 (!IoWithinStackLimits( (ULONG_PTR)CurrentThreadContext, sizeof( THREAD_CONTEXT ) ) ||
1060#else
1061 (((ULONG_PTR) CurrentThreadContext > StackBottom - sizeof( THREAD_CONTEXT )) ||
1062 ((ULONG_PTR) CurrentThreadContext <= StackTop) ||
1063#endif
1064 FlagOn( (ULONG_PTR) CurrentThreadContext, 0x3 ) ||
1065 (CurrentThreadContext->Cdfs != 0x53464443))) {
1066
1067 ThreadContext->Cdfs = 0x53464443;
1068 ThreadContext->SavedTopLevelIrp = (PIRP) CurrentThreadContext;
1069 ThreadContext->TopLevelIrpContext = IrpContext;
1070 IoSetTopLevelIrp( (PIRP) ThreadContext );
1071
1072 IrpContext->TopLevel = IrpContext;
1073 IrpContext->ThreadContext = ThreadContext;
1074
1075 SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_TOP_LEVEL_CDFS );
1076
1077 //
1078 // Otherwise use the IrpContext in the thread context.
1079 //
1080
1081 } else {
1082
1083 IrpContext->TopLevel = CurrentThreadContext->TopLevelIrpContext;
1084 }
1085
1086 return;
1087}
#define ASSERT_IRP_CONTEXT(IC)
Definition: cddata.h:248
THREAD_CONTEXT * PTHREAD_CONTEXT
Definition: cdstruc.h:1386
VOID NTAPI IoGetStackLimits(OUT PULONG_PTR LowLimit, OUT PULONG_PTR HighLimit)
Definition: util.c:78
LOGICAL NTAPI IoWithinStackLimits(_In_ ULONG_PTR RegionStart, _In_ SIZE_T RegionSize)

Referenced by _IRQL_requires_max_(), and CdFspDispatch().

Variable Documentation

◆ CdAudioDirentSize

ULONG CdAudioDirentSize = FIELD_OFFSET( RAW_DIRENT, FileId ) + sizeof( CdAudioFileName ) + sizeof( SYSTEM_USE_XA )

Definition at line 78 of file cddata.c.

Referenced by _When_(), and CdUpdateVcbFromVolDescriptor().

◆ CdAudioDirentsPerSector

ULONG CdAudioDirentsPerSector = SECTOR_SIZE / (FIELD_OFFSET( RAW_DIRENT, FileId ) + sizeof( CdAudioFileName ) + sizeof( SYSTEM_USE_XA ))

Definition at line 79 of file cddata.c.

Referenced by _When_().

◆ CdAudioFileName

CHAR CdAudioFileName[] = { 'T', 'r', 'a', 'c', 'k', '0', '0', '.', 'c', 'd', 'a' }

Definition at line 76 of file cddata.c.

Referenced by _When_().

◆ CdAudioFileNameLength

UCHAR CdAudioFileNameLength = sizeof( CdAudioFileName )

Definition at line 77 of file cddata.c.

Referenced by _When_().

◆ CdAudioLabel

WCHAR CdAudioLabel[] = { L'A', L'u', L'd', L'i', L'o', L' ', L'C', L'D' }

Definition at line 69 of file cddata.c.

Referenced by CdUpdateVcbFromVolDescriptor().

◆ CdAudioLabelLength

USHORT CdAudioLabelLength = sizeof( CdAudioLabel )

Definition at line 70 of file cddata.c.

Referenced by CdUpdateVcbFromVolDescriptor().

◆ CdAudioPlayHeader

LONG CdAudioPlayHeader[]
Initial value:
= {
0x46464952,
4 * 11 - 8,
0x41444443,
0x20746d66,
24,
0x00000001,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000
}

Definition at line 102 of file cddata.c.

◆ CdAudioSystemUseOffset

ULONG CdAudioSystemUseOffset = FIELD_OFFSET( RAW_DIRENT, FileId ) + sizeof( CdAudioFileName )

Definition at line 80 of file cddata.c.

Referenced by _When_().

◆ CdData

◆ CdFastIoDispatch

FAST_IO_DISPATCH CdFastIoDispatch

Definition at line 43 of file cddata.c.

Referenced by CdInitializeGlobalData(), and DriverEntry().

◆ CdHsgId

CHAR CdHsgId[] = { 'C', 'D', 'R', 'O', 'M' }

Definition at line 61 of file cddata.c.

Referenced by _Success_().

◆ CdIsoId

CHAR CdIsoId[] = { 'C', 'D', '0', '0', '1' }

Definition at line 62 of file cddata.c.

Referenced by _Success_(), and CdFindActiveVolDescriptor().

◆ CdJolietEscape

PCHAR CdJolietEscape[] = { "%/@", "%/C", "%/E" }

Definition at line 86 of file cddata.c.

Referenced by CdFindActiveVolDescriptor().

◆ CdUnicodeDirectoryNames

UNICODE_STRING CdUnicodeDirectoryNames[]
Initial value:
= {
}
WCHAR CdUnicodeSelfArray[]
Definition: cddata.c:49
WCHAR CdUnicodeParentArray[]
Definition: cddata.c:50

Definition at line 52 of file cddata.c.

Referenced by CdUpdateDirentName(), and CdUpdatePathEntryName().

◆ CdUnicodeParentArray

WCHAR CdUnicodeParentArray[] = { L'.', L'.' }

Definition at line 50 of file cddata.c.

◆ CdUnicodeSelfArray

WCHAR CdUnicodeSelfArray[] = { L'.' }

Definition at line 49 of file cddata.c.

Referenced by CdCreateInternalStream().

◆ CdXAAudioPhileHeader

LONG CdXAAudioPhileHeader[]
Initial value:
= {
0x46464952,
-8,
0x45564157,
0x20746d66,
16,
0x00020001,
44100,
2352 * 75,
0x00100004,
0x61746164,
-44
}

Definition at line 136 of file cddata.c.

◆ CdXAFileHeader

LONG CdXAFileHeader[]
Initial value:
= {
0x46464952,
-8,
0x41584443,
0x20746d66,
16,
0,
0x41580000,
0,
0,
0x61746164,
-44
}

Definition at line 165 of file cddata.c.

◆ CdXaId

CHAR CdXaId[] = { 'C', 'D', '-', 'X', 'A', '0', '0', '1' }

Definition at line 63 of file cddata.c.

Referenced by CdUpdateVcbFromVolDescriptor().