SECTION_ALL_ACCESS
};
-static const INFORMATION_CLASS_INFO ExSectionInfoClass[] =
-{
- ICI_SQ_SAME( sizeof(SECTION_BASIC_INFORMATION), sizeof(ULONG), ICIF_QUERY ), /* SectionBasicInformation */
- ICI_SQ_SAME( sizeof(SECTION_IMAGE_INFORMATION), sizeof(ULONG), ICIF_QUERY ), /* SectionImageInformation */
-};
/* FUNCTIONS *****************************************************************/
SectionSize.QuadPart = 0xFFFFFFFF;
InitializeObjectAttributes(&Obj,
&Name,
- OBJ_PERMANENT,
+ OBJ_PERMANENT | OBJ_KERNEL_EXCLUSIVE,
NULL,
NULL);
Status = MmCreateSection((PVOID)&PhysSection,
if (FileObject == NULL)
return STATUS_INVALID_FILE_FOR_SECTION;
+#ifndef NEWCC
+ if (FileObject->SectionObjectPointer->SharedCacheMap == NULL)
+ {
+ DPRINT1("Denying section creation due to missing cache initialization\n");
+ return STATUS_INVALID_FILE_FOR_SECTION;
+ }
+#endif
+
/*
* Create the section
*/
*
* @implemented
*/
-NTSTATUS NTAPI
-NtQuerySection(IN HANDLE SectionHandle,
- IN SECTION_INFORMATION_CLASS SectionInformationClass,
- OUT PVOID SectionInformation,
- IN SIZE_T SectionInformationLength,
- OUT PSIZE_T ResultLength OPTIONAL)
+NTSTATUS
+NTAPI
+NtQuerySection(
+ _In_ HANDLE SectionHandle,
+ _In_ SECTION_INFORMATION_CLASS SectionInformationClass,
+ _Out_ PVOID SectionInformation,
+ _In_ SIZE_T SectionInformationLength,
+ _Out_opt_ PSIZE_T ResultLength)
{
PROS_SECTION_OBJECT Section;
KPROCESSOR_MODE PreviousMode;
PAGED_CODE();
PreviousMode = ExGetPreviousMode();
+ if (PreviousMode != KernelMode)
+ {
+ _SEH2_TRY
+ {
+ ProbeForWrite(SectionInformation,
+ SectionInformationLength,
+ __alignof(ULONG));
+ if (ResultLength != NULL)
+ {
+ ProbeForWrite(ResultLength,
+ sizeof(*ResultLength),
+ __alignof(SIZE_T));
+ }
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ return _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+ }
- Status = DefaultQueryInfoBufferCheck(SectionInformationClass,
- ExSectionInfoClass,
- sizeof(ExSectionInfoClass) / sizeof(ExSectionInfoClass[0]),
- SectionInformation,
- (ULONG)SectionInformationLength,
- NULL,
- ResultLength,
- PreviousMode);
-
- if(!NT_SUCCESS(Status))
+ if (SectionInformationClass == SectionBasicInformation)
{
- DPRINT1("NtQuerySection() failed, Status: 0x%x\n", Status);
- return Status;
+ if (SectionInformationLength < sizeof(SECTION_BASIC_INFORMATION))
+ {
+ return STATUS_INFO_LENGTH_MISMATCH;
+ }
+ }
+ else if (SectionInformationClass == SectionImageInformation)
+ {
+ if (SectionInformationLength < sizeof(SECTION_IMAGE_INFORMATION))
+ {
+ return STATUS_INFO_LENGTH_MISMATCH;
+ }
+ }
+ else
+ {
+ return STATUS_INVALID_INFO_CLASS;
}
Status = ObReferenceObjectByHandle(SectionHandle,
PreviousMode,
(PVOID*)(PVOID)&Section,
NULL);
- if (NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to reference section: 0x%lx\n", Status);
+ return Status;
+ }
+
+ switch (SectionInformationClass)
{
- switch (SectionInformationClass)
- {
case SectionBasicInformation:
{
PSECTION_BASIC_INFORMATION Sbi = (PSECTION_BASIC_INFORMATION)SectionInformation;
break;
}
- }
-
- ObDereferenceObject(Section);
}
+ ObDereferenceObject(Section);
+
return(Status);
}