ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
November 2017
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
22 participants
186 discussions
Start a n
N
ew thread
[reactos] 01/01: [LIBJPEG] Add a PCH.
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d05c658dbded63b192e07…
commit d05c658dbded63b192e07d75f94e79b0099bb612 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun Nov 26 13:16:29 2017 +0100 [LIBJPEG] Add a PCH. --- dll/3rdparty/libjpeg/CMakeLists.txt | 7 +++++-- dll/3rdparty/libjpeg/precomp.h | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dll/3rdparty/libjpeg/CMakeLists.txt b/dll/3rdparty/libjpeg/CMakeLists.txt index 7330953491..41a142dba0 100644 --- a/dll/3rdparty/libjpeg/CMakeLists.txt +++ b/dll/3rdparty/libjpeg/CMakeLists.txt @@ -10,7 +10,7 @@ include_directories( ${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/libjpeg ${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/zlib) -add_library(libjpeg SHARED +list(APPEND SOURCE jaricom.c jcapimin.c jcapistd.c @@ -56,8 +56,11 @@ add_library(libjpeg SHARED jquant2.c jutils.c jmemmgr.c - jmemnobs.c) + jmemnobs.c + precomp.h) +add_library(libjpeg SHARED ${SOURCE}) set_module_type(libjpeg win32dll) add_importlibs(libjpeg msvcrt kernel32) +add_pch(libjpeg precomp.h SOURCE) add_cd_file(TARGET libjpeg DESTINATION reactos/system32 FOR all) diff --git a/dll/3rdparty/libjpeg/precomp.h b/dll/3rdparty/libjpeg/precomp.h new file mode 100644 index 0000000000..156d2903bf --- /dev/null +++ b/dll/3rdparty/libjpeg/precomp.h @@ -0,0 +1,8 @@ +#ifndef _LIBJPEG_PRECOMP_H_ +#define _LIBJPEG_PRECOMP_H_ + +#define JPEG_INTERNALS +#include "jinclude.h" +#include "jpeglib.h" + +#endif /* _LIBJPEG_PRECOMP_H_ */
7 years
1
0
0
0
[reactos] 01/01: [CDFS_NEW] Fix broken cast. Spotted by Thomas
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9d67a24799e29e8329333…
commit 9d67a24799e29e832933311a8e6ba21787e40f6a Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Sat Nov 25 20:15:28 2017 +0100 [CDFS_NEW] Fix broken cast. Spotted by Thomas --- drivers/filesystems/cdfs_new/cddata.c | 1 + drivers/filesystems/cdfs_new/cdprocs.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/filesystems/cdfs_new/cddata.c b/drivers/filesystems/cdfs_new/cddata.c index ff2c61cfaf..70af0b127b 100755 --- a/drivers/filesystems/cdfs_new/cddata.c +++ b/drivers/filesystems/cdfs_new/cddata.c @@ -211,6 +211,7 @@ __drv_dispatchType(IRP_MJ_CLEANUP) __drv_dispatchType(IRP_MJ_PNP) __drv_dispatchType(IRP_MJ_SHUTDOWN) NTSTATUS +NTAPI CdFsdDispatch ( _In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp diff --git a/drivers/filesystems/cdfs_new/cdprocs.h b/drivers/filesystems/cdfs_new/cdprocs.h index 6c957aebba..1d788b28e1 100755 --- a/drivers/filesystems/cdfs_new/cdprocs.h +++ b/drivers/filesystems/cdfs_new/cdprocs.h @@ -1761,6 +1761,7 @@ __drv_dispatchType(IRP_MJ_CLEANUP) __drv_dispatchType(IRP_MJ_PNP) __drv_dispatchType(IRP_MJ_SHUTDOWN) NTSTATUS +NTAPI CdFsdDispatch ( _In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp
7 years
1
0
0
0
[reactos] 06/06: [CDFS_NEW] Address review comments: - Don't define-out volatile. - Cleanup the ros-specific hdd-backed device object on shutdown. - Fix hdd-backed use. Required a rather ugly hack. - Update README.FSD
by David Quintana
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=67a7e45e351b70356fee4…
commit 67a7e45e351b70356fee442c31cb5de14a0de37e Author: David Quintana <gigaherz(a)gmail.com> AuthorDate: Fri Nov 24 19:55:23 2017 +0100 [CDFS_NEW] Address review comments: - Don't define-out volatile. - Cleanup the ros-specific hdd-backed device object on shutdown. - Fix hdd-backed use. Required a rather ugly hack. - Update README.FSD --- drivers/filesystems/cdfs_new/cdstruc.h | 2 +- drivers/filesystems/cdfs_new/deviosup.c | 9 +++++++++ drivers/filesystems/cdfs_new/fsctrl.c | 5 +++++ drivers/filesystems/cdfs_new/shutdown.c | 4 ++++ media/doc/README.FSD | 6 ++++-- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/filesystems/cdfs_new/cdstruc.h b/drivers/filesystems/cdfs_new/cdstruc.h index 8a5c02d534..270cf9cf59 100755 --- a/drivers/filesystems/cdfs_new/cdstruc.h +++ b/drivers/filesystems/cdfs_new/cdstruc.h @@ -171,7 +171,7 @@ typedef PVOID PBCB; //**** Bcb's are now part of the cache module #define BYTE_COUNT_EMBEDDED_NAME (32) #ifdef __REACTOS__ -#define __volatile +#define __volatile volatile #define _Unreferenced_parameter_ #define __field_range(a,b) #define __analysis_assert(x) diff --git a/drivers/filesystems/cdfs_new/deviosup.c b/drivers/filesystems/cdfs_new/deviosup.c index a0bb2b7ffd..517a094a7e 100755 --- a/drivers/filesystems/cdfs_new/deviosup.c +++ b/drivers/filesystems/cdfs_new/deviosup.c @@ -2607,6 +2607,9 @@ Return Value: // Make sure we don't try and read past end of the last track. // +#ifdef __REACTOS__ + if (Vcb->CdromToc) { +#endif TrackData = &Vcb->CdromToc->TrackData[(Vcb->CdromToc->LastTrack - Vcb->CdromToc->FirstTrack + 1)]; SwapCopyUchar4( &EndBlock, &TrackData->Address ); @@ -2617,6 +2620,12 @@ Return Value: Blocks = CD_SEC_CHUNK_BLOCKS; } +#ifdef __REACTOS__ + } else { + // HACK!!!!!!!! Might cause reads to overrun the end of the partition, no idea what consequences that can have. + Blocks = CD_SEC_CHUNK_BLOCKS; + } +#endif if ((0 == Blocks) || (Lbn < 16)) { diff --git a/drivers/filesystems/cdfs_new/fsctrl.c b/drivers/filesystems/cdfs_new/fsctrl.c index 8e039ef54b..e330699fc3 100755 --- a/drivers/filesystems/cdfs_new/fsctrl.c +++ b/drivers/filesystems/cdfs_new/fsctrl.c @@ -1066,7 +1066,12 @@ Return Value: // if (!FlagOn( Vcb->VcbState, VCB_STATE_AUDIO_DISK) && +#ifndef __REACTOS__ ((Vcb->CdromToc->LastTrack - Vcb->CdromToc->FirstTrack) == 0)) { +#else + ((FilesystemDeviceType == FILE_DEVICE_DISK_FILE_SYSTEM) || + ((Vcb->CdromToc->LastTrack - Vcb->CdromToc->FirstTrack) == 0))) { +#endif ULONG Index; PUCHAR Buffer; diff --git a/drivers/filesystems/cdfs_new/shutdown.c b/drivers/filesystems/cdfs_new/shutdown.c index d6c70580a6..30d060cde3 100644 --- a/drivers/filesystems/cdfs_new/shutdown.c +++ b/drivers/filesystems/cdfs_new/shutdown.c @@ -167,6 +167,10 @@ Return Value: IoUnregisterFileSystem( CdData.FileSystemDeviceObject ); IoDeleteDevice( CdData.FileSystemDeviceObject ); +#ifdef __REACTOS__ + IoUnregisterFileSystem( CdData.HddFileSystemDeviceObject ); + IoDeleteDevice( CdData.HddFileSystemDeviceObject ); +#endif CdCompleteRequest( IrpContext, Irp, STATUS_SUCCESS ); return STATUS_SUCCESS; diff --git a/media/doc/README.FSD b/media/doc/README.FSD index 539a0c058d..681a4a0fd5 100644 --- a/media/doc/README.FSD +++ b/media/doc/README.FSD @@ -16,5 +16,7 @@ The following FSD are shared with:
http://www.acc.umu.se/~bosse/
reactos/drivers/filesystems/ffs # Synced to 0.5.2 reactos/drivers/filesystems/reiserfs # Synced to 0.26 -The following FSD are shared with:
https://github.com/Microsoft/Windows-driver-samples
. -reactos/drivers/filesystems/fastfat_new # Synced to 2817004 +The following FSD are shared with:
https://github.com/Microsoft/Windows-driver-samples
+ +reactos/drivers/filesystems/fastfat_new # Synced to 2817004 +reactos/drivers/filesystems/cdfs_new # Synced to 2817004
7 years
1
0
0
0
[reactos] 05/06: Revert "[CDFS_NEW] Use CdAcquireForCreateSection from the old driver in place of the newer CdFilterCallbackAcquireForCreateSection."
by David Quintana
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6a3bbf24e012e4985b97c…
commit 6a3bbf24e012e4985b97ca4d79604c28fe0133d7 Author: David Quintana <gigaherz(a)gmail.com> AuthorDate: Fri Nov 24 18:15:42 2017 +0100 Revert "[CDFS_NEW] Use CdAcquireForCreateSection from the old driver in place of the newer CdFilterCallbackAcquireForCreateSection." This reverts commit 8410d0327522b51be9926994ce2ec0263d36310f. --- drivers/filesystems/cdfs_new/cdinit.c | 6 ---- drivers/filesystems/cdfs_new/cdprocs.h | 8 ----- drivers/filesystems/cdfs_new/resrcsup.c | 54 --------------------------------- 3 files changed, 68 deletions(-) diff --git a/drivers/filesystems/cdfs_new/cdinit.c b/drivers/filesystems/cdfs_new/cdinit.c index d9c96db04f..871419ac57 100755 --- a/drivers/filesystems/cdfs_new/cdinit.c +++ b/drivers/filesystems/cdfs_new/cdinit.c @@ -191,9 +191,7 @@ Return Value: sizeof(FS_FILTER_CALLBACKS) ); FilterCallbacks.SizeOfFsFilterCallbacks = sizeof(FS_FILTER_CALLBACKS); -#ifndef __REACTOS__ FilterCallbacks.PreAcquireForSectionSynchronization = CdFilterCallbackAcquireForCreateSection; -#endif Status = FsRtlRegisterFileSystemFilterCallbacks( DriverObject, &FilterCallbacks ); @@ -359,15 +357,11 @@ Return Value: CdFastIoDispatch.FastIoUnlockSingle = CdFastUnlockSingle; // UnlockSingle CdFastIoDispatch.FastIoUnlockAll = CdFastUnlockAll; // UnlockAll CdFastIoDispatch.FastIoUnlockAllByKey = CdFastUnlockAllByKey; // UnlockAllByKey -#ifndef __REACTOS__ // // This callback has been replaced by CdFilterCallbackAcquireForCreateSection. // CdFastIoDispatch.AcquireFileForNtCreateSection = NULL; -#else - CdFastIoDispatch.AcquireFileForNtCreateSection = CdAcquireForCreateSection; -#endif CdFastIoDispatch.ReleaseFileForNtCreateSection = CdReleaseForCreateSection; CdFastIoDispatch.FastIoQueryNetworkOpenInfo = CdFastQueryNetworkInfo; // QueryNetworkInfo diff --git a/drivers/filesystems/cdfs_new/cdprocs.h b/drivers/filesystems/cdfs_new/cdprocs.h index 6506b233cb..6c957aebba 100755 --- a/drivers/filesystems/cdfs_new/cdprocs.h +++ b/drivers/filesystems/cdfs_new/cdprocs.h @@ -1121,7 +1121,6 @@ CdReleaseFromCache ( _Inout_ PFCB Fcb ); -#ifndef __REACTOS__ _Requires_lock_held_(_Global_critical_region_) NTSTATUS NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ @@ -1129,13 +1128,6 @@ CdFilterCallbackAcquireForCreateSection ( _In_ PFS_FILTER_CALLBACK_DATA CallbackData, _Unreferenced_parameter_ PVOID *CompletionContext ); -#else -VOID -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ -CdAcquireForCreateSection ( - IN PFILE_OBJECT FileObject - ); -#endif _Function_class_(FAST_IO_RELEASE_FILE) _Requires_lock_held_(_Global_critical_region_) diff --git a/drivers/filesystems/cdfs_new/resrcsup.c b/drivers/filesystems/cdfs_new/resrcsup.c index 0e7ebd9d30..c9eaa7be26 100755 --- a/drivers/filesystems/cdfs_new/resrcsup.c +++ b/drivers/filesystems/cdfs_new/resrcsup.c @@ -23,11 +23,7 @@ Abstract: #ifdef ALLOC_PRAGMA #pragma alloc_text(PAGE, CdAcquireForCache) -#ifndef __REACTOS__ #pragma alloc_text(PAGE, CdFilterCallbackAcquireForCreateSection) -#else -#pragma alloc_text(PAGE, CdAcquireForCreateSection) -#endif #pragma alloc_text(PAGE, CdAcquireResource) #pragma alloc_text(PAGE, CdNoopAcquire) #pragma alloc_text(PAGE, CdNoopRelease) @@ -278,7 +274,6 @@ Return Value: } -#ifndef __REACTOS__ _Requires_lock_held_(_Global_critical_region_) NTSTATUS NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ @@ -361,55 +356,6 @@ Return Value: UNREFERENCED_PARAMETER( CompletionContext ); } -#else -VOID -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ -CdAcquireForCreateSection ( - IN PFILE_OBJECT FileObject - ) - -/*++ - -Routine Description: - - This is the callback routine for MM to use to acquire the file exclusively. - -Arguments: - - FileObject - File object for a Cdfs stream. - -Return Value: - - None - ---*/ - -{ - PAGED_CODE(); - - - // - // Get the Fcb resource exclusively. - // - - ExAcquireResourceExclusiveLite( &((PFCB) FileObject->FsContext)->FcbNonpaged->FcbResource, - TRUE ); - - // - // Take the File resource shared. We need this later on when MM calls - // QueryStandardInfo to get the file size. - // - // If we don't use StarveExclusive, then we can get wedged behind an - // exclusive waiter who is waiting on someone else holding it shared in the - // read->initializecachemap path (which calls createsection) who is in turn - // waiting on us to finish the create section. - // - - ExAcquireSharedStarveExclusive( ((PFCB) FileObject->FsContext)->Resource, - TRUE ); -} -#endif - _Function_class_(FAST_IO_RELEASE_FILE)
7 years
1
0
0
0
[reactos] 04/06: [CDFS_NEW] Accept STATUS_NOT_IMPLEMENTED for IOCTL_CDROM_READ_TOC_EX fallback to IOCTL_CDROM_READ_TOC.
by David Quintana
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ec26cde4a13b3889883d3…
commit ec26cde4a13b3889883d3e1b19f7878179c76df5 Author: David Quintana <gigaherz(a)gmail.com> AuthorDate: Fri Nov 24 18:11:29 2017 +0100 [CDFS_NEW] Accept STATUS_NOT_IMPLEMENTED for IOCTL_CDROM_READ_TOC_EX fallback to IOCTL_CDROM_READ_TOC. --- drivers/filesystems/cdfs_new/strucsup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/filesystems/cdfs_new/strucsup.c b/drivers/filesystems/cdfs_new/strucsup.c index 8082d5f1fb..7aa9c7211a 100755 --- a/drivers/filesystems/cdfs_new/strucsup.c +++ b/drivers/filesystems/cdfs_new/strucsup.c @@ -2292,6 +2292,7 @@ RetryReadToc: if (!UseReadToc && ((Status == STATUS_INVALID_DEVICE_REQUEST) || + (Status == STATUS_NOT_IMPLEMENTED) || /* ReactOS Change: we return STATUS_NOT_IMPLEMENTED for IOCTL_CDROM_READ_TOC_EX */ (Status == STATUS_INVALID_PARAMETER))) { UseReadToc = TRUE;
7 years
1
0
0
0
[reactos] 03/06: [CDFS_NEW] Use CdAcquireForCreateSection from the old driver in place of the newer CdFilterCallbackAcquireForCreateSection.
by David Quintana
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bc2378a3560a384c47d2a…
commit bc2378a3560a384c47d2a4c83886531ad8f0af90 Author: David Quintana <gigaherz(a)gmail.com> AuthorDate: Fri Nov 24 17:27:46 2017 +0100 [CDFS_NEW] Use CdAcquireForCreateSection from the old driver in place of the newer CdFilterCallbackAcquireForCreateSection. --- drivers/filesystems/cdfs_new/cdinit.c | 6 ++++ drivers/filesystems/cdfs_new/cdprocs.h | 8 +++++ drivers/filesystems/cdfs_new/resrcsup.c | 54 +++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) diff --git a/drivers/filesystems/cdfs_new/cdinit.c b/drivers/filesystems/cdfs_new/cdinit.c index 871419ac57..d9c96db04f 100755 --- a/drivers/filesystems/cdfs_new/cdinit.c +++ b/drivers/filesystems/cdfs_new/cdinit.c @@ -191,7 +191,9 @@ Return Value: sizeof(FS_FILTER_CALLBACKS) ); FilterCallbacks.SizeOfFsFilterCallbacks = sizeof(FS_FILTER_CALLBACKS); +#ifndef __REACTOS__ FilterCallbacks.PreAcquireForSectionSynchronization = CdFilterCallbackAcquireForCreateSection; +#endif Status = FsRtlRegisterFileSystemFilterCallbacks( DriverObject, &FilterCallbacks ); @@ -357,11 +359,15 @@ Return Value: CdFastIoDispatch.FastIoUnlockSingle = CdFastUnlockSingle; // UnlockSingle CdFastIoDispatch.FastIoUnlockAll = CdFastUnlockAll; // UnlockAll CdFastIoDispatch.FastIoUnlockAllByKey = CdFastUnlockAllByKey; // UnlockAllByKey +#ifndef __REACTOS__ // // This callback has been replaced by CdFilterCallbackAcquireForCreateSection. // CdFastIoDispatch.AcquireFileForNtCreateSection = NULL; +#else + CdFastIoDispatch.AcquireFileForNtCreateSection = CdAcquireForCreateSection; +#endif CdFastIoDispatch.ReleaseFileForNtCreateSection = CdReleaseForCreateSection; CdFastIoDispatch.FastIoQueryNetworkOpenInfo = CdFastQueryNetworkInfo; // QueryNetworkInfo diff --git a/drivers/filesystems/cdfs_new/cdprocs.h b/drivers/filesystems/cdfs_new/cdprocs.h index 6c957aebba..6506b233cb 100755 --- a/drivers/filesystems/cdfs_new/cdprocs.h +++ b/drivers/filesystems/cdfs_new/cdprocs.h @@ -1121,6 +1121,7 @@ CdReleaseFromCache ( _Inout_ PFCB Fcb ); +#ifndef __REACTOS__ _Requires_lock_held_(_Global_critical_region_) NTSTATUS NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ @@ -1128,6 +1129,13 @@ CdFilterCallbackAcquireForCreateSection ( _In_ PFS_FILTER_CALLBACK_DATA CallbackData, _Unreferenced_parameter_ PVOID *CompletionContext ); +#else +VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ +CdAcquireForCreateSection ( + IN PFILE_OBJECT FileObject + ); +#endif _Function_class_(FAST_IO_RELEASE_FILE) _Requires_lock_held_(_Global_critical_region_) diff --git a/drivers/filesystems/cdfs_new/resrcsup.c b/drivers/filesystems/cdfs_new/resrcsup.c index c9eaa7be26..0e7ebd9d30 100755 --- a/drivers/filesystems/cdfs_new/resrcsup.c +++ b/drivers/filesystems/cdfs_new/resrcsup.c @@ -23,7 +23,11 @@ Abstract: #ifdef ALLOC_PRAGMA #pragma alloc_text(PAGE, CdAcquireForCache) +#ifndef __REACTOS__ #pragma alloc_text(PAGE, CdFilterCallbackAcquireForCreateSection) +#else +#pragma alloc_text(PAGE, CdAcquireForCreateSection) +#endif #pragma alloc_text(PAGE, CdAcquireResource) #pragma alloc_text(PAGE, CdNoopAcquire) #pragma alloc_text(PAGE, CdNoopRelease) @@ -274,6 +278,7 @@ Return Value: } +#ifndef __REACTOS__ _Requires_lock_held_(_Global_critical_region_) NTSTATUS NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ @@ -356,6 +361,55 @@ Return Value: UNREFERENCED_PARAMETER( CompletionContext ); } +#else +VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ +CdAcquireForCreateSection ( + IN PFILE_OBJECT FileObject + ) + +/*++ + +Routine Description: + + This is the callback routine for MM to use to acquire the file exclusively. + +Arguments: + + FileObject - File object for a Cdfs stream. + +Return Value: + + None + +--*/ + +{ + PAGED_CODE(); + + + // + // Get the Fcb resource exclusively. + // + + ExAcquireResourceExclusiveLite( &((PFCB) FileObject->FsContext)->FcbNonpaged->FcbResource, + TRUE ); + + // + // Take the File resource shared. We need this later on when MM calls + // QueryStandardInfo to get the file size. + // + // If we don't use StarveExclusive, then we can get wedged behind an + // exclusive waiter who is waiting on someone else holding it shared in the + // read->initializecachemap path (which calls createsection) who is in turn + // waiting on us to finish the create section. + // + + ExAcquireSharedStarveExclusive( ((PFCB) FileObject->FsContext)->Resource, + TRUE ); +} +#endif + _Function_class_(FAST_IO_RELEASE_FILE)
7 years
1
0
0
0
[reactos] 02/06: [CDFS_NEW] Re-apply many of the reactos-specific changes and fix build. - Also, get rid of the old diff file.
by David Quintana
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5429771b9936a6d8aee6f…
commit 5429771b9936a6d8aee6ffb3860310673f467e93 Author: David Quintana <gigaherz(a)gmail.com> AuthorDate: Thu Nov 23 21:05:28 2017 +0100 [CDFS_NEW] Re-apply many of the reactos-specific changes and fix build. - Also, get rid of the old diff file. --- drivers/filesystems/cdfs_new/allocsup.c | 10 +- drivers/filesystems/cdfs_new/cachesup.c | 8 +- drivers/filesystems/cdfs_new/cddata.c | 40 +- drivers/filesystems/cdfs_new/cdinit.c | 78 +- drivers/filesystems/cdfs_new/cdprocs.h | 59 +- drivers/filesystems/cdfs_new/cdstruc.h | 18 +- drivers/filesystems/cdfs_new/cleanup.c | 18 +- drivers/filesystems/cdfs_new/close.c | 8 +- drivers/filesystems/cdfs_new/create.c | 52 +- drivers/filesystems/cdfs_new/devctrl.c | 4 +- drivers/filesystems/cdfs_new/deviosup.c | 45 +- drivers/filesystems/cdfs_new/dirctrl.c | 27 +- drivers/filesystems/cdfs_new/dirsup.c | 2 +- drivers/filesystems/cdfs_new/fieldoff.c | 2 +- drivers/filesystems/cdfs_new/fileinfo.c | 45 +- drivers/filesystems/cdfs_new/filobsup.c | 10 +- drivers/filesystems/cdfs_new/fsctrl.c | 91 +- drivers/filesystems/cdfs_new/fspdisp.c | 11 +- drivers/filesystems/cdfs_new/lockctrl.c | 34 +- drivers/filesystems/cdfs_new/namesup.c | 16 +- drivers/filesystems/cdfs_new/pathsup.c | 2 +- drivers/filesystems/cdfs_new/pnp.c | 6 +- drivers/filesystems/cdfs_new/prefxsup.c | 2 +- drivers/filesystems/cdfs_new/read.c | 28 +- drivers/filesystems/cdfs_new/resrcsup.c | 11 +- drivers/filesystems/cdfs_new/shutdown.c | 2 +- drivers/filesystems/cdfs_new/strucsup.c | 54 +- drivers/filesystems/cdfs_new/verfysup.c | 21 +- drivers/filesystems/cdfs_new/volinfo.c | 15 +- drivers/filesystems/cdfs_new/wdk_wnet_to_ros.diff | 985 ---------------------- drivers/filesystems/cdfs_new/workque.c | 10 +- drivers/filesystems/cdfs_new/write.c | 25 +- 32 files changed, 541 insertions(+), 1198 deletions(-) diff --git a/drivers/filesystems/cdfs_new/allocsup.c b/drivers/filesystems/cdfs_new/allocsup.c index 6a92817cb5..44a330111e 100755 --- a/drivers/filesystems/cdfs_new/allocsup.c +++ b/drivers/filesystems/cdfs_new/allocsup.c @@ -44,7 +44,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -86,8 +86,10 @@ CdDiskOffsetFromMcbEntry ( _Requires_lock_held_(_Global_critical_region_) VOID +#ifdef _MSC_VER // PREFast currently has no way to express the Fcb==Fcb->Vcb->VolumeDasdFcb early return #pragma warning(suppress: 6001 6101) +#endif CdLookupAllocation ( _In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb, @@ -164,7 +166,7 @@ Return Value: // Use a try finally to facilitate cleanup. // - try { + _SEH2_TRY { // // We use a loop to perform the lookup. If we don't find the mapping in the @@ -308,7 +310,7 @@ Return Value: FirstPass = FALSE; } - } finally { + } _SEH2_FINALLY { if (CleanupParent) { @@ -323,7 +325,7 @@ Return Value: } if (UnlockFcb) { CdUnlockFcb( IrpContext, Fcb ); } - } + } _SEH2_END; return; } diff --git a/drivers/filesystems/cdfs_new/cachesup.c b/drivers/filesystems/cdfs_new/cachesup.c index eea1fd28da..37ac74437a 100755 --- a/drivers/filesystems/cdfs_new/cachesup.c +++ b/drivers/filesystems/cdfs_new/cachesup.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -95,7 +95,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Create the internal stream. The Vpb should be pointing at our volume @@ -281,7 +281,7 @@ Return Value: } } - } finally { + } _SEH2_FINALLY { // // Cleanup any dirent structures we may have used. @@ -323,7 +323,7 @@ Return Value: } CdUnlockFcb( IrpContext, Fcb ); - } + } _SEH2_END; return; } diff --git a/drivers/filesystems/cdfs_new/cddata.c b/drivers/filesystems/cdfs_new/cddata.c index 15cfe2d5db..ff2c61cfaf 100755 --- a/drivers/filesystems/cdfs_new/cddata.c +++ b/drivers/filesystems/cdfs_new/cddata.c @@ -17,7 +17,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" #ifdef CD_SANITY BOOLEAN CdTestTopLevel = TRUE; @@ -287,7 +287,7 @@ Return Value: // Use a try-except to handle the exception cases. // - try { + _SEH2_TRY { // // If the IrpContext is NULL then this is the first pass through @@ -436,10 +436,10 @@ Return Value: CdCompleteRequest( IrpContext, Irp, Status ); } - } except( CdExceptionFilter( IrpContext, GetExceptionInformation() )) { + } _SEH2_EXCEPT( CdExceptionFilter( IrpContext, _SEH2_GetExceptionInformation() )) { - Status = CdProcessException( IrpContext, Irp, GetExceptionCode() ); - } + Status = CdProcessException( IrpContext, Irp, _SEH2_GetExceptionCode() ); + } _SEH2_END; } while (Status == STATUS_CANT_WAIT); @@ -597,7 +597,9 @@ Return Value: if (TestStatus && !FsRtlIsNtstatusExpected( ExceptionCode )) { -#pragma prefast( suppress: __WARNING_USE_OTHER_FUNCTION, "We're corrupted." ) +#ifdef _MSC_VER +#pragma prefast( suppress: __WARNING_USE_OTHER_FUNCTION, "We're corrupted." ) +#endif CdBugCheck( (ULONG_PTR) ExceptionPointer->ExceptionRecord, (ULONG_PTR) ExceptionPointer->ContextRecord, (ULONG_PTR) ExceptionPointer->ExceptionRecord->ExceptionAddress ); @@ -686,7 +688,7 @@ Return Value: // Note that (children of) CdFsdPostRequest can raise (Mdl allocation). // - try { + _SEH2_TRY { if (ExceptionCode == STATUS_CANT_WAIT) { @@ -702,11 +704,10 @@ Return Value: ExceptionCode = CdFsdPostRequest( IrpContext, Irp ); } } - except( CdExceptionFilter( IrpContext, GetExceptionInformation() )) { - - ExceptionCode = GetExceptionCode(); - } + _SEH2_EXCEPT( CdExceptionFilter( IrpContext, _SEH2_GetExceptionInformation() )) { + ExceptionCode = _SEH2_GetExceptionCode(); + } _SEH2_END; // // If we posted the request or our caller will retry then just return here. // @@ -1009,6 +1010,10 @@ Return Value: { PTHREAD_CONTEXT CurrentThreadContext; +#ifdef __REACTOS__ + ULONG_PTR StackTop; + ULONG_PTR StackBottom; +#endif PAGED_CODE(); @@ -1040,9 +1045,21 @@ Return Value: // If this is not a valid Cdfs context then use the input thread // context and store it in the top level context. // + +#ifdef __REACTOS__ + IoGetStackLimits( &StackTop, &StackBottom); +#endif + +#ifdef _MSC_VER #pragma warning(suppress: 6011) // Bug in PREFast around bitflag operations +#endif if (FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_TOP_LEVEL ) || +#ifndef __REACTOS__ (!IoWithinStackLimits( (ULONG_PTR)CurrentThreadContext, sizeof( THREAD_CONTEXT ) ) || +#else + (((ULONG_PTR) CurrentThreadContext > StackBottom - sizeof( THREAD_CONTEXT )) || + ((ULONG_PTR) CurrentThreadContext <= StackTop) || +#endif FlagOn( (ULONG_PTR) CurrentThreadContext, 0x3 ) || (CurrentThreadContext->Cdfs != 0x53464443))) { @@ -1073,6 +1090,7 @@ _Function_class_(FAST_IO_CHECK_IF_POSSIBLE) _IRQL_requires_same_ _Success_(return != FALSE) BOOLEAN +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFastIoCheckIfPossible ( _In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, diff --git a/drivers/filesystems/cdfs_new/cdinit.c b/drivers/filesystems/cdfs_new/cdinit.c index 5ec9d50324..871419ac57 100755 --- a/drivers/filesystems/cdfs_new/cdinit.c +++ b/drivers/filesystems/cdfs_new/cdinit.c @@ -13,7 +13,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -25,6 +25,7 @@ Abstract: DRIVER_INITIALIZE DriverEntry; NTSTATUS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ DriverEntry( _In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath @@ -35,6 +36,7 @@ DriverEntry( DRIVER_UNLOAD CdUnload; VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdUnload( _In_ PDRIVER_OBJECT DriverObject ); @@ -43,6 +45,10 @@ NTSTATUS CdInitializeGlobalData ( _In_ PDRIVER_OBJECT DriverObject, _In_ PDEVICE_OBJECT FileSystemDeviceObject +#ifdef __REACTOS__ + , + IN PDEVICE_OBJECT HddFileSystemDeviceObject +#endif ); #ifdef ALLOC_PRAGMA @@ -57,6 +63,7 @@ CdInitializeGlobalData ( // NTSTATUS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ DriverEntry( _In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath @@ -86,6 +93,9 @@ Return Value: UNICODE_STRING UnicodeString; PDEVICE_OBJECT CdfsFileSystemDeviceObject; FS_FILTER_CALLBACKS FilterCallbacks; +#ifdef __REACTOS__ + PDEVICE_OBJECT HddFileSystemDeviceObject; +#endif UNREFERENCED_PARAMETER( RegistryPath ); @@ -107,11 +117,34 @@ Return Value: return Status; } +#ifdef __REACTOS__ + // + // Create the HDD device object. + // + + RtlInitUnicodeString( &UnicodeString, L"\\CdfsHdd" ); + + Status = IoCreateDevice( DriverObject, + 0, + &UnicodeString, + FILE_DEVICE_DISK_FILE_SYSTEM, + 0, + FALSE, + &HddFileSystemDeviceObject ); + + if (!NT_SUCCESS( Status )) { + IoDeleteDevice (CdfsFileSystemDeviceObject); + return Status; + } +#endif + +#ifdef _MSC_VER #pragma prefast(push) #pragma prefast(disable: 28155, "the dispatch routine has the correct type, prefast is just being paranoid.") #pragma prefast(disable: 28168, "the dispatch routine has the correct type, prefast is just being paranoid.") #pragma prefast(disable: 28169, "the dispatch routine has the correct type, prefast is just being paranoid.") #pragma prefast(disable: 28175, "we're allowed to change these.") +#endif DriverObject->DriverUnload = CdUnload; @@ -143,9 +176,11 @@ Return Value: DriverObject->MajorFunction[IRP_MJ_CLEANUP] = DriverObject->MajorFunction[IRP_MJ_PNP] = DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = (PDRIVER_DISPATCH) CdFsdDispatch; +#ifdef _MSC_VER #pragma prefast(pop) #pragma prefast(suppress: 28175, "this is a file system driver, we're allowed to touch FastIoDispatch.") +#endif DriverObject->FastIoDispatch = &CdFastIoDispatch; // @@ -164,6 +199,9 @@ Return Value: if (!NT_SUCCESS( Status )) { IoDeleteDevice( CdfsFileSystemDeviceObject ); +#ifdef __REACTOS__ + IoDeleteDevice (HddFileSystemDeviceObject); +#endif return Status; } @@ -171,9 +209,16 @@ Return Value: // Initialize the global data structures // +#ifndef __REACTOS__ Status = CdInitializeGlobalData( DriverObject, CdfsFileSystemDeviceObject ); +#else + Status = CdInitializeGlobalData( DriverObject, CdfsFileSystemDeviceObject, HddFileSystemDeviceObject ); +#endif if (!NT_SUCCESS (Status)) { IoDeleteDevice (CdfsFileSystemDeviceObject); +#ifdef __REACTOS__ + IoDeleteDevice (HddFileSystemDeviceObject); +#endif return Status; } @@ -184,9 +229,16 @@ Return Value: // CdfsFileSystemDeviceObject->Flags |= DO_LOW_PRIORITY_FILESYSTEM; +#ifdef __REACTOS__ + HddFileSystemDeviceObject->Flags |= DO_LOW_PRIORITY_FILESYSTEM; +#endif IoRegisterFileSystem( CdfsFileSystemDeviceObject ); ObReferenceObject (CdfsFileSystemDeviceObject); +#ifdef __REACTOS__ + IoRegisterFileSystem( HddFileSystemDeviceObject ); + ObReferenceObject (HddFileSystemDeviceObject); +#endif #ifdef CDFS_TELEMETRY_DATA // @@ -206,6 +258,7 @@ Return Value: VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdUnload( _In_ PDRIVER_OBJECT DriverObject ) @@ -245,6 +298,9 @@ Return Value: IoFreeWorkItem (CdData.CloseItem); ExDeleteResourceLite( &CdData.DataResource ); ObDereferenceObject (CdData.FileSystemDeviceObject); +#ifdef __REACTOS__ + ObDereferenceObject (CdData.HddFileSystemDeviceObject); +#endif } // @@ -255,6 +311,10 @@ NTSTATUS CdInitializeGlobalData ( _In_ PDRIVER_OBJECT DriverObject, _In_ PDEVICE_OBJECT FileSystemDeviceObject +#ifdef __REACTOS__ + , + IN PDEVICE_OBJECT HddFileSystemDeviceObject +#endif ) /*++ @@ -284,8 +344,10 @@ Return Value: CdFastIoDispatch.SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH); +#ifdef _MSC_VER #pragma prefast(push) #pragma prefast(disable:28155, "these are all correct") +#endif CdFastIoDispatch.FastIoCheckIfPossible = CdFastIoCheckIfPossible; // CheckForFastIo CdFastIoDispatch.FastIoRead = FsRtlCopyRead; // Read @@ -295,7 +357,6 @@ Return Value: CdFastIoDispatch.FastIoUnlockSingle = CdFastUnlockSingle; // UnlockSingle CdFastIoDispatch.FastIoUnlockAll = CdFastUnlockAll; // UnlockAll CdFastIoDispatch.FastIoUnlockAllByKey = CdFastUnlockAllByKey; // UnlockAllByKey - // // This callback has been replaced by CdFilterCallbackAcquireForCreateSection. // @@ -309,7 +370,9 @@ Return Value: CdFastIoDispatch.PrepareMdlWrite = FsRtlPrepareMdlWriteDev; CdFastIoDispatch.MdlWriteComplete = FsRtlMdlWriteCompleteDev; +#ifdef _MSC_VER #pragma prefast(pop) +#endif // // Initialize the CdData structure. @@ -322,6 +385,9 @@ Return Value: CdData.DriverObject = DriverObject; CdData.FileSystemDeviceObject = FileSystemDeviceObject; +#ifdef __REACTOS__ + CdData.HddFileSystemDeviceObject = HddFileSystemDeviceObject; +#endif InitializeListHead( &CdData.VcbQueue ); @@ -331,10 +397,10 @@ Return Value: // Initialize the cache manager callback routines // - CdData.CacheManagerCallbacks.AcquireForLazyWrite = &CdAcquireForCache; - CdData.CacheManagerCallbacks.ReleaseFromLazyWrite = &CdReleaseFromCache; - CdData.CacheManagerCallbacks.AcquireForReadAhead = &CdAcquireForCache; - CdData.CacheManagerCallbacks.ReleaseFromReadAhead = &CdReleaseFromCache; + CdData.CacheManagerCallbacks.AcquireForLazyWrite = (PVOID)&CdAcquireForCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */ + CdData.CacheManagerCallbacks.ReleaseFromLazyWrite = (PVOID)&CdReleaseFromCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */ + CdData.CacheManagerCallbacks.AcquireForReadAhead = (PVOID)&CdAcquireForCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */ + CdData.CacheManagerCallbacks.ReleaseFromReadAhead = (PVOID)&CdReleaseFromCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */ CdData.CacheManagerVolumeCallbacks.AcquireForLazyWrite = &CdNoopAcquire; CdData.CacheManagerVolumeCallbacks.ReleaseFromLazyWrite = &CdNoopRelease; diff --git a/drivers/filesystems/cdfs_new/cdprocs.h b/drivers/filesystems/cdfs_new/cdprocs.h index d2f7db0b4b..6c957aebba 100755 --- a/drivers/filesystems/cdfs_new/cdprocs.h +++ b/drivers/filesystems/cdfs_new/cdprocs.h @@ -17,26 +17,31 @@ Abstract: #ifndef _CDPROCS_ #define _CDPROCS_ +#ifdef _MSC_VER #pragma warning( disable: 4127 ) // conditional expression is constant #pragma warning( push ) #pragma warning( disable: 4201 ) // nonstandard extension used : nameless struct/union #pragma warning( disable: 4214 ) // nonstandard extension used : bit field types +#endif #include <ntifs.h> #include <ntddcdrm.h> #include <ntdddisk.h> #include <ntddscsi.h> +#ifdef __REACTOS__ +#include <pseh/pseh2.h> +#endif #ifndef INLINE #define INLINE __inline #endif #include "nodetype.h" -#include "Cd.h" -#include "CdStruc.h" -#include "CdData.h" +#include "cd.h" +#include "cdstruc.h" +#include "cddata.h" #ifdef CDFS_TELEMETRY_DATA @@ -46,7 +51,9 @@ Abstract: #endif // CDFS_TELEMETRY_DATA +#ifdef _MSC_VER #pragma warning( pop ) +#endif //**** x86 compiler bug **** @@ -221,8 +228,9 @@ CdPurgeVolume ( _In_ BOOLEAN DismountUnderway ); +static /* ReactOS Change: GCC "multiple definition" */ +INLINE /* GCC only accepts __inline as the first modifier */ VOID -INLINE CdVerifyOrCreateDirStreamFile ( _In_ PIRP_CONTEXT IrpContext, _In_ PFCB Fcb @@ -364,6 +372,7 @@ CdHijackIrpAndFlushDevice ( // ); // +#ifndef __REACTOS__ #define CdMapUserBuffer(IC, UB) { \ *(UB) = (PVOID) ( ((IC)->Irp->MdlAddress == NULL) ? \ (IC)->Irp->UserBuffer : \ @@ -373,6 +382,18 @@ CdHijackIrpAndFlushDevice ( } \ } +#else +#define CdMapUserBuffer(IC, UB) { \ + *(UB) = (PVOID) ( ((IC)->Irp->MdlAddress == NULL) ? \ + (IC)->Irp->UserBuffer : \ + (MmGetSystemAddressForMdlSafe( (IC)->Irp->MdlAddress, NormalPagePriority))); \ + if (NULL == *(UB)) { \ + CdRaiseStatus( (IC), STATUS_INSUFFICIENT_RESOURCES); \ + } \ + } + +#endif + #define CdLockUserBuffer(IC,BL,OP) { \ if ((IC)->Irp->MdlAddress == NULL) { \ @@ -1071,12 +1092,14 @@ BOOLEAN DummyRestoreIrql(_Inout_ PFAST_MUTEX FastMutex); #endif BOOLEAN +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdNoopAcquire ( _In_ PVOID Fcb, _In_ BOOLEAN Wait ); VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdNoopRelease ( _In_ PVOID Fcb ); @@ -1084,6 +1107,7 @@ CdNoopRelease ( _Requires_lock_held_(_Global_critical_region_) _When_(return!=0, _Acquires_shared_lock_(*Fcb->Resource)) BOOLEAN +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdAcquireForCache ( _Inout_ PFCB Fcb, _In_ BOOLEAN Wait @@ -1092,12 +1116,14 @@ CdAcquireForCache ( _Requires_lock_held_(_Global_critical_region_) _Releases_lock_(*Fcb->Resource) VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdReleaseFromCache ( _Inout_ PFCB Fcb ); _Requires_lock_held_(_Global_critical_region_) NTSTATUS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFilterCallbackAcquireForCreateSection ( _In_ PFS_FILTER_CALLBACK_DATA CallbackData, _Unreferenced_parameter_ PVOID *CompletionContext @@ -1106,6 +1132,7 @@ CdFilterCallbackAcquireForCreateSection ( _Function_class_(FAST_IO_RELEASE_FILE) _Requires_lock_held_(_Global_critical_region_) VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdReleaseForCreateSection ( _In_ PFILE_OBJECT FileObject ); @@ -1324,7 +1351,7 @@ CdTeardownStructures ( sizeof( CD_IO_CONTEXT ), \ TAG_IO_CONTEXT ) -#define CdFreeIoContext(IO) CdFreePool( &(IO) ) +#define CdFreeIoContext(IO) CdFreePool( (PVOID) &(IO) ) /* ReactOS Change: GCC "passing argument 1 from incompatible pointer type" */ PFCB CdLookupFcbTable ( @@ -1356,15 +1383,20 @@ CdProcessToc ( // #define CdPagedPool PagedPool +#ifndef __REACTOS__ #define CdNonPagedPool NonPagedPoolNx #define CdNonPagedPoolCacheAligned NonPagedPoolNxCacheAligned +#else +#define CdNonPagedPool NonPagedPool +#define CdNonPagedPoolCacheAligned NonPagedPoolCacheAligned +#endif // // Verification support routines. Contained in verfysup.c // - +static /* ReactOS Change: GCC "multiple definition" */ INLINE BOOLEAN CdOperationIsDasdOpen ( @@ -1461,6 +1493,7 @@ CdFsdPostRequest ( _Requires_lock_held_(_Global_critical_region_) VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdPrePostIrp ( _Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp @@ -1468,6 +1501,7 @@ CdPrePostIrp ( _Requires_lock_held_(_Global_critical_region_) VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdOplockComplete ( _Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp @@ -1483,6 +1517,7 @@ CdOplockComplete ( // otherwise // +/* GCC complains about multi-line comments. //#ifndef BooleanFlagOn //#define BooleanFlagOn(F,SF) ( \ // (BOOLEAN)(((F) & (SF)) != 0) \ @@ -1500,6 +1535,7 @@ CdOplockComplete ( // (Flags) &= ~(SingleFlag); \ //} //#endif +*/ // // CAST @@ -1575,6 +1611,7 @@ CdOplockComplete ( ((ULONG) (L)) >> SECTOR_SHIFT \ ) +static /* ReactOS Change: GCC "multiple definition" */ INLINE ULONG SectorsFromLlBytes( @@ -2144,16 +2181,24 @@ CdCommonShutdown ( // Implemented in Shutdown.c // #define try_return(S) { S; goto try_exit; } // +#ifndef __REACTOS__ #define try_return(S) { S; goto try_exit; } #define try_leave(S) { S; leave; } +#else +#define try_return(S) { S; goto try_exit; } +#define try_leave(S) { S; _SEH2_LEAVE; } +#endif // // Encapsulate safe pool freeing // +/* ReactOS Change: GCC "passing argument 1 of CdFreePool from incompatible pointer type" */ +#define CdFreePool(x) _CdFreePool((PVOID*)(x)) +static /* ReactOS Change: GCC "multiple definition" */ INLINE VOID -CdFreePool( +_CdFreePool( _Inout_ _At_(*Pool, __drv_freesMem(Mem) _Post_null_) PVOID *Pool ) { diff --git a/drivers/filesystems/cdfs_new/cdstruc.h b/drivers/filesystems/cdfs_new/cdstruc.h index 72abe0a1c3..8a5c02d534 100755 --- a/drivers/filesystems/cdfs_new/cdstruc.h +++ b/drivers/filesystems/cdfs_new/cdstruc.h @@ -170,6 +170,12 @@ typedef PVOID PBCB; //**** Bcb's are now part of the cache module #define BYTE_COUNT_EMBEDDED_NAME (32) +#ifdef __REACTOS__ +#define __volatile +#define _Unreferenced_parameter_ +#define __field_range(a,b) +#define __analysis_assert(x) +#endif // // The CD_MCB is used to store the mapping of logical file offset to @@ -349,6 +355,10 @@ typedef struct _CD_DATA { PDEVICE_OBJECT FileSystemDeviceObject; +#ifdef __REACTOS__ + PDEVICE_OBJECT HddFileSystemDeviceObject; +#endif + // // Following are used to manage the async and delayed close queue. // @@ -545,8 +555,8 @@ typedef struct _VCB { // ULONG VcbCleanup; - __volatile ULONG VcbReference; - __volatile ULONG VcbUserReference; + __volatile LONG VcbReference; /* ReactOS Change: GCC 'pointer targets in passing argument 1 of 'InterlockedXxx' differ in signedness */ + __volatile LONG VcbUserReference; /* ReactOS Change: GCC 'pointer targets in passing argument 1 of 'InterlockedXxx' differ in signedness */ // // Fcb for the Volume Dasd file, root directory and the Path Table. @@ -732,7 +742,7 @@ typedef struct _VOLUME_DEVICE_OBJECT { // executed later. // - __volatile ULONG PostedRequestCount; + __volatile LONG PostedRequestCount; /* ReactOS Change: GCC "pointer targets in passing argument 1 of 'InterlockedDecrement' differ in signedness" */ // // The following field indicates the number of IRP's waiting @@ -957,7 +967,7 @@ typedef struct _FCB { // ULONG FcbCleanup; - __volatile ULONG FcbReference; + __volatile LONG FcbReference; /* ReactOS Change: GCC 'pointer targets in passing argument 1 of 'InterlockedXxx' differ in signedness */ ULONG FcbUserReference; // diff --git a/drivers/filesystems/cdfs_new/cleanup.c b/drivers/filesystems/cdfs_new/cleanup.c index a0d8ce43fc..0cdda166f5 100755 --- a/drivers/filesystems/cdfs_new/cleanup.c +++ b/drivers/filesystems/cdfs_new/cleanup.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -190,7 +190,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Case on the type of open that we are trying to cleanup. @@ -258,7 +258,9 @@ Return Value: default : +#ifdef _MSC_VER #pragma prefast( suppress:__WARNING_USE_OTHER_FUNCTION, "argument bogus" ) +#endif CdBugCheck( TypeOfOpen, 0, 0 ); } @@ -311,15 +313,15 @@ Return Value: IoRemoveShareAccess( FileObject, &Fcb->ShareAccess ); - } finally { + } _SEH2_FINALLY { - CdReleaseFcb( IrpContext, Fcb ); + CdReleaseFcb( IrpContext, Fcb ); if (SendUnlockNotification) { FsRtlNotifyVolumeEvent( FileObject, FSRTL_VOLUME_UNLOCK ); } - } + } _SEH2_END; // // If appropriate, try to spark teardown by purging the volume. Should @@ -337,19 +339,19 @@ Return Value: CdAcquireCdData( IrpContext); - try { + _SEH2_TRY { CdAcquireVcbExclusive( IrpContext, Vcb, FALSE ); VcbAcquired = TRUE; CdPurgeVolume( IrpContext, Vcb, FALSE ); - } finally { + } _SEH2_FINALLY { if (VcbAcquired) { CdReleaseVcb( IrpContext, Vcb ); } CdReleaseCdData( IrpContext); - } + } _SEH2_END; } // diff --git a/drivers/filesystems/cdfs_new/close.c b/drivers/filesystems/cdfs_new/close.c index 5e45587544..fecb1e6dbf 100755 --- a/drivers/filesystems/cdfs_new/close.c +++ b/drivers/filesystems/cdfs_new/close.c @@ -42,7 +42,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -81,6 +81,7 @@ CdRemoveClose ( IO_WORKITEM_ROUTINE CdCloseWorker; VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdCloseWorker ( _In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PVOID Context @@ -170,7 +171,7 @@ Return Value: // Free the IrpContextLite. // - CdFreeIrpContextLite( (PIRP_CONTEXT_LITE) IrpContext ); + CdFreeIrpContextLite( *(PVOID*)&IrpContext ); /* ReactOS Change: GCC "error: invalid lvalue in unary '&'" */ // // Remember we have the IrpContext from the stack. @@ -318,7 +319,9 @@ Return Value: } +#ifdef _MSC_VER #pragma prefast(suppress:26165, "Esp:1153") +#endif FsRtlExitFileSystem(); } @@ -650,6 +653,7 @@ Return Value: } VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdCloseWorker ( _In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PVOID Context diff --git a/drivers/filesystems/cdfs_new/create.c b/drivers/filesystems/cdfs_new/create.c index 695121df0f..1fb744139e 100755 --- a/drivers/filesystems/cdfs_new/create.c +++ b/drivers/filesystems/cdfs_new/create.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -119,7 +119,9 @@ CdCompleteFcbOpen ( _Requires_lock_held_(_Global_critical_region_) NTSTATUS +#ifdef _MSC_VER #pragma prefast(suppress:26165, "Esp:1153") +#endif CdCommonCreate ( _Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp @@ -168,7 +170,7 @@ Return Value: PFILE_OBJECT FileObject; - COMPOUND_PATH_ENTRY CompoundPathEntry = {0}; + COMPOUND_PATH_ENTRY CompoundPathEntry = {{0}};/* ReactOS Change: GCC "missing braces around initializer" */ BOOLEAN CleanupCompoundPathEntry = FALSE; FILE_ENUM_CONTEXT FileContext = {0}; @@ -229,7 +231,7 @@ Return Value: PUNICODE_STRING FileName; PUNICODE_STRING RelatedFileName = NULL; - CD_NAME RemainingName = {0}; + CD_NAME RemainingName = {{0}};/* ReactOS Change: GCC "missing braces around initializer" */ CD_NAME FinalName; PCD_NAME MatchingName = NULL; @@ -382,7 +384,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Verify that the Vcb is not in an unusable condition. This routine @@ -926,7 +928,7 @@ Return Value: RelatedCcb )); try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { // // Cleanup the PathEntry if initialized. @@ -951,7 +953,7 @@ Return Value: // condition. // - if (AbnormalTermination()) { + if (_SEH2_AbnormalTermination()) { // @@ -1011,7 +1013,7 @@ Return Value: // CdCompleteRequest( IrpContext, Irp, Status ); - } + } _SEH2_END; return Status; } @@ -1348,10 +1350,14 @@ Return Value: // // Do a quick check to make sure there are no wildcards. // +#ifdef _MSC_VER #pragma prefast(push) #pragma prefast(suppress:26000, "RemainingName->FileName.Buffer = FileName.Buffer + (RelatedNameLength + SeparatorLength); FileName.MaximumLength < (RelatedNameLength + SeparatorLength + RemainingNameLength).") +#endif if (FsRtlDoesNameContainWildCards( &RemainingName->FileName )) { +#ifdef _MSC_VER #pragma prefast(pop) +#endif return STATUS_OBJECT_NAME_INVALID; } @@ -1453,10 +1459,14 @@ Return Value: } } +#ifdef _MSC_VER #pragma prefast(push) #pragma prefast(suppress:26030, "RemainingName->FileName.Buffer = FileName.Buffer + (RelatedNameLength + SeparatorLength); FileName.MaximumLength < (RelatedNameLength + SeparatorLength + RemainingNameLength).") +#endif return STATUS_SUCCESS; +#ifdef _MSC_VER #pragma prefast(pop) +#endif } @@ -1528,7 +1538,7 @@ Return Value: FILE_ENUM_CONTEXT FileContext; BOOLEAN CleanupFileContext = FALSE; - COMPOUND_PATH_ENTRY CompoundPathEntry = {0}; + COMPOUND_PATH_ENTRY CompoundPathEntry = {{0}};/* ReactOS Change: GCC "missing braces around initializer" */ BOOLEAN CleanupCompoundPathEntry = FALSE; FILE_ID FileId; @@ -1548,7 +1558,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Go ahead and figure out the TypeOfOpen and NodeType. We can @@ -1942,7 +1952,7 @@ Return Value: } try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { if (UnlockVcb) { @@ -1958,7 +1968,7 @@ Return Value: CdCleanupCompoundPathEntry( IrpContext, &CompoundPathEntry ); } - } + } _SEH2_END; return Status; } @@ -2166,7 +2176,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Check the related Ccb to see if this was an OpenByFileId. @@ -2324,7 +2334,7 @@ Return Value: IrpSp->Parameters.Create.SecurityContext->DesiredAccess ); } - } finally { + } _SEH2_FINALLY { // // Unlock the Vcb if held. @@ -2343,7 +2353,7 @@ Return Value: CdReleaseFcb( IrpContext, ParentFcb ); } - } + } _SEH2_END; return Status; } @@ -2443,7 +2453,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Check if a version number was used to open this file. @@ -2614,7 +2624,7 @@ Return Value: CcbFlags, IrpSp->Parameters.Create.SecurityContext->DesiredAccess ); - } finally { + } _SEH2_FINALLY { // // Unlock the Vcb if held. @@ -2633,7 +2643,7 @@ Return Value: CdReleaseFcb( IrpContext, ParentFcb ); } - } + } _SEH2_END; return Status; } @@ -2803,8 +2813,8 @@ Return Value: OplockStatus = FsRtlCheckOplock( CdGetFcbOplock(Fcb), IrpContext->Irp, IrpContext, - CdOplockComplete, - CdPrePostIrp ); + (PVOID)CdOplockComplete, /* ReactOS Change: GCC "assignment from incompatible pointer type" */ + (PVOID)CdPrePostIrp ); /* ReactOS Change: GCC "assignment from incompatible pointer type" */ if (OplockStatus == STATUS_PENDING) { @@ -2835,8 +2845,8 @@ Return Value: OplockStatus = FsRtlCheckOplock( CdGetFcbOplock(Fcb), IrpContext->Irp, IrpContext, - CdOplockComplete, - CdPrePostIrp ); + (PVOID)CdOplockComplete,/* ReactOS Change: GCC "assignment from incompatible pointer type" */ + (PVOID)CdPrePostIrp );/* ReactOS Change: GCC "assignment from incompatible pointer type" */ if (OplockStatus == STATUS_PENDING) { diff --git a/drivers/filesystems/cdfs_new/devctrl.c b/drivers/filesystems/cdfs_new/devctrl.c index ce120f56ae..4d0a70ad55 100755 --- a/drivers/filesystems/cdfs_new/devctrl.c +++ b/drivers/filesystems/cdfs_new/devctrl.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -30,6 +30,7 @@ Abstract: IO_COMPLETION_ROUTINE CdDevCtrlCompletionRoutine; NTSTATUS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdDevCtrlCompletionRoutine ( _In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, @@ -172,6 +173,7 @@ Return Value: // NTSTATUS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdDevCtrlCompletionRoutine ( _In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, diff --git a/drivers/filesystems/cdfs_new/deviosup.c b/drivers/filesystems/cdfs_new/deviosup.c index b2f9467b51..a0bb2b7ffd 100755 --- a/drivers/filesystems/cdfs_new/deviosup.c +++ b/drivers/filesystems/cdfs_new/deviosup.c @@ -13,7 +13,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -407,7 +407,7 @@ Return Value: // Use a try-finally to perform the final cleanup. // - try { + _SEH2_TRY { // // Loop while there are more bytes to transfer. @@ -568,7 +568,7 @@ Return Value: } try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { // // Perform final cleanup on the IoRuns if necessary. @@ -578,7 +578,7 @@ Return Value: CdFinishBuffers( IrpContext, IoRuns, CleanupRunCount, TRUE, FALSE ); } - } + } _SEH2_END; return Status; } @@ -677,7 +677,7 @@ Return Value: // Use a try-finally to perform the final cleanup. // - try { + _SEH2_TRY { // // If the initial offset lies within the RIFF header then copy the @@ -979,7 +979,7 @@ Return Value: KeFlushIoBuffers( IrpContext->Irp->MdlAddress, TRUE, FALSE ); try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { // // Perform final cleanup on the IoRuns if necessary. @@ -989,7 +989,7 @@ Return Value: CdFinishBuffers( IrpContext, IoRuns, CleanupRunCount, TRUE, FALSE ); } - } + } _SEH2_END; return Status; } @@ -1282,16 +1282,18 @@ Return Value: // deallocate the Mdl and return the appropriate "expected" status. // - try { + _SEH2_TRY { MmProbeAndLockPages( Mdl, IrpContext->Irp->RequestorMode, IoWriteAccess ); Status = STATUS_SUCCESS; +#ifdef _MSC_VER #pragma warning(suppress: 6320) - } except(EXCEPTION_EXECUTE_HANDLER) { +#endif + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - Status = GetExceptionCode(); + Status = _SEH2_GetExceptionCode(); IoFreeMdl( Mdl ); IrpContext->Irp->MdlAddress = NULL; @@ -1300,7 +1302,7 @@ Return Value: Status = STATUS_INVALID_USER_BUFFER; } - } + } _SEH2_END; } // @@ -1890,7 +1892,9 @@ Return Value: CurrentRawOffset = (LONGLONG) ((ULONG) CurrentRawOffset / RAW_SECTOR_SIZE); +#ifdef _MSC_VER #pragma prefast( suppress: __WARNING_RESULTOFSHIFTCASTTOLARGERSIZE, "This is fine beacuse raw sector size > sector shift" ) +#endif CurrentCookedOffset = (LONGLONG) ((ULONG) CurrentRawOffset << SECTOR_SHIFT ); CurrentRawOffset = (LONGLONG) ((ULONG) CurrentRawOffset * RAW_SECTOR_SIZE); @@ -2384,6 +2388,7 @@ Return Value: IO_COMPLETION_ROUTINE CdSyncCompletionRoutine; NTSTATUS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdSyncCompletionRoutine ( PDEVICE_OBJECT DeviceObject, PIRP Irp, @@ -2514,7 +2519,7 @@ Return Value: CdAcquireCacheForRead( IrpContext); - try { + _SEH2_TRY { // // Check the cache hasn't gone away due to volume verify failure (which @@ -2656,18 +2661,20 @@ Return Value: // pages and update the MDL with physical page information. // - try { + _SEH2_TRY { MmProbeAndLockPages( Vcb->SectorCacheIrp->MdlAddress, KernelMode, (LOCK_OPERATION) IoWriteAccess ); } +#ifdef _MSC_VER #pragma warning(suppress: 6320) - except(EXCEPTION_EXECUTE_HANDLER) { +#endif + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { IoFreeMdl( Vcb->SectorCacheIrp->MdlAddress ); Vcb->SectorCacheIrp->MdlAddress = NULL; - } + } _SEH2_END; if (NULL == Vcb->SectorCacheIrp->MdlAddress) { @@ -2738,10 +2745,10 @@ Return Value: Result = TRUE; } - finally { + _SEH2_FINALLY { CdReleaseCache( IrpContext); - } + } _SEH2_END; return Result; } @@ -3418,6 +3425,7 @@ Return Value: // NTSTATUS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdMultiSyncCompletionRoutine ( PDEVICE_OBJECT DeviceObject, PIRP Irp, @@ -3505,6 +3513,7 @@ Return Value: // NTSTATUS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdMultiAsyncCompletionRoutine ( PDEVICE_OBJECT DeviceObject, PIRP Irp, @@ -3624,6 +3633,7 @@ Return Value: // NTSTATUS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdSingleSyncCompletionRoutine ( PDEVICE_OBJECT DeviceObject, PIRP Irp, @@ -3687,6 +3697,7 @@ Return Value: // NTSTATUS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdSingleAsyncCompletionRoutine ( PDEVICE_OBJECT DeviceObject, PIRP Irp, diff --git a/drivers/filesystems/cdfs_new/dirctrl.c b/drivers/filesystems/cdfs_new/dirctrl.c index 71cfccb6ba..08e8317f94 100755 --- a/drivers/filesystems/cdfs_new/dirctrl.c +++ b/drivers/filesystems/cdfs_new/dirctrl.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -292,7 +292,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Verify the Fcb is still good. @@ -504,7 +504,7 @@ Return Value: // such trickery. // - try { + _SEH2_TRY { // // Zero and initialize the base part of the current entry. @@ -579,6 +579,9 @@ Return Value: NamesInfo->FileNameLength = FileNameBytes + SeparatorBytes + VersionStringBytes; break; + + /* ReactOS Change: GCC "enumeration value not handled in switch" */ + default: break; } // @@ -712,8 +715,10 @@ Return Value: LastEntry = NextEntry; NextEntry = QuadAlign( Information ); +#ifdef _MSC_VER #pragma warning(suppress: 6320) - } except (EXCEPTION_EXECUTE_HANDLER) { +#endif + } _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER) { // // We had a problem filling in the user's buffer, so stop and @@ -722,13 +727,13 @@ Return Value: // Information = 0; - try_leave( Status = GetExceptionCode()); - } + try_leave( Status = _SEH2_GetExceptionCode()); + } _SEH2_END; } DoCcbUpdate = TRUE; - } finally { + } _SEH2_FINALLY { // // Cleanup our search context - *before* aquiring the FCB mutex exclusive, @@ -767,7 +772,7 @@ Return Value: // CdReleaseFile( IrpContext, Fcb ); - } + } _SEH2_END; // // Complete the request here. @@ -836,7 +841,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Verify the Vcb. @@ -861,14 +866,14 @@ Return Value: NULL, NULL ); - } finally { + } _SEH2_FINALLY { // // Release the Vcb. // CdReleaseVcb( IrpContext, IrpContext->Vcb ); - } + } _SEH2_END; // // Cleanup the IrpContext. diff --git a/drivers/filesystems/cdfs_new/dirsup.c b/drivers/filesystems/cdfs_new/dirsup.c index b1667d3d3f..364b78e8e9 100755 --- a/drivers/filesystems/cdfs_new/dirsup.c +++ b/drivers/filesystems/cdfs_new/dirsup.c @@ -65,7 +65,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module diff --git a/drivers/filesystems/cdfs_new/fieldoff.c b/drivers/filesystems/cdfs_new/fieldoff.c index 0aecc39288..b9d457521f 100755 --- a/drivers/filesystems/cdfs_new/fieldoff.c +++ b/drivers/filesystems/cdfs_new/fieldoff.c @@ -1,4 +1,4 @@ -#include "CdProcs.h" +#include "cdprocs.h" #include <stdio.h> #define doit(a,b) { printf("%s %04lx %4lx %s\n", #a, FIELD_OFFSET(a,b), sizeof(d.b), #b); } diff --git a/drivers/filesystems/cdfs_new/fileinfo.c b/drivers/filesystems/cdfs_new/fileinfo.c index cd9f1af38a..62c929bac4 100755 --- a/drivers/filesystems/cdfs_new/fileinfo.c +++ b/drivers/filesystems/cdfs_new/fileinfo.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -167,7 +167,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // We only support query on file and directory handles. @@ -327,7 +327,7 @@ Return Value: Irp->IoStatus.Information = IrpSp->Parameters.QueryFile.Length - Length; - } finally { + } _SEH2_FINALLY { // // Release the file. @@ -337,7 +337,7 @@ Return Value: CdReleaseFile( IrpContext, Fcb ); } - } + } _SEH2_END; // // Complete the request if we didn't raise. @@ -409,7 +409,7 @@ Return Value: CdAcquireFileShared( IrpContext, Fcb ); - try { + _SEH2_TRY { // // Make sure the Fcb is in a usable condition. This @@ -448,10 +448,10 @@ Return Value: Status = STATUS_SUCCESS; try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { CdReleaseFile( IrpContext, Fcb ); - } + } _SEH2_END; // // Complete the request if there was no raise. @@ -466,6 +466,7 @@ _Function_class_(FAST_IO_QUERY_BASIC_INFO) _IRQL_requires_same_ _Success_(return != FALSE) BOOLEAN +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFastQueryBasicInfo ( _In_ PFILE_OBJECT FileObject, _In_ BOOLEAN Wait, @@ -543,7 +544,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Only deal with 'good' Fcb's. @@ -573,12 +574,12 @@ Return Value: Result = TRUE; } - } finally { + } _SEH2_FINALLY { ExReleaseResourceLite( Fcb->Resource ); FsRtlExitFileSystem(); - } + } _SEH2_END; return Result; } @@ -588,6 +589,7 @@ _Function_class_(FAST_IO_QUERY_STANDARD_INFO) _IRQL_requires_same_ _Success_(return != FALSE) BOOLEAN +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFastQueryStdInfo ( _In_ PFILE_OBJECT FileObject, _In_ BOOLEAN Wait, @@ -665,7 +667,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Only deal with 'good' Fcb's. @@ -705,12 +707,12 @@ Return Value: Result = TRUE; } - } finally { + } _SEH2_FINALLY { ExReleaseResourceLite( Fcb->Resource ); FsRtlExitFileSystem(); - } + } _SEH2_END; return Result; } @@ -720,6 +722,7 @@ _Function_class_(FAST_IO_QUERY_NETWORK_OPEN_INFO) _IRQL_requires_same_ _Success_(return != FALSE) BOOLEAN +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFastQueryNetworkInfo ( _In_ PFILE_OBJECT FileObject, _In_ BOOLEAN Wait, @@ -797,7 +800,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Only deal with 'good' Fcb's. @@ -842,12 +845,12 @@ Return Value: Result = TRUE; } - } finally { + } _SEH2_FINALLY { ExReleaseResourceLite( Fcb->Resource ); FsRtlExitFileSystem(); - } + } _SEH2_END; return Result; } @@ -1272,7 +1275,7 @@ Return Value: PUNICODE_STRING NameToUse; ULONG DirentOffset; - COMPOUND_PATH_ENTRY CompoundPathEntry = {0}; + COMPOUND_PATH_ENTRY CompoundPathEntry = {{0}};/* ReactOS Change: GCC "missing braces around initializer" */ FILE_ENUM_CONTEXT FileContext; PFCB ParentFcb = NULL; @@ -1307,7 +1310,7 @@ Return Value: // Use a try-finally to cleanup the structures. // - try { + _SEH2_TRY { ParentFcb = Fcb->ParentFcb; CdAcquireFileShared( IrpContext, ParentFcb ); @@ -1418,12 +1421,12 @@ Return Value: RtlCopyMemory( Buffer->FileName, ShortNameBuffer, Buffer->FileNameLength ); try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { if (CleanupFileLookup) { CdCleanupDirContext( IrpContext, &DirContext ); - CdCleanupDirent( IrpContext, &Dirent ); + CdCleanupDirent( IrpContext, &Dirent );/* ReactOS Change: GCC "passing argument 1 from incompatible pointer type" */ } else if (CleanupDirectoryLookup) { @@ -1435,7 +1438,7 @@ Return Value: CdReleaseFile( IrpContext, ParentFcb ); } - } + } _SEH2_END; // // Reduce the available bytes by the amount stored into this buffer. diff --git a/drivers/filesystems/cdfs_new/filobsup.c b/drivers/filesystems/cdfs_new/filobsup.c index 1354bc1152..d957a795c4 100755 --- a/drivers/filesystems/cdfs_new/filobsup.c +++ b/drivers/filesystems/cdfs_new/filobsup.c @@ -13,7 +13,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -109,8 +109,10 @@ Return Value: FileObject->FsContext = Fcb; FileObject->FsContext2 = Ccb; +#ifdef _MSC_VER #pragma warning( suppress: 4213 ) - SetFlag( ((ULONG_PTR) FileObject->FsContext2), TypeOfOpen ); +#endif + SetFlag( (*(PULONG_PTR)&FileObject->FsContext2), TypeOfOpen ); /* ReactOS Change: GCC "invalid lvalue in assignment" */ // // Set the Vpb field in the file object. @@ -186,8 +188,10 @@ Return Value: *Fcb = FileObject->FsContext; *Ccb = FileObject->FsContext2; +#ifdef _MSC_VER #pragma warning( suppress: 4213 ) - ClearFlag( (ULONG_PTR) *Ccb, TYPE_OF_OPEN_MASK ); +#endif + ClearFlag( (*(PULONG_PTR)Ccb), TYPE_OF_OPEN_MASK ); /* ReactOS Change: GCC "invalid lvalue in assignment" */ } // diff --git a/drivers/filesystems/cdfs_new/fsctrl.c b/drivers/filesystems/cdfs_new/fsctrl.c index 8a113f04ec..8e039ef54b 100755 --- a/drivers/filesystems/cdfs_new/fsctrl.c +++ b/drivers/filesystems/cdfs_new/fsctrl.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -532,7 +532,9 @@ CdReMountOldVcb ( IoAcquireVpbSpinLock( &SavedIrql ); +#ifdef _MSC_VER #pragma prefast(suppress: 28175, "this is a filesystem driver, touching the vpb is allowed") +#endif NewVcb->Vpb->RealDevice->Vpb = OldVcb->Vpb; OldVcb->Vpb->RealDevice = NewVcb->Vpb->RealDevice; @@ -639,6 +641,10 @@ Return Value: ULONG TocDiskFlags = 0; ULONG MediaChangeCount = 0; +#ifdef __REACTOS__ + DEVICE_TYPE FilesystemDeviceType; +#endif + #ifdef CDFS_TELEMETRY_DATA GUID VolumeGuid; GUID VolumeCorrelationId = { 0 }; @@ -651,7 +657,16 @@ Return Value: // always be waitable. // +#ifdef __REACTOS__ + if (IrpSp->DeviceObject == CdData.HddFileSystemDeviceObject) { + FilesystemDeviceType = FILE_DEVICE_DISK_FILE_SYSTEM; + } else { +#endif NT_ASSERT( Vpb->RealDevice->DeviceType == FILE_DEVICE_CD_ROM ); +#ifdef __REACTOS__ + FilesystemDeviceType = FILE_DEVICE_CD_ROM_FILE_SYSTEM; + } +#endif NT_ASSERT( FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT )); #ifdef CDFS_TELEMETRY_DATA @@ -697,7 +712,11 @@ Return Value: // Status = CdPerformDevIoCtrl( IrpContext, +#ifndef __REACTOS__ IOCTL_CDROM_CHECK_VERIFY, +#else + (FilesystemDeviceType == FILE_DEVICE_DISK_FILE_SYSTEM ? IOCTL_DISK_CHECK_VERIFY : IOCTL_CDROM_CHECK_VERIFY), +#endif DeviceObjectWeTalkTo, &MediaChangeCount, sizeof(ULONG), @@ -726,7 +745,11 @@ Return Value: // Status = CdPerformDevIoCtrl( IrpContext, +#ifndef __REACTOS__ IOCTL_CDROM_GET_DRIVE_GEOMETRY, +#else + (FilesystemDeviceType == FILE_DEVICE_DISK_FILE_SYSTEM ? IOCTL_DISK_GET_DRIVE_GEOMETRY : IOCTL_CDROM_GET_DRIVE_GEOMETRY), +#endif DeviceObjectWeTalkTo, &DiskGeometry, sizeof( DISK_GEOMETRY ), @@ -769,7 +792,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Allocate a buffer to query the TOC. @@ -794,7 +817,11 @@ Return Value: Status = IoCreateDevice( CdData.DriverObject, sizeof( VOLUME_DEVICE_OBJECT ) - sizeof( DEVICE_OBJECT ), NULL, +#ifndef __REACTOS__ FILE_DEVICE_CD_ROM_FILE_SYSTEM, +#else + FilesystemDeviceType, +#endif 0, FALSE, (PDEVICE_OBJECT *) &VolDo ); @@ -848,7 +875,21 @@ Return Value: if (Status != STATUS_SUCCESS) { +#ifdef __REACTOS__ + + // + // Don't bail out if that was a disk based ISO image, it is legit + // + + if (FilesystemDeviceType == FILE_DEVICE_DISK_FILE_SYSTEM) { + CdFreePool( &CdromToc ); + Status = STATUS_SUCCESS; + } else { +#endif try_leave( Status ); +#ifdef __REACTOS__ + } +#endif } // @@ -1164,7 +1205,7 @@ Return Value: Status = STATUS_SUCCESS; - } finally { + } _SEH2_FINALLY { // // Free the TOC buffer if not in the Vcb. @@ -1188,7 +1229,7 @@ Return Value: // If we are not mounting the device, then set the verify bit again. // - if ((AbnormalTermination() || (Status != STATUS_SUCCESS)) && + if ((_SEH2_AbnormalTermination() || (Status != STATUS_SUCCESS)) && SetDoVerifyOnFail) { CdMarkRealDevForVerify( IrpContext->RealDevice); @@ -1225,7 +1266,7 @@ Return Value: // CdReleaseCdData( IrpContext ); - } + } _SEH2_END; // // Now send mount notification. @@ -1338,7 +1379,7 @@ Return Value: CdAcquireCdData( IrpContext ); - try { + _SEH2_TRY { CdAcquireVcbExclusive( IrpContext, Vcb, FALSE ); ReleaseVcb = TRUE; @@ -1682,8 +1723,7 @@ Return Value: } } - } - finally { + } _SEH2_FINALLY { // // Free the TOC buffer if allocated. @@ -1708,7 +1748,7 @@ Return Value: } CdReleaseCdData( IrpContext ); - } + } _SEH2_END; // // Now send mount notification. @@ -1838,7 +1878,7 @@ Return Value: // Use a try finally to free the Fcb. // - try { + _SEH2_TRY { // // Verify the Fcb. @@ -1868,14 +1908,14 @@ Return Value: Irp = NULL; - } finally { + } _SEH2_FINALLY { // // Release all of our resources // CdReleaseFcb( IrpContext, Fcb ); - } + } _SEH2_END; // // Complete the request if there was no exception. @@ -1951,7 +1991,7 @@ Return Value: Vcb = Fcb->Vcb; CdAcquireVcbExclusive( IrpContext, Vcb, FALSE ); - try { + _SEH2_TRY { // // Verify the Vcb. @@ -1961,7 +2001,7 @@ Return Value: Status = CdLockVolumeInternal( IrpContext, Vcb, IrpSp->FileObject ); - } finally { + } _SEH2_FINALLY { // // Release the Vcb. @@ -1969,11 +2009,11 @@ Return Value: CdReleaseVcb( IrpContext, Vcb ); - if (AbnormalTermination() || !NT_SUCCESS( Status )) { + if (_SEH2_AbnormalTermination() || !NT_SUCCESS( Status )) { FsRtlNotifyVolumeEvent( IrpSp->FileObject, FSRTL_VOLUME_LOCK_FAILED ); } - } + } _SEH2_END; // // Complete the request if there haven't been any exceptions. @@ -2454,7 +2494,12 @@ Return Value: // We only allow the invalidate call to come in on our file system devices. // +#ifndef __REACTOS__ if (IrpSp->DeviceObject != CdData.FileSystemDeviceObject) { +#else + if (IrpSp->DeviceObject != CdData.FileSystemDeviceObject && + IrpSp->DeviceObject != CdData.HddFileSystemDeviceObject) { +#endif CdCompleteRequest( IrpContext, Irp, STATUS_INVALID_DEVICE_REQUEST ); @@ -2507,7 +2552,7 @@ Return Value: 0, *IoFileObjectType, KernelMode, - &FileToMarkBad, + (PVOID*)&FileToMarkBad, /* ReactOS Change: GCC "passing argument 5 of 'ObReferenceObjectByHandle' from incompatible pointer type" */ NULL ); if (!NT_SUCCESS(Status)) { @@ -2578,7 +2623,9 @@ Return Value: IoAcquireVpbSpinLock( &SavedIrql ); +#ifdef _MSC_VER #pragma prefast(suppress: 28175, "this is a filesystem driver, touching the vpb is allowed") +#endif if (DeviceToMarkBad->Vpb == Vcb->Vpb) { PVPB NewVpb = Vcb->SwapVpb; @@ -2592,11 +2639,15 @@ Return Value: NewVpb->Size = sizeof( VPB ); NewVpb->RealDevice = DeviceToMarkBad; +#ifdef _MSC_VER #pragma prefast(push) #pragma prefast(disable: 28175, "this is a filesystem driver, touching the vpb is allowed") +#endif NewVpb->Flags = FlagOn( DeviceToMarkBad->Vpb->Flags, VPB_REMOVE_PENDING ); DeviceToMarkBad->Vpb = NewVpb; +#ifdef _MSC_VER #pragma prefast(pop) +#endif Vcb->SwapVpb = NULL; } @@ -2871,7 +2922,7 @@ Return Value: // Check for whether this device supports XA and multi-session. // - try { + _SEH2_TRY { // // Allocate a buffer for the last session information. @@ -2949,10 +3000,10 @@ Return Value: ThisPass += 1; } - } finally { + } _SEH2_FINALLY { if (CdromToc != NULL) { CdFreePool( &CdromToc ); } - } + } _SEH2_END; } // diff --git a/drivers/filesystems/cdfs_new/fspdisp.c b/drivers/filesystems/cdfs_new/fspdisp.c index b38548d6b2..e119b117e8 100755 --- a/drivers/filesystems/cdfs_new/fspdisp.c +++ b/drivers/filesystems/cdfs_new/fspdisp.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -24,6 +24,7 @@ Abstract: VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFspDispatch ( _In_ PVOID Context ) @@ -95,7 +96,7 @@ Return Value: while (TRUE) { - try { + _SEH2_TRY { // // Reinitialize for the next try at completing this @@ -185,10 +186,10 @@ Return Value: CdCompleteRequest( IrpContext, Irp, Status ); } - } except( CdExceptionFilter( IrpContext, GetExceptionInformation() )) { + } _SEH2_EXCEPT( CdExceptionFilter( IrpContext, _SEH2_GetExceptionInformation() )) { - Status = CdProcessException( IrpContext, Irp, GetExceptionCode() ); - } + Status = CdProcessException( IrpContext, Irp, _SEH2_GetExceptionCode() ); + } _SEH2_END; // // Break out of the loop if we didn't get CANT_WAIT. diff --git a/drivers/filesystems/cdfs_new/lockctrl.c b/drivers/filesystems/cdfs_new/lockctrl.c index edf0d07af1..6c0352c9ab 100755 --- a/drivers/filesystems/cdfs_new/lockctrl.c +++ b/drivers/filesystems/cdfs_new/lockctrl.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -89,7 +89,7 @@ Return Value: Status = FsRtlCheckOplock( CdGetFcbOplock(Fcb), Irp, IrpContext, - CdOplockComplete, + (PVOID)CdOplockComplete,/* ReactOS Change: GCC "assignment from incompatible pointer type" */ NULL ); // @@ -138,6 +138,7 @@ Return Value: BOOLEAN +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFastLock ( _In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, @@ -225,7 +226,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // We check whether we can proceed based on the state of the file oplocks. @@ -249,7 +250,9 @@ Return Value: // Now call the FsRtl routine to perform the lock request. // +#ifdef _MSC_VER #pragma prefast(suppress: 28159, "prefast thinks this is an obsolete routine, but it is ok for CDFS to use it") +#endif if ((Results = FsRtlFastLock( Fcb->FileLock, FileObject, FileOffset, @@ -277,16 +280,17 @@ Return Value: } try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { FsRtlExitFileSystem(); - } + } _SEH2_END; return Results; } BOOLEAN +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFastUnlockSingle ( _In_ PFILE_OBJECT FileObject, _In_ PLARGE_INTEGER FileOffset, @@ -369,7 +373,7 @@ Return Value: FsRtlEnterFileSystem(); - try { + _SEH2_TRY { // // We check whether we can proceed based on the state of the file oplocks. @@ -419,16 +423,17 @@ Return Value: } try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { FsRtlExitFileSystem(); - } + } _SEH2_END; return Results; } BOOLEAN +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFastUnlockAll ( _In_ PFILE_OBJECT FileObject, _In_ PEPROCESS ProcessId, @@ -502,7 +507,7 @@ Return Value: FsRtlEnterFileSystem(); - try { + _SEH2_TRY { // // We check whether we can proceed based on the state of the file oplocks. @@ -543,16 +548,17 @@ Return Value: CdUnlockFcb( IrpContext, Fcb ); try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { FsRtlExitFileSystem(); - } + } _SEH2_END; return Results; } BOOLEAN +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFastUnlockAllByKey ( _In_ PFILE_OBJECT FileObject, _In_ PVOID ProcessId, @@ -629,7 +635,7 @@ Return Value: FsRtlEnterFileSystem(); - try { + _SEH2_TRY { // // We check whether we can proceed based on the state of the file oplocks. @@ -671,10 +677,10 @@ Return Value: CdUnlockFcb( IrpContext, Fcb ); try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { FsRtlExitFileSystem(); - } + } _SEH2_END; return Results; } diff --git a/drivers/filesystems/cdfs_new/namesup.c b/drivers/filesystems/cdfs_new/namesup.c index dc3ed319c1..96e3aa3d3e 100755 --- a/drivers/filesystems/cdfs_new/namesup.c +++ b/drivers/filesystems/cdfs_new/namesup.c @@ -13,7 +13,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -171,10 +171,14 @@ Return Value: while (RemainingByteCount != 0) { +#ifdef _MSC_VER #pragma prefast(push) #pragma prefast(suppress:26014, "RemainingByteCount is even") +#endif *Destination = *Source; +#ifdef _MSC_VER #pragma prefast(pop) +#endif Source += 2; Destination += 2; @@ -251,7 +255,9 @@ Return Value: // copy the data. // +#ifdef _MSC_VER #pragma prefast( suppress:26015, "CD_NAME structures have two UNICODE_STRING structures pointing to the same allocation. there is no way to tell prefast this is the case and that the allocation is always big enough."); +#endif *(UpcaseName->VersionString.Buffer) = L';'; UpcaseName->VersionString.Buffer += 1; @@ -759,10 +765,14 @@ Return Value: // may use 2 bytes as DBCS characters. // +#ifdef _MSC_VER #pragma prefast(push) #pragma prefast(suppress:26014, "OemNameOffset <= BaseNameOffset throughout this loop; OemName buffer previously allocated based on ShortName's length.") +#endif if (FsRtlIsLeadDbcsCharacter(OemName.Buffer[OemNameOffset])) { +#ifdef _MSC_VER #pragma prefast(pop) +#endif OemNameOffset += 2; @@ -796,11 +806,15 @@ Return Value: // Now copy the dirent string into the biased name buffer. // +#ifdef _MSC_VER #pragma prefast(push) +#endif RtlCopyMemory( NextWchar, BiasedShortName.Buffer, BiasedShortName.Length ); +#ifdef _MSC_VER #pragma prefast(pop) +#endif Length += BiasedShortName.Length; NextWchar += (BiasedShortName.Length / sizeof( WCHAR )); diff --git a/drivers/filesystems/cdfs_new/pathsup.c b/drivers/filesystems/cdfs_new/pathsup.c index bd5d1dcfd7..97d3468598 100755 --- a/drivers/filesystems/cdfs_new/pathsup.c +++ b/drivers/filesystems/cdfs_new/pathsup.c @@ -73,7 +73,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module diff --git a/drivers/filesystems/cdfs_new/pnp.c b/drivers/filesystems/cdfs_new/pnp.c index b3237df35c..02609e72f1 100755 --- a/drivers/filesystems/cdfs_new/pnp.c +++ b/drivers/filesystems/cdfs_new/pnp.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -62,6 +62,7 @@ CdPnpCancelRemove ( IO_COMPLETION_ROUTINE CdPnpCompletionRoutine; NTSTATUS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdPnpCompletionRoutine ( _In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, @@ -142,7 +143,9 @@ Return Value: // field that takes us past the end of an ordinary device object. // +#ifdef _MSC_VER #pragma prefast(suppress: 28175, "this is a filesystem driver, touching the size member is allowed") +#endif if (OurDeviceObject->DeviceObject.Size != sizeof(VOLUME_DEVICE_OBJECT) || NodeType( &OurDeviceObject->Vcb ) != CDFS_NTC_VCB) { @@ -812,6 +815,7 @@ Return Value: // NTSTATUS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdPnpCompletionRoutine ( _In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, diff --git a/drivers/filesystems/cdfs_new/prefxsup.c b/drivers/filesystems/cdfs_new/prefxsup.c index 6a7b6c590d..2acb2bc62c 100755 --- a/drivers/filesystems/cdfs_new/prefxsup.c +++ b/drivers/filesystems/cdfs_new/prefxsup.c @@ -13,7 +13,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module diff --git a/drivers/filesystems/cdfs_new/read.c b/drivers/filesystems/cdfs_new/read.c index 43e8f9cecb..4e3046d444 100755 --- a/drivers/filesystems/cdfs_new/read.c +++ b/drivers/filesystems/cdfs_new/read.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -34,14 +34,24 @@ Abstract: // This macro just puts a nice little try-except around RtlZeroMemory // +#ifndef __REACTOS__ #define SafeZeroMemory(IC,AT,BYTE_COUNT) { \ - try { \ + _SEH2_TRY { \ RtlZeroMemory( (AT), (BYTE_COUNT) ); \ __pragma(warning(suppress: 6320)) \ - } except( EXCEPTION_EXECUTE_HANDLER ) { \ + } _SEH2_EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { \ CdRaiseStatus( IC, STATUS_INVALID_USER_BUFFER ); \ - } \ + } _SEH2_END; \ } +#else +#define SafeZeroMemory(IC,AT,BYTE_COUNT) { \ + _SEH2_TRY { \ + RtlZeroMemory( (AT), (BYTE_COUNT) ); \ + } _SEH2_EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { \ + CdRaiseStatus( IC, STATUS_INVALID_USER_BUFFER ); \ + } _SEH2_END; \ +} +#endif // // Read ahead amount used for normal data files @@ -186,7 +196,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Verify the Fcb. Allow reads if this is a DASD handle that is @@ -231,8 +241,8 @@ Return Value: Status = FsRtlCheckOplock( CdGetFcbOplock(Fcb), Irp, IrpContext, - CdOplockComplete, - CdPrePostIrp ); + (PVOID)CdOplockComplete,/* ReactOS Change: GCC "assignment from incompatible pointer type" */ + (PVOID)CdPrePostIrp );/* ReactOS Change: GCC "assignment from incompatible pointer type" */ // // If the result is not STATUS_SUCCESS then the Irp was completed @@ -530,7 +540,7 @@ Return Value: } try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { // // Release the Fcb. @@ -540,7 +550,7 @@ Return Value: CdReleaseFile( IrpContext, Fcb ); } - } + } _SEH2_END; // // Post the request if we got CANT_WAIT. diff --git a/drivers/filesystems/cdfs_new/resrcsup.c b/drivers/filesystems/cdfs_new/resrcsup.c index 86b2b91aa8..c9eaa7be26 100755 --- a/drivers/filesystems/cdfs_new/resrcsup.c +++ b/drivers/filesystems/cdfs_new/resrcsup.c @@ -13,7 +13,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -96,7 +96,9 @@ Return Value: switch (Type) { case AcquireExclusive: +#ifdef _MSC_VER #pragma prefast( suppress:28137, "prefast believes Wait should be a constant, but this is ok for CDFS" ) +#endif Acquired = ExAcquireResourceExclusiveLite( Resource, Wait ); break; @@ -133,6 +135,7 @@ Return Value: _Requires_lock_held_(_Global_critical_region_) _When_(return!=0, _Acquires_shared_lock_(*Fcb->Resource)) BOOLEAN +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdAcquireForCache ( _Inout_ PFCB Fcb, _In_ BOOLEAN Wait @@ -171,6 +174,7 @@ Return Value: _Requires_lock_held_(_Global_critical_region_) _Releases_lock_(*Fcb->Resource) VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdReleaseFromCache ( _Inout_ PFCB Fcb ) @@ -205,6 +209,7 @@ Return Value: BOOLEAN +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdNoopAcquire ( _In_ PVOID Fcb, _In_ BOOLEAN Wait @@ -240,6 +245,7 @@ Return Value: VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdNoopRelease ( _In_ PVOID Fcb ) @@ -267,10 +273,10 @@ Return Value: UNREFERENCED_PARAMETER( Fcb ); } - _Requires_lock_held_(_Global_critical_region_) NTSTATUS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFilterCallbackAcquireForCreateSection ( _In_ PFS_FILTER_CALLBACK_DATA CallbackData, _Unreferenced_parameter_ PVOID *CompletionContext @@ -355,6 +361,7 @@ Return Value: _Function_class_(FAST_IO_RELEASE_FILE) _Requires_lock_held_(_Global_critical_region_) VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdReleaseForCreateSection ( _In_ PFILE_OBJECT FileObject ) diff --git a/drivers/filesystems/cdfs_new/shutdown.c b/drivers/filesystems/cdfs_new/shutdown.c index ca42635afd..d6c70580a6 100644 --- a/drivers/filesystems/cdfs_new/shutdown.c +++ b/drivers/filesystems/cdfs_new/shutdown.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module diff --git a/drivers/filesystems/cdfs_new/strucsup.c b/drivers/filesystems/cdfs_new/strucsup.c index 5f354ac213..8082d5f1fb 100755 --- a/drivers/filesystems/cdfs_new/strucsup.c +++ b/drivers/filesystems/cdfs_new/strucsup.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -167,6 +167,7 @@ CdDeleteFcbNonpaged ( RTL_GENERIC_COMPARE_ROUTINE CdFcbTableCompare; RTL_GENERIC_COMPARE_RESULTS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFcbTableCompare ( _In_ PRTL_GENERIC_TABLE FcbTable, _In_ PVOID Fid1, @@ -177,6 +178,7 @@ CdFcbTableCompare ( RTL_GENERIC_ALLOCATE_ROUTINE CdAllocateFcbTable; PVOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdAllocateFcbTable ( _In_ PRTL_GENERIC_TABLE FcbTable, _In_ CLONG ByteSize @@ -186,6 +188,7 @@ CdAllocateFcbTable ( RTL_GENERIC_FREE_ROUTINE CdDeallocateFcbTable; VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdDeallocateFcbTable ( _In_ PRTL_GENERIC_TABLE FcbTable, _In_ __drv_freesMem(Mem) _Post_invalid_ PVOID Buffer @@ -318,19 +321,19 @@ Return Value: // uninitialize the notify structures before returning. // - try { + _SEH2_TRY { Vcb->SwapVpb = FsRtlAllocatePoolWithTag( CdNonPagedPool, sizeof( VPB ), TAG_VPB ); } - finally { + _SEH2_FINALLY { - if (AbnormalTermination()) { + if (_SEH2_AbnormalTermination()) { FsRtlNotifyUninitializeSync( &Vcb->NotifySync ); } - } + } _SEH2_END; // // Nothing beyond this point should raise. @@ -475,7 +478,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Copy the block size and compute the various block masks. @@ -862,10 +865,10 @@ Return Value: SetFlag( Vcb->VcbState, VCB_STATE_ISO ); } - } finally { + } _SEH2_FINALLY { if (UnlockVcb) { CdUnlockVcb( IrpContext, Vcb ); } - } + } _SEH2_END; } @@ -968,7 +971,9 @@ Return Value: // // Now delete the volume device object. // +#ifdef _MSC_VER #pragma prefast( suppress: __WARNING_BUFFER_UNDERFLOW, "This is ok, the Vcb is embedded in our volume device object, and that is what we are really deleting." ) +#endif IoDeleteDevice( (PDEVICE_OBJECT) CONTAINING_RECORD( Vcb, VOLUME_DEVICE_OBJECT, Vcb )); @@ -1069,7 +1074,9 @@ Return Value: default: +#ifdef _MSC_VER #pragma prefast( suppress: __WARNING_USE_OTHER_FUNCTION, "This is a bug." ) +#endif CdBugCheck( 0, 0, 0 ); } @@ -1262,7 +1269,7 @@ Return Value: CdLockFcb( IrpContext, Fcb ); - try { + _SEH2_TRY { // // Initialize the common header in the Fcb. The node type is already @@ -1385,10 +1392,10 @@ Return Value: CdInsertFcbTable( IrpContext, Fcb ); SetFlag( Fcb->FcbState, FCB_STATE_IN_FCB_TABLE ); - } finally { + } _SEH2_FINALLY { CdUnlockFcb( IrpContext, Fcb ); - } + } _SEH2_END; return; } @@ -1600,7 +1607,12 @@ Return Value: // occur in the context of fileobjects (i.e., mount). // +#ifndef __REACTOS__ if (IrpSp->DeviceObject == CdData.FileSystemDeviceObject) { +#else + if (IrpSp->DeviceObject == CdData.FileSystemDeviceObject || + IrpSp->DeviceObject == CdData.HddFileSystemDeviceObject) { +#endif if (IrpSp->FileObject != NULL && IrpSp->MajorFunction != IRP_MJ_CREATE && @@ -1678,7 +1690,12 @@ Return Value: // the Vcb field. // +#ifndef __REACTOS__ if (IrpSp->DeviceObject != CdData.FileSystemDeviceObject) { +#else + if (IrpSp->DeviceObject != CdData.FileSystemDeviceObject && + IrpSp->DeviceObject != CdData.HddFileSystemDeviceObject) { +#endif NewIrpContext->Vcb = &((PVOLUME_DEVICE_OBJECT) IrpSp->DeviceObject)->Vcb; @@ -1959,7 +1976,7 @@ Return Value: // Use a try-finally to safely clear the top-level field. // - try { + _SEH2_TRY { // // Loop until we find an Fcb we can't remove. @@ -2063,7 +2080,7 @@ Return Value: } while (CurrentFcb != NULL); - } finally { + } _SEH2_FINALLY { // // Release the current Fcb if we have acquired it. @@ -2079,7 +2096,7 @@ Return Value: // ClearFlag( IrpContext->TopLevel->Flags, IRP_CONTEXT_FLAG_IN_TEARDOWN ); - } + } _SEH2_END; *RemovedStartingFcb = (CurrentFcb != StartingFcb); return; @@ -2493,7 +2510,7 @@ Return Value: Vcb->PathTableFcb = NULL; } - CdDeallocateFcbIndex( IrpContext, Fcb ); + CdDeallocateFcbIndex( IrpContext, *(PVOID*)&Fcb );/* ReactOS Change: GCC "passing argument 1 from incompatible pointer type" */ break; case CDFS_NTC_FCB_DATA : @@ -2511,7 +2528,7 @@ Return Value: Vcb->VolumeDasdFcb = NULL; } - CdDeallocateFcbData( IrpContext, Fcb ); + CdDeallocateFcbData( IrpContext, *(PVOID*)&Fcb );/* ReactOS Change: GCC "passing argument 1 from incompatible pointer type" */ } // @@ -2615,7 +2632,7 @@ Return Value: ExDeleteResourceLite( &FcbNonpaged->FcbResource ); - CdDeallocateFcbNonpaged( IrpContext, FcbNonpaged ); + CdDeallocateFcbNonpaged( IrpContext, *(PVOID*)&FcbNonpaged );/* ReactOS Change: GCC "passing argument 1 from incompatible pointer type" */ return; } @@ -2626,6 +2643,7 @@ Return Value: // RTL_GENERIC_COMPARE_RESULTS +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFcbTableCompare ( _In_ PRTL_GENERIC_TABLE FcbTable, _In_ PVOID Fid1, @@ -2683,6 +2701,7 @@ Return Value: // PVOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdAllocateFcbTable ( _In_ PRTL_GENERIC_TABLE FcbTable, _In_ CLONG ByteSize @@ -2719,6 +2738,7 @@ Return Value: // Local support routine // VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdDeallocateFcbTable ( _In_ PRTL_GENERIC_TABLE FcbTable, _In_ __drv_freesMem(Mem) _Post_invalid_ PVOID Buffer diff --git a/drivers/filesystems/cdfs_new/verfysup.c b/drivers/filesystems/cdfs_new/verfysup.c index 015b367b1d..f53769a215 100755 --- a/drivers/filesystems/cdfs_new/verfysup.c +++ b/drivers/filesystems/cdfs_new/verfysup.c @@ -13,7 +13,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -92,7 +92,7 @@ Return Value: Vcb = &CONTAINING_RECORD( IrpSp->DeviceObject, VOLUME_DEVICE_OBJECT, DeviceObject )->Vcb; - try { + _SEH2_TRY { // // Send down the verify FSCTL. Note that this is sent to the @@ -206,7 +206,7 @@ Return Value: Status = CdFsdPostRequest( IrpContext, Irp ); } - } except(CdExceptionFilter( IrpContext, GetExceptionInformation() )) { + } _SEH2_EXCEPT(CdExceptionFilter( IrpContext, _SEH2_GetExceptionInformation() )) { // // We had some trouble trying to perform the verify or raised @@ -214,8 +214,8 @@ Return Value: // the error status that we get back from the execption code. // - Status = CdProcessException( IrpContext, Irp, GetExceptionCode() ); - } + Status = CdProcessException( IrpContext, Irp, _SEH2_GetExceptionCode() ); + } _SEH2_END; return Status; } @@ -384,7 +384,9 @@ Return Value: IoAcquireVpbSpinLock( &SavedIrql ); +#ifdef _MSC_VER #pragma prefast(suppress: 28175, "this is a filesystem driver, touching the vpb is allowed") +#endif if (Vcb->Vpb->RealDevice->Vpb == Vcb->Vpb) { CdMarkRealDevForVerify( Vcb->Vpb->RealDevice); @@ -602,6 +604,9 @@ Return Value: CdRaiseStatus( IrpContext, STATUS_FILE_INVALID ); } break; + + /* ReactOS Change: GCC "enumeration value not handled in switch" */ + default: break; } } @@ -881,7 +886,9 @@ Return Value: // mount request. // +#ifdef _MSC_VER #pragma prefast(suppress: 28175, "this is a filesystem driver, touching the vpb is allowed") +#endif if (OldVpb->RealDevice->Vpb == OldVpb) { // @@ -897,11 +904,15 @@ Return Value: Vcb->SwapVpb->Type = IO_TYPE_VPB; Vcb->SwapVpb->Size = sizeof( VPB ); +#ifdef _MSC_VER #pragma prefast(push) #pragma prefast(disable: 28175, "this is a filesystem driver, touching the vpb is allowed") +#endif Vcb->SwapVpb->RealDevice = OldVpb->RealDevice; Vcb->SwapVpb->RealDevice->Vpb = Vcb->SwapVpb; +#ifdef _MSC_VER #pragma prefast(pop) +#endif Vcb->SwapVpb->Flags = FlagOn( OldVpb->Flags, VPB_REMOVE_PENDING ); diff --git a/drivers/filesystems/cdfs_new/volinfo.c b/drivers/filesystems/cdfs_new/volinfo.c index 6640fd8aeb..7448dd5850 100755 --- a/drivers/filesystems/cdfs_new/volinfo.c +++ b/drivers/filesystems/cdfs_new/volinfo.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -59,6 +59,10 @@ CdQueryFsAttributeInfo ( _Inout_ PULONG Length ); +#ifdef __REACTOS__ +#define PFILE_FS_SECTOR_SIZE_INFORMATION PVOID +#endif + NTSTATUS CdQueryFsSectorSizeInfo ( _In_ PIRP_CONTEXT IrpContext, @@ -141,7 +145,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Verify the Vcb. @@ -184,6 +188,9 @@ Return Value: Status = CdQueryFsSectorSizeInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length ); break; #endif + + /* ReactOS Change: GCC "enumeration value not handled in switch" */ + default: break; } // @@ -192,14 +199,14 @@ Return Value: Irp->IoStatus.Information = IrpSp->Parameters.QueryVolume.Length - Length; - } finally { + } _SEH2_FINALLY { // // Release the Vcb. // CdReleaseVcb( IrpContext, Fcb->Vcb ); - } + } _SEH2_END; // // Complete the request if we didn't raise. diff --git a/drivers/filesystems/cdfs_new/wdk_wnet_to_ros.diff b/drivers/filesystems/cdfs_new/wdk_wnet_to_ros.diff deleted file mode 100644 index f6144dd1d9..0000000000 --- a/drivers/filesystems/cdfs_new/wdk_wnet_to_ros.diff +++ /dev/null @@ -1,985 +0,0 @@ -Index: drivers/filesystems/cdfs_new/deviosup.c -=================================================================== ---- drivers/filesystems/cdfs_new/deviosup.c (revision 34615) -+++ drivers/filesystems/cdfs_new/deviosup.c (working copy) -@@ -165,6 +165,7 @@ - ); - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdMultiSyncCompletionRoutine ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, -@@ -172,6 +173,7 @@ - ); - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdMultiAsyncCompletionRoutine ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, -@@ -179,6 +181,7 @@ - ); - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdSingleSyncCompletionRoutine ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, -@@ -186,6 +189,7 @@ - ); - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdSingleAsyncCompletionRoutine ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, -@@ -2943,6 +2947,7 @@ - // - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdMultiSyncCompletionRoutine ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, -@@ -3029,6 +3034,7 @@ - // - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdMultiAsyncCompletionRoutine ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, -@@ -3066,7 +3072,8 @@ - - { - PCD_IO_CONTEXT IoContext = Context; -- PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation( Irp ); -+ /* ReactOS Change: GCC Unused Variable */ -+ //PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation( Irp ); - - AssertVerifyDeviceIrp( Irp ); - -@@ -3148,6 +3155,7 @@ - // - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdSingleSyncCompletionRoutine ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, -@@ -3207,6 +3215,7 @@ - // - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdSingleAsyncCompletionRoutine ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, -@@ -3267,7 +3276,7 @@ - // and finally, free the context record. - // - -- CdFreeIoContext( (PCD_IO_CONTEXT) Context ); -+ CdFreeIoContext( Context ); /* ReactOS Change: GCC "error: invalid lvalue in unary '&'" */ - return STATUS_SUCCESS; - - UNREFERENCED_PARAMETER( DeviceObject ); -Index: drivers/filesystems/cdfs_new/dirctrl.c -=================================================================== ---- drivers/filesystems/cdfs_new/dirctrl.c (revision 34615) -+++ drivers/filesystems/cdfs_new/dirctrl.c (working copy) -@@ -209,7 +209,7 @@ - - ULONG BaseLength; - -- PFILE_BOTH_DIR_INFORMATION DirInfo; -+ PFILE_BOTH_DIR_INFORMATION DirInfo = NULL; /* ReactOS Change: GCC Uninit var */ - PFILE_NAMES_INFORMATION NamesInfo; - PFILE_ID_FULL_DIR_INFORMATION IdFullDirInfo; - PFILE_ID_BOTH_DIR_INFORMATION IdBothDirInfo; -@@ -579,6 +579,9 @@ - NamesInfo->FileNameLength = FileNameBytes + SeparatorBytes + VersionStringBytes; - - break; -+ -+ /* ReactOS Change: GCC "enumeration value not handled in switch" */ -+ default: break; - } - - // -Index: drivers/filesystems/cdfs_new/create.c -=================================================================== ---- drivers/filesystems/cdfs_new/create.c (revision 34615) -+++ drivers/filesystems/cdfs_new/create.c (working copy) -@@ -2106,7 +2106,7 @@ - PFCB NextFcb; - PFCB ParentFcb = NULL; - -- NTSTATUS Status; -+ NTSTATUS Status = STATUS_SUCCESS; /* ReactOS Change: GCC uninitialized variable */ - - PAGED_CODE(); - -@@ -2757,8 +2757,8 @@ - OplockStatus = FsRtlCheckOplock( &Fcb->Oplock, - IrpContext->Irp, - IrpContext, -- CdOplockComplete, -- CdPrePostIrp ); -+ (PVOID)CdOplockComplete, /* ReactOS Change: GCC "assignment from incompatible pointer type" */ -+ (PVOID)CdPrePostIrp ); /* ReactOS Change: GCC "assignment from incompatible pointer type" */ - - if (OplockStatus == STATUS_PENDING) { - -@@ -2789,8 +2789,8 @@ - OplockStatus = FsRtlCheckOplock( &Fcb->Oplock, - IrpContext->Irp, - IrpContext, -- CdOplockComplete, -- CdPrePostIrp ); -+ (PVOID)CdOplockComplete,/* ReactOS Change: GCC "assignment from incompatible pointer type" */ -+ (PVOID)CdPrePostIrp );/* ReactOS Change: GCC "assignment from incompatible pointer type" */ - - if (OplockStatus == STATUS_PENDING) { - -Index: drivers/filesystems/cdfs_new/devctrl.c -=================================================================== ---- drivers/filesystems/cdfs_new/devctrl.c (revision 34615) -+++ drivers/filesystems/cdfs_new/devctrl.c (working copy) -@@ -27,6 +27,7 @@ - // - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdDevCtrlCompletionRoutine ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, -@@ -64,7 +64,7 @@ - PIO_STACK_LOCATION IrpSp; - PIO_STACK_LOCATION NextIrpSp; - -- PVOID TargetBuffer = NULL; -+// PVOID TargetBuffer = NULL; /* ReactOS Change: GCC unused variable */ - - PAGED_CODE(); - -@@ -171,6 +172,7 @@ - // - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdDevCtrlCompletionRoutine ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, -Index: drivers/filesystems/cdfs_new/close.c -=================================================================== ---- drivers/filesystems/cdfs_new/close.c (revision 34615) -+++ drivers/filesystems/cdfs_new/close.c (working copy) -@@ -77,6 +77,7 @@ - ); - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdCloseWorker ( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context -@@ -136,9 +137,9 @@ - // - // Continue processing until there are no more closes to process. - // -+ /* ReactOS Change: "GCC suggest parentheses around assignment used as truth value" */ -+ while ((IrpContext = CdRemoveClose( Vcb ))) { - -- while (IrpContext = CdRemoveClose( Vcb )) { -- - // - // If we don't have an IrpContext then use the one on the stack. - // Initialize it for this request. -@@ -165,7 +166,7 @@ - // Free the IrpContextLite. - // - -- CdFreeIrpContextLite( (PIRP_CONTEXT_LITE) IrpContext ); -+ CdFreeIrpContextLite( IrpContext ); /* ReactOS Change: GCC "error: invalid lvalue in unary '&'" */ - - // - // Remember we have the IrpContext from the stack. -@@ -662,6 +663,7 @@ - } - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdCloseWorker ( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context -Index: drivers/filesystems/cdfs_new/dirsup.c -=================================================================== ---- drivers/filesystems/cdfs_new/dirsup.c (revision 34615) -+++ drivers/filesystems/cdfs_new/dirsup.c (working copy) -@@ -465,7 +465,7 @@ - // Save a pointer to the time stamps. - // - -- Dirent->CdTime = RawDirent->RecordTime; -+ Dirent->CdTime = (PCHAR)RawDirent->RecordTime; /* ReactOS change: GCC "pointer targets in assignment differ in signedness" */ - - // - // Copy the dirent flags. -@@ -501,7 +501,7 @@ - } - - Dirent->FileNameLen = RawDirent->FileIdLen; -- Dirent->FileName = RawDirent->FileId; -+ Dirent->FileName = (PCHAR)RawDirent->FileId; /* ReactOS change: GCC "pointer targets in assignment differ in signedness" */ - - // - // If there are any remaining bytes at the end of the dirent then -@@ -1457,7 +1457,7 @@ - --*/ - - { -- XA_EXTENT_TYPE ExtentType; -+ XA_EXTENT_TYPE ExtentType = 0; /* ReactOS Change: GCC Uninit var */ - PCOMPOUND_DIRENT CurrentCompoundDirent; - PDIRENT CurrentDirent; - -Index: drivers/filesystems/cdfs_new/read.c -=================================================================== ---- drivers/filesystems/cdfs_new/read.c (revision 34615) -+++ drivers/filesystems/cdfs_new/read.c (working copy) -@@ -79,7 +79,7 @@ - --*/ - - { -- NTSTATUS Status; -+ NTSTATUS Status = STATUS_SUCCESS; /* ReactOS Change: GCC Uninit var */ - PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation( Irp ); - - TYPE_OF_OPEN TypeOfOpen; -@@ -225,8 +225,8 @@ - Status = FsRtlCheckOplock( &Fcb->Oplock, - Irp, - IrpContext, -- CdOplockComplete, -- CdPrePostIrp ); -+ (PVOID)CdOplockComplete,/* ReactOS Change: GCC "assignment from incompatible pointer type" */ -+ (PVOID)CdPrePostIrp );/* ReactOS Change: GCC "assignment from incompatible pointer type" */ - - // - // If the result is not STATUS_SUCCESS then the Irp was completed -Index: drivers/filesystems/cdfs_new/volinfo.c -=================================================================== ---- drivers/filesystems/cdfs_new/volinfo.c (revision 34615) -+++ drivers/filesystems/cdfs_new/volinfo.c (working copy) -@@ -166,8 +166,11 @@ - - Status = CdQueryFsAttributeInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length ); - break; -+ -+ /* ReactOS Change: GCC "enumeration value not handled in switch" */ -+ default: break; - } -- -+ - // - // Set the information field to the number of bytes actually filled in - // -Index: drivers/filesystems/cdfs_new/cddata.c -=================================================================== ---- drivers/filesystems/cdfs_new/cddata.c (revision 34615) -+++ drivers/filesystems/cdfs_new/cddata.c (working copy) -@@ -417,7 +417,6 @@ - return Status; - } - -- - #ifdef CD_SANITY - - VOID -@@ -481,7 +480,6 @@ - - #endif - -- - LONG - CdExceptionFilter ( - IN PIRP_CONTEXT IrpContext, -@@ -1006,6 +1004,7 @@ - - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastIoCheckIfPossible ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, -Index: drivers/filesystems/cdfs_new/allocsup.c -=================================================================== ---- drivers/filesystems/cdfs_new/allocsup.c (revision 34615) -+++ drivers/filesystems/cdfs_new/allocsup.c (working copy) -@@ -128,7 +128,7 @@ - { - BOOLEAN FirstPass = TRUE; - ULONG McbEntryOffset; -- PFCB ParentFcb; -+ PFCB ParentFcb = NULL; /* ReactOS Change: GCC uninitialized variable bug */ - BOOLEAN CleanupParent = FALSE; - - BOOLEAN UnlockFcb = FALSE; -Index: drivers/filesystems/cdfs_new/verfysup.c -=================================================================== ---- drivers/filesystems/cdfs_new/verfysup.c (revision 34615) -+++ drivers/filesystems/cdfs_new/verfysup.c (working copy) -@@ -431,7 +431,7 @@ - ULONG MediaChangeCount = 0; - BOOLEAN ForceVerify = FALSE; - BOOLEAN DevMarkedForVerify; -- KIRQL SavedIrql; -+ //KIRQL SavedIrql; /* ReactOS Change: GCC Unused variable */ - - PAGED_CODE(); - -@@ -581,6 +581,9 @@ - - CdRaiseStatus( IrpContext, STATUS_FILE_INVALID ); - break; -+ -+ /* ReactOS Change: GCC "enumeration value not handled in switch" */ -+ default: break; - } - } - -@@ -613,7 +616,7 @@ - --*/ - - { -- NTSTATUS Status = STATUS_SUCCESS; -+ //NTSTATUS Status = STATUS_SUCCESS; /* ReactOS Change: GCC Unused variable */ - PVCB Vcb = Fcb->Vcb; - PDEVICE_OBJECT RealDevice = Vcb->Vpb->RealDevice; - PIRP Irp; -Index: drivers/filesystems/cdfs_new/filobsup.c -=================================================================== ---- drivers/filesystems/cdfs_new/filobsup.c (revision 34615) -+++ drivers/filesystems/cdfs_new/filobsup.c (working copy) -@@ -105,7 +105,7 @@ - FileObject->FsContext = Fcb; - FileObject->FsContext2 = Ccb; - -- SetFlag( ((ULONG_PTR) FileObject->FsContext2), TypeOfOpen ); -+ SetFlag( (*(PULONG_PTR)&FileObject->FsContext2), TypeOfOpen ); /* ReactOS Change: GCC "invalid lvalue in assignment" */ - - // - // Set the Vpb field in the file object. -@@ -176,7 +176,7 @@ - *Fcb = FileObject->FsContext; - *Ccb = FileObject->FsContext2; - -- ClearFlag( (ULONG_PTR) *Ccb, TYPE_OF_OPEN_MASK ); -+ ClearFlag( (*(PULONG_PTR)Ccb), TYPE_OF_OPEN_MASK ); /* ReactOS Change: GCC "invalid lvalue in assignment" */ - } - - // -Index: drivers/filesystems/cdfs_new/pathsup.c -=================================================================== ---- drivers/filesystems/cdfs_new/pathsup.c (revision 34615) -+++ drivers/filesystems/cdfs_new/pathsup.c (working copy) -@@ -764,7 +764,7 @@ - - PathEntry->PathEntryLength = WordAlign( PathEntry->PathEntryLength ); - -- PathEntry->DirName = RawPathEntry->DirId; -+ PathEntry->DirName = (PCHAR)RawPathEntry->DirId; /* ReactOS Change: GCC "assignment makes pointer from integer without a cast" */ - - return TRUE; - } -Index: drivers/filesystems/cdfs_new/cdprocs.h -=================================================================== ---- drivers/filesystems/cdfs_new/cdprocs.h (revision 34615) -+++ drivers/filesystems/cdfs_new/cdprocs.h (working copy) -@@ -902,33 +904,39 @@ - } - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdNoopAcquire ( - IN PVOID Fcb, - IN BOOLEAN Wait - ); - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdNoopRelease ( - IN PVOID Fcb - ); - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdAcquireForCache ( - IN PFCB Fcb, - IN BOOLEAN Wait - ); - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdReleaseFromCache ( - IN PFCB Fcb - ); - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdAcquireForCreateSection ( - IN PFILE_OBJECT FileObject - ); - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdReleaseForCreateSection ( - IN PFILE_OBJECT FileObject - ); -@@ -1184,8 +1192,8 @@ - // Verification support routines. Contained in verfysup.c - // - -- --INLINE -+/* ReactOS Change: "LD multiple definition of `_CdOperationIsDasdOpen'" */ -+static inline - BOOLEAN - CdOperationIsDasdOpen( - IN PIRP_CONTEXT IrpContext -@@ -1272,12 +1280,14 @@ - ); - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdPrePostIrp ( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp - ); - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdOplockComplete ( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp -@@ -1293,7 +1303,9 @@ - // otherwise - // - --//#ifndef BooleanFlagOn -+/* ReactOS Change: GCC doesn't understand the comment style */ -+/* -+ //#ifndef BooleanFlagOn - //#define BooleanFlagOn(F,SF) ( \ - // (BOOLEAN)(((F) & (SF)) != 0) \ - //) -@@ -1310,6 +1322,7 @@ - // (Flags) &= ~(SingleFlag); \ - //} - //#endif -+*/ - - // - // CAST -@@ -1598,6 +1611,7 @@ - // - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastQueryBasicInfo ( - IN PFILE_OBJECT FileObject, - IN BOOLEAN Wait, -@@ -1607,6 +1621,7 @@ - ); - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastQueryStdInfo ( - IN PFILE_OBJECT FileObject, - IN BOOLEAN Wait, -@@ -1616,6 +1631,7 @@ - ); - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastLock ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, -@@ -1629,6 +1645,7 @@ - ); - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastUnlockSingle ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, -@@ -1640,6 +1657,7 @@ - ); - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastUnlockAll ( - IN PFILE_OBJECT FileObject, - PEPROCESS ProcessId, -@@ -1648,6 +1666,7 @@ - ); - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastUnlockAllByKey ( - IN PFILE_OBJECT FileObject, - PVOID ProcessId, -@@ -1657,6 +1676,7 @@ - ); - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastIoCheckIfPossible ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, -@@ -1669,6 +1689,7 @@ - ); - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastQueryNetworkInfo ( - IN PFILE_OBJECT FileObject, - IN BOOLEAN Wait, -@@ -1862,17 +1883,26 @@ - // - // #define try_return(S) { S; goto try_exit; } - // -+/* ReactOS Change: Remove SEH */ -+#define try -+#define leave goto exitLabel; -+#define finally if (0) goto exitLabel; exitLabel: -+#define except(x) while (0) -+#define GetExceptionCode() 0 -+#define AbnormalTermination() 0 - - #define try_return(S) { S; goto try_exit; } - #define try_leave(S) { S; leave; } - -+ - // - // Encapsulate safe pool freeing - // -+/* ReactOS Change: GCC "passing argument 1 of CdFreePool from incompatible pointer type" */ -+#define CdFreePool(x) _CdFreePool((PVOID*)(x)) - --INLINE --VOID --CdFreePool( -+/* ReactOS Change: "LD multiple definition of `_CdOperationIsDasdOpen'" */ -+static inline void _CdFreePool( - IN PVOID *Pool - ) - { -Index: drivers/filesystems/cdfs_new/resrcsup.c -=================================================================== ---- drivers/filesystems/cdfs_new/resrcsup.c (revision 34615) -+++ drivers/filesystems/cdfs_new/resrcsup.c (working copy) -@@ -123,6 +123,7 @@ - - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdAcquireForCache ( - IN PFCB Fcb, - IN BOOLEAN Wait -@@ -159,6 +160,7 @@ - - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdReleaseFromCache ( - IN PFCB Fcb - ) -@@ -193,6 +195,7 @@ - - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdNoopAcquire ( - IN PVOID Fcb, - IN BOOLEAN Wait -@@ -224,6 +227,7 @@ - - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdNoopRelease ( - IN PVOID Fcb - ) -@@ -251,6 +255,7 @@ - - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdAcquireForCreateSection ( - IN PFILE_OBJECT FileObject - ) -@@ -298,6 +303,7 @@ - - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdReleaseForCreateSection ( - IN PFILE_OBJECT FileObject - ) -Index: drivers/filesystems/cdfs_new/namesup.c -=================================================================== ---- drivers/filesystems/cdfs_new/namesup.c (revision 34615) -+++ drivers/filesystems/cdfs_new/namesup.c (working copy) -@@ -206,7 +206,7 @@ - - { - NTSTATUS Status; -- PVOID NewBuffer; -+ //PVOID NewBuffer; /* ReactOS Change: GCC Uninitialized variable */ - - PAGED_CODE(); - -Index: drivers/filesystems/cdfs_new/cdinit.c -=================================================================== ---- drivers/filesystems/cdfs_new/cdinit.c (revision 34615) -+++ drivers/filesystems/cdfs_new/cdinit.c (working copy) -@@ -22,12 +22,14 @@ - #define BugCheckFileId (CDFS_BUG_CHECK_CDINIT) - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - DriverEntry( - IN PDRIVER_OBJECT DriverObject, - IN PUNICODE_STRING RegistryPath - ); - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdUnload( - IN PDRIVER_OBJECT DriverObject - ); -@@ -39,6 +41,7 @@ - ); - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdShutdown ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp -@@ -57,6 +60,7 @@ - // - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - DriverEntry( - IN PDRIVER_OBJECT DriverObject, - IN PUNICODE_STRING RegistryPath -@@ -169,6 +173,7 @@ - } - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdShutdown ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp -@@ -200,6 +205,7 @@ - - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdUnload( - IN PDRIVER_OBJECT DriverObject - ) -@@ -310,10 +316,10 @@ - // Initialize the cache manager callback routines - // - -- CdData.CacheManagerCallbacks.AcquireForLazyWrite = &CdAcquireForCache; -- CdData.CacheManagerCallbacks.ReleaseFromLazyWrite = &CdReleaseFromCache; -- CdData.CacheManagerCallbacks.AcquireForReadAhead = &CdAcquireForCache; -- CdData.CacheManagerCallbacks.ReleaseFromReadAhead = &CdReleaseFromCache; -+ CdData.CacheManagerCallbacks.AcquireForLazyWrite = (PVOID)&CdAcquireForCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */ -+ CdData.CacheManagerCallbacks.ReleaseFromLazyWrite = (PVOID)&CdReleaseFromCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */ -+ CdData.CacheManagerCallbacks.AcquireForReadAhead = (PVOID)&CdAcquireForCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */ -+ CdData.CacheManagerCallbacks.ReleaseFromReadAhead = (PVOID)&CdReleaseFromCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */ - - CdData.CacheManagerVolumeCallbacks.AcquireForLazyWrite = &CdNoopAcquire; - CdData.CacheManagerVolumeCallbacks.ReleaseFromLazyWrite = &CdNoopRelease; -Index: drivers/filesystems/cdfs_new/cdstruc.h -=================================================================== ---- drivers/filesystems/cdfs_new/cdstruc.h (revision 34615) -+++ drivers/filesystems/cdfs_new/cdstruc.h (working copy) -@@ -504,8 +504,8 @@ - // - - ULONG VcbCleanup; -- ULONG VcbReference; -- ULONG VcbUserReference; -+ LONG VcbReference; /* ReactOS Change: GCC 'pointer targets in passing argument 1 of 'InterlockedXxx' differ in signedness */ -+ LONG VcbUserReference; /* ReactOS Change: GCC 'pointer targets in passing argument 1 of 'InterlockedXxx' differ in signedness */ - - // - // Fcb for the Volume Dasd file, root directory and the Path Table. -@@ -655,7 +655,7 @@ - // executed later. - // - -- ULONG PostedRequestCount; -+ LONG PostedRequestCount; /* ReactOS Change: GCC "pointer targets in passing argument 1 of 'InterlockedDecrement' differ in signedness" */ - - // - // The following field indicates the number of IRP's waiting -@@ -878,7 +878,7 @@ - // - - ULONG FcbCleanup; -- ULONG FcbReference; -+ LONG FcbReference; /* ReactOS Change: GCC 'pointer targets in passing argument 1 of 'InterlockedXxx' differ in signedness */ - ULONG FcbUserReference; - - // -Index: drivers/filesystems/cdfs_new/lockctrl.c -=================================================================== ---- drivers/filesystems/cdfs_new/lockctrl.c (revision 34615) -+++ drivers/filesystems/cdfs_new/lockctrl.c (working copy) -@@ -89,7 +89,7 @@ - Status = FsRtlCheckOplock( &Fcb->Oplock, - Irp, - IrpContext, -- CdOplockComplete, -+ (PVOID)CdOplockComplete,/* ReactOS Change: GCC "assignment from incompatible pointer type" */ - NULL ); - - // -@@ -138,6 +138,7 @@ - - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastLock ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, -@@ -246,8 +247,8 @@ - // - // Now call the FsRtl routine to perform the lock request. - // -- -- if (Results = FsRtlFastLock( Fcb->FileLock, -+ /* ReactOS Change: GCC "suggest parentheses around assignment used as truth value" */ -+ if ((Results = FsRtlFastLock( Fcb->FileLock, - FileObject, - FileOffset, - Length, -@@ -257,7 +258,7 @@ - ExclusiveLock, - IoStatus, - NULL, -- FALSE )) { -+ FALSE ))) { - - // - // Set the flag indicating if Fast I/O is questionable. We -@@ -284,6 +285,7 @@ - - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastUnlockSingle ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, -@@ -424,6 +426,7 @@ - - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastUnlockAll ( - IN PFILE_OBJECT FileObject, - PEPROCESS ProcessId, -@@ -546,6 +549,7 @@ - - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastUnlockAllByKey ( - IN PFILE_OBJECT FileObject, - PVOID ProcessId, -Index: drivers/filesystems/cdfs_new/strucsup.c -=================================================================== ---- drivers/filesystems/cdfs_new/strucsup.c (revision 34615) -+++ drivers/filesystems/cdfs_new/strucsup.c (working copy) -@@ -438,7 +438,7 @@ - --*/ - - { -- ULONG Shift; -+ //ULONG Shift; /* ReactOS Change: GCC Unused variable */ - ULONG StartingBlock; - ULONG ByteCount; - -Index: drivers/filesystems/cdfs_new/fileinfo.c -=================================================================== ---- drivers/filesystems/cdfs_new/fileinfo.c (revision 34615) -+++ drivers/filesystems/cdfs_new/fileinfo.c (working copy) -@@ -460,6 +460,7 @@ - - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastQueryBasicInfo ( - IN PFILE_OBJECT FileObject, - IN BOOLEAN Wait, -@@ -577,6 +578,7 @@ - - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastQueryStdInfo ( - IN PFILE_OBJECT FileObject, - IN BOOLEAN Wait, -@@ -704,6 +706,7 @@ - - - BOOLEAN -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdFastQueryNetworkInfo ( - IN PFILE_OBJECT FileObject, - IN BOOLEAN Wait, -Index: drivers/filesystems/cdfs_new/fsctrl.c -=================================================================== ---- drivers/filesystems/cdfs_new/fsctrl.c (revision 34615) -+++ drivers/filesystems/cdfs_new/fsctrl.c (working copy) -@@ -82,7 +82,8 @@ - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp - ); -- -+ -+NTSTATUS /* ReactOS Change: Function did not have a type??? */ - CdIsVolumeDirty ( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp -@@ -918,7 +919,7 @@ - - if (CdIsRemount( IrpContext, Vcb, &OldVcb )) { - -- KIRQL SavedIrql; -+ //KIRQL SavedIrql; /* ReactOS Change: GCC Unused variable */ - - ASSERT( NULL != OldVcb->SwapVpb ); - -@@ -1374,7 +1375,7 @@ - // Compute the length of the volume name - // - -- AnsiLabel.Buffer = CdRvdVolId( RawIsoVd, Vcb->VcbState ); -+ AnsiLabel.Buffer = (PCHAR)CdRvdVolId( RawIsoVd, Vcb->VcbState ); /* ReactOS Change: GCC "pointer targets in assignment differ in signedness" */ - AnsiLabel.MaximumLength = AnsiLabel.Length = VOLUME_ID_LENGTH; - - UnicodeLabel.MaximumLength = VOLUME_ID_LENGTH * sizeof( WCHAR ); -@@ -1401,7 +1402,7 @@ - } else { - - CdConvertBigToLittleEndian( IrpContext, -- CdRvdVolId( RawIsoVd, Vcb->VcbState ), -+ (PCHAR)CdRvdVolId( RawIsoVd, Vcb->VcbState ),/* ReactOS Change: GCC "pointer targets in assignment differ in signedness" */ - VOLUME_ID_LENGTH, - (PCHAR) VolumeLabel ); - -@@ -2005,7 +2006,7 @@ - // - // Local support routine - // -- -+NTSTATUS /* ReactOS Change: Function did not have a type??? */ - CdIsVolumeDirty ( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp -@@ -2296,9 +2297,9 @@ - 0, - *IoFileObjectType, - KernelMode, -- &FileToMarkBad, -+ (PVOID*)&FileToMarkBad, /* ReactOS Change: GCC "passing argument 5 of 'ObReferenceObjectByHandle' from incompatible pointer type" */ - NULL ); - - if (!NT_SUCCESS(Status)) { -@@ -2642,8 +2643,8 @@ - // The track address is BigEndian, we need to flip the bytes. - // - -- Source = (PUCHAR) &CdromToc->TrackData[0].Address[3]; -- Dest = (PUCHAR) &BaseSector; -+ Source = (PCHAR) &CdromToc->TrackData[0].Address[3];/* ReactOS Change: GCC "pointer targets in assignment differ in signedness" */ -+ Dest = (PCHAR) &BaseSector; /* ReactOS Change: GCC "pointer targets in assignment differ in signedness" */ - - do { - -@@ -3118,7 +3119,7 @@ - if (NT_SUCCESS( RtlOemToUnicodeN( &Vcb->Vpb->VolumeLabel[0], - MAXIMUM_VOLUME_LABEL_LENGTH, - &Length, -- CdRvdVolId( RawIsoVd, Vcb->VcbState ), -+ (PCHAR)CdRvdVolId( RawIsoVd, Vcb->VcbState ),/* ReactOS Change: GCC "pointer targets in assignment differ in signedness" */ - VOLUME_ID_LENGTH ))) { - - Vcb->Vpb->VolumeLabelLength = (USHORT) Length; -@@ -3131,7 +3132,7 @@ - } else { - - CdConvertBigToLittleEndian( IrpContext, -- CdRvdVolId( RawIsoVd, Vcb->VcbState ), -+ (PCHAR)CdRvdVolId( RawIsoVd, Vcb->VcbState ),/* ReactOS Change: GCC "pointer targets in assignment differ in signedness" */ - VOLUME_ID_LENGTH, - (PCHAR) Vcb->Vpb->VolumeLabel ); - -Index: drivers/filesystems/cdfs_new/pnp.c -=================================================================== ---- drivers/filesystems/cdfs_new/pnp.c (revision 34615) -+++ drivers/filesystems/cdfs_new/pnp.c (working copy) -@@ -51,6 +51,7 @@ - ); - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdPnpCompletionRoutine ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, -@@ -774,6 +775,7 @@ - // - - NTSTATUS -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdPnpCompletionRoutine ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, -Index: drivers/filesystems/cdfs_new/workque.c -=================================================================== ---- drivers/filesystems/cdfs_new/workque.c (revision 34615) -+++ drivers/filesystems/cdfs_new/workque.c (working copy) -@@ -97,6 +97,7 @@ - - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdPrePostIrp ( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp -@@ -209,6 +210,7 @@ - - - VOID -+NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ - CdOplockComplete ( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp -@@ -386,7 +388,7 @@ - // - - ExInitializeWorkItem( &IrpContext->WorkQueueItem, -- CdFspDispatch, -+ (PVOID)CdFspDispatch,/* ReactOS Change: GCC "assignment from incompatible pointer type" */ - IrpContext ); - - ExQueueWorkItem( &IrpContext->WorkQueueItem, CriticalWorkQueue ); diff --git a/drivers/filesystems/cdfs_new/workque.c b/drivers/filesystems/cdfs_new/workque.c index ee548826ba..e3975a8c47 100755 --- a/drivers/filesystems/cdfs_new/workque.c +++ b/drivers/filesystems/cdfs_new/workque.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -100,6 +100,7 @@ Return Value: _Requires_lock_held_(_Global_critical_region_) VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdPrePostIrp ( _Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp @@ -224,6 +225,7 @@ Return Value: _Requires_lock_held_(_Global_critical_region_) VOID +NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdOplockComplete ( _Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp @@ -401,12 +403,16 @@ Return Value: // Send it off..... // +#ifdef _MSC_VER #pragma prefast(suppress:28155, "the function prototype is correct") +#endif ExInitializeWorkItem( &IrpContext->WorkQueueItem, - CdFspDispatch, + (PVOID)CdFspDispatch,/* ReactOS Change: GCC "assignment from incompatible pointer type" */ IrpContext ); +#ifdef _MSC_VER #pragma prefast(suppress: 28159, "prefast believes this routine is obsolete, but it is ok for CDFS to continue using it") +#endif ExQueueWorkItem( &IrpContext->WorkQueueItem, CriticalWorkQueue ); return; diff --git a/drivers/filesystems/cdfs_new/write.c b/drivers/filesystems/cdfs_new/write.c index 36a41a7cd3..70c8494e08 100644 --- a/drivers/filesystems/cdfs_new/write.c +++ b/drivers/filesystems/cdfs_new/write.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -34,15 +34,24 @@ Abstract: // This macro just puts a nice little try-except around RtlZeroMemory // +#ifndef __REACTOS__ #define SafeZeroMemory(IC,AT,BYTE_COUNT) { \ - try { \ + _SEH2_TRY { \ RtlZeroMemory( (AT), (BYTE_COUNT) ); \ __pragma(warning(suppress: 6320)) \ - } except( EXCEPTION_EXECUTE_HANDLER ) { \ + } _SEH2_EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { \ CdRaiseStatus( IC, STATUS_INVALID_USER_BUFFER ); \ - } \ + } _SEH2_END; \ } - +#else +#define SafeZeroMemory(IC,AT,BYTE_COUNT) { \ + _SEH2_TRY { \ + RtlZeroMemory( (AT), (BYTE_COUNT) ); \ + } _SEH2_EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { \ + CdRaiseStatus( IC, STATUS_INVALID_USER_BUFFER ); \ + } _SEH2_END; \ +} +#endif #ifdef ALLOC_PRAGMA #pragma alloc_text(PAGE, CdCommonWrite) @@ -153,7 +162,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Verify the Fcb. Allow writes if this is a DASD handle that is @@ -346,7 +355,7 @@ Return Value: } try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { // // Release the Fcb. @@ -356,7 +365,7 @@ Return Value: CdReleaseFile( IrpContext, Fcb ); } - } + } _SEH2_END; // // Post the request if we got CANT_WAIT.
7 years
1
0
0
0
[reactos] 01/06: [CDFS_NEW] Replace old driver with a Ms-PL licensed version straight out of the driver samples github repository.
by David Quintana
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fd345482634d8ef4c64e5…
commit fd345482634d8ef4c64e5910ce4752ac0c7438cc Author: David Quintana <gigaherz(a)gmail.com> AuthorDate: Thu Nov 23 21:02:16 2017 +0100 [CDFS_NEW] Replace old driver with a Ms-PL licensed version straight out of the driver samples github repository. --- drivers/filesystems/cdfs_new/CMakeLists.txt | 5 +- drivers/filesystems/cdfs_new/README.md | 20 + drivers/filesystems/cdfs_new/allocsup.c | 134 ++- drivers/filesystems/cdfs_new/cachesup.c | 73 +- drivers/filesystems/cdfs_new/cd.h | 8 +- drivers/filesystems/cdfs_new/cddata.c | 256 +++-- drivers/filesystems/cdfs_new/cddata.h | 113 +- drivers/filesystems/cdfs_new/cdfs.rc | 19 +- drivers/filesystems/cdfs_new/cdinit.c | 199 ++-- drivers/filesystems/cdfs_new/cdprocs.h | 1434 +++++++++++++++---------- drivers/filesystems/cdfs_new/cdprocssrc.c | 1 + drivers/filesystems/cdfs_new/cdstruc.h | 198 +++- drivers/filesystems/cdfs_new/cleanup.c | 64 +- drivers/filesystems/cdfs_new/close.c | 143 ++- drivers/filesystems/cdfs_new/create.c | 306 +++--- drivers/filesystems/cdfs_new/devctrl.c | 25 +- drivers/filesystems/cdfs_new/deviosup.c | 1507 ++++++++++++++++++--------- drivers/filesystems/cdfs_new/dirctrl.c | 183 ++-- drivers/filesystems/cdfs_new/dirsup.c | 161 +-- drivers/filesystems/cdfs_new/fieldoff.c | 4 +- drivers/filesystems/cdfs_new/fileinfo.c | 274 ++--- drivers/filesystems/cdfs_new/filobsup.c | 49 +- drivers/filesystems/cdfs_new/fsctrl.c | 668 ++++++++---- drivers/filesystems/cdfs_new/fspdisp.c | 40 +- drivers/filesystems/cdfs_new/lockctrl.c | 127 +-- drivers/filesystems/cdfs_new/namesup.c | 189 +++- drivers/filesystems/cdfs_new/nodetype.h | 17 +- drivers/filesystems/cdfs_new/pathsup.c | 100 +- drivers/filesystems/cdfs_new/pnp.c | 140 ++- drivers/filesystems/cdfs_new/prefxsup.c | 56 +- drivers/filesystems/cdfs_new/read.c | 68 +- drivers/filesystems/cdfs_new/resrcsup.c | 119 ++- drivers/filesystems/cdfs_new/shutdown.c | 175 ++++ drivers/filesystems/cdfs_new/strucsup.c | 464 +++++---- drivers/filesystems/cdfs_new/verfysup.c | 145 +-- drivers/filesystems/cdfs_new/volinfo.c | 187 +++- drivers/filesystems/cdfs_new/workque.c | 54 +- drivers/filesystems/cdfs_new/write.c | 381 +++++++ 38 files changed, 5301 insertions(+), 2805 deletions(-) diff --git a/drivers/filesystems/cdfs_new/CMakeLists.txt b/drivers/filesystems/cdfs_new/CMakeLists.txt index c0b56e99db..8bf4fa2639 100644 --- a/drivers/filesystems/cdfs_new/CMakeLists.txt +++ b/drivers/filesystems/cdfs_new/CMakeLists.txt @@ -6,6 +6,7 @@ list(APPEND SOURCE cachesup.c cddata.c cdinit.c + cdprocssrc.c cleanup.c close.c create.c @@ -24,10 +25,12 @@ list(APPEND SOURCE prefxsup.c read.c resrcsup.c + shutdown.c strucsup.c verfysup.c volinfo.c - workque.c) + workque.c + write.c) add_library(cdfs SHARED ${SOURCE} cdfs.rc) set_module_type(cdfs kernelmodedriver) diff --git a/drivers/filesystems/cdfs_new/README.md b/drivers/filesystems/cdfs_new/README.md new file mode 100644 index 0000000000..cbe8e4c468 --- /dev/null +++ b/drivers/filesystems/cdfs_new/README.md @@ -0,0 +1,20 @@ +<!--- + name: CDFS File System Driver + platform: WDM + language: cpp + category: FileSystem + description: The CD-ROM file system driver (cdfs) sample is a file system driver for removable media. + samplefwlink:
http://go.microsoft.com/fwlink/p/?LinkId=617642
+---> + + +CDFS File System Driver +======================= + +The CD-ROM file system driver (cdfs) sample is a sample file system driver that you can use to write new file systems. + +Cdfs is a read-only file system that addresses various issues such as accessing data on disk, interacting with the cache manager, and handling various I/O operations such as opening files, performing reads on a file, retrieving information on a file, and performing various control operations on the file system. The Cdfs file system is included with the Microsoft Windows operating system. + +## Universal Windows Driver Compliant +This sample builds a Universal Windows Driver. It uses only APIs and DDIs that are included in OneCoreUAP. + diff --git a/drivers/filesystems/cdfs_new/allocsup.c b/drivers/filesystems/cdfs_new/allocsup.c index 93b35bcfda..6a92817cb5 100755 --- a/drivers/filesystems/cdfs_new/allocsup.c +++ b/drivers/filesystems/cdfs_new/allocsup.c @@ -44,7 +44,7 @@ Abstract: --*/ -#include "cdprocs.h" +#include "CdProcs.h" // // The Bug check file id for this module @@ -58,18 +58,18 @@ Abstract: ULONG CdFindMcbEntry ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN LONGLONG FileOffset + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ LONGLONG FileOffset ); VOID CdDiskOffsetFromMcbEntry ( - IN PIRP_CONTEXT IrpContext, - IN PCD_MCB_ENTRY McbEntry, - IN LONGLONG FileOffset, - IN PLONGLONG DiskOffset, - IN PULONG ByteCount + _In_ PIRP_CONTEXT IrpContext, + _In_ PCD_MCB_ENTRY McbEntry, + _In_ LONGLONG FileOffset, + _Out_ PLONGLONG DiskOffset, + _Out_ PULONG ByteCount ); #ifdef ALLOC_PRAGMA @@ -84,13 +84,16 @@ CdDiskOffsetFromMcbEntry ( #endif +_Requires_lock_held_(_Global_critical_region_) VOID +// PREFast currently has no way to express the Fcb==Fcb->Vcb->VolumeDasdFcb early return +#pragma warning(suppress: 6001 6101) CdLookupAllocation ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN LONGLONG FileOffset, - OUT PLONGLONG DiskOffset, - OUT PULONG ByteCount + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ LONGLONG FileOffset, + _Out_ PLONGLONG DiskOffset, + _Out_ PULONG ByteCount ) /*++ @@ -128,7 +131,7 @@ Return Value: { BOOLEAN FirstPass = TRUE; ULONG McbEntryOffset; - PFCB ParentFcb = NULL; /* ReactOS Change: GCC uninitialized variable bug */ + PFCB ParentFcb = NULL; BOOLEAN CleanupParent = FALSE; BOOLEAN UnlockFcb = FALSE; @@ -137,19 +140,31 @@ Return Value: ULONG CurrentMcbOffset; PCD_MCB_ENTRY CurrentMcbEntry; - DIRENT_ENUM_CONTEXT DirContext; - DIRENT Dirent; + DIRENT_ENUM_CONTEXT DirContext = {0}; + DIRENT Dirent = {0}; PAGED_CODE(); ASSERT_IRP_CONTEXT( IrpContext ); ASSERT_FCB( Fcb ); + // + // For DASD IO we already have clamped the read to the volume limits. + // We'll allow reading beyond those limits for extended DASD IO, so + // no MCB lookup here. + // + + if (Fcb == Fcb->Vcb->VolumeDasdFcb) { + + *DiskOffset = FileOffset; + return; + } + // // Use a try finally to facilitate cleanup. // - _SEH2_TRY { + try { // // We use a loop to perform the lookup. If we don't find the mapping in the @@ -215,10 +230,7 @@ Return Value: // Do an unsafe test to see if we need to create a file object. // - if (ParentFcb->FileObject == NULL) { - - CdCreateInternalStream( IrpContext, ParentFcb->Vcb, ParentFcb ); - } + CdVerifyOrCreateDirStreamFile( IrpContext, ParentFcb); // // Initialize the local variables to indicate the first dirent @@ -296,7 +308,7 @@ Return Value: FirstPass = FALSE; } - } _SEH2_FINALLY { + } finally { if (CleanupParent) { @@ -311,7 +323,7 @@ Return Value: } if (UnlockFcb) { CdUnlockFcb( IrpContext, Fcb ); } - } _SEH2_END; + } return; } @@ -319,11 +331,11 @@ Return Value: VOID CdAddAllocationFromDirent ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN ULONG McbEntryOffset, - IN LONGLONG StartingFileOffset, - IN PDIRENT Dirent + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB Fcb, + _In_ ULONG McbEntryOffset, + _In_ LONGLONG StartingFileOffset, + _In_ PDIRENT Dirent ) /*++ @@ -358,6 +370,8 @@ Return Value: PAGED_CODE(); + UNREFERENCED_PARAMETER( IrpContext ); + ASSERT_IRP_CONTEXT( IrpContext ); ASSERT_FCB( Fcb ); ASSERT_LOCKED_FCB( Fcb ); @@ -466,10 +480,10 @@ Return Value: VOID CdAddInitialAllocation ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN ULONG StartingBlock, - IN LONGLONG DataLength + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB Fcb, + _In_ ULONG StartingBlock, + _In_ LONGLONG DataLength ) /*++ @@ -505,11 +519,13 @@ Return Value: PAGED_CODE(); + UNREFERENCED_PARAMETER( IrpContext ); + ASSERT_IRP_CONTEXT( IrpContext ); ASSERT_FCB( Fcb ); ASSERT_LOCKED_FCB( Fcb ); - ASSERT( 0 == Fcb->Mcb.CurrentEntryCount); - ASSERT( CDFS_NTC_FCB_DATA != Fcb->NodeTypeCode); + NT_ASSERT( 0 == Fcb->Mcb.CurrentEntryCount); + NT_ASSERT( CDFS_NTC_FCB_DATA != Fcb->NodeTypeCode); // // Update the new entry with the input data. @@ -555,9 +571,9 @@ Return Value: VOID CdTruncateAllocation ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN LONGLONG StartingFileOffset + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB Fcb, + _In_ LONGLONG StartingFileOffset ) /*++ @@ -591,7 +607,7 @@ Return Value: ASSERT_LOCKED_FCB( Fcb ); // - // Find the entry containing this starting offset. + // Find the entry containg this starting offset. // McbEntryOffset = CdFindMcbEntry( IrpContext, Fcb, StartingFileOffset ); @@ -606,10 +622,11 @@ Return Value: } +_At_(Fcb->NodeByteSize, _In_range_(>=, FIELD_OFFSET( FCB, FcbType ))) VOID CdInitializeMcb ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb + _In_ PIRP_CONTEXT IrpContext, + _Inout_updates_bytes_(Fcb->NodeByteSize) PFCB Fcb ) /*++ @@ -635,6 +652,8 @@ Return Value: { PAGED_CODE(); + UNREFERENCED_PARAMETER( IrpContext ); + ASSERT_IRP_CONTEXT( IrpContext ); ASSERT_FCB( Fcb ); @@ -652,10 +671,14 @@ Return Value: } +_At_(Fcb->NodeByteSize, _In_range_(>=, FIELD_OFFSET( FCB, FcbType ))) +_When_(Fcb->NodeTypeCode == CDFS_NTC_FCB_PATH_TABLE, _At_(Fcb->NodeByteSize, _In_range_(==, SIZEOF_FCB_INDEX))) +_When_(Fcb->NodeTypeCode == CDFS_NTC_FCB_INDEX, _At_(Fcb->NodeByteSize, _In_range_(==, SIZEOF_FCB_INDEX))) +_When_(Fcb->NodeTypeCode == CDFS_NTC_FCB_DATA, _At_(Fcb->NodeByteSize, _In_range_(==, SIZEOF_FCB_DATA))) VOID CdUninitializeMcb ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb + _In_ PIRP_CONTEXT IrpContext, + _Inout_updates_bytes_(Fcb->NodeByteSize) PFCB Fcb ) /*++ @@ -681,6 +704,8 @@ Return Value: { PAGED_CODE(); + UNREFERENCED_PARAMETER( IrpContext ); + ASSERT_IRP_CONTEXT( IrpContext ); ASSERT_FCB( Fcb ); @@ -698,14 +723,14 @@ Return Value: // -// Local support routine +// Local suupport routine // ULONG CdFindMcbEntry ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN LONGLONG FileOffset + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ LONGLONG FileOffset ) /*++ @@ -736,6 +761,8 @@ Return Value: PAGED_CODE(); + UNREFERENCED_PARAMETER( IrpContext ); + ASSERT_IRP_CONTEXT( IrpContext ); ASSERT_FCB( Fcb ); ASSERT_LOCKED_FCB( Fcb ); @@ -781,11 +808,11 @@ Return Value: VOID CdDiskOffsetFromMcbEntry ( - IN PIRP_CONTEXT IrpContext, - IN PCD_MCB_ENTRY McbEntry, - IN LONGLONG FileOffset, - IN PLONGLONG DiskOffset, - IN PULONG ByteCount + _In_ PIRP_CONTEXT IrpContext, + _In_ PCD_MCB_ENTRY McbEntry, + _In_ LONGLONG FileOffset, + _Out_ PLONGLONG DiskOffset, + _Out_ PULONG ByteCount ) /*++ @@ -827,6 +854,9 @@ Return Value: LONGLONG LocalByteCount; PAGED_CODE(); + + UNREFERENCED_PARAMETER( IrpContext ); + ASSERT_IRP_CONTEXT( IrpContext ); // diff --git a/drivers/filesystems/cdfs_new/cachesup.c b/drivers/filesystems/cdfs_new/cachesup.c index 600262f84a..eea1fd28da 100755 --- a/drivers/filesystems/cdfs_new/cachesup.c +++ b/drivers/filesystems/cdfs_new/cachesup.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "cdprocs.h" +#include "CdProcs.h" // // The Bug check file id for this module @@ -36,9 +36,10 @@ Abstract: VOID CdCreateInternalStream ( - IN PIRP_CONTEXT IrpContext, - IN PVCB Vcb, - IN PFCB Fcb + _In_ PIRP_CONTEXT IrpContext, + _In_ PVCB Vcb, + _Inout_ PFCB Fcb, + _In_ PUNICODE_STRING Name ) /*++ @@ -69,8 +70,8 @@ Return Value: BOOLEAN CleanupDirContext = FALSE; BOOLEAN UpdateFcbSizes = FALSE; - DIRENT Dirent; - DIRENT_ENUM_CONTEXT DirContext; + DIRENT Dirent = {0}; + DIRENT_ENUM_CONTEXT DirContext = {0}; PAGED_CODE(); @@ -94,14 +95,14 @@ Return Value: // Use a try-finally to facilitate cleanup. // - _SEH2_TRY { + try { // // Create the internal stream. The Vpb should be pointing at our volume // device object at this point. // - StreamFile = IoCreateStreamFileObject( NULL, Vcb->Vpb->RealDevice ); + StreamFile = IoCreateStreamFileObjectLite( NULL, Vcb->Vpb->RealDevice ); if (StreamFile == NULL) { @@ -127,6 +128,14 @@ Return Value: StreamFileOpen, Fcb, NULL ); + + // + // We'll give stream file objects a name to aid IO profiling etc. We + // NULL this in CdDeleteInternalStream before OB deletes the file object, + // and before CdRemovePrefix is called (which frees Fcb names). + // + + StreamFile->FileName = *Name; // // We will reference the current Fcb twice to keep it from going @@ -272,7 +281,7 @@ Return Value: } } - } _SEH2_FINALLY { + } finally { // // Cleanup any dirent structures we may have used. @@ -290,6 +299,14 @@ Return Value: if (StreamFile != NULL) { + // + // Null the name pointer, since the stream file object never actually + // 'owns' the names, we just point it to existing ones. + // + + StreamFile->FileName.Buffer = NULL; + StreamFile->FileName.MaximumLength = StreamFile->FileName.Length = 0; + ObDereferenceObject( StreamFile ); Fcb->FileObject = NULL; } @@ -306,7 +323,7 @@ Return Value: } CdUnlockFcb( IrpContext, Fcb ); - } _SEH2_END; + } return; } @@ -314,8 +331,8 @@ Return Value: VOID CdDeleteInternalStream ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB Fcb ) /*++ @@ -342,6 +359,8 @@ Return Value: PAGED_CODE(); + UNREFERENCED_PARAMETER( IrpContext ); + ASSERT_IRP_CONTEXT( IrpContext ); ASSERT_FCB( Fcb ); @@ -375,17 +394,23 @@ Return Value: CcUninitializeCacheMap( FileObject, NULL, NULL ); } + // + // Null the name pointer, since the stream file object never actually + // 'owns' the names, we just point it to existing ones. + // + + FileObject->FileName.Buffer = NULL; + FileObject->FileName.MaximumLength = FileObject->FileName.Length = 0; + ObDereferenceObject( FileObject ); } - - return; } NTSTATUS CdCompleteMdl ( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ) /*++ @@ -434,11 +459,13 @@ Return Value: } + +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdPurgeVolume ( - IN PIRP_CONTEXT IrpContext, - IN PVCB Vcb, - IN BOOLEAN DismountUnderway + _In_ PIRP_CONTEXT IrpContext, + _In_ PVCB Vcb, + _In_ BOOLEAN DismountUnderway ) /*++ @@ -592,7 +619,7 @@ Return Value: if (Vcb->PathTableFcb != NULL) { ThisFcb = Vcb->PathTableFcb; - InterlockedIncrement( &Vcb->PathTableFcb->FcbReference ); + InterlockedIncrement( (LONG*)&Vcb->PathTableFcb->FcbReference ); if ((ThisFcb->FcbNonpaged->SegmentObject.DataSectionObject != NULL) && !CcPurgeCacheSection( &ThisFcb->FcbNonpaged->SegmentObject, @@ -606,7 +633,7 @@ Return Value: CdDeleteInternalStream( IrpContext, ThisFcb ); - InterlockedDecrement( &ThisFcb->FcbReference ); + InterlockedDecrement( (LONG*)&ThisFcb->FcbReference ); CdTeardownStructures( IrpContext, ThisFcb, &RemovedFcb ); } @@ -614,7 +641,7 @@ Return Value: if (Vcb->VolumeDasdFcb != NULL) { ThisFcb = Vcb->VolumeDasdFcb; - InterlockedIncrement( &ThisFcb->FcbReference ); + InterlockedIncrement( (LONG*)&ThisFcb->FcbReference ); if ((ThisFcb->FcbNonpaged->SegmentObject.DataSectionObject != NULL) && !CcPurgeCacheSection( &ThisFcb->FcbNonpaged->SegmentObject, @@ -626,7 +653,7 @@ Return Value: Status = STATUS_UNABLE_TO_DELETE_SECTION; } - InterlockedDecrement( &ThisFcb->FcbReference ); + InterlockedDecrement( (LONG*)&ThisFcb->FcbReference ); CdTeardownStructures( IrpContext, ThisFcb, &RemovedFcb ); } diff --git a/drivers/filesystems/cdfs_new/cd.h b/drivers/filesystems/cdfs_new/cd.h index ef41b58968..f830210a7b 100755 --- a/drivers/filesystems/cdfs_new/cd.h +++ b/drivers/filesystems/cdfs_new/cd.h @@ -221,7 +221,7 @@ typedef struct _RAW_JOLIET_VD { UCHAR Reserved[8]; // reserved 8 = 0 ULONG VolSpaceI; // size of the volume in LBN's Intel ULONG VolSpaceM; // size of the volume in LBN's Motorola - UCHAR CharSet[32]; // character set bytes 0 = ASCII, Joliet Seq here + UCHAR CharSet[32]; // character set bytes 0 = ASCII, Joliett Seq here USHORT VolSetSizeI; // volume set size Intel USHORT VolSetSizeM; // volume set size Motorola USHORT VolSeqNumI; // volume set sequence number Intel @@ -383,9 +383,9 @@ typedef RAW_DIRENT *PRAW_DIRENT; // // VOID // CdConvertCdTimeToNtTime ( -// IN PIRP_CONTEXT IrpContext, -// IN PCHAR CdTime, -// OUT PLARGE_INTEGER NtTime +// _In_ PIRP_CONTEXT IrpContext, +// _In_ PCHAR CdTime, +// _Out_ PLARGE_INTEGER NtTime // ); // diff --git a/drivers/filesystems/cdfs_new/cddata.c b/drivers/filesystems/cdfs_new/cddata.c index c8367233ab..15cfe2d5db 100755 --- a/drivers/filesystems/cdfs_new/cddata.c +++ b/drivers/filesystems/cdfs_new/cddata.c @@ -17,7 +17,7 @@ Abstract: --*/ -#include "cdprocs.h" +#include "CdProcs.h" #ifdef CD_SANITY BOOLEAN CdTestTopLevel = TRUE; @@ -178,16 +178,42 @@ LONG CdXAFileHeader[] = { -44 // <CD-XA Raw Sectors> ADJUST }; +#ifdef CDFS_TELEMETRY_DATA + +// +// Telemetry Data for reporting +// + +CDFS_TELEMETRY_DATA_CONTEXT CdTelemetryData; + +#endif // CDFS_TELEMETRY_DATA + #ifdef ALLOC_PRAGMA #pragma alloc_text(PAGE, CdFastIoCheckIfPossible) #pragma alloc_text(PAGE, CdSerial32) +#pragma alloc_text(PAGE, CdSetThreadContext) #endif - +_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 CdFsdDispatch ( - IN PVOLUME_DEVICE_OBJECT VolumeDeviceObject, - IN PIRP Irp + _In_ PDEVICE_OBJECT DeviceObject, + _Inout_ PIRP Irp ) /*++ @@ -214,7 +240,7 @@ Routine Description: Arguments: - VolumeDeviceObject - Supplies the volume device object for this request + DeviceObject - Supplies the volume device object for this request Irp - Supplies the Irp being processed @@ -225,7 +251,7 @@ Return Value: --*/ { - THREAD_CONTEXT ThreadContext; + THREAD_CONTEXT ThreadContext = {0}; PIRP_CONTEXT IrpContext = NULL; BOOLEAN Wait; @@ -243,6 +269,8 @@ Return Value: ASSERT_OPTIONAL_IRP( Irp ); + UNREFERENCED_PARAMETER( DeviceObject ); + FsRtlEnterFileSystem(); #ifdef CD_SANITY @@ -259,7 +287,7 @@ Return Value: // Use a try-except to handle the exception cases. // - _SEH2_TRY { + try { // // If the IrpContext is NULL then this is the first pass through @@ -293,7 +321,7 @@ Return Value: CdSetThreadContext( IrpContext, &ThreadContext ); #ifdef CD_SANITY - ASSERT( !CdTestTopLevel || + NT_ASSERT( !CdTestTopLevel || SafeNodeType( IrpContext->TopLevel ) == CDFS_NTC_IRP_CONTEXT ); #endif @@ -347,6 +375,11 @@ Return Value: break; + case IRP_MJ_WRITE : + + Status = CdCommonWrite( IrpContext, Irp ); + break; + case IRP_MJ_QUERY_INFORMATION : Status = CdCommonQueryInfo( IrpContext, Irp ); @@ -392,40 +425,46 @@ Return Value: Status = CdCommonPnp( IrpContext, Irp ); break; + case IRP_MJ_SHUTDOWN : + + Status = CdCommonShutdown( IrpContext, Irp ); + break; + default : Status = STATUS_INVALID_DEVICE_REQUEST; CdCompleteRequest( IrpContext, Irp, Status ); } - } _SEH2_EXCEPT( CdExceptionFilter( IrpContext, _SEH2_GetExceptionInformation() )) { + } except( CdExceptionFilter( IrpContext, GetExceptionInformation() )) { - Status = CdProcessException( IrpContext, Irp, _SEH2_GetExceptionCode() ); - } _SEH2_END; + Status = CdProcessException( IrpContext, Irp, GetExceptionCode() ); + } } while (Status == STATUS_CANT_WAIT); #ifdef CD_SANITY - ASSERT( !CdTestTopLevel || + NT_ASSERT( !CdTestTopLevel || (PreviousTopLevel == IoGetTopLevelIrp()) ); #endif FsRtlExitFileSystem(); - ASSERT( SaveIrql == KeGetCurrentIrql( )); + NT_ASSERT( SaveIrql == KeGetCurrentIrql( )); return Status; } + #ifdef CD_SANITY VOID -CdRaiseStatusEx( - IN PIRP_CONTEXT IrpContext, - IN NTSTATUS Status, - IN BOOLEAN NormalizeStatus, - IN OPTIONAL ULONG FileId, - IN OPTIONAL ULONG Line +CdRaiseStatusEx ( + _In_ PIRP_CONTEXT IrpContext, + _In_ NTSTATUS Status, + _In_ BOOLEAN NormalizeStatus, + _In_opt_ ULONG FileId, + _In_opt_ ULONG Line ) { BOOLEAN BreakIn = FALSE; @@ -461,7 +500,7 @@ CdRaiseStatusEx( DbgPrint( "CDFS: Contact CDFS.SYS component owner for triage.\n"); DbgPrint( "CDFS: 'eb %p 0;eb %p 0' to disable this alert.\n", &CdTestRaisedStatus, &CdBreakOnAnyRaise); - DbgBreakPoint(); + NT_ASSERT(FALSE); } if (NormalizeStatus) { @@ -480,10 +519,11 @@ CdRaiseStatusEx( #endif + LONG CdExceptionFilter ( - IN PIRP_CONTEXT IrpContext, - IN PEXCEPTION_POINTERS ExceptionPointer + _Inout_ PIRP_CONTEXT IrpContext, + _In_ PEXCEPTION_POINTERS ExceptionPointer ) /*++ @@ -557,6 +597,7 @@ Return Value: if (TestStatus && !FsRtlIsNtstatusExpected( ExceptionCode )) { +#pragma prefast( suppress: __WARNING_USE_OTHER_FUNCTION, "We're corrupted." ) CdBugCheck( (ULONG_PTR) ExceptionPointer->ExceptionRecord, (ULONG_PTR) ExceptionPointer->ContextRecord, (ULONG_PTR) ExceptionPointer->ExceptionRecord->ExceptionAddress ); @@ -567,11 +608,13 @@ Return Value: } + +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdProcessException ( - IN PIRP_CONTEXT IrpContext OPTIONAL, - IN PIRP Irp, - IN NTSTATUS ExceptionCode + _In_opt_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp, + _In_ NTSTATUS ExceptionCode ) /*++ @@ -601,7 +644,7 @@ Return Value: --*/ { - PDEVICE_OBJECT Device; + PDEVICE_OBJECT Device = NULL; PVPB Vpb; PETHREAD Thread; @@ -625,17 +668,6 @@ Return Value: ExceptionCode = IrpContext->ExceptionStatus; - // - // If we are not a top level request then we just complete the request - // with the current status code. - // - - if (!FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_TOP_LEVEL )) { - - CdCompleteRequest( IrpContext, Irp, ExceptionCode ); - return ExceptionCode; - } - // // Check if we are posting this request. One of the following must be true // if we are to post a request. @@ -644,7 +676,8 @@ Return Value: // or we are forcing this to be posted. // // - Status code is STATUS_VERIFY_REQUIRED and we are at APC level - // or higher. Can't wait for IO in the verify path in this case. + // or higher, or within a guarded region. Can't wait for IO in + // the verify path in this case. // // Set the MORE_PROCESSING flag in the IrpContext to keep if from being // deleted if this is a retryable condition. @@ -653,27 +686,26 @@ Return Value: // Note that (children of) CdFsdPostRequest can raise (Mdl allocation). // - _SEH2_TRY { - + try { + if (ExceptionCode == STATUS_CANT_WAIT) { if (FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_FORCE_POST )) { ExceptionCode = CdFsdPostRequest( IrpContext, Irp ); } - - } else if (ExceptionCode == STATUS_VERIFY_REQUIRED) { - - if (KeGetCurrentIrql() >= APC_LEVEL) { - - ExceptionCode = CdFsdPostRequest( IrpContext, Irp ); - } + } + else if ((ExceptionCode == STATUS_VERIFY_REQUIRED) && + FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_TOP_LEVEL ) && + KeAreAllApcsDisabled()) { + + ExceptionCode = CdFsdPostRequest( IrpContext, Irp ); } } - _SEH2_EXCEPT( CdExceptionFilter( IrpContext, _SEH2_GetExceptionInformation() )) { + except( CdExceptionFilter( IrpContext, GetExceptionInformation() )) { - ExceptionCode = _SEH2_GetExceptionCode(); - } _SEH2_END; + ExceptionCode = GetExceptionCode(); + } // // If we posted the request or our caller will retry then just return here. @@ -687,6 +719,17 @@ Return Value: ClearFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_MORE_PROCESSING ); + // + // If we are not a top level request then we just complete the request + // with the current status code. + // + + if (!FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_TOP_LEVEL )) { + + CdCompleteRequest( IrpContext, Irp, ExceptionCode ); + return ExceptionCode; + } + // // Store this error into the Irp for posting back to the Io system. // @@ -722,20 +765,34 @@ Return Value: Device = IoGetDeviceToVerify( PsGetCurrentThread() ); IoSetDeviceToVerify( PsGetCurrentThread(), NULL ); - ASSERT( Device != NULL ); + NT_ASSERT( Device != NULL ); - // - // Let's not BugCheck just because the driver messes up. - // + } - if (Device == NULL) { + // + // It turns out some storage drivers really do set invalid non-NULL device + // objects to verify. + // + // To work around this, completely ignore the device to verify in the thread, + // and just use our real device object instead. + // - ExceptionCode = STATUS_DRIVER_INTERNAL_ERROR; + if (IrpContext->Vcb) { - CdCompleteRequest( IrpContext, Irp, ExceptionCode ); + Device = IrpContext->Vcb->Vpb->RealDevice; + } - return ExceptionCode; - } + // + // Let's not BugCheck just because the device to verify is somehow still NULL. + // + + if (Device == NULL) { + + ExceptionCode = STATUS_DRIVER_INTERNAL_ERROR; + + CdCompleteRequest( IrpContext, Irp, ExceptionCode ); + + return ExceptionCode; } // @@ -773,6 +830,7 @@ Return Value: Vpb = NULL; } + // // The device to verify is either in my thread local storage // or that of the thread that owns the Irp. @@ -786,18 +844,31 @@ Return Value: Thread = PsGetCurrentThread(); Device = IoGetDeviceToVerify( Thread ); - ASSERT( Device != NULL ); + NT_ASSERT( Device != NULL ); + } - // - // Let's not BugCheck just because the driver messes up. - // + // + // It turns out some storage drivers really do set invalid non-NULL device + // objects to verify. + // + // To work around this, completely ignore the device to verify in the thread, + // and just use our real device object instead. + // - if (Device == NULL) { + if (IrpContext->Vcb) { - CdCompleteRequest( IrpContext, Irp, ExceptionCode ); + Device = IrpContext->Vcb->Vpb->RealDevice; + } - return ExceptionCode; - } + // + // Let's not BugCheck just because the device to verify is somehow still NULL. + // + + if (Device == NULL) { + + CdCompleteRequest( IrpContext, Irp, ExceptionCode ); + + return ExceptionCode; } // @@ -839,9 +910,9 @@ Return Value: VOID CdCompleteRequest ( - IN PIRP_CONTEXT IrpContext OPTIONAL, - IN PIRP Irp OPTIONAL, - IN NTSTATUS Status + _Inout_opt_ PIRP_CONTEXT IrpContext, + _Inout_opt_ PIRP Irp, + _In_ NTSTATUS Status ) /*++ @@ -906,8 +977,8 @@ Return Value: VOID CdSetThreadContext ( - IN PIRP_CONTEXT IrpContext, - IN PTHREAD_CONTEXT ThreadContext + _Inout_ PIRP_CONTEXT IrpContext, + _In_ PTHREAD_CONTEXT ThreadContext ) /*++ @@ -938,8 +1009,6 @@ Return Value: { PTHREAD_CONTEXT CurrentThreadContext; - ULONG_PTR StackTop; - ULONG_PTR StackBottom; PAGED_CODE(); @@ -971,12 +1040,9 @@ Return Value: // If this is not a valid Cdfs context then use the input thread // context and store it in the top level context. // - - IoGetStackLimits( &StackTop, &StackBottom); - +#pragma warning(suppress: 6011) // Bug in PREFast around bitflag operations if (FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_TOP_LEVEL ) || - (((ULONG_PTR) CurrentThreadContext > StackBottom - sizeof( THREAD_CONTEXT )) || - ((ULONG_PTR) CurrentThreadContext <= StackTop) || + (!IoWithinStackLimits( (ULONG_PTR)CurrentThreadContext, sizeof( THREAD_CONTEXT ) ) || FlagOn( (ULONG_PTR) CurrentThreadContext, 0x3 ) || (CurrentThreadContext->Cdfs != 0x53464443))) { @@ -1002,18 +1068,23 @@ Return Value: return; } - + +_Function_class_(FAST_IO_CHECK_IF_POSSIBLE) +_IRQL_requires_same_ +_Success_(return != FALSE) BOOLEAN -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdFastIoCheckIfPossible ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN ULONG LockKey, - IN BOOLEAN CheckForReadOperation, - OUT PIO_STATUS_BLOCK IoStatus, - IN PDEVICE_OBJECT DeviceObject + _In_ PFILE_OBJECT FileObject, + _In_ PLARGE_INTEGER FileOffset, + _In_ ULONG Length, + _In_ BOOLEAN Wait, + _In_ ULONG LockKey, + _In_ BOOLEAN CheckForReadOperation, + _Pre_notnull_ + _When_(return != FALSE, _Post_equal_to_(_Old_(IoStatus))) + _When_(return == FALSE, _Post_valid_) + PIO_STATUS_BLOCK IoStatus, + _In_ PDEVICE_OBJECT DeviceObject ) /*++ @@ -1054,6 +1125,9 @@ Return Value: PAGED_CODE(); + UNREFERENCED_PARAMETER( Wait ); + UNREFERENCED_PARAMETER( DeviceObject ); + // // Decode the type of file object we're being asked to process and // make sure that is is only a user file open. @@ -1090,8 +1164,8 @@ Return Value: ULONG CdSerial32 ( - IN PCHAR Buffer, - IN ULONG ByteCount + _In_reads_bytes_(ByteCount) PCHAR Buffer, + _In_ ULONG ByteCount ) /*++ diff --git a/drivers/filesystems/cdfs_new/cddata.h b/drivers/filesystems/cdfs_new/cddata.h index a03fc36f34..395b1862ca 100755 --- a/drivers/filesystems/cdfs_new/cddata.h +++ b/drivers/filesystems/cdfs_new/cddata.h @@ -94,82 +94,77 @@ extern LONG CdXAFileHeader[]; extern LONG CdAudioPlayHeader[]; extern LONG CdXAAudioPhileHeader[]; - +#ifdef CDFS_TELEMETRY_DATA + // -// Turn on pseudo-asserts if CD_FREE_ASSERTS is defined. +// Globals for Telemetry data. // -#if !DBG -#ifdef CD_FREE_ASSERTS -#undef ASSERT -#undef ASSERTMSG -#define ASSERT(exp) if (!(exp)) { extern BOOLEAN KdDebuggerEnabled; DbgPrint("%s:%d %s\n",__FILE__,__LINE__,#exp); if (KdDebuggerEnabled) { DbgBreakPoint(); } } -#define ASSERTMSG(msg,exp) if (!(exp)) { extern BOOLEAN KdDebuggerEnabled; DbgPrint("%s:%d %s %s\n",__FILE__,__LINE__,msg,#exp); if (KdDebuggerEnabled) { DbgBreakPoint(); } } -#endif -#endif +extern CDFS_TELEMETRY_DATA_CONTEXT CdTelemetryData; + +#endif // CDFS_TELEMETRY_DATA - // // The following assertion macros ensure that the indicated structure // is valid // -// ASSERT_STRUCT( IN PVOID Struct, IN CSHORT NodeType ); -// ASSERT_OPTIONAL_STRUCT( IN PVOID Struct OPTIONAL, IN CSHORT NodeType ); +// ASSERT_STRUCT( _In_ PVOID Struct, _In_ CSHORT NodeType ); +// ASSERT_OPTIONAL_STRUCT( _In_opt_ PVOID Struct, _In_ CSHORT NodeType ); // -// ASSERT_VCB( IN PVCB Vcb ); -// ASSERT_OPTIONAL_VCB( IN PVCB Vcb OPTIONAL ); +// ASSERT_VCB( _In_ PVCB Vcb ); +// ASSERT_OPTIONAL_VCB( _In_opt_ PVCB Vcb ); // -// ASSERT_FCB( IN PFCB Fcb ); -// ASSERT_OPTIONAL_FCB( IN PFCB Fcb OPTIONAL ); +// ASSERT_FCB( _In_ PFCB Fcb ); +// ASSERT_OPTIONAL_FCB( _In_opt_ PFCB Fcb ); // -// ASSERT_FCB_NONPAGED( IN PFCB_NONPAGED FcbNonpaged ); -// ASSERT_OPTIONAL_FCB( IN PFCB_NONPAGED FcbNonpaged OPTIONAL ); +// ASSERT_FCB_NONPAGED( _In_ PFCB_NONPAGED FcbNonpaged ); +// ASSERT_OPTIONAL_FCB( _In_opt_ PFCB_NONPAGED FcbNonpaged ); // -// ASSERT_CCB( IN PSCB Ccb ); -// ASSERT_OPTIONAL_CCB( IN PSCB Ccb OPTIONAL ); +// ASSERT_CCB( _In_ PSCB Ccb ); +// ASSERT_OPTIONAL_CCB( _In_opt_ PSCB Ccb ); // -// ASSERT_IRP_CONTEXT( IN PIRP_CONTEXT IrpContext ); -// ASSERT_OPTIONAL_IRP_CONTEXT( IN PIRP_CONTEXT IrpContext OPTIONAL ); +// ASSERT_IRP_CONTEXT( _In_ PIRP_CONTEXT IrpContext ); +// ASSERT_OPTIONAL_IRP_CONTEXT( _In_opt_ PIRP_CONTEXT IrpContext ); // -// ASSERT_IRP( IN PIRP Irp ); -// ASSERT_OPTIONAL_IRP( IN PIRP Irp OPTIONAL ); +// ASSERT_IRP( _In_ PIRP Irp ); +// ASSERT_OPTIONAL_IRP( _In_opt_ PIRP Irp ); // -// ASSERT_FILE_OBJECT( IN PFILE_OBJECT FileObject ); -// ASSERT_OPTIONAL_FILE_OBJECT( IN PFILE_OBJECT FileObject OPTIONAL ); +// ASSERT_FILE_OBJECT( _In_ PFILE_OBJECT FileObject ); +// ASSERT_OPTIONAL_FILE_OBJECT( _In_opt_ PFILE_OBJECT FileObject ); // // The following macros are used to check the current thread owns // the indicated resource // -// ASSERT_EXCLUSIVE_RESOURCE( IN PERESOURCE Resource ); +// ASSERT_EXCLUSIVE_RESOURCE( _In_ PERESOURCE Resource ); // -// ASSERT_SHARED_RESOURCE( IN PERESOURCE Resource ); +// ASSERT_SHARED_RESOURCE( _In_ PERESOURCE Resource ); // -// ASSERT_RESOURCE_NOT_MINE( IN PERESOURCE Resource ); +// ASSERT_RESOURCE_NOT_MINE( _In_ PERESOURCE Resource ); // // The following macros are used to check whether the current thread -// owns the resource in the given structures. +// owns the resoures in the given structures. // // ASSERT_EXCLUSIVE_CDDATA // -// ASSERT_EXCLUSIVE_VCB( IN PVCB Vcb ); +// ASSERT_EXCLUSIVE_VCB( _In_ PVCB Vcb ); // -// ASSERT_SHARED_VCB( IN PVCB Vcb ); +// ASSERT_SHARED_VCB( _In_ PVCB Vcb ); // -// ASSERT_EXCLUSIVE_FCB( IN PFCB Fcb ); +// ASSERT_EXCLUSIVE_FCB( _In_ PFCB Fcb ); // -// ASSERT_SHARED_FCB( IN PFCB Fcb ); +// ASSERT_SHARED_FCB( _In_ PFCB Fcb ); // -// ASSERT_EXCLUSIVE_FILE( IN PFCB Fcb ); +// ASSERT_EXCLUSIVE_FILE( _In_ PFCB Fcb ); // -// ASSERT_SHARED_FILE( IN PFCB Fcb ); +// ASSERT_SHARED_FILE( _In_ PFCB Fcb ); // -// ASSERT_LOCKED_VCB( IN PVCB Vcb ); +// ASSERT_LOCKED_VCB( _In_ PVCB Vcb ); // -// ASSERT_NOT_LOCKED_VCB( IN PVCB Vcb ); +// ASSERT_NOT_LOCKED_VCB( _In_ PVCB Vcb ); // -// ASSERT_LOCKED_FCB( IN PFCB Fcb ); +// ASSERT_LOCKED_FCB( _In_ PFCB Fcb ); // -// ASSERT_NOT_LOCKED_FCB( IN PFCB Fcb ); +// ASSERT_NOT_LOCKED_FCB( _In_ PFCB Fcb ); // // @@ -183,19 +178,19 @@ extern LONG CdXAAudioPhileHeader[]; #ifdef CD_SANITY -#define ASSERT_STRUCT(S,T) ASSERT( SafeNodeType( S ) == (T) ) -#define ASSERT_OPTIONAL_STRUCT(S,T) ASSERT( ((S) == NULL) || (SafeNodeType( S ) == (T)) ) +#define ASSERT_STRUCT(S,T) NT_ASSERT( SafeNodeType( S ) == (T) ) +#define ASSERT_OPTIONAL_STRUCT(S,T) NT_ASSERT( ((S) == NULL) || (SafeNodeType( S ) == (T)) ) #define ASSERT_VCB(V) ASSERT_STRUCT( (V), CDFS_NTC_VCB ) #define ASSERT_OPTIONAL_VCB(V) ASSERT_OPTIONAL_STRUCT( (V), CDFS_NTC_VCB ) #define ASSERT_FCB(F) \ - ASSERT( (SafeNodeType( F ) == CDFS_NTC_FCB_DATA ) || \ + NT_ASSERT( (SafeNodeType( F ) == CDFS_NTC_FCB_DATA ) || \ (SafeNodeType( F ) == CDFS_NTC_FCB_INDEX ) || \ (SafeNodeType( F ) == CDFS_NTC_FCB_PATH_TABLE ) ) #define ASSERT_OPTIONAL_FCB(F) \ - ASSERT( ((F) == NULL) || \ + NT_ASSERT( ((F) == NULL) || \ (SafeNodeType( F ) == CDFS_NTC_FCB_DATA ) || \ (SafeNodeType( F ) == CDFS_NTC_FCB_INDEX ) || \ (SafeNodeType( F ) == CDFS_NTC_FCB_PATH_TABLE ) ) @@ -215,27 +210,27 @@ extern LONG CdXAAudioPhileHeader[]; #define ASSERT_FILE_OBJECT(FO) ASSERT_STRUCT( (FO), IO_TYPE_FILE ) #define ASSERT_OPTIONAL_FILE_OBJECT(FO) ASSERT_OPTIONAL_STRUCT( (FO), IO_TYPE_FILE ) -#define ASSERT_EXCLUSIVE_RESOURCE(R) ASSERT( ExIsResourceAcquiredExclusiveLite( R )) +#define ASSERT_EXCLUSIVE_RESOURCE(R) NT_ASSERT( ExIsResourceAcquiredExclusiveLite( R )) -#define ASSERT_SHARED_RESOURCE(R) ASSERT( ExIsResourceAcquiredSharedLite( R )) +#define ASSERT_SHARED_RESOURCE(R) NT_ASSERT( ExIsResourceAcquiredSharedLite( R )) -#define ASSERT_RESOURCE_NOT_MINE(R) ASSERT( !ExIsResourceAcquiredSharedLite( R )) +#define ASSERT_RESOURCE_NOT_MINE(R) NT_ASSERT( !ExIsResourceAcquiredSharedLite( R )) -#define ASSERT_EXCLUSIVE_CDDATA ASSERT( ExIsResourceAcquiredExclusiveLite( &CdData.DataResource )) -#define ASSERT_EXCLUSIVE_VCB(V) ASSERT( ExIsResourceAcquiredExclusiveLite( &(V)->VcbResource )) -#define ASSERT_SHARED_VCB(V) ASSERT( ExIsResourceAcquiredSharedLite( &(V)->VcbResource )) +#define ASSERT_EXCLUSIVE_CDDATA NT_ASSERT( ExIsResourceAcquiredExclusiveLite( &CdData.DataResource )) +#define ASSERT_EXCLUSIVE_VCB(V) NT_ASSERT( ExIsResourceAcquiredExclusiveLite( &(V)->VcbResource )) +#define ASSERT_SHARED_VCB(V) NT_ASSERT( ExIsResourceAcquiredSharedLite( &(V)->VcbResource )) -#define ASSERT_EXCLUSIVE_FCB(F) ASSERT( ExIsResourceAcquiredExclusiveLite( &(F)->FcbNonpaged->FcbResource )) -#define ASSERT_SHARED_FCB(F) ASSERT( ExIsResourceAcquiredSharedLite( &(F)->FcbNonpaged->FcbResource )) +#define ASSERT_EXCLUSIVE_FCB(F) NT_ASSERT( ExIsResourceAcquiredExclusiveLite( &(F)->FcbNonpaged->FcbResource )) +#define ASSERT_SHARED_FCB(F) NT_ASSERT( ExIsResourceAcquiredSharedLite( &(F)->FcbNonpaged->FcbResource )) -#define ASSERT_EXCLUSIVE_FILE(F) ASSERT( ExIsResourceAcquiredExclusiveLite( (F)->Resource )) -#define ASSERT_SHARED_FILE(F) ASSERT( ExIsResourceAcquiredSharedLite( (F)->Resource )) +#define ASSERT_EXCLUSIVE_FILE(F) NT_ASSERT( ExIsResourceAcquiredExclusiveLite( (F)->Resource )) +#define ASSERT_SHARED_FILE(F) NT_ASSERT( ExIsResourceAcquiredSharedLite( (F)->Resource )) -#define ASSERT_LOCKED_VCB(V) ASSERT( (V)->VcbLockThread == PsGetCurrentThread() ) -#define ASSERT_NOT_LOCKED_VCB(V) ASSERT( (V)->VcbLockThread != PsGetCurrentThread() ) +#define ASSERT_LOCKED_VCB(V) NT_ASSERT( (V)->VcbLockThread == PsGetCurrentThread() ) +#define ASSERT_NOT_LOCKED_VCB(V) NT_ASSERT( (V)->VcbLockThread != PsGetCurrentThread() ) -#define ASSERT_LOCKED_FCB(F) ASSERT( !FlagOn( (F)->FcbState, FCB_STATE_IN_FCB_TABLE) || ((F)->FcbLockThread == PsGetCurrentThread())) -#define ASSERT_NOT_LOCKED_FCB(F) ASSERT( (F)->FcbLockThread != PsGetCurrentThread() ) +#define ASSERT_LOCKED_FCB(F) NT_ASSERT( !FlagOn( (F)->FcbState, FCB_STATE_IN_FCB_TABLE) || ((F)->FcbLockThread == PsGetCurrentThread())) +#define ASSERT_NOT_LOCKED_FCB(F) NT_ASSERT( (F)->FcbLockThread != PsGetCurrentThread() ) #else diff --git a/drivers/filesystems/cdfs_new/cdfs.rc b/drivers/filesystems/cdfs_new/cdfs.rc index 1cf70c6084..5d4dcafce0 100644 --- a/drivers/filesystems/cdfs_new/cdfs.rc +++ b/drivers/filesystems/cdfs_new/cdfs.rc @@ -1,7 +1,14 @@ -/* $Id: cdfs.rc 21710 2006-04-22 16:36:21Z tretiakov $ */ +// +// Copyright (C) Microsoft. All rights reserved. +// +#include <verrsrc.h> + +#include <ntverp.h> + +#define VER_FILETYPE VFT_DRV +#define VER_FILESUBTYPE VFT2_DRV_SYSTEM +#define VER_FILEDESCRIPTION_STR "CD-ROM File System Driver" +#define VER_INTERNALNAME_STR "cdfs.sys" + +#include "common.ver" -#define REACTOS_VERSION_DLL -#define REACTOS_STR_FILE_DESCRIPTION "ISO9660 Driver\0" -#define REACTOS_STR_INTERNAL_NAME "cdfs\0" -#define REACTOS_STR_ORIGINAL_FILENAME "cdfs.sys\0" -#include <reactos/version.rc> diff --git a/drivers/filesystems/cdfs_new/cdinit.c b/drivers/filesystems/cdfs_new/cdinit.c index b6bec14c45..5ec9d50324 100755 --- a/drivers/filesystems/cdfs_new/cdinit.c +++ b/drivers/filesystems/cdfs_new/cdinit.c @@ -13,7 +13,7 @@ Abstract: --*/ -#include "cdprocs.h" +#include "CdProcs.h" // // The Bug check file id for this module @@ -21,40 +21,33 @@ Abstract: #define BugCheckFileId (CDFS_BUG_CHECK_CDINIT) +// Tell prefast the function type. +DRIVER_INITIALIZE DriverEntry; + NTSTATUS -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ DriverEntry( - IN PDRIVER_OBJECT DriverObject, - IN PUNICODE_STRING RegistryPath + _In_ PDRIVER_OBJECT DriverObject, + _In_ PUNICODE_STRING RegistryPath ); + +// tell prefast this is a driver unload function +DRIVER_UNLOAD CdUnload; + VOID -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdUnload( - IN PDRIVER_OBJECT DriverObject + _In_ PDRIVER_OBJECT DriverObject ); NTSTATUS CdInitializeGlobalData ( - IN PDRIVER_OBJECT DriverObject, - IN PDEVICE_OBJECT FileSystemDeviceObject -#ifdef __REACTOS__ - , - IN PDEVICE_OBJECT HddFileSystemDeviceObject -#endif - ); - -NTSTATUS -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ -CdShutdown ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp + _In_ PDRIVER_OBJECT DriverObject, + _In_ PDEVICE_OBJECT FileSystemDeviceObject ); #ifdef ALLOC_PRAGMA #pragma alloc_text(INIT, DriverEntry) #pragma alloc_text(PAGE, CdUnload) -#pragma alloc_text(PAGE, CdShutdown) #pragma alloc_text(INIT, CdInitializeGlobalData) #endif @@ -64,10 +57,9 @@ CdShutdown ( // NTSTATUS -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ DriverEntry( - IN PDRIVER_OBJECT DriverObject, - IN PUNICODE_STRING RegistryPath + _In_ PDRIVER_OBJECT DriverObject, + _In_ PUNICODE_STRING RegistryPath ) /*++ @@ -93,9 +85,9 @@ Return Value: NTSTATUS Status; UNICODE_STRING UnicodeString; PDEVICE_OBJECT CdfsFileSystemDeviceObject; -#ifdef __REACTOS__ - PDEVICE_OBJECT HddFileSystemDeviceObject; -#endif + FS_FILTER_CALLBACKS FilterCallbacks; + + UNREFERENCED_PARAMETER( RegistryPath ); // // Create the device object. @@ -115,27 +107,14 @@ Return Value: return Status; } -#ifdef __REACTOS__ - // - // Create the HDD device object. - // - - RtlInitUnicodeString( &UnicodeString, L"\\CdfsHdd" ); - - Status = IoCreateDevice( DriverObject, - 0, - &UnicodeString, - FILE_DEVICE_DISK_FILE_SYSTEM, - 0, - FALSE, - &HddFileSystemDeviceObject ); +#pragma prefast(push) +#pragma prefast(disable: 28155, "the dispatch routine has the correct type, prefast is just being paranoid.") +#pragma prefast(disable: 28168, "the dispatch routine has the correct type, prefast is just being paranoid.") +#pragma prefast(disable: 28169, "the dispatch routine has the correct type, prefast is just being paranoid.") +#pragma prefast(disable: 28175, "we're allowed to change these.") - if (!NT_SUCCESS( Status )) { - IoDeleteDevice (CdfsFileSystemDeviceObject); - return Status; - } -#endif DriverObject->DriverUnload = CdUnload; + // // Note that because of the way data caching is done, we set neither // the Direct I/O or Buffered I/O bit in DeviceObject->Flags. If @@ -153,6 +132,7 @@ Return Value: DriverObject->MajorFunction[IRP_MJ_CREATE] = DriverObject->MajorFunction[IRP_MJ_CLOSE] = DriverObject->MajorFunction[IRP_MJ_READ] = + DriverObject->MajorFunction[IRP_MJ_WRITE] = DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION]= @@ -161,17 +141,29 @@ Return Value: DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DriverObject->MajorFunction[IRP_MJ_LOCK_CONTROL] = DriverObject->MajorFunction[IRP_MJ_CLEANUP] = - DriverObject->MajorFunction[IRP_MJ_PNP] = (PDRIVER_DISPATCH) CdFsdDispatch; - DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = CdShutdown; + DriverObject->MajorFunction[IRP_MJ_PNP] = + DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = (PDRIVER_DISPATCH) CdFsdDispatch; +#pragma prefast(pop) +#pragma prefast(suppress: 28175, "this is a file system driver, we're allowed to touch FastIoDispatch.") DriverObject->FastIoDispatch = &CdFastIoDispatch; - Status = IoRegisterShutdownNotification (CdfsFileSystemDeviceObject); - if (!NT_SUCCESS (Status)) { - IoDeleteDevice (CdfsFileSystemDeviceObject); -#ifdef __REACTOS__ - IoDeleteDevice (HddFileSystemDeviceObject); -#endif + // + // Initialize the filter callbacks we use. + // + + RtlZeroMemory( &FilterCallbacks, + sizeof(FS_FILTER_CALLBACKS) ); + + FilterCallbacks.SizeOfFsFilterCallbacks = sizeof(FS_FILTER_CALLBACKS); + FilterCallbacks.PreAcquireForSectionSynchronization = CdFilterCallbackAcquireForCreateSection; + + Status = FsRtlRegisterFileSystemFilterCallbacks( DriverObject, + &FilterCallbacks ); + + if (!NT_SUCCESS( Status )) { + + IoDeleteDevice( CdfsFileSystemDeviceObject ); return Status; } @@ -179,16 +171,9 @@ Return Value: // Initialize the global data structures // -#ifndef __REACTOS__ Status = CdInitializeGlobalData( DriverObject, CdfsFileSystemDeviceObject ); -#else - Status = CdInitializeGlobalData( DriverObject, CdfsFileSystemDeviceObject, HddFileSystemDeviceObject ); -#endif if (!NT_SUCCESS (Status)) { IoDeleteDevice (CdfsFileSystemDeviceObject); -#ifdef __REACTOS__ - IoDeleteDevice (HddFileSystemDeviceObject); -#endif return Status; } @@ -199,69 +184,30 @@ Return Value: // CdfsFileSystemDeviceObject->Flags |= DO_LOW_PRIORITY_FILESYSTEM; -#ifdef __REACTOS__ - HddFileSystemDeviceObject->Flags |= DO_LOW_PRIORITY_FILESYSTEM; -#endif IoRegisterFileSystem( CdfsFileSystemDeviceObject ); ObReferenceObject (CdfsFileSystemDeviceObject); -#ifdef __REACTOS__ - IoRegisterFileSystem( HddFileSystemDeviceObject ); - ObReferenceObject (HddFileSystemDeviceObject); -#endif +#ifdef CDFS_TELEMETRY_DATA // - // And return to our caller + // Initialize Telemetry // - return( STATUS_SUCCESS ); -} - -NTSTATUS -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ -CdShutdown ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp - ) -/*++ - -Routine Description: - - This routine is the shutdown handler for CDFS. + CdInitializeTelemetry(); -Arguments: - - DeviceObject - Supplies the registered device object for CDFS. - Irp - Shutdown IRP - - -Return Value: - - None. - ---*/ -{ -#ifdef __REACTOS__ - ASSERT(DeviceObject == CdData.FileSystemDeviceObject || - DeviceObject == CdData.HddFileSystemDeviceObject); #endif - IoUnregisterFileSystem (DeviceObject); -#ifndef __REACTOS__ - IoDeleteDevice (CdData.FileSystemDeviceObject); -#else - IoDeleteDevice (DeviceObject); -#endif + // + // And return to our caller + // - CdCompleteRequest( NULL, Irp, STATUS_SUCCESS ); - return STATUS_SUCCESS; + return( STATUS_SUCCESS ); } VOID -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdUnload( - IN PDRIVER_OBJECT DriverObject + _In_ PDRIVER_OBJECT DriverObject ) /*++ @@ -281,6 +227,10 @@ Return Value: { PIRP_CONTEXT IrpContext; + PAGED_CODE(); + + UNREFERENCED_PARAMETER( DriverObject ); + // // Free any IRP contexts // @@ -295,9 +245,6 @@ Return Value: IoFreeWorkItem (CdData.CloseItem); ExDeleteResourceLite( &CdData.DataResource ); ObDereferenceObject (CdData.FileSystemDeviceObject); -#ifdef __REACTOS__ - ObDereferenceObject (CdData.HddFileSystemDeviceObject); -#endif } // @@ -306,12 +253,8 @@ Return Value: NTSTATUS CdInitializeGlobalData ( - IN PDRIVER_OBJECT DriverObject, - IN PDEVICE_OBJECT FileSystemDeviceObject -#ifdef __REACTOS__ - , - IN PDEVICE_OBJECT HddFileSystemDeviceObject -#endif + _In_ PDRIVER_OBJECT DriverObject, + _In_ PDEVICE_OBJECT FileSystemDeviceObject ) /*++ @@ -340,6 +283,10 @@ Return Value: RtlZeroMemory( &CdFastIoDispatch, sizeof( FAST_IO_DISPATCH )); CdFastIoDispatch.SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH); + +#pragma prefast(push) +#pragma prefast(disable:28155, "these are all correct") + CdFastIoDispatch.FastIoCheckIfPossible = CdFastIoCheckIfPossible; // CheckForFastIo CdFastIoDispatch.FastIoRead = FsRtlCopyRead; // Read CdFastIoDispatch.FastIoQueryBasicInfo = CdFastQueryBasicInfo; // QueryBasicInfo @@ -348,7 +295,12 @@ Return Value: CdFastIoDispatch.FastIoUnlockSingle = CdFastUnlockSingle; // UnlockSingle CdFastIoDispatch.FastIoUnlockAll = CdFastUnlockAll; // UnlockAll CdFastIoDispatch.FastIoUnlockAllByKey = CdFastUnlockAllByKey; // UnlockAllByKey - CdFastIoDispatch.AcquireFileForNtCreateSection = CdAcquireForCreateSection; + + // + // This callback has been replaced by CdFilterCallbackAcquireForCreateSection. + // + + CdFastIoDispatch.AcquireFileForNtCreateSection = NULL; CdFastIoDispatch.ReleaseFileForNtCreateSection = CdReleaseForCreateSection; CdFastIoDispatch.FastIoQueryNetworkOpenInfo = CdFastQueryNetworkInfo; // QueryNetworkInfo @@ -357,6 +309,8 @@ Return Value: CdFastIoDispatch.PrepareMdlWrite = FsRtlPrepareMdlWriteDev; CdFastIoDispatch.MdlWriteComplete = FsRtlMdlWriteCompleteDev; +#pragma prefast(pop) + // // Initialize the CdData structure. // @@ -368,9 +322,6 @@ Return Value: CdData.DriverObject = DriverObject; CdData.FileSystemDeviceObject = FileSystemDeviceObject; -#ifdef __REACTOS__ - CdData.HddFileSystemDeviceObject = HddFileSystemDeviceObject; -#endif InitializeListHead( &CdData.VcbQueue ); @@ -380,10 +331,10 @@ Return Value: // Initialize the cache manager callback routines // - CdData.CacheManagerCallbacks.AcquireForLazyWrite = (PVOID)&CdAcquireForCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */ - CdData.CacheManagerCallbacks.ReleaseFromLazyWrite = (PVOID)&CdReleaseFromCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */ - CdData.CacheManagerCallbacks.AcquireForReadAhead = (PVOID)&CdAcquireForCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */ - CdData.CacheManagerCallbacks.ReleaseFromReadAhead = (PVOID)&CdReleaseFromCache;/* ReactOS Change: GCC "assignment from incompatible pointer type" */ + CdData.CacheManagerCallbacks.AcquireForLazyWrite = &CdAcquireForCache; + CdData.CacheManagerCallbacks.ReleaseFromLazyWrite = &CdReleaseFromCache; + CdData.CacheManagerCallbacks.AcquireForReadAhead = &CdAcquireForCache; + CdData.CacheManagerCallbacks.ReleaseFromReadAhead = &CdReleaseFromCache; CdData.CacheManagerVolumeCallbacks.AcquireForLazyWrite = &CdNoopAcquire; CdData.CacheManagerVolumeCallbacks.ReleaseFromLazyWrite = &CdNoopRelease; diff --git a/drivers/filesystems/cdfs_new/cdprocs.h b/drivers/filesystems/cdfs_new/cdprocs.h index 2b066e7192..d2f7db0b4b 100755 --- a/drivers/filesystems/cdfs_new/cdprocs.h +++ b/drivers/filesystems/cdfs_new/cdprocs.h @@ -17,24 +17,36 @@ Abstract: #ifndef _CDPROCS_ #define _CDPROCS_ +#pragma warning( disable: 4127 ) // conditional expression is constant + +#pragma warning( push ) +#pragma warning( disable: 4201 ) // nonstandard extension used : nameless struct/union +#pragma warning( disable: 4214 ) // nonstandard extension used : bit field types + #include <ntifs.h> #include <ntddcdrm.h> #include <ntdddisk.h> #include <ntddscsi.h> -#ifdef __REACTOS__ -#include <pseh/pseh2.h> -#endif #ifndef INLINE #define INLINE __inline #endif #include "nodetype.h" -#include "cd.h" -#include "cdstruc.h" -#include "cddata.h" +#include "Cd.h" +#include "CdStruc.h" +#include "CdData.h" + +#ifdef CDFS_TELEMETRY_DATA + +#include <winmeta.h> +#include <TraceLoggingProvider.h> +#include <telemetry\MicrosoftTelemetry.h> + +#endif // CDFS_TELEMETRY_DATA +#pragma warning( pop ) //**** x86 compiler bug **** @@ -43,6 +55,14 @@ Abstract: #define Int64ShraMod32(a, b) ((LONGLONG)(a) >> (b)) #endif +#ifndef Min +#define Min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef Max +#define Max(a, b) ((a) > (b) ? (a) : (b)) +#endif + // // Here are the different pool tags. // @@ -91,9 +111,9 @@ Abstract: // // BOOLEAN // CdIllegalFcbAccess ( -// IN PIRP_CONTEXT IrpContext, -// IN TYPE_OF_OPEN TypeOfOpen, -// IN ACCESS_MASK DesiredAccess +// _In_ PIRP_CONTEXT IrpContext, +// _In_ TYPE_OF_OPEN TypeOfOpen, +// _In_ ACCESS_MASK DesiredAccess // ); // @@ -117,49 +137,55 @@ Abstract: // These routines are for querying allocation on individual streams. // +_Requires_lock_held_(_Global_critical_region_) VOID CdLookupAllocation ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN LONGLONG FileOffset, - OUT PLONGLONG DiskOffset, - OUT PULONG ByteCount + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ LONGLONG FileOffset, + _Out_ PLONGLONG DiskOffset, + _Out_ PULONG ByteCount ); VOID CdAddAllocationFromDirent ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN ULONG McbEntryOffset, - IN LONGLONG StartingFileOffset, - IN PDIRENT Dirent + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB Fcb, + _In_ ULONG McbEntryOffset, + _In_ LONGLONG StartingFileOffset, + _In_ PDIRENT Dirent ); VOID CdAddInitialAllocation ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN ULONG StartingBlock, - IN LONGLONG DataLength + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB Fcb, + _In_ ULONG StartingBlock, + _In_ LONGLONG DataLength ); VOID CdTruncateAllocation ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN LONGLONG StartingFileOffset + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB Fcb, + _In_ LONGLONG StartingFileOffset ); +_At_(Fcb->NodeByteSize, _In_range_(>=, FIELD_OFFSET( FCB, FcbType ))) VOID CdInitializeMcb ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb + _In_ PIRP_CONTEXT IrpContext, + _Inout_updates_bytes_(Fcb->NodeByteSize) PFCB Fcb ); +_At_(Fcb->NodeByteSize, _In_range_(>=, FIELD_OFFSET( FCB, FcbType ))) +_When_(Fcb->NodeTypeCode == CDFS_NTC_FCB_PATH_TABLE, _At_(Fcb->NodeByteSize, _In_range_(==, SIZEOF_FCB_INDEX))) +_When_(Fcb->NodeTypeCode == CDFS_NTC_FCB_INDEX, _At_(Fcb->NodeByteSize, _In_range_(==, SIZEOF_FCB_INDEX))) +_When_(Fcb->NodeTypeCode == CDFS_NTC_FCB_DATA, _At_(Fcb->NodeByteSize, _In_range_(==, SIZEOF_FCB_DATA))) VOID CdUninitializeMcb ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb + _In_ PIRP_CONTEXT IrpContext, + _Inout_updates_bytes_(Fcb->NodeByteSize) PFCB Fcb ); @@ -169,35 +195,58 @@ CdUninitializeMcb ( VOID CdCreateInternalStream ( - IN PIRP_CONTEXT IrpContext, - IN PVCB Vcb, - IN PFCB Fcb + _In_ PIRP_CONTEXT IrpContext, + _In_ PVCB Vcb, + _Inout_ PFCB Fcb, + _In_ PUNICODE_STRING Name ); VOID CdDeleteInternalStream ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB Fcb ); NTSTATUS CdCompleteMdl ( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdPurgeVolume ( - IN PIRP_CONTEXT IrpContext, - IN PVCB Vcb, - IN BOOLEAN DismountUnderway + _In_ PIRP_CONTEXT IrpContext, + _In_ PVCB Vcb, + _In_ BOOLEAN DismountUnderway ); +VOID +INLINE +CdVerifyOrCreateDirStreamFile ( + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb + ) +{ + // + // Unsafe test to see if call / lock neccessary. + // + + if (NULL == Fcb->FileObject) { + + CdCreateInternalStream( IrpContext, + Fcb->Vcb, + Fcb, + &Fcb->FileNamePrefix.ExactCaseName.FileName); + } +} + + // // VOID // CdUnpinData ( -// IN PIRP_CONTEXT IrpContext, -// IN OUT PBCB *Bcb +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PBCB *Bcb // ); // @@ -212,56 +261,97 @@ CdPurgeVolume ( // the on disk structure and do not alter any other data structures. // +_Requires_lock_held_(_Global_critical_region_) +VOID +CdFreeDirCache ( + _In_ PIRP_CONTEXT IrpContext + ); + +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdNonCachedRead ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN LONGLONG StartingOffset, - IN ULONG ByteCount + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ LONGLONG StartingOffset, + _In_ ULONG ByteCount ); +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdNonCachedXARead ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN LONGLONG StartingOffset, - IN ULONG ByteCount + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ LONGLONG StartingOffset, + _In_ ULONG ByteCount + ); + +_Requires_lock_held_(_Global_critical_region_) +NTSTATUS +CdVolumeDasdWrite ( + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ LONGLONG StartingOffset, + _In_ ULONG ByteCount ); BOOLEAN CdReadSectors ( - IN PIRP_CONTEXT IrpContext, - IN LONGLONG StartingOffset, - IN ULONG ByteCount, - IN BOOLEAN RaiseOnError, - IN OUT PVOID Buffer, - IN PDEVICE_OBJECT TargetDeviceObject + _In_ PIRP_CONTEXT IrpContext, + _In_ LONGLONG StartingOffset, + _In_ ULONG ByteCount, + _In_ BOOLEAN ReturnError, + _Out_writes_bytes_(ByteCount) PVOID Buffer, + _In_ PDEVICE_OBJECT TargetDeviceObject ); NTSTATUS CdCreateUserMdl ( - IN PIRP_CONTEXT IrpContext, - IN ULONG BufferLength, - IN BOOLEAN RaiseOnError + _In_ PIRP_CONTEXT IrpContext, + _In_ ULONG BufferLength, + _In_ BOOLEAN RaiseOnError, + _In_ LOCK_OPERATION Operation ); NTSTATUS +FASTCALL CdPerformDevIoCtrl ( - IN PIRP_CONTEXT IrpContext, - IN ULONG IoControlCode, - IN PDEVICE_OBJECT Device, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength, - IN BOOLEAN InternalDeviceIoControl, - IN BOOLEAN OverrideVerify, - OUT PIO_STATUS_BLOCK Iosb OPTIONAL + _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 + ); + +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 + ); + +NTSTATUS +CdHijackIrpAndFlushDevice ( + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp, + _In_ PDEVICE_OBJECT TargetDeviceObject ); + // // VOID // CdMapUserBuffer ( -// IN PIRP_CONTEXT IrpContext -// OUT PVOID UserBuffer +// _In_ PIRP_CONTEXT IrpContext +// _Out_ PVOID UserBuffer // ); // // Returns pointer to sys address. Will raise on failure. @@ -269,25 +359,25 @@ CdPerformDevIoCtrl ( // // VOID // CdLockUserBuffer ( -// IN PIRP_CONTEXT IrpContext, -// IN ULONG BufferLength +// _Inout_ PIRP_CONTEXT IrpContext, +// _In_ ULONG BufferLength // ); // #define CdMapUserBuffer(IC, UB) { \ *(UB) = (PVOID) ( ((IC)->Irp->MdlAddress == NULL) ? \ (IC)->Irp->UserBuffer : \ - (MmGetSystemAddressForMdlSafe( (IC)->Irp->MdlAddress, NormalPagePriority))); \ + (MmGetSystemAddressForMdlSafe( (IC)->Irp->MdlAddress, NormalPagePriority | MdlMappingNoExecute))); \ if (NULL == *(UB)) { \ CdRaiseStatus( (IC), STATUS_INSUFFICIENT_RESOURCES); \ } \ } -#define CdLockUserBuffer(IC,BL) { \ - if ((IC)->Irp->MdlAddress == NULL) { \ - (VOID) CdCreateUserMdl( (IC), (BL), TRUE ); \ - } \ +#define CdLockUserBuffer(IC,BL,OP) { \ + if ((IC)->Irp->MdlAddress == NULL) { \ + (VOID) CdCreateUserMdl( (IC), (BL), TRUE, (OP) ); \ + } \ } @@ -297,122 +387,124 @@ CdPerformDevIoCtrl ( VOID CdLookupDirent ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN ULONG DirentOffset, - OUT PDIRENT_ENUM_CONTEXT DirContext + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ ULONG DirentOffset, + _Out_ PDIRENT_ENUM_CONTEXT DirContext ); BOOLEAN CdLookupNextDirent ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN PDIRENT_ENUM_CONTEXT CurrentDirContext, - OUT PDIRENT_ENUM_CONTEXT NextDirContext + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ PDIRENT_ENUM_CONTEXT CurrentDirContext, + _Inout_ PDIRENT_ENUM_CONTEXT NextDirContext ); +_At_(Dirent->CdTime, _Post_notnull_) VOID CdUpdateDirentFromRawDirent ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN PDIRENT_ENUM_CONTEXT DirContext, - IN OUT PDIRENT Dirent + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ PDIRENT_ENUM_CONTEXT DirContext, + _Inout_ PDIRENT Dirent ); VOID CdUpdateDirentName ( - IN PIRP_CONTEXT IrpContext, - IN OUT PDIRENT Dirent, - IN ULONG IgnoreCase + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PDIRENT Dirent, + _In_ ULONG IgnoreCase ); -BOOLEAN +_Success_(return != FALSE) BOOLEAN CdFindFile ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN PCD_NAME Name, - IN BOOLEAN IgnoreCase, - IN OUT PFILE_ENUM_CONTEXT FileContext, - OUT PCD_NAME *MatchingName + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ PCD_NAME Name, + _In_ BOOLEAN IgnoreCase, + _Inout_ PFILE_ENUM_CONTEXT FileContext, + _Out_ PCD_NAME *MatchingName ); BOOLEAN CdFindDirectory ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN PCD_NAME Name, - IN BOOLEAN IgnoreCase, - IN OUT PFILE_ENUM_CONTEXT FileContext + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ PCD_NAME Name, + _In_ BOOLEAN IgnoreCase, + _Inout_ PFILE_ENUM_CONTEXT FileContext ); +_At_(FileContext->ShortName.FileName.MaximumLength, _In_range_(>=, BYTE_COUNT_8_DOT_3)) BOOLEAN CdFindFileByShortName ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN PCD_NAME Name, - IN BOOLEAN IgnoreCase, - IN ULONG ShortNameDirentOffset, - IN OUT PFILE_ENUM_CONTEXT FileContext + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ PCD_NAME Name, + _In_ BOOLEAN IgnoreCase, + _In_ ULONG ShortNameDirentOffset, + _Inout_ PFILE_ENUM_CONTEXT FileContext ); BOOLEAN CdLookupNextInitialFileDirent ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN OUT PFILE_ENUM_CONTEXT FileContext + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _Inout_ PFILE_ENUM_CONTEXT FileContext ); VOID CdLookupLastFileDirent ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN PFILE_ENUM_CONTEXT FileContext + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ PFILE_ENUM_CONTEXT FileContext ); VOID CdCleanupFileContext ( - IN PIRP_CONTEXT IrpContext, - IN PFILE_ENUM_CONTEXT FileContext + _In_ PIRP_CONTEXT IrpContext, + _In_ PFILE_ENUM_CONTEXT FileContext ); // // VOID // CdInitializeFileContext ( -// IN PIRP_CONTEXT IrpContext, -// IN PFILE_ENUM_CONTEXT FileContext +// _In_ PIRP_CONTEXT IrpContext, +// _Out_ PFILE_ENUM_CONTEXT FileContext // ); // // // VOID // CdInitializeDirent ( -// IN PIRP_CONTEXT IrpContext, -// IN PDIRENT Dirent +// _In_ PIRP_CONTEXT IrpContext, +// _Out_ PDIRENT Dirent // ); // // VOID // CdInitializeDirContext ( -// IN PIRP_CONTEXT IrpContext, -// IN PDIRENT_ENUM_CONTEXT DirContext +// _In_ PIRP_CONTEXT IrpContext, +// _Out_ PDIRENT_ENUM_CONTEXT DirContext // ); // // VOID // CdCleanupDirent ( -// IN PIRP_CONTEXT IrpContext, -// IN PDIRENT Dirent +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PDIRENT Dirent // ); // // VOID // CdCleanupDirContext ( -// IN PIRP_CONTEXT IrpContext, -// IN PDIRENT_ENUM_CONTEXT DirContext +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PDIRENT_ENUM_CONTEXT DirContext // ); // // VOID // CdLookupInitialFileDirent ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb, -// IN PFILE_ENUM_CONTEXT FileContext, -// IN ULONG DirentOffset +// _In_ PIRP_CONTEXT IrpContext, +// _In_ PFCB Fcb, +// _Out_ PFILE_ENUM_CONTEXT FileContext, +// _In_ ULONG DirentOffset // ); // @@ -472,27 +564,33 @@ typedef enum _TYPE_OF_OPEN { } TYPE_OF_OPEN; typedef TYPE_OF_OPEN *PTYPE_OF_OPEN; +_When_(TypeOfOpen == UnopenedFileObject, _At_(Fcb, _In_opt_)) +_When_(TypeOfOpen != UnopenedFileObject, _At_(Fcb, _In_)) VOID CdSetFileObject ( - IN PIRP_CONTEXT IrpContext, - IN PFILE_OBJECT FileObject, - IN TYPE_OF_OPEN TypeOfOpen, - IN PFCB Fcb OPTIONAL, - IN PCCB Ccb OPTIONAL + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFILE_OBJECT FileObject, + _In_ TYPE_OF_OPEN TypeOfOpen, + PFCB Fcb, + _In_opt_ PCCB Ccb ); +_When_(return == UnopenedFileObject, _At_(*Fcb, _Post_null_)) +_When_(return != UnopenedFileObject, _At_(Fcb, _Outptr_)) +_When_(return == UnopenedFileObject, _At_(*Ccb, _Post_null_)) +_When_(return != UnopenedFileObject, _At_(Ccb, _Outptr_)) TYPE_OF_OPEN CdDecodeFileObject ( - IN PIRP_CONTEXT IrpContext, - IN PFILE_OBJECT FileObject, - OUT PFCB *Fcb, - OUT PCCB *Ccb + _In_ PIRP_CONTEXT IrpContext, + _In_ PFILE_OBJECT FileObject, + PFCB *Fcb, + PCCB *Ccb ); TYPE_OF_OPEN CdFastDecodeFileObject ( - IN PFILE_OBJECT FileObject, - OUT PFCB *Fcb + _In_ PFILE_OBJECT FileObject, + _Out_ PFCB *Fcb ); @@ -500,69 +598,77 @@ CdFastDecodeFileObject ( // Name support routines, implemented in NameSup.c // +_Post_satisfies_(_Old_(CdName->FileName.Length) >= + CdName->FileName.Length + CdName->VersionString.Length) VOID CdConvertNameToCdName ( - IN PIRP_CONTEXT IrpContext, - IN OUT PCD_NAME CdName + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PCD_NAME CdName ); VOID CdConvertBigToLittleEndian ( - IN PIRP_CONTEXT IrpContext, - IN PCHAR BigEndian, - IN ULONG ByteCount, - OUT PCHAR LittleEndian + _In_ PIRP_CONTEXT IrpContext, + _In_reads_bytes_(ByteCount) PCHAR BigEndian, + _In_ ULONG ByteCount, + _Out_writes_bytes_(ByteCount) PCHAR LittleEndian ); VOID CdUpcaseName ( - IN PIRP_CONTEXT IrpContext, - IN PCD_NAME Name, - IN OUT PCD_NAME UpcaseName + _In_ PIRP_CONTEXT IrpContext, + _In_ PCD_NAME Name, + _Inout_ PCD_NAME UpcaseName ); VOID CdDissectName ( - IN PIRP_CONTEXT IrpContext, - IN OUT PUNICODE_STRING RemainingName, - OUT PUNICODE_STRING FinalName + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PUNICODE_STRING RemainingName, + _Out_ PUNICODE_STRING FinalName + ); + +BOOLEAN +CdIsLegalName ( + _In_ PIRP_CONTEXT IrpContext, + _In_ PUNICODE_STRING FileName ); BOOLEAN CdIs8dot3Name ( - IN PIRP_CONTEXT IrpContext, - IN UNICODE_STRING FileName + _In_ PIRP_CONTEXT IrpContext, + _In_ UNICODE_STRING FileName ); VOID CdGenerate8dot3Name ( - IN PIRP_CONTEXT IrpContext, - IN PUNICODE_STRING FileName, - IN ULONG DirentOffset, - OUT PWCHAR ShortFileName, - OUT PUSHORT ShortByteCount + _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 ); BOOLEAN CdIsNameInExpression ( - IN PIRP_CONTEXT IrpContext, - IN PCD_NAME CurrentName, - IN PCD_NAME SearchExpression, - IN ULONG WildcardFlags, - IN BOOLEAN CheckVersion + _In_ PIRP_CONTEXT IrpContext, + _In_ PCD_NAME CurrentName, + _In_ PCD_NAME SearchExpression, + _In_ ULONG WildcardFlags, + _In_ BOOLEAN CheckVersion ); ULONG CdShortNameDirentOffset ( - IN PIRP_CONTEXT IrpContext, - IN PUNICODE_STRING Name + _In_ PIRP_CONTEXT IrpContext, + _In_ PUNICODE_STRING Name ); FSRTL_COMPARISON_RESULT CdFullCompareNames ( - IN PIRP_CONTEXT IrpContext, - IN PUNICODE_STRING NameA, - IN PUNICODE_STRING NameB + _In_ PIRP_CONTEXT IrpContext, + _In_ PUNICODE_STRING NameA, + _In_ PUNICODE_STRING NameB ); @@ -570,18 +676,20 @@ CdFullCompareNames ( // Filesystem control operations. Implemented in Fsctrl.c // +_Requires_lock_held_(_Global_critical_region_) +_Requires_lock_held_(Vcb->VcbResource) NTSTATUS CdLockVolumeInternal ( - IN PIRP_CONTEXT IrpContext, - IN PVCB Vcb, - IN PFILE_OBJECT FileObject OPTIONAL + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PVCB Vcb, + _In_opt_ PFILE_OBJECT FileObject ); NTSTATUS CdUnlockVolumeInternal ( - IN PIRP_CONTEXT IrpContext, - IN PVCB Vcb, - IN PFILE_OBJECT FileObject OPTIONAL + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PVCB Vcb, + _In_opt_ PFILE_OBJECT FileObject ); @@ -591,47 +699,48 @@ CdUnlockVolumeInternal ( VOID CdLookupPathEntry ( - IN PIRP_CONTEXT IrpContext, - IN ULONG PathEntryOffset, - IN ULONG Ordinal, - IN BOOLEAN VerifyBounds, - IN OUT PCOMPOUND_PATH_ENTRY CompoundPathEntry + _In_ PIRP_CONTEXT IrpContext, + _In_ ULONG PathEntryOffset, + _In_ ULONG Ordinal, + _In_ BOOLEAN VerifyBounds, + _Inout_ PCOMPOUND_PATH_ENTRY CompoundPathEntry ); BOOLEAN CdLookupNextPathEntry ( - IN PIRP_CONTEXT IrpContext, - IN OUT PPATH_ENUM_CONTEXT PathContext, - IN OUT PPATH_ENTRY PathEntry + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PPATH_ENUM_CONTEXT PathContext, + _Inout_ PPATH_ENTRY PathEntry ); +_Success_(return != FALSE) BOOLEAN CdFindPathEntry ( - IN PIRP_CONTEXT IrpContext, - IN PFCB ParentFcb, - IN PCD_NAME DirName, - IN BOOLEAN IgnoreCase, - IN OUT PCOMPOUND_PATH_ENTRY CompoundPathEntry + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB ParentFcb, + _In_ PCD_NAME DirName, + _In_ BOOLEAN IgnoreCase, + _Inout_ PCOMPOUND_PATH_ENTRY CompoundPathEntry ); VOID CdUpdatePathEntryName ( - IN PIRP_CONTEXT IrpContext, - IN OUT PPATH_ENTRY PathEntry, - IN BOOLEAN IgnoreCase + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PPATH_ENTRY PathEntry, + _In_ BOOLEAN IgnoreCase ); // // VOID // CdInitializeCompoundPathEntry ( -// IN PIRP_CONTEXT IrpContext, -// IN PCOMPOUND_PATH_ENTRY CompoundPathEntry +// _In_ PIRP_CONTEXT IrpContext, +// _Out_ PCOMPOUND_PATH_ENTRY CompoundPathEntry // ); // // VOID // CdCleanupCompoundPathEntry ( -// IN PIRP_CONTEXT IrpContext, -// IN PCOMPOUND_PATH_ENTRY CompoundPathEntry +// _In_ PIRP_CONTEXT IrpContext, +// _Out_ PCOMPOUND_PATH_ENTRY CompoundPathEntry // ); // @@ -655,26 +764,27 @@ CdUpdatePathEntryName ( VOID CdInsertPrefix ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN PCD_NAME Name, - IN BOOLEAN IgnoreCase, - IN BOOLEAN ShortNameMatch, - IN PFCB ParentFcb + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB Fcb, + _In_ PCD_NAME Name, + _In_ BOOLEAN IgnoreCase, + _In_ BOOLEAN ShortNameMatch, + _Inout_ PFCB ParentFcb ); VOID CdRemovePrefix ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB Fcb ); +_Requires_lock_held_(_Global_critical_region_) VOID CdFindPrefix ( - IN PIRP_CONTEXT IrpContext, - IN OUT PFCB *CurrentFcb, - IN OUT PUNICODE_STRING RemainingName, - IN BOOLEAN IgnoreCase + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB *CurrentFcb, + _Inout_ PUNICODE_STRING RemainingName, + _In_ BOOLEAN IgnoreCase ); @@ -706,93 +816,98 @@ typedef enum _TYPE_OF_ACQUIRE { } TYPE_OF_ACQUIRE, *PTYPE_OF_ACQUIRE; +_Requires_lock_held_(_Global_critical_region_) +_When_(Type == AcquireExclusive && return != FALSE, _Acquires_exclusive_lock_(*Resource)) +_When_(Type == AcquireShared && return != FALSE, _Acquires_shared_lock_(*Resource)) +_When_(Type == AcquireSharedStarveExclusive && return != FALSE, _Acquires_shared_lock_(*Resource)) +_When_(IgnoreWait == FALSE, _Post_satisfies_(return == TRUE)) BOOLEAN CdAcquireResource ( - IN PIRP_CONTEXT IrpContext, - IN PERESOURCE Resource, - IN BOOLEAN IgnoreWait, - IN TYPE_OF_ACQUIRE Type + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PERESOURCE Resource, + _In_ BOOLEAN IgnoreWait, + _In_ TYPE_OF_ACQUIRE Type ); // // BOOLEAN // CdAcquireCdData ( -// IN PIRP_CONTEXT IrpContext +// _In_ PIRP_CONTEXT IrpContext // ); // // VOID // CdReleaseCdData ( -// IN PIRP_CONTEXT IrpContext +// _In_ PIRP_CONTEXT IrpContext // ); // // BOOLEAN // CdAcquireVcbExclusive ( -// IN PIRP_CONTEXT IrpContext, -// IN PVCB Vcb, -// IN BOOLEAN IgnoreWait +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PVCB Vcb, +// _In_ BOOLEAN IgnoreWait // ); // // BOOLEAN // CdAcquireVcbShared ( -// IN PIRP_CONTEXT IrpContext, -// IN PVCB Vcb, -// IN BOOLEAN IgnoreWait +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PVCB Vcb, +// _In_ BOOLEAN IgnoreWait // ); // // VOID // CdReleaseVcb ( -// IN PIRP_CONTEXT IrpContext, -// IN PVCB Vcb +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PVCB Vcb // ); // // VOID // CdAcquireAllFiles ( -// IN PIRP_CONTEXT, -// IN PVCB Vcb +// _In_ PIRP_CONTEXT, +// _In_ PVCB Vcb // ); // // VOID // CdReleaseAllFiles ( -// IN PIRP_CONTEXT, -// IN PVCB Vcb +// _In_ PIRP_CONTEXT, +// _In_ PVCB Vcb // ); // // VOID // CdAcquireFileExclusive ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb, +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb, // ); // // VOID // CdAcquireFileShared ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb // ); // // VOID // CdReleaseFile ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb // ); // // BOOLEAN // CdAcquireFcbExclusive ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb, -// IN BOOLEAN IgnoreWait +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb, +// _In_ BOOLEAN IgnoreWait // ); // // BOOLEAN // CdAcquireFcbShared ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb, -// IN BOOLEAN IgnoreWait +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb, +// _In_ BOOLEAN IgnoreWait // ); // // BOOLEAN // CdReleaseFcb ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb // ); // // VOID @@ -805,27 +920,40 @@ CdAcquireResource ( // // VOID // CdLockVcb ( -// IN PIRP_CONTEXT IrpContext +// _In_ PIRP_CONTEXT IrpContext // ); // // VOID // CdUnlockVcb ( -// IN PIRP_CONTEXT IrpContext +// _In_ PIRP_CONTEXT IrpContext // ); // // VOID // CdLockFcb ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb // ); // // VOID // CdUnlockFcb ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb // ); // + +#define CdAcquireCacheForRead( IC) \ + ExAcquireResourceSharedLite( &(IC)->Vcb->SectorCacheResource, TRUE) + +#define CdAcquireCacheForUpdate( IC) \ + ExAcquireResourceExclusiveLite( &(IC)->Vcb->SectorCacheResource, TRUE) + +#define CdReleaseCache( IC) \ + ExReleaseResourceLite( &(IC)->Vcb->SectorCacheResource); + +#define CdConvertCacheToShared( IC) \ + ExConvertExclusiveToSharedLite( &(IC)->Vcb->SectorCacheResource); + #define CdAcquireCdData(IC) \ ExAcquireResourceExclusiveLite( &CdData.DataResource, TRUE ) @@ -878,21 +1006,38 @@ CdAcquireResource ( #define CdLockVcb(IC,V) \ ExAcquireFastMutex( &(V)->VcbMutex ); \ - ASSERT( NULL == (V)->VcbLockThread); \ + NT_ASSERT( NULL == (V)->VcbLockThread); \ (V)->VcbLockThread = PsGetCurrentThread() #define CdUnlockVcb(IC,V) \ - ASSERT( NULL != (V)->VcbLockThread); \ + NT_ASSERT( NULL != (V)->VcbLockThread); \ (V)->VcbLockThread = NULL; \ ExReleaseFastMutex( &(V)->VcbMutex ) +#if defined(_PREFAST_) + +_Success_(return) +_IRQL_saves_global_(OldIrql, FastMutex) +BOOLEAN DummySaveIrql(_Inout_ PFAST_MUTEX FastMutex); + +_Success_(return) +_IRQL_restores_global_(OldIrql, FastMutex) +BOOLEAN DummyRestoreIrql(_Inout_ PFAST_MUTEX FastMutex); +#endif // _PREFAST_ + #define CdLockFcb(IC,F) { \ PVOID _CurrentThread = PsGetCurrentThread(); \ if (_CurrentThread != (F)->FcbLockThread) { \ ExAcquireFastMutex( &(F)->FcbNonpaged->FcbMutex ); \ - ASSERT( (F)->FcbLockCount == 0 ); \ + NT_ASSERT( (F)->FcbLockCount == 0 ); \ + _Analysis_assume_( (F)->FcbLockCount == 0 ); \ (F)->FcbLockThread = _CurrentThread; \ } \ + else \ + { \ + _Analysis_assume_lock_held_( (F)->FcbNonpaged->FcbMutex ); \ + _Analysis_assume_(FALSE != DummySaveIrql(&(F)->FcbNonpaged->FcbMutex)); \ + } \ (F)->FcbLockCount += 1; \ } @@ -902,44 +1047,67 @@ CdAcquireResource ( (F)->FcbLockThread = NULL; \ ExReleaseFastMutex( &(F)->FcbNonpaged->FcbMutex ); \ } \ + else \ + { \ + _Analysis_assume_lock_not_held_( (F)->FcbNonpaged->FcbMutex ); \ + _Analysis_assume_(FALSE != DummyRestoreIrql(&(F)->FcbNonpaged->FcbMutex)); \ + } \ } +// +// The following macro is used to retrieve the oplock structure within +// the Fcb. This structure was moved to the advanced Fcb header +// in Win8. +// + +#if (NTDDI_VERSION >= NTDDI_WIN8) + +#define CdGetFcbOplock(F) &(F)->Header.Oplock + +#else + +#define CdGetFcbOplock(F) &(F)->Oplock + +#endif + BOOLEAN -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdNoopAcquire ( - IN PVOID Fcb, - IN BOOLEAN Wait + _In_ PVOID Fcb, + _In_ BOOLEAN Wait ); VOID -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdNoopRelease ( - IN PVOID Fcb + _In_ PVOID Fcb ); +_Requires_lock_held_(_Global_critical_region_) +_When_(return!=0, _Acquires_shared_lock_(*Fcb->Resource)) BOOLEAN -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdAcquireForCache ( - IN PFCB Fcb, - IN BOOLEAN Wait + _Inout_ PFCB Fcb, + _In_ BOOLEAN Wait ); +_Requires_lock_held_(_Global_critical_region_) +_Releases_lock_(*Fcb->Resource) VOID -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdReleaseFromCache ( - IN PFCB Fcb + _Inout_ PFCB Fcb ); -VOID -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ -CdAcquireForCreateSection ( - IN PFILE_OBJECT FileObject +_Requires_lock_held_(_Global_critical_region_) +NTSTATUS +CdFilterCallbackAcquireForCreateSection ( + _In_ PFS_FILTER_CALLBACK_DATA CallbackData, + _Unreferenced_parameter_ PVOID *CompletionContext ); +_Function_class_(FAST_IO_RELEASE_FILE) +_Requires_lock_held_(_Global_critical_region_) VOID -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdReleaseForCreateSection ( - IN PFILE_OBJECT FileObject + _In_ PFILE_OBJECT FileObject ); @@ -949,108 +1117,110 @@ CdReleaseForCreateSection ( VOID CdInitializeVcb ( - IN PIRP_CONTEXT IrpContext, - IN OUT PVCB Vcb, - IN PDEVICE_OBJECT TargetDeviceObject, - IN PVPB Vpb, - IN PCDROM_TOC CdromToc, - IN ULONG TocLength, - IN ULONG TocTrackCount, - IN ULONG TocDiskFlags, - IN ULONG BlockFactor, - IN ULONG MediaChangeCount + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PVCB Vcb, + _In_ __drv_aliasesMem PDEVICE_OBJECT TargetDeviceObject, + _In_ __drv_aliasesMem PVPB Vpb, + _In_ __drv_aliasesMem PCDROM_TOC_LARGE CdromToc, + _In_ ULONG TocLength, + _In_ ULONG TocTrackCount, + _In_ ULONG TocDiskFlags, + _In_ ULONG BlockFactor, + _In_ ULONG MediaChangeCount ); VOID CdUpdateVcbFromVolDescriptor ( - IN PIRP_CONTEXT IrpContext, - IN OUT PVCB Vcb, - IN PCHAR RawIsoVd OPTIONAL + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PVCB Vcb, + _In_reads_bytes_opt_(SECTOR_SIZE) PCHAR RawIsoVd ); VOID CdDeleteVcb ( - IN PIRP_CONTEXT IrpContext, - IN OUT PVCB Vcb + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PVCB Vcb ); PFCB CdCreateFcb ( - IN PIRP_CONTEXT IrpContext, - IN FILE_ID FileId, - IN NODE_TYPE_CODE NodeTypeCode, - OUT PBOOLEAN FcbExisted OPTIONAL + _In_ PIRP_CONTEXT IrpContext, + _In_ FILE_ID FileId, + _In_ NODE_TYPE_CODE NodeTypeCode, + _Out_opt_ PBOOLEAN FcbExisted ); VOID CdInitializeFcbFromPathEntry ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN PFCB ParentFcb OPTIONAL, - IN PPATH_ENTRY PathEntry + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB Fcb, + _In_opt_ PFCB ParentFcb, + _In_ PPATH_ENTRY PathEntry ); VOID CdInitializeFcbFromFileContext ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN PFCB ParentFcb OPTIONAL, - IN PFILE_ENUM_CONTEXT FileContext + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB Fcb, + _In_ PFCB ParentFcb, + _In_ PFILE_ENUM_CONTEXT FileContext ); PCCB CdCreateCcb ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN ULONG Flags + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ ULONG Flags ); VOID CdDeleteCcb ( - IN PIRP_CONTEXT IrpContext, - IN PCCB Ccb + _In_ PIRP_CONTEXT IrpContext, + _In_ __drv_freesMem( Pool ) PCCB Ccb ); +_When_(RaiseOnError || return, _At_(Fcb->FileLock, _Post_notnull_)) +_When_(RaiseOnError, _At_(IrpContext, _Pre_notnull_)) BOOLEAN CdCreateFileLock ( - IN PIRP_CONTEXT IrpContext OPTIONAL, - IN PFCB Fcb, - IN BOOLEAN RaiseOnError + _In_opt_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB Fcb, + _In_ BOOLEAN RaiseOnError ); VOID CdDeleteFileLock ( - IN PIRP_CONTEXT IrpContext, - IN PFILE_LOCK FileLock + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFILE_LOCK FileLock ); -PIRP_CONTEXT +_Ret_valid_ PIRP_CONTEXT CdCreateIrpContext ( - IN PIRP Irp, - IN BOOLEAN Wait + _In_ PIRP Irp, + _In_ BOOLEAN Wait ); VOID CdCleanupIrpContext ( - IN PIRP_CONTEXT IrpContext, - IN BOOLEAN Post + _In_ PIRP_CONTEXT IrpContext, + _In_ BOOLEAN Post ); VOID CdInitializeStackIrpContext ( - OUT PIRP_CONTEXT IrpContext, - IN PIRP_CONTEXT_LITE IrpContextLite + _Out_ PIRP_CONTEXT IrpContext, + _In_ PIRP_CONTEXT_LITE IrpContextLite ); // // PIRP_CONTEXT_LITE // CdCreateIrpContextLite ( -// IN PIRP_CONTEXT IrpContext +// _In_ PIRP_CONTEXT IrpContext // ); // // VOID // CdFreeIrpContextLite ( -// IN PIRP_CONTEXT_LITE IrpContextLite +// _Inout_ PIRP_CONTEXT_LITE IrpContextLite // ); // @@ -1060,52 +1230,53 @@ CdInitializeStackIrpContext ( #define CdFreeIrpContextLite(ICL) \ CdFreePool( &(ICL) ) +_Requires_lock_held_(_Global_critical_region_) VOID CdTeardownStructures ( - IN PIRP_CONTEXT IrpContext, - IN PFCB StartingFcb, - OUT PBOOLEAN RemovedStartingFcb + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PFCB StartingFcb, + _Out_ PBOOLEAN RemovedStartingFcb ); // // VOID // CdIncrementCleanupCounts ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb // ); // // VOID // CdDecrementCleanupCounts ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb // ); // // VOID // CdIncrementReferenceCounts ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb, -// IN ULONG ReferenceCount -// IN ULONG UserReferenceCount +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb, +// _In_ ULONG ReferenceCount +// _In_ ULONG UserReferenceCount // ); // // VOID // CdDecrementReferenceCounts ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb, -// IN ULONG ReferenceCount -// IN ULONG UserReferenceCount +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb, +// _In_ ULONG ReferenceCount +// _In_ ULONG UserReferenceCount // ); // // VOID // CdIncrementFcbReference ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb // ); // // VOID // CdDecrementFcbReference ( -// IN PIRP_CONTEXT IrpContext, -// IN PFCB Fcb +// _In_ PIRP_CONTEXT IrpContext, +// _Inout_ PFCB Fcb // ); // @@ -1157,26 +1328,26 @@ CdTeardownStructures ( PFCB CdLookupFcbTable ( - IN PIRP_CONTEXT IrpContext, - IN PVCB Vcb, - IN FILE_ID FileId + _In_ PIRP_CONTEXT IrpContext, + _In_ PVCB Vcb, + _In_ FILE_ID FileId ); PFCB CdGetNextFcb ( - IN PIRP_CONTEXT IrpContext, - IN PVCB Vcb, - IN PVOID *RestartKey + _In_ PIRP_CONTEXT IrpContext, + _In_ PVCB Vcb, + _In_ PVOID *RestartKey ); NTSTATUS CdProcessToc ( - IN PIRP_CONTEXT IrpContext, - IN PDEVICE_OBJECT TargetDeviceObject, - IN PCDROM_TOC CdromToc, - IN OUT PULONG Length, - OUT PULONG TrackCount, - OUT PULONG DiskFlags + _In_ PIRP_CONTEXT IrpContext, + _In_ PDEVICE_OBJECT TargetDeviceObject, + _In_ PCDROM_TOC_LARGE CdromToc, + _Inout_ PULONG Length, + _Out_ PULONG TrackCount, + _Inout_ PULONG DiskFlags ); // @@ -1185,19 +1356,19 @@ CdProcessToc ( // #define CdPagedPool PagedPool -#define CdNonPagedPool NonPagedPool -#define CdNonPagedPoolCacheAligned NonPagedPoolCacheAligned +#define CdNonPagedPool NonPagedPoolNx +#define CdNonPagedPoolCacheAligned NonPagedPoolNxCacheAligned // // Verification support routines. Contained in verfysup.c // -/* ReactOS Change: "LD multiple definition of `_CdOperationIsDasdOpen'" */ -static inline + +INLINE BOOLEAN -CdOperationIsDasdOpen( - IN PIRP_CONTEXT IrpContext +CdOperationIsDasdOpen ( + _In_ PIRP_CONTEXT IrpContext ) { PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation( IrpContext->Irp); @@ -1207,37 +1378,44 @@ CdOperationIsDasdOpen( (IrpSp->FileObject->RelatedFileObject == NULL)); } - +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdPerformVerify ( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp, - IN PDEVICE_OBJECT DeviceToVerify + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp, + _In_ PDEVICE_OBJECT DeviceToVerify ); +_Requires_lock_held_(_Global_critical_region_) BOOLEAN CdCheckForDismount ( - IN PIRP_CONTEXT IrpContext, - IN PVCB, - IN BOOLEAN Force + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PVCB Vcb, + _In_ BOOLEAN Force + ); + +BOOLEAN +CdMarkDevForVerifyIfVcbMounted ( + _Inout_ PVCB Vcb ); VOID CdVerifyVcb ( - IN PIRP_CONTEXT IrpContext, - IN PVCB Vcb + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PVCB Vcb ); BOOLEAN CdVerifyFcbOperation ( - IN PIRP_CONTEXT IrpContext OPTIONAL, - IN PFCB Fcb + _In_opt_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb ); +_Requires_lock_held_(_Global_critical_region_) BOOLEAN CdDismountVcb ( - IN PIRP_CONTEXT IrpContext, - IN PVCB Vcb + _In_ PIRP_CONTEXT IrpContext, + _Inout_ PVCB Vcb ); @@ -1258,8 +1436,8 @@ CdDismountVcb ( // // BOOLEAN // CdIsRawDevice ( -// IN PIRP_CONTEXT IrpContext, -// IN NTSTATUS Status +// _In_ PIRP_CONTEXT IrpContext, +// _In_ NTSTATUS Status // ); // @@ -1274,24 +1452,25 @@ CdDismountVcb ( // workque.c // +_Requires_lock_held_(_Global_critical_region_) NTSTATUS -CdFsdPostRequest( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp +CdFsdPostRequest ( + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); +_Requires_lock_held_(_Global_critical_region_) VOID -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdPrePostIrp ( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); +_Requires_lock_held_(_Global_critical_region_) VOID -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdOplockComplete ( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); @@ -1304,9 +1483,7 @@ CdOplockComplete ( // otherwise // -/* ReactOS Change: GCC doesn't understand the comment style */ -/* - //#ifndef BooleanFlagOn +//#ifndef BooleanFlagOn //#define BooleanFlagOn(F,SF) ( \ // (BOOLEAN)(((F) & (SF)) != 0) \ //) @@ -1323,20 +1500,19 @@ CdOplockComplete ( // (Flags) &= ~(SingleFlag); \ //} //#endif -*/ // // CAST // Add2Ptr ( -// IN PVOID Pointer, -// IN ULONG Increment -// IN (CAST) +// _In_ PVOID Pointer, +// _In_ ULONG Increment +// _In_ (CAST) // ); // // ULONG // PtrOffset ( -// IN PVOID BasePtr, -// IN PVOID OffsetPtr +// _In_ PVOID BasePtr, +// _In_ PVOID OffsetPtr // ); // @@ -1399,6 +1575,15 @@ CdOplockComplete ( ((ULONG) (L)) >> SECTOR_SHIFT \ ) +INLINE +ULONG +SectorsFromLlBytes( + ULONGLONG Bytes +) { + + return (ULONG)(Bytes >> SECTOR_SHIFT); +} + #define LlBytesFromSectors(L) ( \ Int64ShllMod32( (LONGLONG)(L), SECTOR_SHIFT ) \ ) @@ -1499,61 +1684,97 @@ typedef union _USHORT2 { *((USHORT2 *)(Dst)) = *((UNALIGNED USHORT2 *)(Src));\ } - +// +// This macro copies an unaligned src longword to a dst longword, +// performing an little/big endian swap. +// + +#define SwapCopyUchar4(Dst,Src) { \ + *((UNALIGNED UCHAR1 *)(Dst)) = *((UNALIGNED UCHAR1 *)(Src) + 3); \ + *((UNALIGNED UCHAR1 *)(Dst) + 1) = *((UNALIGNED UCHAR1 *)(Src) + 2); \ + *((UNALIGNED UCHAR1 *)(Dst) + 2) = *((UNALIGNED UCHAR1 *)(Src) + 1); \ + *((UNALIGNED UCHAR1 *)(Dst) + 3) = *((UNALIGNED UCHAR1 *)(Src)); \ +} + +VOID +CdLbnToMmSsFf ( + _In_ ULONG Blocks, + _Out_writes_(3) PUCHAR Msf + ); + // // Following routines handle entry in and out of the filesystem. They are // contained in CdData.c // +_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 CdFsdDispatch ( - IN PVOLUME_DEVICE_OBJECT VolumeDeviceObject, - IN PIRP Irp + _In_ PDEVICE_OBJECT DeviceObject, + _Inout_ PIRP Irp ); +// DRIVER_DISPATCH CdFsdDispatch; + LONG CdExceptionFilter ( - IN PIRP_CONTEXT IrpContext, - IN PEXCEPTION_POINTERS ExceptionPointer + _Inout_ PIRP_CONTEXT IrpContext, + _In_ PEXCEPTION_POINTERS ExceptionPointer ); +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdProcessException ( - IN PIRP_CONTEXT IrpContext OPTIONAL, - IN PIRP Irp, - IN NTSTATUS ExceptionCode + _In_opt_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp, + _In_ NTSTATUS ExceptionCode ); VOID CdCompleteRequest ( - IN PIRP_CONTEXT IrpContext OPTIONAL, - IN PIRP Irp OPTIONAL, - IN NTSTATUS Status + _Inout_opt_ PIRP_CONTEXT IrpContext, + _Inout_opt_ PIRP Irp, + _In_ NTSTATUS Status ); // // VOID // CdRaiseStatus ( -// IN PRIP_CONTEXT IrpContext, -// IN NT_STATUS Status +// _In_ PRIP_CONTEXT IrpContext, +// _In_ NT_STATUS Status // ); // // VOID // CdNormalizeAndRaiseStatus ( -// IN PRIP_CONTEXT IrpContext, -// IN NT_STATUS Status +// _In_ PRIP_CONTEXT IrpContext, +// _In_ NT_STATUS Status // ); // #if 0 #define AssertVerifyDevice(C, S) \ - ASSERT( (C) == NULL || \ + NT_ASSERT( (C) == NULL || \ FlagOn( (C)->Flags, IRP_CONTEXT_FLAG_IN_FSP ) || \ !((S) == STATUS_VERIFY_REQUIRED && \ IoGetDeviceToVerify( PsGetCurrentThread() ) == NULL )); #define AssertVerifyDeviceIrp(I) \ - ASSERT( (I) == NULL || \ + NT_ASSERT( (I) == NULL || \ !(((I)->IoStatus.Status) == STATUS_VERIFY_REQUIRED && \ ((I)->Tail.Overlay.Thread == NULL || \ IoGetDeviceToVerify( (I)->Tail.Overlay.Thread ) == NULL ))); @@ -1567,12 +1788,12 @@ CdCompleteRequest ( DECLSPEC_NORETURN VOID -CdRaiseStatusEx( - IN PIRP_CONTEXT IrpContext, - IN NTSTATUS Status, - IN BOOLEAN NormalizeStatus, - IN OPTIONAL ULONG FileId, - IN OPTIONAL ULONG Line +CdRaiseStatusEx ( + _In_ PIRP_CONTEXT IrpContext, + _In_ NTSTATUS Status, + _In_ BOOLEAN NormalizeStatus, + _In_opt_ ULONG FileId, + _In_opt_ ULONG Line ); #else @@ -1581,11 +1802,11 @@ INLINE DECLSPEC_NORETURN VOID CdRaiseStatusEx( - IN PIRP_CONTEXT IrpContext, - IN NTSTATUS Status, - IN BOOLEAN NormalizeStatus, - IN ULONG Fileid, - IN ULONG Line + _In_ PIRP_CONTEXT IrpContext, + _In_ NTSTATUS Status, + _In_ BOOLEAN NormalizeStatus, + _In_ ULONG Fileid, + _In_ ULONG Line ) { if (NormalizeStatus) { @@ -1611,93 +1832,104 @@ CdRaiseStatusEx( // Following are the fast entry points. // -BOOLEAN -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ -CdFastQueryBasicInfo ( - IN PFILE_OBJECT FileObject, - IN BOOLEAN Wait, - IN OUT PFILE_BASIC_INFORMATION Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN PDEVICE_OBJECT DeviceObject - ); +// _Success_(return != FALSE) +// BOOLEAN +// CdFastQueryBasicInfo ( +// _In_ PFILE_OBJECT FileObject, +// _In_ BOOLEAN Wait, +// _Out_ PFILE_BASIC_INFORMATION Buffer, +// _Out_ PIO_STATUS_BLOCK IoStatus, +// _In_ PDEVICE_OBJECT DeviceObject +// ); -BOOLEAN -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ -CdFastQueryStdInfo ( - IN PFILE_OBJECT FileObject, - IN BOOLEAN Wait, - IN OUT PFILE_STANDARD_INFORMATION Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN PDEVICE_OBJECT DeviceObject - ); +FAST_IO_QUERY_BASIC_INFO CdFastQueryBasicInfo; -BOOLEAN -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ -CdFastLock ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - PEPROCESS ProcessId, - ULONG Key, - BOOLEAN FailImmediately, - BOOLEAN ExclusiveLock, - OUT PIO_STATUS_BLOCK IoStatus, - IN PDEVICE_OBJECT DeviceObject - ); +// _Success_(return != FALSE) +// BOOLEAN +// CdFastQueryStdInfo ( +// _In_ PFILE_OBJECT FileObject, +// _In_ BOOLEAN Wait, +// _Out_ PFILE_STANDARD_INFORMATION Buffer, +// _Out_ PIO_STATUS_BLOCK IoStatus, +// _In_ PDEVICE_OBJECT DeviceObject +// ); -BOOLEAN -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ -CdFastUnlockSingle ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - PEPROCESS ProcessId, - ULONG Key, - OUT PIO_STATUS_BLOCK IoStatus, - IN PDEVICE_OBJECT DeviceObject - ); +FAST_IO_QUERY_STANDARD_INFO CdFastQueryStdInfo; -BOOLEAN -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ -CdFastUnlockAll ( - IN PFILE_OBJECT FileObject, - PEPROCESS ProcessId, - OUT PIO_STATUS_BLOCK IoStatus, - IN PDEVICE_OBJECT DeviceObject - ); +// BOOLEAN +// CdFastLock ( +// _In_ PFILE_OBJECT FileObject, +// _In_ PLARGE_INTEGER FileOffset, +// _In_ PLARGE_INTEGER Length, +// _In_ PEPROCESS ProcessId, +// _In_ ULONG Key, +// _In_ BOOLEAN FailImmediately, +// _In_ BOOLEAN ExclusiveLock, +// _Out_ PIO_STATUS_BLOCK IoStatus, +// _In_ PDEVICE_OBJECT DeviceObject +// ); -BOOLEAN -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ -CdFastUnlockAllByKey ( - IN PFILE_OBJECT FileObject, - PVOID ProcessId, - ULONG Key, - OUT PIO_STATUS_BLOCK IoStatus, - IN PDEVICE_OBJECT DeviceObject - ); +FAST_IO_LOCK CdFastLock; -BOOLEAN -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ -CdFastIoCheckIfPossible ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN ULONG LockKey, - IN BOOLEAN CheckForReadOperation, - OUT PIO_STATUS_BLOCK IoStatus, - IN PDEVICE_OBJECT DeviceObject - ); +// BOOLEAN +// CdFastUnlockSingle ( +// _In_ PFILE_OBJECT FileObject, +// _In_ PLARGE_INTEGER FileOffset, +// _In_ PLARGE_INTEGER Length, +// _In_ PEPROCESS ProcessId, +// _In_ ULONG Key, +// _Out_ PIO_STATUS_BLOCK IoStatus, +// _In_ PDEVICE_OBJECT DeviceObject +// ); -BOOLEAN -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ -CdFastQueryNetworkInfo ( - IN PFILE_OBJECT FileObject, - IN BOOLEAN Wait, - OUT PFILE_NETWORK_OPEN_INFORMATION Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN PDEVICE_OBJECT DeviceObject - ); +FAST_IO_UNLOCK_SINGLE CdFastUnlockSingle; + +// BOOLEAN +// CdFastUnlockAll ( +// _In_ PFILE_OBJECT FileObject, +// _In_ PEPROCESS ProcessId, +// _Out_ PIO_STATUS_BLOCK IoStatus, +// _In_ PDEVICE_OBJECT DeviceObject +// ); + +FAST_IO_UNLOCK_ALL CdFastUnlockAll; + +// BOOLEAN +// CdFastUnlockAllByKey ( +// _In_ PFILE_OBJECT FileObject, +// _In_ PVOID ProcessId, +// _In_ ULONG Key, +// _Out_ PIO_STATUS_BLOCK IoStatus, +// _In_ PDEVICE_OBJECT DeviceObject +// ); + +FAST_IO_UNLOCK_ALL_BY_KEY CdFastUnlockAllByKey; + +// BOOLEAN +// CdFastIoCheckIfPossible ( +// _In_ PFILE_OBJECT FileObject, +// _In_ PLARGE_INTEGER FileOffset, +// _In_ ULONG Length, +// _In_ BOOLEAN Wait, +// _In_ ULONG LockKey, +// _In_ BOOLEAN CheckForReadOperation, +// _Out_ PIO_STATUS_BLOCK IoStatus, +// _In_ PDEVICE_OBJECT DeviceObject +// ); + +FAST_IO_CHECK_IF_POSSIBLE CdFastIoCheckIfPossible; + +// _Success_(return != FALSE) +// BOOLEAN +// CdFastQueryNetworkInfo ( +// _In_ PFILE_OBJECT FileObject, +// _In_ BOOLEAN Wait, +// _Out_ PFILE_NETWORK_OPEN_INFORMATION Buffer, +// _Out_ PIO_STATUS_BLOCK IoStatus, +// _In_ PDEVICE_OBJECT DeviceObject +// ); + +FAST_IO_QUERY_NETWORK_OPEN_INFO CdFastQueryNetworkInfo; // // Following are the routines to handle the top level thread logic. @@ -1705,15 +1937,15 @@ CdFastQueryNetworkInfo ( VOID CdSetThreadContext ( - IN PIRP_CONTEXT IrpContext, - IN PTHREAD_CONTEXT ThreadContext + _Inout_ PIRP_CONTEXT IrpContext, + _In_ PTHREAD_CONTEXT ThreadContext ); // // VOID // CdRestoreThreadContext ( -// IN PIRP_CONTEXT IrpContext +// _Inout_ PIRP_CONTEXT IrpContext // ); // @@ -1724,8 +1956,8 @@ CdSetThreadContext ( ULONG CdSerial32 ( - IN PCHAR Buffer, - IN ULONG ByteCount + _In_reads_bytes_(ByteCount) PCHAR Buffer, + _In_ ULONG ByteCount ); // @@ -1751,7 +1983,7 @@ CdSerial32 ( #define CdIsFastIoPossible(F) ((BOOLEAN) \ ((((F)->Vcb->VcbCondition != VcbMounted ) || \ - !FsRtlOplockIsFastIoPossible( &(F)->Oplock )) ? \ + !FsRtlOplockIsFastIoPossible( CdGetFcbOplock(F) )) ? \ \ FastIoIsNotPossible : \ \ @@ -1769,14 +2001,16 @@ CdSerial32 ( // work routine. // -VOID -CdFspDispatch ( // implemented in FspDisp.c - IN PIRP_CONTEXT IrpContext - ); +// VOID +// CdFspDispatch ( // implemented in FspDisp.c +// _Inout_ PIRP_CONTEXT IrpContext +// ); + +WORKER_THREAD_ROUTINE CdFspDispatch; VOID CdFspClose ( // implemented in Close.c - IN PVCB Vcb OPTIONAL + _In_opt_ PVCB Vcb ); // @@ -1784,78 +2018,103 @@ CdFspClose ( // implemented in Close.c // based on the IrpSp major functions. // +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdCommonCreate ( // Implemented in Create.c - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdCommonClose ( // Implemented in Close.c - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdCommonRead ( // Implemented in Read.c - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); +_Requires_lock_held_(_Global_critical_region_) +NTSTATUS +CdCommonWrite ( // Implemented in Write.c + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp + ); + +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdCommonQueryInfo ( // Implemented in FileInfo.c - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdCommonSetInfo ( // Implemented in FileInfo.c - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdCommonQueryVolInfo ( // Implemented in VolInfo.c - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdCommonDirControl ( // Implemented in DirCtrl.c - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdCommonFsControl ( // Implemented in FsCtrl.c - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); NTSTATUS CdCommonDevControl ( // Implemented in DevCtrl.c - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); NTSTATUS CdCommonLockControl ( // Implemented in LockCtrl.c - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdCommonCleanup ( // Implemented in Cleanup.c - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdCommonPnp ( // Implemented in Pnp.c - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp + ); + +_Requires_lock_held_(_Global_critical_region_) +NTSTATUS +CdCommonShutdown ( // Implemented in Shutdown.c + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ); + // // The following macros are used to establish the semantics needed @@ -1885,24 +2144,17 @@ CdCommonPnp ( // Implemented in Pnp.c // #define try_return(S) { S; goto try_exit; } // -#ifndef __REACTOS__ #define try_return(S) { S; goto try_exit; } #define try_leave(S) { S; leave; } -#else -#define try_return(S) { S; goto try_exit; } -#define try_leave(S) { S; _SEH2_LEAVE; } -#endif - // // Encapsulate safe pool freeing // -/* ReactOS Change: GCC "passing argument 1 of CdFreePool from incompatible pointer type" */ -#define CdFreePool(x) _CdFreePool((PVOID*)(x)) -/* ReactOS Change: "LD multiple definition of `_CdOperationIsDasdOpen'" */ -static inline void _CdFreePool( - IN PVOID *Pool +INLINE +VOID +CdFreePool( + _Inout_ _At_(*Pool, __drv_freesMem(Mem) _Post_null_) PVOID *Pool ) { if (*Pool != NULL) { @@ -1912,6 +2164,116 @@ static inline void _CdFreePool( } } +#ifdef CDFS_TELEMETRY_DATA + +// +// CDFS Telemetry. Current implementation uses the Telemetry TraceLogging APIs. +// +// The Telemetry TraceLoggingWrite() routines use a lot of stack space. We must +// therefor wrap all our telemetry points with our own routines, and add a guard to +// make sure there's enough stack space to call these routines. +// +// These telemetry routines should not be called on high-performance code paths. +// + +TRACELOGGING_DECLARE_PROVIDER( CdTelemetryProvider ); + +VOID +CdInitializeTelemetry ( + VOID + ); + +DECLSPEC_NOINLINE +VOID +CdTelemetryMount ( + __in PGUID VolumeGuid, + __in NTSTATUS Status, + __in PVCB Vcb + ); + +// +// Every additional argument passed to TraceLoggingWrite() consumes an additional +// 16 to 32 bytes extra stack space. Having 512 bytes reserved space should be +// sufficient for up to 20 arguments or so. This will be less of course if our +// wrapper routines also declare their own local variables. +// + +#define CDFS_TELEMETRY_STACK_THRESHOLD_DEFAULT 512 // for "small" telemetry points +#define CDFS_TELEMETRY_STACK_THRESHOLD_LARGE 2048 // for "large" telemetry points + +INLINE +BOOLEAN +CdTelemetryGuard ( + __in ULONG StackSpaceNeeded ) +/*++ + +Routine Description: + + This routine returns TRUE only when: + + 1) There is an ETW listener, AND + 2) There is enough free stack space to safely call the Telemetry TraceLogging APIs + + We'll also count how many times there wasn't enough stack space, and include this + value as part of the periodic cdfs Telemetry. + +Arguments: + + StackSpaceNeeded - Stack space needed in bytes + +--*/ +{ + ASSERT( IoGetRemainingStackSize() >= StackSpaceNeeded ); + + if (CdTelemetryProvider->LevelPlus1 <= 5) { + + // + // Bail out early if there are no ETW listeners + // + + return FALSE; + } + + if (IoGetRemainingStackSize() < StackSpaceNeeded) { + + // + // Count how many times it was unsafe to generate telemetry because of + // not enough stack space. + // + + InterlockedIncrement( &CdTelemetryData.MissedTelemetryPoints ); + + return FALSE; + } + + return TRUE; +} + +#define CdTelemetryMountSafe( VolumeGuid, Status, Vcb ) \ + if (CdTelemetryGuard( CDFS_TELEMETRY_STACK_THRESHOLD_LARGE )) { \ + CdTelemetryMount( VolumeGuid, Status, Vcb ); \ + } + +#if DBG +#define CDFS_TELEMETRY_PERIODIC_INTERVAL CdTelemetryData.PeriodicInterval +#else +#define CDFS_TELEMETRY_PERIODIC_INTERVAL INTERVAL_ONE_DAY +#endif + +#else // CDFS_TELEMETRY_DATA + +// +// When CDFS_TELEMETRY_DATA is not defined then the CdTelemetry___Safe() routines +// expand to nothing. This minimizes the cdfs.sys binary footprint. This also +// means that the places where these Safe() routines are called do not +// have to have to be surrounded by #ifdef CDFS_TELEMETRY_DATA .. #endif +// + + +#define CdTelemetryMountSafe( ... ) NOTHING + +#endif // CDFS_TELEMETRY_DATA + #endif // _CDPROCS_ diff --git a/drivers/filesystems/cdfs_new/cdprocssrc.c b/drivers/filesystems/cdfs_new/cdprocssrc.c new file mode 100644 index 0000000000..a370cab122 --- /dev/null +++ b/drivers/filesystems/cdfs_new/cdprocssrc.c @@ -0,0 +1 @@ +#include "cdprocs.h" \ No newline at end of file diff --git a/drivers/filesystems/cdfs_new/cdstruc.h b/drivers/filesystems/cdfs_new/cdstruc.h index 1259349db2..72abe0a1c3 100755 --- a/drivers/filesystems/cdfs_new/cdstruc.h +++ b/drivers/filesystems/cdfs_new/cdstruc.h @@ -133,7 +133,7 @@ Abstract: 5. A fast mutex in the Vcb will protect access to the Fcb table and the open counts in the Vcb. It is also used to modify the reference counts in all Fcbs. This mutex cannot be acquired - exclusively and is an end resource. + exclusely and is an end resource. 6. A fast mutex in the Fcb will synchronize access to all Fcb fields which aren't synchronized in some other way. A thread may acquire @@ -244,7 +244,7 @@ typedef struct _CD_NAME { UNICODE_STRING FileName; // - // String containing the version number. + // String containging the version number. // UNICODE_STRING VersionString; @@ -318,7 +318,7 @@ typedef struct _CD_DATA { // The type and size of this record (must be CDFS_NTC_DATA_HEADER) // - NODE_TYPE_CODE NodeTypeCode; + _Field_range_(==, CDFS_NTC_DATA_HEADER) NODE_TYPE_CODE NodeTypeCode; NODE_BYTE_SIZE NodeByteSize; // @@ -349,10 +349,6 @@ typedef struct _CD_DATA { PDEVICE_OBJECT FileSystemDeviceObject; -#ifdef __REACTOS__ - PDEVICE_OBJECT HddFileSystemDeviceObject; -#endif - // // Following are used to manage the async and delayed close queue. // @@ -360,7 +356,7 @@ typedef struct _CD_DATA { // two close queues. // ReduceDelayedClose - Indicates that we have hit the upper threshold // for the delayed close queue and need to reduce it to lower threshold. - // + // Flags - CD flags. // AsyncCloseQueue - Queue of IrpContext waiting for async close operation. // AsyncCloseCount - Number of entries on the async close queue. // @@ -368,7 +364,7 @@ typedef struct _CD_DATA { // operation. // MaxDelayedCloseCount - Trigger delay close work at this threshold. // MinDelayedCloseCount - Turn off delay close work at this threshold. - // DelayedCloseCount - Number of entries on the delayed close queue. + // DelayedCloseCount - Number of entries on the delayted close queue. // // CloseItem - Workqueue item used to start FspClose thread. // @@ -377,7 +373,7 @@ typedef struct _CD_DATA { ULONG AsyncCloseCount; BOOLEAN FspCloseActive; BOOLEAN ReduceDelayedClose; - USHORT PadUshort; + USHORT Flags; // // The following fields describe the deferred close file objects. @@ -418,7 +414,48 @@ typedef struct _CD_DATA { } CD_DATA; typedef CD_DATA *PCD_DATA; - + +#define CD_FLAGS_SHUTDOWN (0x0001) + + +// +// Since DVD drives allow > 100 "sessions", we need to use a larger TOC +// than the legacy CD definition. The maximum is theoretically 0xaa-16 (max +// number of open tracks in a session), but it's quite possible that some +// drive does not enforce this, so we'll go with 169 (track 0xaa is always the +// leadout). +// + +#define MAXIMUM_NUMBER_TRACKS_LARGE 0xAA + +typedef struct _CDROM_TOC_LARGE { + + // + // Header + // + + UCHAR Length[2]; // add two bytes for this field + UCHAR FirstTrack; + UCHAR LastTrack; + + // + // Track data + // + + TRACK_DATA TrackData[ MAXIMUM_NUMBER_TRACKS_LARGE]; + +} CDROM_TOC_LARGE, *PCDROM_TOC_LARGE; + +typedef struct _CD_SECTOR_CACHE_CHUNK { + + ULONG BaseLbn; + PUCHAR Buffer; + +} CD_SECTOR_CACHE_CHUNK, *PCD_SECTOR_CACHE_CHUNK; + +#define CD_SEC_CACHE_CHUNKS 4 +#define CD_SEC_CHUNK_BLOCKS 0x18 + // // The Vcb (Volume control block) record corresponds to every // volume mounted by the file system. They are ordered in a queue off @@ -460,7 +497,7 @@ typedef struct _VCB { // The type and size of this record (must be CDFS_NTC_VCB) // - NODE_TYPE_CODE NodeTypeCode; + _Field_range_(==, CDFS_NTC_VCB) NODE_TYPE_CODE NodeTypeCode; NODE_BYTE_SIZE NodeByteSize; // @@ -508,8 +545,8 @@ typedef struct _VCB { // ULONG VcbCleanup; - LONG VcbReference; /* ReactOS Change: GCC 'pointer targets in passing argument 1 of 'InterlockedXxx' differ in signedness */ - LONG VcbUserReference; /* ReactOS Change: GCC 'pointer targets in passing argument 1 of 'InterlockedXxx' differ in signedness */ + __volatile ULONG VcbReference; + __volatile ULONG VcbUserReference; // // Fcb for the Volume Dasd file, root directory and the Path Table. @@ -593,7 +630,7 @@ typedef struct _VCB { // Volume TOC. Cache this information for quick lookup. // - PCDROM_TOC CdromToc; + PCDROM_TOC_LARGE CdromToc; ULONG TocLength; ULONG TrackCount; ULONG DiskFlags; @@ -625,8 +662,42 @@ typedef struct _VCB { PVPB SwapVpb; -} VCB; -typedef VCB *PVCB; + // + // Directory block cache. Read large numbers of blocks on directory + // reads, hoping to benefit from the fact that most mastered/pressed + // discs clump metadata in one place thus allowing us to crudely + // pre-cache and reduce seeks back to directory data during app install, + // file copy etc. + // + // Note that the purpose of this is to PRE cache unread data, + // not cache already read data (since Cc already provides that), thus + // speeding initial access to the volume. + // + + PUCHAR SectorCacheBuffer; + CD_SECTOR_CACHE_CHUNK SecCacheChunks[ CD_SEC_CACHE_CHUNKS]; + ULONG SecCacheLRUChunkIndex; + + PIRP SectorCacheIrp; + KEVENT SectorCacheEvent; + ERESOURCE SectorCacheResource; + +#ifdef CDFS_TELEMETRY_DATA + + // + // An ID that is common across the volume stack used to correlate volume events and for telemetry purposes. + // It may have a different value than the VolumeGuid. + // + + GUID VolumeCorrelationId; + +#endif // CDFS_TELEMETRY_DATA + +#if DBG + ULONG SecCacheHits; + ULONG SecCacheMisses; +#endif +} VCB, *PVCB; #define VCB_STATE_HSG (0x00000001) #define VCB_STATE_ISO (0x00000002) @@ -637,6 +708,8 @@ typedef VCB *PVCB; #define VCB_STATE_AUDIO_DISK (0x00000080) #define VCB_STATE_NOTIFY_REMOUNT (0x00000100) #define VCB_STATE_VPB_NOT_ON_DEVICE (0x00000200) +#define VCB_STATE_SHUTDOWN (0x00000400) +#define VCB_STATE_DISMOUNTED (0x00000800) // @@ -659,7 +732,7 @@ typedef struct _VOLUME_DEVICE_OBJECT { // executed later. // - LONG PostedRequestCount; /* ReactOS Change: GCC "pointer targets in passing argument 1 of 'InterlockedDecrement' differ in signedness" */ + __volatile ULONG PostedRequestCount; // // The following field indicates the number of IRP's waiting @@ -706,12 +779,14 @@ typedef enum _FCB_CONDITION { typedef struct _FCB_DATA { +#if (NTDDI_VERSION < NTDDI_WIN8) // // The following field is used by the oplock module // to maintain current oplock information. // OPLOCK Oplock; +#endif // // The following field is used by the filelock module @@ -780,12 +855,12 @@ typedef struct _FCB_NONPAGED { // Type and size of this record must be CDFS_NTC_FCB_NONPAGED // - NODE_TYPE_CODE NodeTypeCode; + _Field_range_(==, CDFS_NTC_FCB_NONPAGED) NODE_TYPE_CODE NodeTypeCode; NODE_BYTE_SIZE NodeByteSize; // // The following field contains a record of special pointers used by - // MM and Cache to manipulate section objects. Note that the values + // MM and Cache to manipluate section objects. Note that the values // are set outside of the file system. However the file system on an // open/create will set the file object's SectionObject field to // point to this field @@ -882,7 +957,7 @@ typedef struct _FCB { // ULONG FcbCleanup; - LONG FcbReference; /* ReactOS Change: GCC 'pointer targets in passing argument 1 of 'InterlockedXxx' differ in signedness */ + __volatile ULONG FcbReference; ULONG FcbUserReference; // @@ -991,7 +1066,7 @@ typedef struct _CCB { // Type and size of this record (must be CDFS_NTC_CCB) // - NODE_TYPE_CODE NodeTypeCode; + _Field_range_(==, CDFS_NTC_CCB) NODE_TYPE_CODE NodeTypeCode; NODE_BYTE_SIZE NodeByteSize; // @@ -1026,6 +1101,7 @@ typedef CCB *PCCB; #define CCB_FLAG_IGNORE_CASE (0x00000004) #define CCB_FLAG_OPEN_WITH_VERSION (0x00000008) #define CCB_FLAG_DISMOUNT_ON_CLOSE (0x00000010) +#define CCB_FLAG_ALLOW_EXTENDED_DASD_IO (0x00000020) // // Following flags refer to index enumeration. @@ -1041,7 +1117,7 @@ typedef CCB *PCCB; // -// The Irp Context record is allocated for every originating Irp. It is +// The Irp Context record is allocated for every orginating Irp. It is // created by the Fsd dispatch routines, and deallocated by the CdComplete // request routine // @@ -1052,7 +1128,7 @@ typedef struct _IRP_CONTEXT { // Type and size of this record (must be CDFS_NTC_IRP_CONTEXT) // - NODE_TYPE_CODE NodeTypeCode; + _Field_range_(==, CDFS_NTC_IRP_CONTEXT) NODE_TYPE_CODE NodeTypeCode; NODE_BYTE_SIZE NodeByteSize; // @@ -1197,7 +1273,7 @@ typedef struct _IRP_CONTEXT_LITE { // Type and size of this record (must be CDFS_NTC_IRP_CONTEXT_LITE) // - NODE_TYPE_CODE NodeTypeCode; + _Field_range_(==, CDFS_NTC_IRP_CONTEXT_LITE) NODE_TYPE_CODE NodeTypeCode; NODE_BYTE_SIZE NodeByteSize; // @@ -1242,9 +1318,9 @@ typedef struct _CD_IO_CONTEXT { // These two fields are used for multiple run Io // - LONG IrpCount; + __volatile LONG IrpCount; PIRP MasterIrp; - NTSTATUS Status; + __volatile NTSTATUS Status; BOOLEAN AllocatedContext; union { @@ -1491,7 +1567,7 @@ typedef DIRENT_ENUM_CONTEXT *PDIRENT_ENUM_CONTEXT; // // Following structure is used to smooth out the differences in the HSG, ISO -// and Joliet directory entries. +// and Joliett directory entries. // typedef struct _DIRENT { @@ -1763,5 +1839,71 @@ typedef AUDIO_PLAY_HEADER *PAUDIO_PLAY_HEADER; } \ } +#ifdef CDFS_TELEMETRY_DATA +// ============================================================================ +// ============================================================================ +// +// Telemetry +// +// ============================================================================ +// ============================================================================ + +typedef struct _CDFS_TELEMETRY_DATA_CONTEXT { + + // + // Number of times there was not enough stack space to generate telemetry + // + + volatile LONG MissedTelemetryPoints; + + // + // System Time of the last periodic telemtry event. System Time + // is according to KeQuerySystemTime() + // + + LARGE_INTEGER LastPeriodicTelemetrySystemTime; + + // + // TickCount of the last periodic telemtry event. TickCount is + // according to KeQueryTickCount() + // + + LARGE_INTEGER LastPeriodicTelemetryTickCount; + + // + // Hint for Worker thread whether to generate + // periodic telemetry or not + // + + BOOLEAN GeneratePeriodicTelemetry; + + // + // Guid for ID parity with other file systems telemetry. + // + + GUID VolumeGuid; + + +#if DBG + + // + // For DBG builds we want a machanism to change the frequency of + // periodic events + // + + LONGLONG PeriodicInterval; + +#endif + + // + // File system statistics at time of last period telemetry event + // + + FILESYSTEM_STATISTICS CommonStats; + +} CDFS_TELEMETRY_DATA_CONTEXT, *PCDFS_TELEMETRY_DATA_CONTEXT; + +#endif // CDFS_TELEMETRY_DATA + #endif // _CDSTRUC_ diff --git a/drivers/filesystems/cdfs_new/cleanup.c b/drivers/filesystems/cdfs_new/cleanup.c index a89be2ffef..a0d8ce43fc 100755 --- a/drivers/filesystems/cdfs_new/cleanup.c +++ b/drivers/filesystems/cdfs_new/cleanup.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "cdprocs.h" +#include "CdProcs.h" // // The Bug check file id for this module @@ -22,11 +22,11 @@ Abstract: #define BugCheckFileId (CDFS_BUG_CHECK_CLEANUP) - +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdCommonCleanup ( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ) /*++ @@ -82,7 +82,7 @@ Return Value: TYPE_OF_OPEN TypeOfOpen; BOOLEAN SendUnlockNotification = FALSE; - BOOLEAN AttemptTeardown; + BOOLEAN AttemptTeardown = FALSE; BOOLEAN VcbAcquired = FALSE; PVCB Vcb; @@ -148,7 +148,38 @@ Return Value: SetFlag( FileObject->Flags, FO_CLEANUP_COMPLETE ); CdReleaseFile( IrpContext, Fcb); - + + if (TypeOfOpen == UserVolumeOpen) { + + // + // For a force dismount, physically disconnect this Vcb from the device so + // a new mount can occur. Vcb deletion cannot happen at this time since + // there is a reference on it associated with this very request, but we'll + // call check for dismount again later after we process this close. + // + + if (FlagOn( Ccb->Flags, CCB_FLAG_DISMOUNT_ON_CLOSE )) { + + CdAcquireCdData( IrpContext ); + + CdCheckForDismount( IrpContext, Vcb, TRUE ); + + CdReleaseCdData( IrpContext ); + + // + // If this handle actually wrote something, flush the device buffers, + // and then set the verify bit now just to be safe (in case there is no + // dismount). + // + + } else if (FlagOn( FileObject->Flags, FO_FILE_MODIFIED )) { + + CdHijackIrpAndFlushDevice( IrpContext, Irp, Vcb->TargetDeviceObject ); + + CdMarkDevForVerifyIfVcbMounted( Vcb ); + } + } + // // Acquire the current file. // @@ -159,7 +190,7 @@ Return Value: // Use a try-finally to facilitate cleanup. // - _SEH2_TRY { + try { // // Case on the type of open that we are trying to cleanup. @@ -187,7 +218,7 @@ Return Value: // need to check for STATUS_PENDING. // - FsRtlCheckOplock( &Fcb->Oplock, + FsRtlCheckOplock( CdGetFcbOplock(Fcb), Irp, IrpContext, NULL, @@ -221,12 +252,13 @@ Return Value: break; - case UserVolumeOpen : + case UserVolumeOpen: break; default : +#pragma prefast( suppress:__WARNING_USE_OTHER_FUNCTION, "argument bogus" ) CdBugCheck( TypeOfOpen, 0, 0 ); } @@ -257,7 +289,7 @@ Return Value: if (FileObject == Vcb->VolumeLockFileObject) { - ASSERT( FlagOn( Vcb->VcbState, VCB_STATE_LOCKED)); + NT_ASSERT( FlagOn( Vcb->VcbState, VCB_STATE_LOCKED)); IoAcquireVpbSpinLock( &SavedIrql ); @@ -279,15 +311,15 @@ Return Value: IoRemoveShareAccess( FileObject, &Fcb->ShareAccess ); - } _SEH2_FINALLY { + } finally { - CdReleaseFcb( IrpContext, Fcb ); + CdReleaseFcb( IrpContext, Fcb ); if (SendUnlockNotification) { FsRtlNotifyVolumeEvent( FileObject, FSRTL_VOLUME_UNLOCK ); } - } _SEH2_END; + } // // If appropriate, try to spark teardown by purging the volume. Should @@ -305,19 +337,19 @@ Return Value: CdAcquireCdData( IrpContext); - _SEH2_TRY { + try { CdAcquireVcbExclusive( IrpContext, Vcb, FALSE ); VcbAcquired = TRUE; CdPurgeVolume( IrpContext, Vcb, FALSE ); - } _SEH2_FINALLY { + } finally { if (VcbAcquired) { CdReleaseVcb( IrpContext, Vcb ); } CdReleaseCdData( IrpContext); - } _SEH2_END; + } } // diff --git a/drivers/filesystems/cdfs_new/close.c b/drivers/filesystems/cdfs_new/close.c index d2827793c6..5e45587544 100755 --- a/drivers/filesystems/cdfs_new/close.c +++ b/drivers/filesystems/cdfs_new/close.c @@ -42,7 +42,7 @@ Abstract: --*/ -#include "cdprocs.h" +#include "CdProcs.h" // // The Bug check file id for this module @@ -54,36 +54,40 @@ Abstract: // Local support routines // +_Requires_lock_held_(_Global_critical_region_) BOOLEAN CdCommonClosePrivate ( - IN PIRP_CONTEXT IrpContext, - IN PVCB Vcb, - IN PFCB Fcb, - IN ULONG UserReference, - IN BOOLEAN FromFsd + _In_ PIRP_CONTEXT IrpContext, + _In_ PVCB Vcb, + _In_ PFCB Fcb, + _In_ ULONG UserReference, + _In_ BOOLEAN FromFsd ); VOID CdQueueClose ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN ULONG UserReference, - IN BOOLEAN DelayedClose + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ ULONG UserReference, + _In_ BOOLEAN DelayedClose ); PIRP_CONTEXT CdRemoveClose ( - IN PVCB Vcb OPTIONAL + _In_opt_ PVCB Vcb ); +// Tell prefast this is a workitem routine +IO_WORKITEM_ROUTINE CdCloseWorker; + VOID -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdCloseWorker ( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context + _In_ PDEVICE_OBJECT DeviceObject, + _In_opt_ PVOID Context ); #ifdef ALLOC_PRAGMA +#pragma alloc_text(PAGE, CdFspClose) #pragma alloc_text(PAGE, CdCommonClose) #pragma alloc_text(PAGE, CdCommonClosePrivate) #pragma alloc_text(PAGE, CdQueueClose) @@ -94,7 +98,7 @@ CdCloseWorker ( VOID CdFspClose ( - IN PVCB Vcb OPTIONAL + _In_opt_ PVCB Vcb ) /*++ @@ -120,7 +124,7 @@ Return Value: PIRP_CONTEXT IrpContext; IRP_CONTEXT StackIrpContext; - THREAD_CONTEXT ThreadContext; + THREAD_CONTEXT ThreadContext = {0}; PFCB Fcb; ULONG UserReference; @@ -137,8 +141,8 @@ Return Value: // // Continue processing until there are no more closes to process. // - /* ReactOS Change: "GCC suggest parentheses around assignment used as truth value" */ - while ((IrpContext = CdRemoveClose( Vcb ))) { + + while ((IrpContext = CdRemoveClose( Vcb )) != NULL) { // // If we don't have an IrpContext then use the one on the stack. @@ -166,7 +170,7 @@ Return Value: // Free the IrpContextLite. // - CdFreeIrpContextLite( IrpContext ); /* ReactOS Change: GCC "error: invalid lvalue in unary '&'" */ + CdFreeIrpContextLite( (PIRP_CONTEXT_LITE) IrpContext ); // // Remember we have the IrpContext from the stack. @@ -191,6 +195,8 @@ Return Value: IrpContext->ExceptionStatus = STATUS_SUCCESS; } + _Analysis_assume_(Fcb != NULL && Fcb->Vcb != NULL); + // // We have an IrpContext. Now we need to set the top level thread // context. @@ -261,6 +267,9 @@ Return Value: } CurrentVcb = Fcb->Vcb; + + _Analysis_assume_( CurrentVcb != NULL ); + CdAcquireVcbShared( IrpContext, CurrentVcb, FALSE ); VcbHoldCount = 0; @@ -309,14 +318,15 @@ Return Value: } +#pragma prefast(suppress:26165, "Esp:1153") FsRtlExitFileSystem(); } - +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdCommonClose ( - IN PIRP_CONTEXT IrpContext, - IN PIRP Irp + _Inout_ PIRP_CONTEXT IrpContext, + _Inout_ PIRP Irp ) /*++ @@ -349,7 +359,6 @@ Return Value: ULONG UserReference = 0; BOOLEAN PotentialVcbTeardown = FALSE; - BOOLEAN ForceDismount = FALSE; PAGED_CODE(); @@ -397,13 +406,6 @@ Return Value: UserReference = 1; - // - // Was a FSCTL_DISMOUNT issued on this handle? If so, we need to - // force a dismount of the volume now. - // - - ForceDismount = BooleanFlagOn( Ccb->Flags, CCB_FLAG_DISMOUNT_ON_CLOSE); - // // We can always deallocate the Ccb if present. // @@ -431,7 +433,8 @@ Return Value: // if we can't acquire all of the resources. // - } else { + } + else { // // If we may be dismounting this volume then acquire the CdData @@ -439,7 +442,7 @@ Return Value: // // Since we now must make volumes go away as soon as reasonable after // the last user handles closes, key off of the cleanup count. It is - // OK to do this more than necessary. Since this Fcb could be holding + // OK to do this more than neccesary. Since this Fcb could be holding // a number of other Fcbs (and thus their references), a simple check // on reference count is not appropriate. // @@ -447,33 +450,17 @@ Return Value: // common case. // - if (((Vcb->VcbCleanup == 0) || ForceDismount) && + if ((Vcb->VcbCleanup == 0) && (Vcb->VcbCondition != VcbMounted)) { // - // Possible. Acquire CdData to synchronise with the remount path, and - // then repeat the tests. - // - // Note that we must send the notification outside of any locks, since - // the worker that processes the notify could also be calling into our - // pnp path which wants both CdData and VcbResource. For a force dismount - // the volume will be marked invalid (no going back), so we will definitely - // go ahead and dismount below. + // Possible dismount. Acquire CdData to synchronise with the remount path + // before looking at the vcb condition again. // - if (ForceDismount) { - - // - // Send notification. - // - - FsRtlNotifyVolumeEvent( IoGetCurrentIrpStackLocation( Irp )->FileObject, - FSRTL_VOLUME_DISMOUNT ); - } - CdAcquireCdData( IrpContext ); - if (((Vcb->VcbCleanup == 0) || ForceDismount) && + if ((Vcb->VcbCleanup == 0) && (Vcb->VcbCondition != VcbMounted) && (Vcb->VcbCondition != VcbMountInProgress) && FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_TOP_LEVEL_CDFS )) { @@ -486,21 +473,16 @@ Return Value: // We can't dismount this volume now, there are other references or // it's just been remounted. // - - CdReleaseCdData( IrpContext); } - } - if (ForceDismount) { - // - // Physically disconnect this Vcb from the device so a new mount can - // occur. Vcb deletion cannot happen at this time since there is - // a handle on it associated with this very request, but we'll call - // check for dismount again later anyway. + // Drop the global lock if we don't need it anymore. // - CdCheckForDismount( IrpContext, Vcb, TRUE ); + if (!PotentialVcbTeardown) { + + CdReleaseCdData( IrpContext ); + } } // @@ -522,7 +504,8 @@ Return Value: // the request. // - } else if (PotentialVcbTeardown) { + } + else if (PotentialVcbTeardown) { CdCheckForDismount( IrpContext, Vcb, FALSE ); } @@ -551,13 +534,14 @@ Return Value: // Local support routine // +_Requires_lock_held_(_Global_critical_region_) BOOLEAN CdCommonClosePrivate ( - IN PIRP_CONTEXT IrpContext, - IN PVCB Vcb, - IN PFCB Fcb, - IN ULONG UserReference, - IN BOOLEAN FromFsd + _In_ PIRP_CONTEXT IrpContext, + _In_ PVCB Vcb, + _In_ PFCB Fcb, + _In_ ULONG UserReference, + _In_ BOOLEAN FromFsd ) /*++ @@ -651,6 +635,9 @@ Return Value: CdReleaseFcb( IrpContext, Fcb ); } + else { + _Analysis_assume_lock_not_held_(Fcb->FcbNonpaged->FcbResource); + } // // Release the Vcb and return to our caller. Let him know we completed @@ -663,10 +650,9 @@ Return Value: } VOID -NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */ CdCloseWorker ( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context + _In_ PDEVICE_OBJECT DeviceObject, + _In_opt_ PVOID Context ) /*++ @@ -687,16 +673,21 @@ Return Value: --*/ { + PAGED_CODE(); + + UNREFERENCED_PARAMETER( DeviceObject ); + UNREFERENCED_PARAMETER( Context ); + CdFspClose (NULL); } VOID CdQueueClose ( - IN PIRP_CONTEXT IrpContext, - IN PFCB Fcb, - IN ULONG UserReference, - IN BOOLEAN DelayedClose + _In_ PIRP_CONTEXT IrpContext, + _In_ PFCB Fcb, + _In_ ULONG UserReference, + _In_ BOOLEAN DelayedClose ) /*++ @@ -880,7 +871,7 @@ Return Value: PIRP_CONTEXT CdRemoveClose ( - IN PVCB Vcb OPTIONAL + _In_opt_ PVCB Vcb ) /*++ diff --git a/drivers/filesystems/cdfs_new/create.c b/drivers/filesystems/cdfs_new/create.c index 3cab9b9ff9..695121df0f 100755 --- a/drivers/filesystems/cdfs_new/create.c +++ b/drivers/filesystems/cdfs_new/create.c @@ -14,7 +14,7 @@ Abstract: --*/ -#include "cdprocs.h" +#include "CdProcs.h" // // The Bug check file id for this module @@ -26,73 +26,84 @@ Abstract: // Local support routines // +_When_(RelatedTypeOfOpen != UnopenedFileObject, _At_(RelatedCcb, _In_)) +_When_(RelatedTypeOfOpen == UnopenedFileObject, _At_(RelatedCcb, _In_opt_)) +_When_(RelatedTypeOfOpen != UnopenedFileObject, _At_(RelatedFileName, _In_)) +_When_(RelatedTypeOfOpen == UnopenedFileObject, _At_(RelatedFileName, _In_opt_)) NTSTATUS CdNormalizeFileNames ( - IN PIRP_CONTEXT IrpContext, - IN PVCB Vcb, - IN BOOLEAN OpenByFileId, - IN BOOLEAN IgnoreCase, - IN TYPE_OF_OPEN RelatedTypeOfOpen, - IN PCCB RelatedCcb OPTIONAL, - IN PUNICODE_STRING RelatedFileName OPTIONAL, - IN OUT PUNICODE_STRING FileName, - IN OUT PCD_NAME RemainingName + _Inout_ PIRP_CONTEXT IrpContext, + _In_ PVCB Vcb, + _In_ BOOLEAN OpenByFileId, + _In_ BOOLEAN IgnoreCase, + _In_ TYPE_OF_OPEN RelatedTypeOfOpen, + PCCB RelatedCcb, + PUNICODE_STRING RelatedFileName, + _Inout_ PUNICODE_STRING FileName, + _Inout_ PCD_NAME RemainingName ); +_Requires_lock_held_(_Global_critical_region_) +_Acquires_exclusive_lock_((*CurrentFcb)->FcbNonpaged->FcbResource) NTSTATUS CdOpenByFileId ( - IN PIRP_CONTEXT IrpContext, - IN PIO_STACK_LOCATION IrpSp, - IN PVCB Vcb, - IN OUT PFCB *CurrentFcb + _In_ PIRP_CONTEXT IrpContext, + _In_ PIO_STACK_LOCATION IrpSp, + _In_ PVCB Vcb, + _Inout_ PFCB *CurrentFcb ); +_Requires_lock_held_(_Global_critical_region_) NTSTATUS CdOpenExistingFcb ( - IN PIRP_CONTEXT IrpContext, - IN PIO_STACK_LOCATION IrpSp, - IN OUT PFCB *CurrentFcb, - IN TYPE_OF_OPEN TypeOfOpen, - IN BOOLEAN IgnoreCase, - IN PCCB RelatedCcb OPTIONAL + _In_ PIRP_CONTEXT IrpContext, + _In_ PIO_STACK_LOCATION IrpSp, + _Inout_ PFCB *CurrentFcb, + _In_ TYPE_OF_OPEN TypeOfOpen, + _In_ BOOLEAN IgnoreCase, + _In_opt_ PCCB RelatedCcb ); +_Requires_lock_held_(_Global_critical_region_) +_Acquires_lock_((*CurrentFcb)->FcbNonpaged->FcbResource) NTSTATUS CdOpenDirectoryFromPathEntry ( - IN PIRP_CONTEXT IrpContext, - IN PIO_STACK_LOCATION IrpSp, - IN PVCB Vcb, - IN OUT PFCB *CurrentFcb, - IN PCD_NAME DirName, - IN BOOLEAN IgnoreCase, - IN BOOLEAN ShortNameMatch, - IN PPATH_ENTRY PathEntry, - IN BOOLEAN PerformUserOpen, - IN PCCB RelatedCcb OPTIONAL + _In_ PIRP_CONTEXT IrpContext, + _In_ PIO_STACK_LOCATION IrpSp, + _In_ PVCB Vcb, + _Inout_ PFCB *CurrentFcb, + _In_ PCD_NAME DirName, + _In_ BOOLEAN IgnoreCase, + _In_ BOOLEAN ShortNameMatch, + _In_ PPATH_ENTRY PathEntry, + _In_ BOOLEAN PerformUserOpen, ... 10456 lines suppressed ...
7 years
1
0
0
0
[reactos] 01/01: [SHELL32] Don't show error when closing disk prop sheet (#144)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=87d276f05d673e53a4132…
commit 87d276f05d673e53a413269099eeb1e7882ec825 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Sat Nov 25 18:27:20 2017 +0900 [SHELL32] Don't show error when closing disk prop sheet (#144) CORE-14035 --- dll/win32/shell32/dialogs/drive.cpp | 16 ++++++++++------ dll/win32/shell32/dialogs/fprop.cpp | 3 ++- dll/win32/shell32/folders/CDrivesFolder.cpp | 4 ++-- dll/win32/shell32/wine/shell32_main.h | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/dll/win32/shell32/dialogs/drive.cpp b/dll/win32/shell32/dialogs/drive.cpp index a5919f027f..3afbe80d8c 100644 --- a/dll/win32/shell32/dialogs/drive.cpp +++ b/dll/win32/shell32/dialogs/drive.cpp @@ -2,6 +2,7 @@ * Shell Library Functions * * Copyright 2005 Johannes Anderwald + * Copyright 2017 Katayama Hirofumi MZ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -127,7 +128,7 @@ typedef struct _DRIVE_PROP_PAGE UINT DriveType; } DRIVE_PROP_PAGE; -BOOL +HRESULT SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, PCUITEMID_CHILD_ARRAY apidl) { HPSXA hpsx = NULL; @@ -145,7 +146,7 @@ SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, PCUITEMID_CHI LPITEMIDLIST completePidl = ILCombine(pidlFolder, apidl[0]); if (!completePidl) - return FALSE; + return E_OUTOFMEMORY; if (ILGetDisplayNameExW(NULL, completePidl, wszName, ILGDN_NORMAL)) { @@ -179,16 +180,19 @@ SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, PCUITEMID_CHI SHAddFromPropSheetExtArray(hpsx, (LPFNADDPROPSHEETPAGE)AddPropSheetPageCallback, (LPARAM)&psh); } - HWND hwnd = (HWND)PropertySheetW(&psh); + // NOTE: Currently property sheet is modal. If we make it modeless, then it returns HWND. + INT_PTR ret = PropertySheetW(&psh); if (hpsx) SHDestroyPropSheetExtArray(hpsx); if (pDrvDefExt) pDrvDefExt->Release(); - if (!hwnd) - return FALSE; - return TRUE; + if (ret > 0) + return S_OK; + if (ret == 0) + return S_FALSE; + return E_FAIL; } static VOID diff --git a/dll/win32/shell32/dialogs/fprop.cpp b/dll/win32/shell32/dialogs/fprop.cpp index ede236fa85..989a9ce6c1 100644 --- a/dll/win32/shell32/dialogs/fprop.cpp +++ b/dll/win32/shell32/dialogs/fprop.cpp @@ -3,6 +3,7 @@ * * Copyright 2005 Johannes Anderwald * Copyright 2012 Rafal Harabien + * Copyright 2017 Katayama Hirofumi MZ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -117,7 +118,7 @@ SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, PCUITEMID_CH /* Handle drives */ if (PathIsRootW(wszPath)) - return SH_ShowDriveProperties(wszPath, pidlFolder, apidl); + return SUCCEEDED(SH_ShowDriveProperties(wszPath, pidlFolder, apidl)); /* Handle files and folders */ PROPSHEETHEADERW Header; diff --git a/dll/win32/shell32/folders/CDrivesFolder.cpp b/dll/win32/shell32/folders/CDrivesFolder.cpp index 701a10643f..196165597f 100644 --- a/dll/win32/shell32/folders/CDrivesFolder.cpp +++ b/dll/win32/shell32/folders/CDrivesFolder.cpp @@ -215,9 +215,9 @@ HRESULT CALLBACK DrivesContextMenuCallback(IShellFolder *psf, if (wParam == DFM_CMD_PROPERTIES) { - if (!SH_ShowDriveProperties(wszBuf, pidlFolder, apidl)) + hr = SH_ShowDriveProperties(wszBuf, pidlFolder, apidl); + if (FAILED(hr)) { - hr = E_FAIL; dwError = ERROR_CAN_NOT_COMPLETE; nStringID = IDS_CANTSHOWPROPERTIES; } diff --git a/dll/win32/shell32/wine/shell32_main.h b/dll/win32/shell32/wine/shell32_main.h index 8e17caf421..170d844b4b 100644 --- a/dll/win32/shell32/wine/shell32_main.h +++ b/dll/win32/shell32/wine/shell32_main.h @@ -184,7 +184,7 @@ BOOL SHELL_IsShortcut(LPCITEMIDLIST) DECLSPEC_HIDDEN; INT_PTR CALLBACK SH_FileGeneralDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK SH_FileVersionDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); HPROPSHEETPAGE SH_CreatePropertySheetPage(WORD wDialogId, DLGPROC pfnDlgProc, LPARAM lParam, LPCWSTR pwszTitle); -BOOL SH_ShowDriveProperties(WCHAR *drive, LPCITEMIDLIST pidlFolder, PCUITEMID_CHILD_ARRAY apidl); +HRESULT SH_ShowDriveProperties(WCHAR *drive, LPCITEMIDLIST pidlFolder, PCUITEMID_CHILD_ARRAY apidl); BOOL SH_ShowRecycleBinProperties(WCHAR sDrive); BOOL SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, PCUITEMID_CHILD_ARRAY apidl); LPWSTR SH_FormatFileSizeWithBytes(PULARGE_INTEGER lpQwSize, LPWSTR pszBuf, UINT cchBuf);
7 years
1
0
0
0
[reactos] 01/01: [GDI] - Add type for setting world transform modification modes.
by jimtabor
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d85023c9c976ec002dcde…
commit d85023c9c976ec002dcde33514252678d2be79f8 Author: jimtabor <james.tabor(a)reactos.org> AuthorDate: Fri Nov 24 17:22:43 2017 -0600 [GDI] - Add type for setting world transform modification modes. References:
https://msdn.microsoft.com/en-us/library/cc230538.aspx
https://github.com/KDE/krita/blob/master/libs/vectorimage/libemf/EmfEnums.h
--- win32ss/gdi/gdi32/objects/coord.c | 3 +-- win32ss/gdi/ntgdi/coord.c | 2 +- win32ss/gdi/ntgdi/path.c | 2 +- win32ss/include/ntgdityp.h | 6 ++++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/win32ss/gdi/gdi32/objects/coord.c b/win32ss/gdi/gdi32/objects/coord.c index 727d4bd4a7..2caa575352 100644 --- a/win32ss/gdi/gdi32/objects/coord.c +++ b/win32ss/gdi/gdi32/objects/coord.c @@ -302,8 +302,7 @@ SetWorldTransform( _In_ HDC hdc, _Out_ CONST XFORM *pxform) { - /* FIXME shall we add undoc #define MWT_SETXFORM 4 ?? */ - return ModifyWorldTransform(hdc, pxform, MWT_MAX+1); + return ModifyWorldTransform(hdc, pxform, MWT_SET); } diff --git a/win32ss/gdi/ntgdi/coord.c b/win32ss/gdi/ntgdi/coord.c index 8d7be4e26c..58d236581b 100644 --- a/win32ss/gdi/ntgdi/coord.c +++ b/win32ss/gdi/ntgdi/coord.c @@ -480,7 +480,7 @@ GreModifyWorldTransform( XFORMOBJ_iCombine(&xoDC, &xoDC, &xoSrc); break; - case MWT_MAX+1: // Must be MWT_SET???? + case MWT_SET: XFORMOBJ_vInit(&xoDC, &pdc->pdcattr->mxWorldToPage); if (XFORMOBJ_iSetXform(&xoDC, pxform) == DDI_ERROR) return FALSE; diff --git a/win32ss/gdi/ntgdi/path.c b/win32ss/gdi/ntgdi/path.c index 5a014a3e03..f4cc24951a 100644 --- a/win32ss/gdi/ntgdi/path.c +++ b/win32ss/gdi/ntgdi/path.c @@ -1529,7 +1529,7 @@ PATH_FillPath( /* Go to GM_ADVANCED temporarily to restore the world transform */ graphicsMode = pdcattr->iGraphicsMode; pdcattr->iGraphicsMode = GM_ADVANCED; - GreModifyWorldTransform(dc, &xform, MWT_MAX+1); + GreModifyWorldTransform(dc, &xform, MWT_SET); pdcattr->iGraphicsMode = graphicsMode; return TRUE; } diff --git a/win32ss/include/ntgdityp.h b/win32ss/include/ntgdityp.h index 7b54c323e8..4bf8aa92fa 100644 --- a/win32ss/include/ntgdityp.h +++ b/win32ss/include/ntgdityp.h @@ -170,6 +170,12 @@ typedef enum GDILoObjType GDILoObjType_LO_METADC16_TYPE = 0x660000 } GDILOOBJTYPE, *PGDILOOBJTYPE; +/** + World Transform modification modes + See [MS-EMF] Section 2.1.24 +*/ +#define MWT_SET 0x04 + #define GdiWorldSpaceToPageSpace 0x203 #define GdiWorldSpaceToDeviceSpace 0x204 #define GdiPageSpaceToDeviceSpace 0x304
7 years
1
0
0
0
← Newer
1
2
3
4
5
...
19
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Results per page:
10
25
50
100
200