Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenpsmgr.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Kernel 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: ntoskrnl/ps/psmgr.c 00005 * PURPOSE: Process Manager: Initialization Code 00006 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) 00007 */ 00008 00009 /* INCLUDES ******************************************************************/ 00010 00011 #include <ntoskrnl.h> 00012 #define NDEBUG 00013 #include <debug.h> 00014 00015 extern ULONG ExpInitializationPhase; 00016 extern BOOLEAN SysThreadCreated; 00017 00018 PVOID KeUserPopEntrySListEnd; 00019 PVOID KeUserPopEntrySListFault; 00020 PVOID KeUserPopEntrySListResume; 00021 00022 GENERIC_MAPPING PspProcessMapping = 00023 { 00024 STANDARD_RIGHTS_READ | PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 00025 STANDARD_RIGHTS_WRITE | PROCESS_CREATE_PROCESS | PROCESS_CREATE_THREAD | 00026 PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_DUP_HANDLE | 00027 PROCESS_TERMINATE | PROCESS_SET_QUOTA | PROCESS_SET_INFORMATION | 00028 PROCESS_SUSPEND_RESUME, 00029 STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE, 00030 PROCESS_ALL_ACCESS 00031 }; 00032 00033 GENERIC_MAPPING PspThreadMapping = 00034 { 00035 STANDARD_RIGHTS_READ | THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION, 00036 STANDARD_RIGHTS_WRITE | THREAD_TERMINATE | THREAD_SUSPEND_RESUME | 00037 THREAD_ALERT | THREAD_SET_INFORMATION | THREAD_SET_CONTEXT, 00038 STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE, 00039 THREAD_ALL_ACCESS 00040 }; 00041 00042 PVOID PspSystemDllBase; 00043 PVOID PspSystemDllSection; 00044 PVOID PspSystemDllEntryPoint; 00045 00046 UNICODE_STRING PsNtDllPathName = 00047 RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntdll.dll"); 00048 00049 PHANDLE_TABLE PspCidTable; 00050 00051 PEPROCESS PsInitialSystemProcess = NULL; 00052 PEPROCESS PsIdleProcess = NULL; 00053 HANDLE PspInitialSystemProcessHandle; 00054 00055 ULONG PsMinimumWorkingSet, PsMaximumWorkingSet; 00056 struct 00057 { 00058 LIST_ENTRY List; 00059 KGUARDED_MUTEX Lock; 00060 } PspWorkingSetChangeHead; 00061 ULONG PspDefaultPagedLimit, PspDefaultNonPagedLimit, PspDefaultPagefileLimit; 00062 BOOLEAN PspDoingGiveBacks; 00063 00064 /* PRIVATE FUNCTIONS *********************************************************/ 00065 00066 USHORT 00067 NTAPI 00068 INIT_FUNCTION 00069 NameToOrdinal(IN PCHAR Name, 00070 IN PVOID DllBase, 00071 IN ULONG NumberOfNames, 00072 IN PULONG NameTable, 00073 IN PUSHORT OrdinalTable) 00074 { 00075 ULONG Mid; 00076 LONG Ret; 00077 00078 /* Fail if no names */ 00079 if (!NumberOfNames) return -1; 00080 00081 /* Do binary search */ 00082 Mid = NumberOfNames >> 1; 00083 Ret = strcmp(Name, (PCHAR)((ULONG_PTR)DllBase + NameTable[Mid])); 00084 00085 /* Check if we found it */ 00086 if (!Ret) return OrdinalTable[Mid]; 00087 00088 /* We didn't. Check if we only had one name to check */ 00089 if (NumberOfNames == 1) return -1; 00090 00091 /* Check if we should look up or down */ 00092 if (Ret < 0) 00093 { 00094 /* Loop down */ 00095 NumberOfNames = Mid; 00096 } 00097 else 00098 { 00099 /* Look up, update tables */ 00100 NameTable = &NameTable[Mid + 1]; 00101 OrdinalTable = &OrdinalTable[Mid + 1]; 00102 NumberOfNames -= (Mid - 1); 00103 } 00104 00105 /* Call us recursively */ 00106 return NameToOrdinal(Name, DllBase, NumberOfNames, NameTable, OrdinalTable); 00107 } 00108 00109 NTSTATUS 00110 NTAPI 00111 INIT_FUNCTION 00112 LookupEntryPoint(IN PVOID DllBase, 00113 IN PCHAR Name, 00114 OUT PVOID *EntryPoint) 00115 { 00116 PULONG NameTable; 00117 PUSHORT OrdinalTable; 00118 PIMAGE_EXPORT_DIRECTORY ExportDirectory; 00119 ULONG ExportSize; 00120 CHAR Buffer[64]; 00121 USHORT Ordinal; 00122 PULONG ExportTable; 00123 00124 /* Get the export directory */ 00125 ExportDirectory = RtlImageDirectoryEntryToData(DllBase, 00126 TRUE, 00127 IMAGE_DIRECTORY_ENTRY_EXPORT, 00128 &ExportSize); 00129 00130 /* Validate the name and copy it */ 00131 if (strlen(Name) > sizeof(Buffer) - 2) return STATUS_INVALID_PARAMETER; 00132 strcpy(Buffer, Name); 00133 00134 /* Setup name tables */ 00135 NameTable = (PULONG)((ULONG_PTR)DllBase + 00136 ExportDirectory->AddressOfNames); 00137 OrdinalTable = (PUSHORT)((ULONG_PTR)DllBase + 00138 ExportDirectory->AddressOfNameOrdinals); 00139 00140 /* Get the ordinal */ 00141 Ordinal = NameToOrdinal(Buffer, 00142 DllBase, 00143 ExportDirectory->NumberOfNames, 00144 NameTable, 00145 OrdinalTable); 00146 00147 /* Make sure the ordinal is valid */ 00148 if (Ordinal >= ExportDirectory->NumberOfFunctions) 00149 { 00150 /* It's not, fail */ 00151 return STATUS_PROCEDURE_NOT_FOUND; 00152 } 00153 00154 /* Resolve the address and write it */ 00155 ExportTable = (PULONG)((ULONG_PTR)DllBase + 00156 ExportDirectory->AddressOfFunctions); 00157 *EntryPoint = (PVOID)((ULONG_PTR)DllBase + ExportTable[Ordinal]); 00158 return STATUS_SUCCESS; 00159 } 00160 00161 NTSTATUS 00162 NTAPI 00163 INIT_FUNCTION 00164 PspLookupSystemDllEntryPoint(IN PCHAR Name, 00165 IN PVOID *EntryPoint) 00166 { 00167 /* Call the LDR Routine */ 00168 return LookupEntryPoint(PspSystemDllBase, Name, EntryPoint); 00169 } 00170 00171 NTSTATUS 00172 NTAPI 00173 INIT_FUNCTION 00174 PspLookupKernelUserEntryPoints(VOID) 00175 { 00176 NTSTATUS Status; 00177 00178 /* Get user-mode APC trampoline */ 00179 Status = PspLookupSystemDllEntryPoint("KiUserApcDispatcher", 00180 &KeUserApcDispatcher); 00181 if (!NT_SUCCESS(Status)) return Status; 00182 00183 /* Get user-mode exception dispatcher */ 00184 Status = PspLookupSystemDllEntryPoint("KiUserExceptionDispatcher", 00185 &KeUserExceptionDispatcher); 00186 if (!NT_SUCCESS(Status)) return Status; 00187 00188 /* Get user-mode callback dispatcher */ 00189 Status = PspLookupSystemDllEntryPoint("KiUserCallbackDispatcher", 00190 &KeUserCallbackDispatcher); 00191 if (!NT_SUCCESS(Status)) return Status; 00192 00193 /* Get user-mode exception raise trampoline */ 00194 Status = PspLookupSystemDllEntryPoint("KiRaiseUserExceptionDispatcher", 00195 &KeRaiseUserExceptionDispatcher); 00196 if (!NT_SUCCESS(Status)) return Status; 00197 00198 /* Get user-mode SLIST exception functions for page fault rollback race hack */ 00199 Status = PspLookupSystemDllEntryPoint("ExpInterlockedPopEntrySListEnd", 00200 &KeUserPopEntrySListEnd); 00201 if (!NT_SUCCESS(Status)) { DPRINT1("this not found\n"); return Status; } 00202 Status = PspLookupSystemDllEntryPoint("ExpInterlockedPopEntrySListFault", 00203 &KeUserPopEntrySListFault); 00204 if (!NT_SUCCESS(Status)) { DPRINT1("this not found\n"); return Status; } 00205 Status = PspLookupSystemDllEntryPoint("ExpInterlockedPopEntrySListResume", 00206 &KeUserPopEntrySListResume); 00207 if (!NT_SUCCESS(Status)) { DPRINT1("this not found\n"); return Status; } 00208 00209 /* On x86, there are multiple ways to do a system call, find the right stubs */ 00210 #if defined(_X86_) 00211 /* Check if this is a machine that supports SYSENTER */ 00212 if (KeFeatureBits & KF_FAST_SYSCALL) 00213 { 00214 /* Get user-mode sysenter stub */ 00215 SharedUserData->SystemCall = (PsNtosImageBase >> (PAGE_SHIFT + 1)); 00216 Status = PspLookupSystemDllEntryPoint("KiFastSystemCall", 00217 (PVOID)&SharedUserData-> 00218 SystemCall); 00219 if (!NT_SUCCESS(Status)) return Status; 00220 00221 /* Get user-mode sysenter return stub */ 00222 Status = PspLookupSystemDllEntryPoint("KiFastSystemCallRet", 00223 (PVOID)&SharedUserData-> 00224 SystemCallReturn); 00225 if (!NT_SUCCESS(Status)) return Status; 00226 } 00227 else 00228 { 00229 /* Get the user-mode interrupt stub */ 00230 Status = PspLookupSystemDllEntryPoint("KiIntSystemCall", 00231 (PVOID)&SharedUserData-> 00232 SystemCall); 00233 if (!NT_SUCCESS(Status)) return Status; 00234 } 00235 00236 /* Set the test instruction */ 00237 SharedUserData->TestRetInstruction = 0xC3; 00238 #endif 00239 00240 /* Return the status */ 00241 return Status; 00242 } 00243 00244 NTSTATUS 00245 NTAPI 00246 INIT_FUNCTION 00247 PspMapSystemDll(IN PEPROCESS Process, 00248 IN PVOID *DllBase, 00249 IN BOOLEAN UseLargePages) 00250 { 00251 NTSTATUS Status; 00252 LARGE_INTEGER Offset = {{0, 0}}; 00253 SIZE_T ViewSize = 0; 00254 PVOID ImageBase = 0; 00255 00256 /* Map the System DLL */ 00257 Status = MmMapViewOfSection(PspSystemDllSection, 00258 Process, 00259 (PVOID*)&ImageBase, 00260 0, 00261 0, 00262 &Offset, 00263 &ViewSize, 00264 ViewShare, 00265 0, 00266 PAGE_READWRITE); 00267 if (Status != STATUS_SUCCESS) 00268 { 00269 /* Normalize status code */ 00270 Status = STATUS_CONFLICTING_ADDRESSES; 00271 } 00272 00273 /* Write the image base and return status */ 00274 if (DllBase) *DllBase = ImageBase; 00275 return Status; 00276 } 00277 00278 NTSTATUS 00279 NTAPI 00280 INIT_FUNCTION 00281 PsLocateSystemDll(VOID) 00282 { 00283 OBJECT_ATTRIBUTES ObjectAttributes; 00284 IO_STATUS_BLOCK IoStatusBlock; 00285 HANDLE FileHandle, SectionHandle; 00286 NTSTATUS Status; 00287 ULONG_PTR HardErrorParameters; 00288 ULONG HardErrorResponse; 00289 00290 /* Locate and open NTDLL to determine ImageBase and LdrStartup */ 00291 InitializeObjectAttributes(&ObjectAttributes, 00292 &PsNtDllPathName, 00293 0, 00294 NULL, 00295 NULL); 00296 Status = ZwOpenFile(&FileHandle, 00297 FILE_READ_ACCESS, 00298 &ObjectAttributes, 00299 &IoStatusBlock, 00300 FILE_SHARE_READ, 00301 0); 00302 if (!NT_SUCCESS(Status)) 00303 { 00304 /* Failed, bugcheck */ 00305 KeBugCheckEx(PROCESS1_INITIALIZATION_FAILED, Status, 2, 0, 0); 00306 } 00307 00308 /* Check if the image is valid */ 00309 Status = MmCheckSystemImage(FileHandle, TRUE); 00310 if (Status == STATUS_IMAGE_CHECKSUM_MISMATCH) 00311 { 00312 /* Raise a hard error */ 00313 HardErrorParameters = (ULONG_PTR)&PsNtDllPathName; 00314 NtRaiseHardError(Status, 00315 1, 00316 1, 00317 &HardErrorParameters, 00318 OptionOk, 00319 &HardErrorResponse); 00320 return Status; 00321 } 00322 00323 /* Create a section for NTDLL */ 00324 Status = ZwCreateSection(&SectionHandle, 00325 SECTION_ALL_ACCESS, 00326 NULL, 00327 NULL, 00328 PAGE_EXECUTE, 00329 SEC_IMAGE, 00330 FileHandle); 00331 ZwClose(FileHandle); 00332 if (!NT_SUCCESS(Status)) 00333 { 00334 /* Failed, bugcheck */ 00335 KeBugCheckEx(PROCESS1_INITIALIZATION_FAILED, Status, 3, 0, 0); 00336 } 00337 00338 /* Reference the Section */ 00339 Status = ObReferenceObjectByHandle(SectionHandle, 00340 SECTION_ALL_ACCESS, 00341 MmSectionObjectType, 00342 KernelMode, 00343 (PVOID*)&PspSystemDllSection, 00344 NULL); 00345 ZwClose(SectionHandle); 00346 if (!NT_SUCCESS(Status)) 00347 { 00348 /* Failed, bugcheck */ 00349 KeBugCheckEx(PROCESS1_INITIALIZATION_FAILED, Status, 4, 0, 0); 00350 } 00351 00352 /* Map it */ 00353 Status = PspMapSystemDll(PsGetCurrentProcess(), &PspSystemDllBase, FALSE); 00354 if (!NT_SUCCESS(Status)) 00355 { 00356 /* Failed, bugcheck */ 00357 KeBugCheckEx(PROCESS1_INITIALIZATION_FAILED, Status, 5, 0, 0); 00358 } 00359 00360 /* Return status */ 00361 return Status; 00362 } 00363 00364 NTSTATUS 00365 NTAPI 00366 INIT_FUNCTION 00367 PspInitializeSystemDll(VOID) 00368 { 00369 NTSTATUS Status; 00370 00371 /* Get user-mode startup thunk */ 00372 Status = PspLookupSystemDllEntryPoint("LdrInitializeThunk", 00373 &PspSystemDllEntryPoint); 00374 if (!NT_SUCCESS(Status)) 00375 { 00376 /* Failed, bugcheck */ 00377 KeBugCheckEx(PROCESS1_INITIALIZATION_FAILED, Status, 7, 0, 0); 00378 } 00379 00380 /* Get all the other entrypoints */ 00381 Status = PspLookupKernelUserEntryPoints(); 00382 if (!NT_SUCCESS(Status)) 00383 { 00384 /* Failed, bugcheck */ 00385 KeBugCheckEx(PROCESS1_INITIALIZATION_FAILED, Status, 8, 0, 0); 00386 } 00387 00388 #ifdef _WINKD_ 00389 /* Let KD know we are done */ 00390 KdUpdateDataBlock(); 00391 #endif 00392 00393 /* Return status */ 00394 return Status; 00395 } 00396 00397 BOOLEAN 00398 NTAPI 00399 INIT_FUNCTION 00400 PspInitPhase1() 00401 { 00402 /* Initialize the System DLL and return status of operation */ 00403 if (!NT_SUCCESS(PspInitializeSystemDll())) return FALSE; 00404 return TRUE; 00405 } 00406 00407 BOOLEAN 00408 NTAPI 00409 INIT_FUNCTION 00410 PspInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock) 00411 { 00412 NTSTATUS Status; 00413 OBJECT_ATTRIBUTES ObjectAttributes; 00414 HANDLE SysThreadHandle; 00415 PETHREAD SysThread; 00416 MM_SYSTEMSIZE SystemSize; 00417 UNICODE_STRING Name; 00418 OBJECT_TYPE_INITIALIZER ObjectTypeInitializer; 00419 ULONG i; 00420 00421 /* Get the system size */ 00422 SystemSize = MmQuerySystemSize(); 00423 00424 /* Setup some memory options */ 00425 PspDefaultPagefileLimit = -1; 00426 switch (SystemSize) 00427 { 00428 /* Medimum systems */ 00429 case MmMediumSystem: 00430 00431 /* Increase the WS sizes a bit */ 00432 PsMinimumWorkingSet += 10; 00433 PsMaximumWorkingSet += 100; 00434 00435 /* Large systems */ 00436 case MmLargeSystem: 00437 00438 /* Increase the WS sizes a bit more */ 00439 PsMinimumWorkingSet += 30; 00440 PsMaximumWorkingSet += 300; 00441 00442 /* Small and other systems */ 00443 default: 00444 break; 00445 } 00446 00447 /* Setup callbacks */ 00448 for (i = 0; i < PSP_MAX_CREATE_THREAD_NOTIFY; i++) 00449 { 00450 ExInitializeCallBack(&PspThreadNotifyRoutine[i]); 00451 } 00452 for (i = 0; i < PSP_MAX_CREATE_PROCESS_NOTIFY; i++) 00453 { 00454 ExInitializeCallBack(&PspProcessNotifyRoutine[i]); 00455 } 00456 for (i = 0; i < PSP_MAX_LOAD_IMAGE_NOTIFY; i++) 00457 { 00458 ExInitializeCallBack(&PspLoadImageNotifyRoutine[i]); 00459 } 00460 00461 /* Setup the quantum table */ 00462 PsChangeQuantumTable(FALSE, PsRawPrioritySeparation); 00463 00464 /* Set quota settings */ 00465 if (!PspDefaultPagedLimit) PspDefaultPagedLimit = 0; 00466 if (!PspDefaultNonPagedLimit) PspDefaultNonPagedLimit = 0; 00467 if (!(PspDefaultNonPagedLimit) && !(PspDefaultPagedLimit)) 00468 { 00469 /* Enable give-backs */ 00470 PspDoingGiveBacks = TRUE; 00471 } 00472 else 00473 { 00474 /* Disable them */ 00475 PspDoingGiveBacks = FALSE; 00476 } 00477 00478 /* Now multiply limits by 1MB */ 00479 PspDefaultPagedLimit <<= 20; 00480 PspDefaultNonPagedLimit <<= 20; 00481 if (PspDefaultPagefileLimit != MAXULONG) PspDefaultPagefileLimit <<= 20; 00482 00483 /* Initialize the Active Process List */ 00484 InitializeListHead(&PsActiveProcessHead); 00485 KeInitializeGuardedMutex(&PspActiveProcessMutex); 00486 00487 /* Get the idle process */ 00488 PsIdleProcess = PsGetCurrentProcess(); 00489 00490 /* Setup the locks */ 00491 PsIdleProcess->ProcessLock.Value = 0; 00492 ExInitializeRundownProtection(&PsIdleProcess->RundownProtect); 00493 00494 /* Initialize the thread list */ 00495 InitializeListHead(&PsIdleProcess->ThreadListHead); 00496 00497 /* Clear kernel time */ 00498 PsIdleProcess->Pcb.KernelTime = 0; 00499 00500 /* Initialize Object Initializer */ 00501 RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer)); 00502 ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer); 00503 ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK | 00504 OBJ_PERMANENT | 00505 OBJ_EXCLUSIVE | 00506 OBJ_OPENIF; 00507 ObjectTypeInitializer.PoolType = NonPagedPool; 00508 ObjectTypeInitializer.SecurityRequired = TRUE; 00509 00510 /* Initialize the Process type */ 00511 RtlInitUnicodeString(&Name, L"Process"); 00512 ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(EPROCESS); 00513 ObjectTypeInitializer.GenericMapping = PspProcessMapping; 00514 ObjectTypeInitializer.ValidAccessMask = PROCESS_ALL_ACCESS; 00515 ObjectTypeInitializer.DeleteProcedure = PspDeleteProcess; 00516 ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &PsProcessType); 00517 00518 /* Initialize the Thread type */ 00519 RtlInitUnicodeString(&Name, L"Thread"); 00520 ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer); 00521 ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(ETHREAD); 00522 ObjectTypeInitializer.GenericMapping = PspThreadMapping; 00523 ObjectTypeInitializer.ValidAccessMask = THREAD_ALL_ACCESS; 00524 ObjectTypeInitializer.DeleteProcedure = PspDeleteThread; 00525 ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &PsThreadType); 00526 00527 /* Initialize the Job type */ 00528 RtlInitUnicodeString(&Name, L"Job"); 00529 ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer); 00530 ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(EJOB); 00531 ObjectTypeInitializer.GenericMapping = PspJobMapping; 00532 ObjectTypeInitializer.ValidAccessMask = JOB_OBJECT_ALL_ACCESS; 00533 ObjectTypeInitializer.DeleteProcedure = PspDeleteJob; 00534 ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &PsJobType); 00535 00536 /* Initialize job structures external to this file */ 00537 PspInitializeJobStructures(); 00538 00539 /* Initialize the Working Set data */ 00540 InitializeListHead(&PspWorkingSetChangeHead.List); 00541 KeInitializeGuardedMutex(&PspWorkingSetChangeHead.Lock); 00542 00543 /* Create the CID Handle table */ 00544 PspCidTable = ExCreateHandleTable(NULL); 00545 if (!PspCidTable) return FALSE; 00546 00547 /* FIXME: Initialize LDT/VDM support */ 00548 00549 /* Setup the reaper */ 00550 ExInitializeWorkItem(&PspReaperWorkItem, PspReapRoutine, NULL); 00551 00552 /* Set the boot access token */ 00553 PspBootAccessToken = (PTOKEN)(PsIdleProcess->Token.Value & ~MAX_FAST_REFS); 00554 00555 /* Setup default object attributes */ 00556 InitializeObjectAttributes(&ObjectAttributes, 00557 NULL, 00558 0, 00559 NULL, 00560 NULL); 00561 00562 /* Create the Initial System Process */ 00563 Status = PspCreateProcess(&PspInitialSystemProcessHandle, 00564 PROCESS_ALL_ACCESS, 00565 &ObjectAttributes, 00566 0, 00567 FALSE, 00568 0, 00569 0, 00570 0, 00571 FALSE); 00572 if (!NT_SUCCESS(Status)) return FALSE; 00573 00574 /* Get a reference to it */ 00575 ObReferenceObjectByHandle(PspInitialSystemProcessHandle, 00576 0, 00577 PsProcessType, 00578 KernelMode, 00579 (PVOID*)&PsInitialSystemProcess, 00580 NULL); 00581 00582 /* Copy the process names */ 00583 strcpy(PsIdleProcess->ImageFileName, "Idle"); 00584 strcpy(PsInitialSystemProcess->ImageFileName, "System"); 00585 00586 /* Allocate a structure for the audit name */ 00587 PsInitialSystemProcess->SeAuditProcessCreationInfo.ImageFileName = 00588 ExAllocatePoolWithTag(PagedPool, 00589 sizeof(OBJECT_NAME_INFORMATION), 00590 TAG_SEPA); 00591 if (!PsInitialSystemProcess->SeAuditProcessCreationInfo.ImageFileName) 00592 { 00593 /* Allocation failed */ 00594 return FALSE; 00595 } 00596 00597 /* Zero it */ 00598 RtlZeroMemory(PsInitialSystemProcess-> 00599 SeAuditProcessCreationInfo.ImageFileName, 00600 sizeof(OBJECT_NAME_INFORMATION)); 00601 00602 /* Setup the system initialization thread */ 00603 Status = PsCreateSystemThread(&SysThreadHandle, 00604 THREAD_ALL_ACCESS, 00605 &ObjectAttributes, 00606 0, 00607 NULL, 00608 Phase1Initialization, 00609 LoaderBlock); 00610 if (!NT_SUCCESS(Status)) return FALSE; 00611 00612 /* Create a handle to it */ 00613 ObReferenceObjectByHandle(SysThreadHandle, 00614 0, 00615 PsThreadType, 00616 KernelMode, 00617 (PVOID*)&SysThread, 00618 NULL); 00619 ObCloseHandle(SysThreadHandle, KernelMode); 00620 SysThreadCreated = TRUE; 00621 00622 /* Return success */ 00623 return TRUE; 00624 } 00625 00626 BOOLEAN 00627 NTAPI 00628 INIT_FUNCTION 00629 PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock) 00630 { 00631 /* Check the initialization phase */ 00632 switch (ExpInitializationPhase) 00633 { 00634 case 0: 00635 00636 /* Do Phase 0 */ 00637 return PspInitPhase0(LoaderBlock); 00638 00639 case 1: 00640 00641 /* Do Phase 1 */ 00642 return PspInitPhase1(); 00643 00644 default: 00645 00646 /* Don't know any other phase! Bugcheck! */ 00647 KeBugCheckEx(UNEXPECTED_INITIALIZATION_CALL, 00648 1, 00649 ExpInitializationPhase, 00650 0, 00651 0); 00652 return FALSE; 00653 } 00654 } 00655 00656 /* PUBLIC FUNCTIONS **********************************************************/ 00657 00658 /* 00659 * @implemented 00660 */ 00661 BOOLEAN 00662 NTAPI 00663 PsGetVersion(IN PULONG MajorVersion OPTIONAL, 00664 IN PULONG MinorVersion OPTIONAL, 00665 IN PULONG BuildNumber OPTIONAL, 00666 IN PUNICODE_STRING CSDVersion OPTIONAL) 00667 { 00668 if (MajorVersion) *MajorVersion = NtMajorVersion; 00669 if (MinorVersion) *MinorVersion = NtMinorVersion; 00670 if (BuildNumber) *BuildNumber = NtBuildNumber; 00671 00672 if (CSDVersion) 00673 { 00674 CSDVersion->Length = 0; 00675 CSDVersion->MaximumLength = 0; 00676 CSDVersion->Buffer = NULL; 00677 #if 0 00678 CSDVersion->Length = CmCSDVersionString.Length; 00679 CSDVersion->MaximumLength = CmCSDVersionString.Maximum; 00680 CSDVersion->Buffer = CmCSDVersionString.Buffer; 00681 #endif 00682 } 00683 00684 /* Check the High word */ 00685 return (NtBuildNumber >> 28) == 0xC; 00686 } 00687 00688 NTSTATUS 00689 NTAPI 00690 NtApphelpCacheControl(IN APPHELPCACHESERVICECLASS Service, 00691 IN PVOID ServiceData) 00692 { 00693 UNIMPLEMENTED; 00694 return STATUS_NOT_IMPLEMENTED; 00695 } 00696 00697 /* EOF */ Generated on Mon May 28 2012 04:37:35 for ReactOS by
1.7.6.1
|