- Remove dependency on ReactOS specific FO_FCB_IS_VALID magic and don't access FCB directly, use NtQueryInformationFile instead.
- Fix deleting of section if an early failure during section creation happens and not all structures are initialized yet.
svn path=/trunk/; revision=10586
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: section.c,v 1.158 2004/08/15 16:39:08 chorns Exp $
+/* $Id: section.c,v 1.159 2004/08/18 02:29:37 navaraf Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c
ULONG RefCount;
PMM_SECTION_SEGMENT SectionSegments;
ULONG RefCount;
PMM_SECTION_SEGMENT SectionSegments;
+ /*
+ * NOTE: Section->ImageSection can be NULL for short time
+ * during the section creating. If we fail for some reason
+ * until the image section is properly initialized we shouldn't
+ * process further here.
+ */
+ if (Section->ImageSection == NULL)
+ return;
+
SectionSegments = Section->ImageSection->Segments;
NrSegments = Section->ImageSection->NrSegments;
SectionSegments = Section->ImageSection->Segments;
NrSegments = Section->ImageSection->NrSegments;
+ /*
+ * NOTE: Section->Segment can be NULL for short time
+ * during the section creating.
+ */
+ if (Section->Segment == NULL)
+ return;
+
if (Section->Segment->Flags & MM_PAGEFILE_SEGMENT)
{
MmpFreePageFileSegment(Section->Segment);
if (Section->Segment->Flags & MM_PAGEFILE_SEGMENT)
{
MmpFreePageFileSegment(Section->Segment);
}
MaximumSize = *UMaximumSize;
}
MaximumSize = *UMaximumSize;
- /*
- * Check the protection
- */
- if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
- SectionPageProtection)
- {
- return(STATUS_INVALID_PAGE_PROTECTION);
- }
-
/*
* Create the section
*/
/*
* Create the section
*/
*/
Section->SectionPageProtection = SectionPageProtection;
Section->AllocationAttributes = AllocationAttributes;
*/
Section->SectionPageProtection = SectionPageProtection;
Section->AllocationAttributes = AllocationAttributes;
+ Section->Segment = NULL;
InitializeListHead(&Section->ViewListHead);
KeInitializeSpinLock(&Section->ViewListLock);
Section->FileObject = NULL;
InitializeListHead(&Section->ViewListHead);
KeInitializeSpinLock(&Section->ViewListLock);
Section->FileObject = NULL;
IO_STATUS_BLOCK Iosb;
LARGE_INTEGER Offset;
CHAR Buffer;
IO_STATUS_BLOCK Iosb;
LARGE_INTEGER Offset;
CHAR Buffer;
+ FILE_STANDARD_INFORMATION FileInfo;
- /*
- * Check the protection
- */
- if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
- SectionPageProtection)
- {
- return(STATUS_INVALID_PAGE_PROTECTION);
- }
/*
* Create the section
*/
/*
* Create the section
*/
*/
Section->SectionPageProtection = SectionPageProtection;
Section->AllocationAttributes = AllocationAttributes;
*/
Section->SectionPageProtection = SectionPageProtection;
Section->AllocationAttributes = AllocationAttributes;
+ Section->Segment = NULL;
InitializeListHead(&Section->ViewListHead);
KeInitializeSpinLock(&Section->ViewListLock);
InitializeListHead(&Section->ViewListHead);
KeInitializeSpinLock(&Section->ViewListLock);
- * We can't do memory mappings if the file system doesn't support the
- * standard FCB
+ * FIXME: This is propably not entirely correct. We can't look into
+ * the standard FCB header because it might not be initialized yet
+ * (as in case of the EXT2FS driver by Manoj Paul Joseph where the
+ * standard file information is filled on first request).
- if (!(FileObject->Flags & FO_FCB_IS_VALID))
+ Status = NtQueryInformationFile(FileHandle,
+ &Iosb,
+ &FileInfo,
+ sizeof(FILE_STANDARD_INFORMATION),
+ FileStandardInformation);
+ if (!NT_SUCCESS(Status))
{
ObDereferenceObject(Section);
ObDereferenceObject(FileObject);
{
ObDereferenceObject(Section);
ObDereferenceObject(FileObject);
- return(STATUS_INVALID_FILE_FOR_SECTION);
- MaximumSize =
- ((PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)->FileSize;
+ MaximumSize = FileInfo.EndOfFile;
- if (MaximumSize.QuadPart >
- ((PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)->FileSize.QuadPart)
+ if (MaximumSize.QuadPart > FileInfo.EndOfFile.QuadPart)
{
Status = NtSetInformationFile(FileHandle,
&Iosb,
{
Status = NtSetInformationFile(FileHandle,
&Iosb,
ULONG Size;
ULONG Characteristics;
ULONG FileAccess = 0;
ULONG Size;
ULONG Characteristics;
ULONG FileAccess = 0;
- /*
- * Check the protection
- */
- if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
- SectionPageProtection)
- {
- return(STATUS_INVALID_PAGE_PROTECTION);
- }
/*
* Specifying a maximum size is meaningless for an image section
/*
* Specifying a maximum size is meaningless for an image section
*/
Section->SectionPageProtection = SectionPageProtection;
Section->AllocationAttributes = AllocationAttributes;
*/
Section->SectionPageProtection = SectionPageProtection;
Section->AllocationAttributes = AllocationAttributes;
+ Section->ImageSection = NULL;
InitializeListHead(&Section->ViewListHead);
KeInitializeSpinLock(&Section->ViewListLock);
InitializeListHead(&Section->ViewListHead);
KeInitializeSpinLock(&Section->ViewListLock);
FileAccess = FILE_READ_DATA;
}
FileAccess = FILE_READ_DATA;
}
- /*
- * We can't do memory mappings if the file system doesn't support the
- * standard FCB
- */
- if (!(FileObject->Flags & FO_FCB_IS_VALID))
- {
- ObDereferenceObject(Section);
- ObDereferenceObject(FileObject);
- ExFreePool(ImageSections);
- return(STATUS_INVALID_FILE_FOR_SECTION);
- }
-
PSECTION_OBJECT SectionObject;
NTSTATUS Status;
PSECTION_OBJECT SectionObject;
NTSTATUS Status;
+ /*
+ * Check the protection
+ */
+ if ((SectionPageProtection & PAGE_FLAGS_VALID_FROM_USER_MODE) !=
+ SectionPageProtection)
+ {
+ return(STATUS_INVALID_PAGE_PROTECTION);
+ }
+
Status = MmCreateSection(&SectionObject,
DesiredAccess,
ObjectAttributes,
Status = MmCreateSection(&SectionObject,
DesiredAccess,
ObjectAttributes,