mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 19:52:56 +00:00
- Setup memory limits in shared user data.
- Loop security descriptors to find NLS data and make a copy of it in kernel pool, because the NLS buffer from NTLDR will be freed on NT. Also discovered a bug in Freeldr where it doesn't allocate ths NLS files sequentially, leaving a hole of 0x1000 between them. Added a hack to compensate (won't break NTLDR booting, just will waste 8KB of memory). - Allocate the system call count table on checked builds. - Refactor Ob/Se booting to match more closely NT, and so that we can do Se initialization in one shot. svn path=/trunk/; revision=24362
This commit is contained in:
parent
62ac7ad5c9
commit
06142d4e0d
4 changed files with 138 additions and 37 deletions
|
@ -25,10 +25,9 @@ ULONG NtBuildNumber = KERNEL_VERSION_BUILD;
|
||||||
ULONG NtGlobalFlag;
|
ULONG NtGlobalFlag;
|
||||||
ULONG ExSuiteMask;
|
ULONG ExSuiteMask;
|
||||||
|
|
||||||
extern ULONG MmCoreDumpType;
|
|
||||||
extern LOADER_MODULE KeLoaderModules[64];
|
extern LOADER_MODULE KeLoaderModules[64];
|
||||||
extern ULONG KeLoaderModuleCount;
|
extern ULONG KeLoaderModuleCount;
|
||||||
extern PRTL_MESSAGE_RESOURCE_DATA KiBugCodeMessages;
|
extern ULONG KiServiceLimit;
|
||||||
BOOLEAN NoGuiBoot = FALSE;
|
BOOLEAN NoGuiBoot = FALSE;
|
||||||
|
|
||||||
/* Init flags and settings */
|
/* Init flags and settings */
|
||||||
|
@ -45,6 +44,7 @@ PVOID ExpNlsTableBase;
|
||||||
ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset;
|
ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset;
|
||||||
ULONG ExpUnicodeCaseTableDataOffset;
|
ULONG ExpUnicodeCaseTableDataOffset;
|
||||||
NLSTABLEINFO ExpNlsTableInfo;
|
NLSTABLEINFO ExpNlsTableInfo;
|
||||||
|
ULONG ExpNlsTableSize;
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
@ -456,6 +456,8 @@ ExpInitializeExecutive(IN ULONG Cpu,
|
||||||
CHAR Buffer[256];
|
CHAR Buffer[256];
|
||||||
ANSI_STRING AnsiPath;
|
ANSI_STRING AnsiPath;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PLIST_ENTRY NextEntry, ListHead;
|
||||||
|
PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
|
||||||
|
|
||||||
/* FIXME: Deprecate soon */
|
/* FIXME: Deprecate soon */
|
||||||
ParseAndCacheLoadedModules();
|
ParseAndCacheLoadedModules();
|
||||||
|
@ -578,22 +580,97 @@ ExpInitializeExecutive(IN ULONG Cpu,
|
||||||
/* Initialize the executive at phase 0 */
|
/* Initialize the executive at phase 0 */
|
||||||
if (!ExInitSystem()) KEBUGCHECK(PHASE0_INITIALIZATION_FAILED);
|
if (!ExInitSystem()) KEBUGCHECK(PHASE0_INITIALIZATION_FAILED);
|
||||||
|
|
||||||
/* Load basic Security for other Managers */
|
/* Set system ranges */
|
||||||
if (!SeInit1()) KEBUGCHECK(SECURITY_INITIALIZATION_FAILED);
|
SharedUserData->Reserved1 = (ULONG_PTR)MmHighestUserAddress;
|
||||||
|
SharedUserData->Reserved3 = (ULONG_PTR)MmSystemRangeStart;
|
||||||
|
|
||||||
|
/* Loop the memory descriptors */
|
||||||
|
ListHead = &LoaderBlock->MemoryDescriptorListHead;
|
||||||
|
NextEntry = ListHead->Flink;
|
||||||
|
while (NextEntry != ListHead)
|
||||||
|
{
|
||||||
|
/* Get the current block */
|
||||||
|
MdBlock = CONTAINING_RECORD(NextEntry,
|
||||||
|
MEMORY_ALLOCATION_DESCRIPTOR,
|
||||||
|
ListEntry);
|
||||||
|
|
||||||
|
/* Check if this is an NLS block */
|
||||||
|
if (MdBlock->MemoryType == LoaderNlsData)
|
||||||
|
{
|
||||||
|
/* Increase the table size */
|
||||||
|
ExpNlsTableSize += MdBlock->PageCount * PAGE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Go to the next block */
|
||||||
|
NextEntry = MdBlock->ListEntry.Flink;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In NT, the memory blocks are contiguous, but in ReactOS they are not,
|
||||||
|
* so unless someone fixes FreeLdr, we'll have to use this icky hack.
|
||||||
|
*/
|
||||||
|
ExpNlsTableSize += 2 * PAGE_SIZE; // BIAS FOR FREELDR. HACK!
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate the table in pool memory, so we can stop depending on the
|
||||||
|
* memory given to use by the loader, which is freed later.
|
||||||
|
*/
|
||||||
|
ExpNlsTableBase = ExAllocatePoolWithTag(NonPagedPool,
|
||||||
|
ExpNlsTableSize,
|
||||||
|
TAG('R', 't', 'l', 'i'));
|
||||||
|
if (!ExpNlsTableBase) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
|
||||||
|
|
||||||
|
/* Copy the codepage data in its new location. */
|
||||||
|
RtlMoveMemory(ExpNlsTableBase,
|
||||||
|
LoaderBlock->NlsData->AnsiCodePageData,
|
||||||
|
ExpNlsTableSize);
|
||||||
|
|
||||||
|
/* Initialize and reset the NLS TAbles */
|
||||||
|
RtlInitNlsTables((PVOID)((ULONG_PTR)ExpNlsTableBase +
|
||||||
|
ExpAnsiCodePageDataOffset),
|
||||||
|
(PVOID)((ULONG_PTR)ExpNlsTableBase +
|
||||||
|
ExpOemCodePageDataOffset),
|
||||||
|
(PVOID)((ULONG_PTR)ExpNlsTableBase +
|
||||||
|
ExpUnicodeCaseTableDataOffset),
|
||||||
|
&ExpNlsTableInfo);
|
||||||
|
RtlResetRtlTranslations(&ExpNlsTableInfo);
|
||||||
|
|
||||||
/* Initialize the Handle Table */
|
/* Initialize the Handle Table */
|
||||||
ExpInitializeHandleTables();
|
ExpInitializeHandleTables();
|
||||||
|
|
||||||
|
#if DBG
|
||||||
|
/* On checked builds, allocate the system call count table */
|
||||||
|
KeServiceDescriptorTable[0].Count =
|
||||||
|
ExAllocatePoolWithTag(NonPagedPool,
|
||||||
|
KiServiceLimit * sizeof(ULONG),
|
||||||
|
TAG('C', 'a', 'l', 'l'));
|
||||||
|
|
||||||
|
/* Use it for the shadow table too */
|
||||||
|
KeServiceDescriptorTableShadow[0].Count = KeServiceDescriptorTable[0].Count;
|
||||||
|
|
||||||
|
/* Make sure allocation succeeded */
|
||||||
|
if (KeServiceDescriptorTable[0].Count)
|
||||||
|
{
|
||||||
|
/* Zero the call counts to 0 */
|
||||||
|
RtlZeroMemory(KeServiceDescriptorTable[0].Count,
|
||||||
|
KiServiceLimit * sizeof(ULONG));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Create the Basic Object Manager Types to allow new Object Types */
|
/* Create the Basic Object Manager Types to allow new Object Types */
|
||||||
ObInit();
|
if (!ObInit()) KEBUGCHECK(OBJECT_INITIALIZATION_FAILED);
|
||||||
|
|
||||||
|
/* Load basic Security for other Managers */
|
||||||
|
if (!SeInit1()) KEBUGCHECK(SECURITY_INITIALIZATION_FAILED);
|
||||||
|
if (!SeInit2()) KEBUGCHECK(SECURITY1_INITIALIZATION_FAILED);
|
||||||
|
|
||||||
/* Set up Region Maps, Sections and the Paging File */
|
/* Set up Region Maps, Sections and the Paging File */
|
||||||
MmInit2();
|
MmInit2();
|
||||||
|
|
||||||
/* Initialize Tokens now that the Object Manager is ready */
|
/* Call OB initialization again */
|
||||||
if (!SeInit2()) KEBUGCHECK(SECURITY1_INITIALIZATION_FAILED);
|
if (!ObInit()) KEBUGCHECK(OBJECT_INITIALIZATION_FAILED);
|
||||||
|
|
||||||
/* Initalize the Process Manager */
|
/* Initialize the Process Manager */
|
||||||
PspInitPhase0();
|
PspInitPhase0();
|
||||||
|
|
||||||
/* Break into the Debugger if requested */
|
/* Break into the Debugger if requested */
|
||||||
|
@ -602,7 +679,7 @@ ExpInitializeExecutive(IN ULONG Cpu,
|
||||||
/* Initialize all processors */
|
/* Initialize all processors */
|
||||||
HalAllProcessorsStarted();
|
HalAllProcessorsStarted();
|
||||||
|
|
||||||
/* Do Phase 1 HAL Initalization */
|
/* Do Phase 1 HAL Initialization */
|
||||||
HalInitSystem(1, KeLoaderBlock);
|
HalInitSystem(1, KeLoaderBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ VOID MmInitSystem(ULONG Phase, PLOADER_PARAMETER_BLOCK LoaderBlock, ULONG LastKe
|
||||||
VOID IoInit(VOID);
|
VOID IoInit(VOID);
|
||||||
VOID IoInit2(BOOLEAN BootLog);
|
VOID IoInit2(BOOLEAN BootLog);
|
||||||
VOID NTAPI IoInit3(VOID);
|
VOID NTAPI IoInit3(VOID);
|
||||||
VOID ObInit(VOID);
|
BOOLEAN NTAPI ObInit(VOID);
|
||||||
VOID PsInit(VOID);
|
VOID PsInit(VOID);
|
||||||
VOID CmInitializeRegistry(VOID);
|
VOID CmInitializeRegistry(VOID);
|
||||||
VOID NTAPI CmInitHives(BOOLEAN SetupBoot);
|
VOID NTAPI CmInitHives(BOOLEAN SetupBoot);
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
|
/* System call count */
|
||||||
|
ULONG KiServiceLimit = NUMBER_OF_SYSCALLS;
|
||||||
|
|
||||||
/* ARC Loader Block */
|
/* ARC Loader Block */
|
||||||
PLOADER_PARAMETER_BLOCK KeLoaderBlock;
|
PLOADER_PARAMETER_BLOCK KeLoaderBlock;
|
||||||
|
|
||||||
|
@ -96,7 +99,7 @@ KiInitSystem(VOID)
|
||||||
/* Initialize the syscall table */
|
/* Initialize the syscall table */
|
||||||
KeServiceDescriptorTable[0].Base = MainSSDT;
|
KeServiceDescriptorTable[0].Base = MainSSDT;
|
||||||
KeServiceDescriptorTable[0].Count = NULL;
|
KeServiceDescriptorTable[0].Count = NULL;
|
||||||
KeServiceDescriptorTable[0].Limit = NUMBER_OF_SYSCALLS;
|
KeServiceDescriptorTable[0].Limit = KiServiceLimit;
|
||||||
KeServiceDescriptorTable[1].Limit = 0;
|
KeServiceDescriptorTable[1].Limit = 0;
|
||||||
KeServiceDescriptorTable[0].Number = MainSSPT;
|
KeServiceDescriptorTable[0].Number = MainSSPT;
|
||||||
|
|
||||||
|
|
|
@ -44,34 +44,19 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
PsInitializeQuotaSystem(VOID);
|
PsInitializeQuotaSystem(VOID);
|
||||||
|
|
||||||
|
ULONG ObpInitializationPhase;
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS *********************************************************/
|
/* PRIVATE FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
VOID
|
BOOLEAN
|
||||||
INIT_FUNCTION
|
INIT_FUNCTION
|
||||||
|
NTAPI
|
||||||
ObInit2(VOID)
|
ObInit2(VOID)
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
PKPRCB Prcb;
|
PKPRCB Prcb;
|
||||||
PNPAGED_LOOKASIDE_LIST CurrentList = NULL;
|
PNPAGED_LOOKASIDE_LIST CurrentList = NULL;
|
||||||
|
|
||||||
/* Initialize the OBJECT_CREATE_INFORMATION List */
|
|
||||||
ExInitializeNPagedLookasideList(&ObpCiLookasideList,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
sizeof(OBJECT_CREATE_INFORMATION),
|
|
||||||
TAG('O', 'b', 'C', 'I'),
|
|
||||||
32);
|
|
||||||
|
|
||||||
/* Set the captured UNICODE_STRING Object Name List */
|
|
||||||
ExInitializeNPagedLookasideList(&ObpNmLookasideList,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
248,
|
|
||||||
TAG('O', 'b', 'N', 'M'),
|
|
||||||
16);
|
|
||||||
|
|
||||||
/* Now allocate the per-processor lists */
|
/* Now allocate the per-processor lists */
|
||||||
for (i = 0; i < KeNumberProcessors; i++)
|
for (i = 0; i < KeNumberProcessors; i++)
|
||||||
{
|
{
|
||||||
|
@ -128,10 +113,13 @@ ObInit2(VOID)
|
||||||
/* Link it */
|
/* Link it */
|
||||||
Prcb->PPLookasideList[LookasideNameBufferList].P = &CurrentList->L;
|
Prcb->PPLookasideList[LookasideNameBufferList].P = &CurrentList->L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
BOOLEAN
|
||||||
INIT_FUNCTION
|
INIT_FUNCTION
|
||||||
|
NTAPI
|
||||||
ObInit(VOID)
|
ObInit(VOID)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
@ -139,6 +127,34 @@ ObInit(VOID)
|
||||||
SECURITY_DESCRIPTOR SecurityDescriptor;
|
SECURITY_DESCRIPTOR SecurityDescriptor;
|
||||||
OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
|
OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
|
||||||
OBP_LOOKUP_CONTEXT Context;
|
OBP_LOOKUP_CONTEXT Context;
|
||||||
|
PKPRCB Prcb = KeGetCurrentPrcb();
|
||||||
|
|
||||||
|
/* Check if this is actually Phase 1 initialization */
|
||||||
|
if (ObpInitializationPhase != 0) goto ObPostPhase0;
|
||||||
|
|
||||||
|
/* Initialize the OBJECT_CREATE_INFORMATION List */
|
||||||
|
ExInitializeNPagedLookasideList(&ObpCiLookasideList,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
sizeof(OBJECT_CREATE_INFORMATION),
|
||||||
|
TAG('O', 'b', 'C', 'I'),
|
||||||
|
32);
|
||||||
|
|
||||||
|
/* Set the captured UNICODE_STRING Object Name List */
|
||||||
|
ExInitializeNPagedLookasideList(&ObpNmLookasideList,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
248,
|
||||||
|
TAG('O', 'b', 'N', 'M'),
|
||||||
|
16);
|
||||||
|
|
||||||
|
/* Temporarily setup both pointers to the shared list */
|
||||||
|
Prcb->PPLookasideList[LookasideCreateInfoList].L = &ObpCiLookasideList.L;
|
||||||
|
Prcb->PPLookasideList[LookasideCreateInfoList].P = &ObpCiLookasideList.L;
|
||||||
|
Prcb->PPLookasideList[LookasideNameBufferList].L = &ObpNmLookasideList.L;
|
||||||
|
Prcb->PPLookasideList[LookasideNameBufferList].P = &ObpNmLookasideList.L;
|
||||||
|
|
||||||
/* Initialize the security descriptor cache */
|
/* Initialize the security descriptor cache */
|
||||||
ObpInitSdCache();
|
ObpInitSdCache();
|
||||||
|
@ -149,9 +165,6 @@ ObInit(VOID)
|
||||||
/* Setup the Object Reaper */
|
/* Setup the Object Reaper */
|
||||||
ExInitializeWorkItem(&ObpReaperWorkItem, ObpReapObject, NULL);
|
ExInitializeWorkItem(&ObpReaperWorkItem, ObpReapObject, NULL);
|
||||||
|
|
||||||
/* Initialize lookaside lists */
|
|
||||||
ObInit2();
|
|
||||||
|
|
||||||
/* Initialize default Quota block */
|
/* Initialize default Quota block */
|
||||||
PsInitializeQuotaSystem();
|
PsInitializeQuotaSystem();
|
||||||
|
|
||||||
|
@ -160,7 +173,6 @@ ObInit(VOID)
|
||||||
ObpKernelHandleTable = PsGetCurrentProcess()->ObjectTable;
|
ObpKernelHandleTable = PsGetCurrentProcess()->ObjectTable;
|
||||||
|
|
||||||
/* Create the Type Type */
|
/* Create the Type Type */
|
||||||
DPRINT("Creating Type Type\n");
|
|
||||||
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
|
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
|
||||||
RtlInitUnicodeString(&Name, L"Type");
|
RtlInitUnicodeString(&Name, L"Type");
|
||||||
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
|
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
|
||||||
|
@ -173,7 +185,6 @@ ObInit(VOID)
|
||||||
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ObTypeObjectType);
|
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ObTypeObjectType);
|
||||||
|
|
||||||
/* Create the Directory Type */
|
/* Create the Directory Type */
|
||||||
DPRINT("Creating Directory Type\n");
|
|
||||||
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
|
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
|
||||||
RtlInitUnicodeString(&Name, L"Directory");
|
RtlInitUnicodeString(&Name, L"Directory");
|
||||||
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
|
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
|
||||||
|
@ -184,6 +195,15 @@ ObInit(VOID)
|
||||||
ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(OBJECT_DIRECTORY);
|
ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(OBJECT_DIRECTORY);
|
||||||
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ObDirectoryType);
|
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ObDirectoryType);
|
||||||
|
|
||||||
|
/* Phase 0 initialization complete */
|
||||||
|
ObpInitializationPhase++;
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
ObPostPhase0:
|
||||||
|
|
||||||
|
/* Re-initialize lookaside lists */
|
||||||
|
ObInit2();
|
||||||
|
|
||||||
/* Create security descriptor */
|
/* Create security descriptor */
|
||||||
RtlCreateSecurityDescriptor(&SecurityDescriptor,
|
RtlCreateSecurityDescriptor(&SecurityDescriptor,
|
||||||
SECURITY_DESCRIPTOR_REVISION1);
|
SECURITY_DESCRIPTOR_REVISION1);
|
||||||
|
@ -199,7 +219,6 @@ ObInit(VOID)
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
/* Create root directory */
|
/* Create root directory */
|
||||||
DPRINT("Creating Root Directory\n");
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
NULL,
|
NULL,
|
||||||
OBJ_PERMANENT,
|
OBJ_PERMANENT,
|
||||||
|
@ -271,5 +290,7 @@ ObInit(VOID)
|
||||||
/* FIXME: Hack Hack! */
|
/* FIXME: Hack Hack! */
|
||||||
ObSystemDeviceMap = ExAllocatePoolWithTag(NonPagedPool, sizeof(*ObSystemDeviceMap), TAG('O', 'b', 'D', 'm'));
|
ObSystemDeviceMap = ExAllocatePoolWithTag(NonPagedPool, sizeof(*ObSystemDeviceMap), TAG('O', 'b', 'D', 'm'));
|
||||||
RtlZeroMemory(ObSystemDeviceMap, sizeof(*ObSystemDeviceMap));
|
RtlZeroMemory(ObSystemDeviceMap, sizeof(*ObSystemDeviceMap));
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue