- Move code from NtCreateSection to MmCreateSection and adjust it.

- Use MmCreateSection instead of NtCreateSection where possible.

svn path=/trunk/; revision=10406
This commit is contained in:
Filip Navara 2004-08-05 19:59:13 +00:00
parent 054fcf9a85
commit 956358275c
4 changed files with 86 additions and 147 deletions

View file

@ -10,6 +10,7 @@
#include <string.h> #include <string.h>
#include <roscfg.h> #include <roscfg.h>
#include <internal/ob.h> #include <internal/ob.h>
#include <internal/mm.h>
#include <ntos/minmax.h> #include <ntos/minmax.h>
#include <reactos/bugcodes.h> #include <reactos/bugcodes.h>
@ -858,7 +859,7 @@ CmiInitNonVolatileRegistryHive (PREGISTRY_HIVE RegistryHive,
ULONG CreateDisposition; ULONG CreateDisposition;
IO_STATUS_BLOCK IoSB; IO_STATUS_BLOCK IoSB;
HANDLE FileHandle; HANDLE FileHandle;
HANDLE SectionHandle; PSECTION_OBJECT SectionObject;
PUCHAR ViewBase; PUCHAR ViewBase;
ULONG ViewSize; ULONG ViewSize;
NTSTATUS Status; NTSTATUS Status;
@ -943,17 +944,17 @@ CmiInitNonVolatileRegistryHive (PREGISTRY_HIVE RegistryHive,
} }
/* Create the hive section */ /* Create the hive section */
Status = NtCreateSection(&SectionHandle, Status = MmCreateSection(&SectionObject,
SECTION_ALL_ACCESS, SECTION_ALL_ACCESS,
NULL, NULL,
NULL, NULL,
PAGE_READWRITE, PAGE_READWRITE,
SEC_COMMIT, SEC_COMMIT,
FileHandle); FileHandle,
NtClose(FileHandle); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("NtCreateSection() failed (Status %lx)\n", Status); DPRINT1("MmCreateSection() failed (Status %lx)\n", Status);
RtlFreeUnicodeString(&RegistryHive->HiveFileName); RtlFreeUnicodeString(&RegistryHive->HiveFileName);
RtlFreeUnicodeString(&RegistryHive->LogFileName); RtlFreeUnicodeString(&RegistryHive->LogFileName);
return(Status); return(Status);
@ -962,8 +963,8 @@ CmiInitNonVolatileRegistryHive (PREGISTRY_HIVE RegistryHive,
/* Map the hive file */ /* Map the hive file */
ViewBase = NULL; ViewBase = NULL;
ViewSize = 0; ViewSize = 0;
Status = NtMapViewOfSection(SectionHandle, Status = MmMapViewOfSection(SectionObject,
NtCurrentProcess(), PsGetCurrentProcess(),
(PVOID*)&ViewBase, (PVOID*)&ViewBase,
0, 0,
ViewSize, ViewSize,
@ -974,8 +975,8 @@ CmiInitNonVolatileRegistryHive (PREGISTRY_HIVE RegistryHive,
PAGE_READWRITE); PAGE_READWRITE);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("MmMapViewInSystemSpace() failed (Status %lx)\n", Status); DPRINT1("MmMapViewOfSection() failed (Status %lx)\n", Status);
NtClose(SectionHandle); ObDereferenceObject(SectionObject);
RtlFreeUnicodeString(&RegistryHive->HiveFileName); RtlFreeUnicodeString(&RegistryHive->HiveFileName);
RtlFreeUnicodeString(&RegistryHive->LogFileName); RtlFreeUnicodeString(&RegistryHive->LogFileName);
return(Status); return(Status);
@ -996,9 +997,9 @@ CmiInitNonVolatileRegistryHive (PREGISTRY_HIVE RegistryHive,
if (RegistryHive->BlockList == NULL) if (RegistryHive->BlockList == NULL)
{ {
DPRINT1("Failed to allocate the hive block list\n"); DPRINT1("Failed to allocate the hive block list\n");
NtUnmapViewOfSection(NtCurrentProcess(), MmUnmapViewOfSection(PsGetCurrentProcess(),
ViewBase); ViewBase);
NtClose(SectionHandle); ObDereferenceObject(SectionObject);
RtlFreeUnicodeString(&RegistryHive->HiveFileName); RtlFreeUnicodeString(&RegistryHive->HiveFileName);
RtlFreeUnicodeString(&RegistryHive->LogFileName); RtlFreeUnicodeString(&RegistryHive->LogFileName);
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
@ -1012,18 +1013,18 @@ CmiInitNonVolatileRegistryHive (PREGISTRY_HIVE RegistryHive,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ExFreePool(RegistryHive->BlockList); ExFreePool(RegistryHive->BlockList);
NtUnmapViewOfSection(NtCurrentProcess(), MmUnmapViewOfSection(PsGetCurrentProcess(),
ViewBase); ViewBase);
NtClose(SectionHandle); ObDereferenceObject(SectionObject);
RtlFreeUnicodeString(&RegistryHive->HiveFileName); RtlFreeUnicodeString(&RegistryHive->HiveFileName);
RtlFreeUnicodeString(&RegistryHive->LogFileName); RtlFreeUnicodeString(&RegistryHive->LogFileName);
return Status; return Status;
} }
/* Unmap and dereference the hive section */ /* Unmap and dereference the hive section */
NtUnmapViewOfSection(NtCurrentProcess(), MmUnmapViewOfSection(PsGetCurrentProcess(),
ViewBase); ViewBase);
NtClose(SectionHandle); ObDereferenceObject(SectionObject);
/* Initialize the free cell list */ /* Initialize the free cell list */
Status = CmiCreateHiveFreeCellList (RegistryHive); Status = CmiCreateHiveFreeCellList (RegistryHive);

View file

@ -20,7 +20,7 @@
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_NLS_H #ifndef __NTOSKRNL_INCLUDE_INTERNAL_NLS_H
#define __NTOSKRNL_INCLUDE_INTERNAL_NLS_H #define __NTOSKRNL_INCLUDE_INTERNAL_NLS_H
extern PVOID NlsSectionObject; extern PSECTION_OBJECT NlsSectionObject;
extern ULONG NlsAnsiTableOffset; extern ULONG NlsAnsiTableOffset;
extern ULONG NlsOemTableOffset; extern ULONG NlsOemTableOffset;

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.155 2004/08/01 07:24:58 hbirr Exp $ /* $Id: section.c,v 1.156 2004/08/05 19:59:13 navaraf Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c * FILE: ntoskrnl/mm/section.c
@ -2094,7 +2094,6 @@ MmpCreateSection(PVOID ObjectBody,
NTSTATUS INIT_FUNCTION NTSTATUS INIT_FUNCTION
MmCreatePhysicalMemorySection(VOID) MmCreatePhysicalMemorySection(VOID)
{ {
HANDLE PhysSectionH;
PSECTION_OBJECT PhysSection; PSECTION_OBJECT PhysSection;
NTSTATUS Status; NTSTATUS Status;
OBJECT_ATTRIBUTES Obj; OBJECT_ATTRIBUTES Obj;
@ -2110,31 +2109,20 @@ MmCreatePhysicalMemorySection(VOID)
0, 0,
NULL, NULL,
NULL); NULL);
Status = NtCreateSection(&PhysSectionH, Status = MmCreateSection(&PhysSection,
SECTION_ALL_ACCESS, SECTION_ALL_ACCESS,
&Obj, &Obj,
&SectionSize, &SectionSize,
PAGE_EXECUTE_READWRITE, PAGE_EXECUTE_READWRITE,
0, 0,
NULL,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DbgPrint("Failed to create PhysicalMemory section\n"); DbgPrint("Failed to create PhysicalMemory section\n");
KEBUGCHECK(0); KEBUGCHECK(0);
} }
Status = ObReferenceObjectByHandle(PhysSectionH,
SECTION_ALL_ACCESS,
NULL,
KernelMode,
(PVOID*)&PhysSection,
NULL);
if (!NT_SUCCESS(Status))
{
DbgPrint("Failed to reference PhysicalMemory section\n");
KEBUGCHECK(0);
}
PhysSection->AllocationAttributes |= SEC_PHYSICALMEMORY; PhysSection->AllocationAttributes |= SEC_PHYSICALMEMORY;
ObDereferenceObject((PVOID)PhysSection);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -2176,7 +2164,7 @@ MmInitSectionImplementation(VOID)
} }
NTSTATUS NTSTATUS
MmCreatePageFileSection(PHANDLE SectionHandle, MmCreatePageFileSection(PSECTION_OBJECT *SectionObject,
ACCESS_MASK DesiredAccess, ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes, POBJECT_ATTRIBUTES ObjectAttributes,
PLARGE_INTEGER UMaximumSize, PLARGE_INTEGER UMaximumSize,
@ -2223,18 +2211,6 @@ MmCreatePageFileSection(PHANDLE SectionHandle,
return(Status); return(Status);
} }
Status = ObInsertObject ((PVOID)Section,
NULL,
DesiredAccess,
0,
NULL,
SectionHandle);
if (!NT_SUCCESS(Status))
{
ObDereferenceObject(Section);
return(Status);
}
/* /*
* Initialize it * Initialize it
*/ */
@ -2248,7 +2224,6 @@ MmCreatePageFileSection(PHANDLE SectionHandle,
TAG_MM_SECTION_SEGMENT); TAG_MM_SECTION_SEGMENT);
if (Segment == NULL) if (Segment == NULL)
{ {
ZwClose(*SectionHandle);
ObDereferenceObject(Section); ObDereferenceObject(Section);
return(STATUS_NO_MEMORY); return(STATUS_NO_MEMORY);
} }
@ -2265,13 +2240,13 @@ MmCreatePageFileSection(PHANDLE SectionHandle,
RtlZeroMemory(&Segment->PageDirectory, sizeof(SECTION_PAGE_DIRECTORY)); RtlZeroMemory(&Segment->PageDirectory, sizeof(SECTION_PAGE_DIRECTORY));
Segment->VirtualAddress = 0; Segment->VirtualAddress = 0;
Segment->Characteristics = 0; Segment->Characteristics = 0;
ObDereferenceObject(Section); *SectionObject = Section;
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS NTSTATUS
MmCreateDataFileSection(PHANDLE SectionHandle, MmCreateDataFileSection(PSECTION_OBJECT *SectionObject,
ACCESS_MASK DesiredAccess, ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes, POBJECT_ATTRIBUTES ObjectAttributes,
PLARGE_INTEGER UMaximumSize, PLARGE_INTEGER UMaximumSize,
@ -2317,18 +2292,6 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
return(Status); return(Status);
} }
Status = ObInsertObject ((PVOID)Section,
NULL,
DesiredAccess,
0,
NULL,
SectionHandle);
if (!NT_SUCCESS(Status))
{
ObDereferenceObject(Section);
return(Status);
}
/* /*
* Initialize it * Initialize it
*/ */
@ -2361,7 +2324,6 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ZwClose(*SectionHandle);
ObDereferenceObject(Section); ObDereferenceObject(Section);
return(Status); return(Status);
} }
@ -2372,7 +2334,6 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
*/ */
if (!(FileObject->Flags & FO_FCB_IS_VALID)) if (!(FileObject->Flags & FO_FCB_IS_VALID))
{ {
ZwClose(*SectionHandle);
ObDereferenceObject(Section); ObDereferenceObject(Section);
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
return(STATUS_INVALID_FILE_FOR_SECTION); return(STATUS_INVALID_FILE_FOR_SECTION);
@ -2402,7 +2363,6 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
FileAllocationInformation); FileAllocationInformation);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ZwClose(*SectionHandle);
ObDereferenceObject(Section); ObDereferenceObject(Section);
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
return(STATUS_SECTION_NOT_EXTENDED); return(STATUS_SECTION_NOT_EXTENDED);
@ -2429,7 +2389,6 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
0); 0);
if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE)) if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE))
{ {
ZwClose(*SectionHandle);
ObDereferenceObject(Section); ObDereferenceObject(Section);
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
return(Status); return(Status);
@ -2438,7 +2397,6 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
FileObject->SectionObjectPointer->SharedCacheMap == NULL) FileObject->SectionObjectPointer->SharedCacheMap == NULL)
{ {
/* FIXME: handle this situation */ /* FIXME: handle this situation */
ZwClose(*SectionHandle);
ObDereferenceObject(Section); ObDereferenceObject(Section);
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
@ -2451,7 +2409,6 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
Status = MmspWaitForFileLock(FileObject); Status = MmspWaitForFileLock(FileObject);
if (Status != STATUS_SUCCESS) if (Status != STATUS_SUCCESS)
{ {
ZwClose(*SectionHandle);
ObDereferenceObject(Section); ObDereferenceObject(Section);
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
return(Status); return(Status);
@ -2468,7 +2425,6 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
if (Segment == NULL) if (Segment == NULL)
{ {
KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE); KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
ZwClose(*SectionHandle);
ObDereferenceObject(Section); ObDereferenceObject(Section);
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
return(STATUS_NO_MEMORY); return(STATUS_NO_MEMORY);
@ -2525,7 +2481,7 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
Section->MaximumSize = MaximumSize; Section->MaximumSize = MaximumSize;
CcRosReferenceCache(FileObject); CcRosReferenceCache(FileObject);
KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE); KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
ObDereferenceObject(Section); *SectionObject = Section;
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -2550,7 +2506,7 @@ static ULONG SectionCharacteristicsToProtect[16] =
}; };
NTSTATUS NTSTATUS
MmCreateImageSection(PHANDLE SectionHandle, MmCreateImageSection(PSECTION_OBJECT *SectionObject,
ACCESS_MASK DesiredAccess, ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes, POBJECT_ATTRIBUTES ObjectAttributes,
PLARGE_INTEGER UMaximumSize, PLARGE_INTEGER UMaximumSize,
@ -2725,20 +2681,6 @@ MmCreateImageSection(PHANDLE SectionHandle,
return(Status); return(Status);
} }
Status = ObInsertObject ((PVOID)Section,
NULL,
DesiredAccess,
0,
NULL,
SectionHandle);
if (!NT_SUCCESS(Status))
{
ObDereferenceObject(Section);
ObDereferenceObject(FileObject);
ExFreePool(ImageSections);
return(Status);
}
/* /*
* Initialize it * Initialize it
*/ */
@ -2765,7 +2707,6 @@ MmCreateImageSection(PHANDLE SectionHandle,
*/ */
if (!(FileObject->Flags & FO_FCB_IS_VALID)) if (!(FileObject->Flags & FO_FCB_IS_VALID))
{ {
ZwClose(*SectionHandle);
ObDereferenceObject(Section); ObDereferenceObject(Section);
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
ExFreePool(ImageSections); ExFreePool(ImageSections);
@ -2778,7 +2719,6 @@ MmCreateImageSection(PHANDLE SectionHandle,
Status = MmspWaitForFileLock(FileObject); Status = MmspWaitForFileLock(FileObject);
if (Status != STATUS_SUCCESS) if (Status != STATUS_SUCCESS)
{ {
ZwClose(*SectionHandle);
ObDereferenceObject(Section); ObDereferenceObject(Section);
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
ExFreePool(ImageSections); ExFreePool(ImageSections);
@ -2794,7 +2734,6 @@ MmCreateImageSection(PHANDLE SectionHandle,
if (ImageSectionObject == NULL) if (ImageSectionObject == NULL)
{ {
KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE); KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
ZwClose(*SectionHandle);
ObDereferenceObject(Section); ObDereferenceObject(Section);
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
ExFreePool(ImageSections); ExFreePool(ImageSections);
@ -2934,19 +2873,6 @@ MmCreateImageSection(PHANDLE SectionHandle,
return(Status); return(Status);
} }
Status = ObInsertObject ((PVOID)Section,
NULL,
DesiredAccess,
0,
NULL,
SectionHandle);
if (!NT_SUCCESS(Status))
{
ObDereferenceObject(Section);
ObDereferenceObject(FileObject);
return(Status);
}
/* /*
* Initialize it * Initialize it
*/ */
@ -2973,7 +2899,6 @@ MmCreateImageSection(PHANDLE SectionHandle,
Status = MmspWaitForFileLock(FileObject); Status = MmspWaitForFileLock(FileObject);
if (Status != STATUS_SUCCESS) if (Status != STATUS_SUCCESS)
{ {
ZwClose(*SectionHandle);
ObDereferenceObject(Section); ObDereferenceObject(Section);
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
return(Status); return(Status);
@ -2996,7 +2921,7 @@ MmCreateImageSection(PHANDLE SectionHandle,
Section->FileObject = FileObject; Section->FileObject = FileObject;
CcRosReferenceCache(FileObject); CcRosReferenceCache(FileObject);
KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE); KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
ObDereferenceObject(Section); *SectionObject = Section;
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -3012,34 +2937,33 @@ NtCreateSection (OUT PHANDLE SectionHandle,
IN ULONG AllocationAttributes, IN ULONG AllocationAttributes,
IN HANDLE FileHandle OPTIONAL) IN HANDLE FileHandle OPTIONAL)
{ {
if (AllocationAttributes & SEC_IMAGE) PSECTION_OBJECT SectionObject;
NTSTATUS Status;
Status = MmCreateSection(&SectionObject,
DesiredAccess,
ObjectAttributes,
MaximumSize,
SectionPageProtection,
AllocationAttributes,
FileHandle,
NULL);
if (NT_SUCCESS(Status))
{ {
return(MmCreateImageSection(SectionHandle, Status = ObInsertObject ((PVOID)SectionObject,
DesiredAccess, NULL,
ObjectAttributes, DesiredAccess,
MaximumSize, 0,
SectionPageProtection, NULL,
AllocationAttributes, SectionHandle);
FileHandle)); if (!NT_SUCCESS(Status))
{
ObDereferenceObject(SectionObject);
}
} }
if (FileHandle != NULL) return Status;
{
return(MmCreateDataFileSection(SectionHandle,
DesiredAccess,
ObjectAttributes,
MaximumSize,
SectionPageProtection,
AllocationAttributes,
FileHandle));
}
return(MmCreatePageFileSection(SectionHandle,
DesiredAccess,
ObjectAttributes,
MaximumSize,
SectionPageProtection,
AllocationAttributes));
} }
@ -4099,7 +4023,7 @@ MmSetBankedSection (DWORD Unknown0,
* Creates a section object. * Creates a section object.
* *
* ARGUMENTS * ARGUMENTS
* SectionObjiect (OUT) * SectionObject (OUT)
* Caller supplied storage for the resulting pointer * Caller supplied storage for the resulting pointer
* to a SECTION_OBJECT instance; * to a SECTION_OBJECT instance;
* *
@ -4144,7 +4068,7 @@ MmSetBankedSection (DWORD Unknown0,
* RETURN VALUE * RETURN VALUE
* Status. * Status.
* *
* @unimplemented * @implemented
*/ */
NTSTATUS STDCALL NTSTATUS STDCALL
MmCreateSection (OUT PSECTION_OBJECT * SectionObject, MmCreateSection (OUT PSECTION_OBJECT * SectionObject,
@ -4156,7 +4080,34 @@ MmCreateSection (OUT PSECTION_OBJECT * SectionObject,
IN HANDLE FileHandle OPTIONAL, IN HANDLE FileHandle OPTIONAL,
IN PFILE_OBJECT File OPTIONAL) IN PFILE_OBJECT File OPTIONAL)
{ {
return (STATUS_NOT_IMPLEMENTED); if (AllocationAttributes & SEC_IMAGE)
{
return(MmCreateImageSection(SectionObject,
DesiredAccess,
ObjectAttributes,
MaximumSize,
SectionPageProtection,
AllocationAttributes,
FileHandle));
}
if (FileHandle != NULL)
{
return(MmCreateDataFileSection(SectionObject,
DesiredAccess,
ObjectAttributes,
MaximumSize,
SectionPageProtection,
AllocationAttributes,
FileHandle));
}
return(MmCreatePageFileSection(SectionObject,
DesiredAccess,
ObjectAttributes,
MaximumSize,
SectionPageProtection,
AllocationAttributes));
} }
/* EOF */ /* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: nls.c,v 1.23 2004/05/31 19:40:49 gdalsnes Exp $ /* $Id: nls.c,v 1.24 2004/08/05 19:59:13 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -29,7 +29,7 @@ static ULONG NlsOemCodePageTableSize = 0;
static PUSHORT NlsUnicodeCasemapTable = NULL; static PUSHORT NlsUnicodeCasemapTable = NULL;
static ULONG NlsUnicodeCasemapTableSize = 0; static ULONG NlsUnicodeCasemapTableSize = 0;
PVOID NlsSectionObject = NULL; PSECTION_OBJECT NlsSectionObject = NULL;
static PVOID NlsSectionBase = NULL; static PVOID NlsSectionBase = NULL;
static ULONG NlsSectionViewSize = 0; static ULONG NlsSectionViewSize = 0;
@ -95,7 +95,6 @@ RtlpCreateNlsSection(VOID)
{ {
NLSTABLEINFO NlsTable; NLSTABLEINFO NlsTable;
LARGE_INTEGER SectionSize; LARGE_INTEGER SectionSize;
HANDLE SectionHandle;
NTSTATUS Status; NTSTATUS Status;
DPRINT("RtlpCreateNlsSection() called\n"); DPRINT("RtlpCreateNlsSection() called\n");
@ -107,32 +106,20 @@ RtlpCreateNlsSection(VOID)
DPRINT("NlsSectionViewSize %lx\n", NlsSectionViewSize); DPRINT("NlsSectionViewSize %lx\n", NlsSectionViewSize);
SectionSize.QuadPart = (LONGLONG)NlsSectionViewSize; SectionSize.QuadPart = (LONGLONG)NlsSectionViewSize;
Status = NtCreateSection(&SectionHandle, Status = MmCreateSection(&NlsSectionObject,
SECTION_ALL_ACCESS, SECTION_ALL_ACCESS,
NULL, NULL,
&SectionSize, &SectionSize,
PAGE_READWRITE, PAGE_READWRITE,
SEC_COMMIT, SEC_COMMIT,
NULL,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("NtCreateSection() failed\n"); DPRINT1("MmCreateSection() failed\n");
KEBUGCHECKEX(0x32, Status, 1, 1, 0); KEBUGCHECKEX(0x32, Status, 1, 1, 0);
} }
Status = ObReferenceObjectByHandle(SectionHandle,
SECTION_ALL_ACCESS,
MmSectionObjectType,
KernelMode,
&NlsSectionObject,
NULL);
NtClose(SectionHandle);
if (!NT_SUCCESS(Status))
{
DPRINT1("ObReferenceObjectByHandle() failed\n");
KEBUGCHECKEX(0x32, Status, 1, 2, 0);
}
Status = MmMapViewInSystemSpace(NlsSectionObject, Status = MmMapViewInSystemSpace(NlsSectionObject,
&NlsSectionBase, &NlsSectionBase,
&NlsSectionViewSize); &NlsSectionViewSize);