mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 07:36:21 +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 ExSuiteMask;
|
||||
|
||||
extern ULONG MmCoreDumpType;
|
||||
extern LOADER_MODULE KeLoaderModules[64];
|
||||
extern ULONG KeLoaderModuleCount;
|
||||
extern PRTL_MESSAGE_RESOURCE_DATA KiBugCodeMessages;
|
||||
extern ULONG KiServiceLimit;
|
||||
BOOLEAN NoGuiBoot = FALSE;
|
||||
|
||||
/* Init flags and settings */
|
||||
|
@ -45,6 +44,7 @@ PVOID ExpNlsTableBase;
|
|||
ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset;
|
||||
ULONG ExpUnicodeCaseTableDataOffset;
|
||||
NLSTABLEINFO ExpNlsTableInfo;
|
||||
ULONG ExpNlsTableSize;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
@ -456,6 +456,8 @@ ExpInitializeExecutive(IN ULONG Cpu,
|
|||
CHAR Buffer[256];
|
||||
ANSI_STRING AnsiPath;
|
||||
NTSTATUS Status;
|
||||
PLIST_ENTRY NextEntry, ListHead;
|
||||
PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
|
||||
|
||||
/* FIXME: Deprecate soon */
|
||||
ParseAndCacheLoadedModules();
|
||||
|
@ -578,22 +580,97 @@ ExpInitializeExecutive(IN ULONG Cpu,
|
|||
/* Initialize the executive at phase 0 */
|
||||
if (!ExInitSystem()) KEBUGCHECK(PHASE0_INITIALIZATION_FAILED);
|
||||
|
||||
/* Load basic Security for other Managers */
|
||||
if (!SeInit1()) KEBUGCHECK(SECURITY_INITIALIZATION_FAILED);
|
||||
/* Set system ranges */
|
||||
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 */
|
||||
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 */
|
||||
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 */
|
||||
MmInit2();
|
||||
|
||||
/* Initialize Tokens now that the Object Manager is ready */
|
||||
if (!SeInit2()) KEBUGCHECK(SECURITY1_INITIALIZATION_FAILED);
|
||||
/* Call OB initialization again */
|
||||
if (!ObInit()) KEBUGCHECK(OBJECT_INITIALIZATION_FAILED);
|
||||
|
||||
/* Initalize the Process Manager */
|
||||
/* Initialize the Process Manager */
|
||||
PspInitPhase0();
|
||||
|
||||
/* Break into the Debugger if requested */
|
||||
|
@ -602,7 +679,7 @@ ExpInitializeExecutive(IN ULONG Cpu,
|
|||
/* Initialize all processors */
|
||||
HalAllProcessorsStarted();
|
||||
|
||||
/* Do Phase 1 HAL Initalization */
|
||||
/* Do Phase 1 HAL Initialization */
|
||||
HalInitSystem(1, KeLoaderBlock);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ VOID MmInitSystem(ULONG Phase, PLOADER_PARAMETER_BLOCK LoaderBlock, ULONG LastKe
|
|||
VOID IoInit(VOID);
|
||||
VOID IoInit2(BOOLEAN BootLog);
|
||||
VOID NTAPI IoInit3(VOID);
|
||||
VOID ObInit(VOID);
|
||||
BOOLEAN NTAPI ObInit(VOID);
|
||||
VOID PsInit(VOID);
|
||||
VOID CmInitializeRegistry(VOID);
|
||||
VOID NTAPI CmInitHives(BOOLEAN SetupBoot);
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
/* System call count */
|
||||
ULONG KiServiceLimit = NUMBER_OF_SYSCALLS;
|
||||
|
||||
/* ARC Loader Block */
|
||||
PLOADER_PARAMETER_BLOCK KeLoaderBlock;
|
||||
|
||||
|
@ -96,7 +99,7 @@ KiInitSystem(VOID)
|
|||
/* Initialize the syscall table */
|
||||
KeServiceDescriptorTable[0].Base = MainSSDT;
|
||||
KeServiceDescriptorTable[0].Count = NULL;
|
||||
KeServiceDescriptorTable[0].Limit = NUMBER_OF_SYSCALLS;
|
||||
KeServiceDescriptorTable[0].Limit = KiServiceLimit;
|
||||
KeServiceDescriptorTable[1].Limit = 0;
|
||||
KeServiceDescriptorTable[0].Number = MainSSPT;
|
||||
|
||||
|
|
|
@ -44,34 +44,19 @@ VOID
|
|||
NTAPI
|
||||
PsInitializeQuotaSystem(VOID);
|
||||
|
||||
ULONG ObpInitializationPhase;
|
||||
|
||||
/* PRIVATE FUNCTIONS *********************************************************/
|
||||
|
||||
VOID
|
||||
BOOLEAN
|
||||
INIT_FUNCTION
|
||||
NTAPI
|
||||
ObInit2(VOID)
|
||||
{
|
||||
ULONG i;
|
||||
PKPRCB Prcb;
|
||||
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 */
|
||||
for (i = 0; i < KeNumberProcessors; i++)
|
||||
{
|
||||
|
@ -128,10 +113,13 @@ ObInit2(VOID)
|
|||
/* Link it */
|
||||
Prcb->PPLookasideList[LookasideNameBufferList].P = &CurrentList->L;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID
|
||||
BOOLEAN
|
||||
INIT_FUNCTION
|
||||
NTAPI
|
||||
ObInit(VOID)
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
|
@ -139,6 +127,34 @@ ObInit(VOID)
|
|||
SECURITY_DESCRIPTOR SecurityDescriptor;
|
||||
OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
|
||||
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 */
|
||||
ObpInitSdCache();
|
||||
|
@ -149,9 +165,6 @@ ObInit(VOID)
|
|||
/* Setup the Object Reaper */
|
||||
ExInitializeWorkItem(&ObpReaperWorkItem, ObpReapObject, NULL);
|
||||
|
||||
/* Initialize lookaside lists */
|
||||
ObInit2();
|
||||
|
||||
/* Initialize default Quota block */
|
||||
PsInitializeQuotaSystem();
|
||||
|
||||
|
@ -160,7 +173,6 @@ ObInit(VOID)
|
|||
ObpKernelHandleTable = PsGetCurrentProcess()->ObjectTable;
|
||||
|
||||
/* Create the Type Type */
|
||||
DPRINT("Creating Type Type\n");
|
||||
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
|
||||
RtlInitUnicodeString(&Name, L"Type");
|
||||
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
|
||||
|
@ -173,7 +185,6 @@ ObInit(VOID)
|
|||
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ObTypeObjectType);
|
||||
|
||||
/* Create the Directory Type */
|
||||
DPRINT("Creating Directory Type\n");
|
||||
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
|
||||
RtlInitUnicodeString(&Name, L"Directory");
|
||||
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
|
||||
|
@ -184,6 +195,15 @@ ObInit(VOID)
|
|||
ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(OBJECT_DIRECTORY);
|
||||
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ObDirectoryType);
|
||||
|
||||
/* Phase 0 initialization complete */
|
||||
ObpInitializationPhase++;
|
||||
return TRUE;
|
||||
|
||||
ObPostPhase0:
|
||||
|
||||
/* Re-initialize lookaside lists */
|
||||
ObInit2();
|
||||
|
||||
/* Create security descriptor */
|
||||
RtlCreateSecurityDescriptor(&SecurityDescriptor,
|
||||
SECURITY_DESCRIPTOR_REVISION1);
|
||||
|
@ -199,7 +219,6 @@ ObInit(VOID)
|
|||
FALSE);
|
||||
|
||||
/* Create root directory */
|
||||
DPRINT("Creating Root Directory\n");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
NULL,
|
||||
OBJ_PERMANENT,
|
||||
|
@ -271,5 +290,7 @@ ObInit(VOID)
|
|||
/* FIXME: Hack Hack! */
|
||||
ObSystemDeviceMap = ExAllocatePoolWithTag(NonPagedPool, sizeof(*ObSystemDeviceMap), TAG('O', 'b', 'D', 'm'));
|
||||
RtlZeroMemory(ObSystemDeviceMap, sizeof(*ObSystemDeviceMap));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue