- NtQuerySection should check for SECTION_QUERY access right and not SECTION_MAP_READ.

- Fix prototype of NtExtendSection.

svn path=/trunk/; revision=10620
This commit is contained in:
Filip Navara 2004-08-20 21:23:49 +00:00
parent 5eef6d16e3
commit b71178e84e
3 changed files with 91 additions and 27 deletions

View file

@ -17,6 +17,7 @@
#define SEC_BASED (0x00200000) #define SEC_BASED (0x00200000)
#define SEC_NO_CHANGE (0x00400000) #define SEC_NO_CHANGE (0x00400000)
#define SEC_FILE (0x00800000)
#define SEC_IMAGE (0x01000000) #define SEC_IMAGE (0x01000000)
#define SEC_VLM (0x02000000) #define SEC_VLM (0x02000000)
#define SEC_RESERVE (0x04000000) #define SEC_RESERVE (0x04000000)

View file

@ -1,5 +1,5 @@
/* $Id: zw.h,v 1.28 2004/07/17 05:13:05 ion Exp $ /* $Id: zw.h,v 1.29 2004/08/20 21:23:49 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -5251,7 +5251,7 @@ NTSTATUS
STDCALL STDCALL
NtExtendSection( NtExtendSection(
IN HANDLE SectionHandle, IN HANDLE SectionHandle,
IN ULONG NewMaximumSize IN PLARGE_INTEGER NewMaximumSize
); );
/* /*
@ -6441,7 +6441,7 @@ NTSTATUS
STDCALL STDCALL
ZwExtendSection( ZwExtendSection(
IN HANDLE SectionHandle, IN HANDLE SectionHandle,
IN ULONG NewMaximumSize IN PLARGE_INTEGER NewMaximumSize
); );
/* /*

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: section.c,v 1.159 2004/08/18 02:29:37 navaraf Exp $ /* $Id: section.c,v 1.160 2004/08/20 21:23:49 navaraf Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c * FILE: ntoskrnl/mm/section.c
@ -3440,30 +3440,41 @@ NtUnmapViewOfSection (HANDLE ProcessHandle,
} }
NTSTATUS STDCALL /**
NtQuerySection (IN HANDLE SectionHandle, * Queries the information of a section object.
IN CINT SectionInformationClass, *
OUT PVOID SectionInformation, * @param SectionHandle
IN ULONG Length, * Handle to the section object. It must be opened with SECTION_QUERY
OUT PULONG ResultLength) * access.
/* * @param SectionInformationClass
* FUNCTION: Queries the information of a section object. * Index to a certain information structure. Can be either
* ARGUMENTS: * SectionBasicInformation or SectionImageInformation. The latter
* SectionHandle = Handle to the section link object * is valid only for sections that were created with the SEC_IMAGE
* SectionInformationClass = Index to a certain information structure * flag.
* SectionInformation (OUT)= Caller supplies storage for resulting * @param SectionInformation
* information * Caller supplies storage for resulting information.
* Length = Size of the supplied storage * @param Length
* ResultLength = Data written * Size of the supplied storage.
* RETURNS: Status * @param ResultLength
* Data written.
* *
* @return Status.
*
* @todo Guard by SEH.
* @implemented
*/ */
NTSTATUS STDCALL
NtQuerySection(IN HANDLE SectionHandle,
IN CINT SectionInformationClass,
OUT PVOID SectionInformation,
IN ULONG Length,
OUT PULONG ResultLength)
{ {
PSECTION_OBJECT Section; PSECTION_OBJECT Section;
NTSTATUS Status; NTSTATUS Status;
Status = ObReferenceObjectByHandle(SectionHandle, Status = ObReferenceObjectByHandle(SectionHandle,
SECTION_MAP_READ, SECTION_QUERY,
MmSectionObjectType, MmSectionObjectType,
UserMode, UserMode,
(PVOID*)&Section, (PVOID*)&Section,
@ -3487,9 +3498,17 @@ NtQuerySection (IN HANDLE SectionHandle,
Sbi = (PSECTION_BASIC_INFORMATION)SectionInformation; Sbi = (PSECTION_BASIC_INFORMATION)SectionInformation;
Sbi->BaseAddress = 0; Sbi->Attributes = Section->AllocationAttributes;
Sbi->Attributes = 0; if (Section->AllocationAttributes & SEC_IMAGE)
Sbi->Size.QuadPart = 0; {
Sbi->BaseAddress = 0;
Sbi->Size.QuadPart = 0;
}
else
{
Sbi->BaseAddress = Section->Segment->VirtualAddress;
Sbi->Size.QuadPart = Section->Segment->Length;
}
*ResultLength = sizeof(SECTION_BASIC_INFORMATION); *ResultLength = sizeof(SECTION_BASIC_INFORMATION);
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
@ -3537,12 +3556,56 @@ NtQuerySection (IN HANDLE SectionHandle,
} }
/**
* Extends size of file backed section.
*
* @param SectionHandle
* Handle to the section object. It must be opened with
* SECTION_EXTEND_SIZE access.
* @param NewMaximumSize
* New maximum size of the section in bytes.
*
* @return Status.
*
* @todo Guard by SEH.
* @todo Move the actual code to internal function MmExtendSection.
* @unimplemented
*/
NTSTATUS STDCALL NTSTATUS STDCALL
NtExtendSection(IN HANDLE SectionHandle, NtExtendSection(IN HANDLE SectionHandle,
IN ULONG NewMaximumSize) IN PLARGE_INTEGER NewMaximumSize)
{ {
UNIMPLEMENTED; PSECTION_OBJECT Section;
return(STATUS_NOT_IMPLEMENTED); NTSTATUS Status;
Status = ObReferenceObjectByHandle(SectionHandle,
SECTION_EXTEND_SIZE,
MmSectionObjectType,
UserMode,
(PVOID*)&Section,
NULL);
if (!NT_SUCCESS(Status))
{
return Status;
}
if (!(Section->AllocationAttributes & SEC_FILE))
{
ObfDereferenceObject(Section);
return STATUS_INVALID_PARAMETER;
}
/*
* - Acquire file extneding resource.
* - Check if we're not resizing the section below it's actual size!
* - Extend segments if needed.
* - Set file information (FileAllocationInformation) to the new size.
* - Release file extending resource.
*/
ObDereferenceObject(Section);
return STATUS_NOT_IMPLEMENTED;
} }