ReactOS  0.4.15-dev-4853-g3a72a52
init.c File Reference
#include <ntoskrnl.h>
#include <reactos/buildno.h>
#include "inbv/logo.h"
#include <debug.h>
Include dependency graph for init.c:

Go to the source code of this file.

Classes

struct  _INIT_BUFFER
 

Macros

#define NDEBUG
 
#define LOADER_PARAMETER_EXTENSION_MIN_SIZE   RTL_SIZEOF_THROUGH_FIELD(LOADER_PARAMETER_EXTENSION, AcpiTableSize)
 

Typedefs

typedef struct _INIT_BUFFER INIT_BUFFER
 
typedef struct _INIT_BUFFERPINIT_BUFFER
 

Functions

BOOLEAN NTAPI MmArmInitSystem (IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
NTSTATUS NTAPI ExpCreateSystemRootLink (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI ExpInitNls (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI ExpLoadInitialProcess (IN PINIT_BUFFER InitBuffer, OUT PRTL_USER_PROCESS_PARAMETERS *ProcessParameters, OUT PCHAR *ProcessEnvironment)
 
ULONG NTAPI ExComputeTickCountMultiplier (IN ULONG ClockIncrement)
 
BOOLEAN NTAPI ExpInitSystemPhase0 (VOID)
 
BOOLEAN NTAPI ExpInitSystemPhase1 (VOID)
 
BOOLEAN NTAPI ExInitSystem (VOID)
 
BOOLEAN NTAPI ExpIsLoaderValid (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI ExpLoadBootSymbols (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI ExBurnMemory (IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG_PTR PagesToDestroy, IN TYPE_OF_MEMORY MemoryType)
 
VOID NTAPI ExpInitializeExecutive (IN ULONG Cpu, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI MmFreeLoaderBlock (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI Phase1InitializationDiscard (IN PVOID Context)
 
VOID NTAPI Phase1Initialization (IN PVOID Context)
 

Variables

ULONG NtMajorVersion = VER_PRODUCTMAJORVERSION
 
ULONG NtMinorVersion = VER_PRODUCTMINORVERSION
 
ULONG NtBuildNumber = VER_PRODUCTBUILD
 
ULONG NtGlobalFlag = 0
 
ULONG ExSuiteMask
 
ULONG CmNtSpBuildNumber
 
ULONG CmNtCSDVersion
 
ULONG CmNtCSDReleaseType
 
UNICODE_STRING CmVersionString
 
UNICODE_STRING CmCSDVersionString
 
CHAR NtBuildLab []
 
ULONG ExpInitializationPhase
 
BOOLEAN ExpInTextModeSetup
 
BOOLEAN IoRemoteBootClient
 
ULONG InitSafeBootMode
 
BOOLEAN InitIsWinPEMode
 
BOOLEAN InitWinPEModeType
 
UNICODE_STRING NtSystemRoot
 
WCHAR NtInitialUserProcessBuffer [128] = L"\\SystemRoot\\System32\\smss.exe"
 
ULONG NtInitialUserProcessBufferLength
 
ULONG NtInitialUserProcessBufferType = REG_SZ
 
PVOID ExpNlsTableBase
 
ULONG ExpAnsiCodePageDataOffset
 
ULONG ExpOemCodePageDataOffset
 
ULONG ExpUnicodeCaseTableDataOffset
 
NLSTABLEINFO ExpNlsTableInfo
 
SIZE_T ExpNlsTableSize
 
PVOID ExpNlsSectionPointer
 
BOOLEAN ExCmosClockIsSane = TRUE
 
BOOLEAN ExpRealTimeIsUniversal
 

Macro Definition Documentation

◆ LOADER_PARAMETER_EXTENSION_MIN_SIZE

#define LOADER_PARAMETER_EXTENSION_MIN_SIZE   RTL_SIZEOF_THROUGH_FIELD(LOADER_PARAMETER_EXTENSION, AcpiTableSize)

Definition at line 20 of file init.c.

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file init.c.

Typedef Documentation

◆ INIT_BUFFER

◆ PINIT_BUFFER

Function Documentation

◆ ExBurnMemory()

VOID NTAPI ExBurnMemory ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock,
IN ULONG_PTR  PagesToDestroy,
IN TYPE_OF_MEMORY  MemoryType 
)

Definition at line 875 of file init.c.

878 {
879  PLIST_ENTRY ListEntry;
880  PMEMORY_ALLOCATION_DESCRIPTOR MemDescriptor;
881 
882  DPRINT1("Burn RAM amount: %lu pages\n", PagesToDestroy);
883 
884  /* Loop the memory descriptors, beginning at the end */
885  for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Blink;
886  ListEntry != &LoaderBlock->MemoryDescriptorListHead;
887  ListEntry = ListEntry->Blink)
888  {
889  /* Get the memory descriptor structure */
890  MemDescriptor = CONTAINING_RECORD(ListEntry,
892  ListEntry);
893 
894  /* Is memory free there or is it temporary? */
895  if (MemDescriptor->MemoryType == LoaderFree ||
896  MemDescriptor->MemoryType == LoaderFirmwareTemporary)
897  {
898  /* Check if the descriptor has more pages than we want */
899  if (MemDescriptor->PageCount > PagesToDestroy)
900  {
901  /* Change block's page count, ntoskrnl doesn't care much */
902  MemDescriptor->PageCount -= PagesToDestroy;
903  break;
904  }
905  else
906  {
907  /* Change block type */
908  MemDescriptor->MemoryType = MemoryType;
909  PagesToDestroy -= MemDescriptor->PageCount;
910 
911  /* Check if we are done */
912  if (PagesToDestroy == 0) break;
913  }
914  }
915  }
916 }
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
TYPE_OF_MEMORY MemoryType
Definition: arc.h:193
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
Definition: typedefs.h:119
#define DPRINT1
Definition: precomp.h:8

Referenced by ExpInitializeExecutive().

◆ ExComputeTickCountMultiplier()

ULONG NTAPI ExComputeTickCountMultiplier ( IN ULONG  ClockIncrement)

Definition at line 605 of file init.c.

606 {
607  ULONG MsRemainder = 0, MsIncrement;
608  ULONG IncrementRemainder;
609  ULONG i;
610 
611  /* Count the number of milliseconds for each clock interrupt */
612  MsIncrement = ClockIncrement / (10 * 1000);
613 
614  /* Count the remainder from the division above, with 24-bit precision */
615  IncrementRemainder = ClockIncrement - (MsIncrement * (10 * 1000));
616  for (i= 0; i < 24; i++)
617  {
618  /* Shift the remainders */
619  MsRemainder <<= 1;
620  IncrementRemainder <<= 1;
621 
622  /* Check if we've went past 1 ms */
623  if (IncrementRemainder >= (10 * 1000))
624  {
625  /* Increase the remainder by one, and substract from increment */
626  IncrementRemainder -= (10 * 1000);
627  MsRemainder |= 1;
628  }
629  }
630 
631  /* Return the increment */
632  return (MsIncrement << 24) | MsRemainder;
633 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int ULONG
Definition: retypes.h:1

Referenced by ExpInitializeExecutive().

◆ ExInitSystem()

BOOLEAN NTAPI ExInitSystem ( VOID  )

Definition at line 742 of file init.c.

743 {
744  /* Check the initialization phase */
745  switch (ExpInitializationPhase)
746  {
747  case 0:
748 
749  /* Do Phase 0 */
750  return ExpInitSystemPhase0();
751 
752  case 1:
753 
754  /* Do Phase 1 */
755  return ExpInitSystemPhase1();
756 
757  default:
758 
759  /* Don't know any other phase! Bugcheck! */
760  KeBugCheck(UNEXPECTED_INITIALIZATION_CALL);
761  return FALSE;
762  }
763 }
BOOLEAN NTAPI ExpInitSystemPhase0(VOID)
Definition: init.c:638
#define FALSE
Definition: types.h:117
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
BOOLEAN NTAPI ExpInitSystemPhase1(VOID)
Definition: init.c:661
ULONG ExpInitializationPhase
Definition: init.c:68

Referenced by ExpInitializeExecutive(), and Phase1InitializationDiscard().

◆ ExpCreateSystemRootLink()

NTSTATUS NTAPI ExpCreateSystemRootLink ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 100 of file init.c.

101 {
102  UNICODE_STRING LinkName;
104  HANDLE LinkHandle;
106  ANSI_STRING AnsiName;
107  CHAR Buffer[256];
110 
111  /* Initialize the ArcName tree */
112  RtlInitUnicodeString(&LinkName, L"\\ArcName");
114  &LinkName,
116  NULL,
118 
119  /* Create it */
120  Status = NtCreateDirectoryObject(&LinkHandle,
123  if (!NT_SUCCESS(Status))
124  {
125  /* Failed */
126  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 1, 0, 0);
127  }
128 
129  /* Close the LinkHandle */
130  NtClose(LinkHandle);
131 
132  /* Initialize the Device tree */
133  RtlInitUnicodeString(&LinkName, L"\\Device");
135  &LinkName,
137  NULL,
139 
140  /* Create it */
141  Status = NtCreateDirectoryObject(&LinkHandle,
144  if (!NT_SUCCESS(Status))
145  {
146  /* Failed */
147  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 2, 0, 0);
148  }
149 
150  /* Close the LinkHandle */
151  ObCloseHandle(LinkHandle, KernelMode);
152 
153  /* Create the system root symlink name */
154  RtlInitAnsiString(&AnsiName, "\\SystemRoot");
155  Status = RtlAnsiStringToUnicodeString(&LinkName, &AnsiName, TRUE);
156  if (!NT_SUCCESS(Status))
157  {
158  /* Failed */
159  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 3, 0, 0);
160  }
161 
162  /* Initialize the attributes for the link */
164  &LinkName,
166  NULL,
168 
169  /* Build the ARC name */
170  sprintf(Buffer,
171  "\\ArcName\\%s%s",
172  LoaderBlock->ArcBootDeviceName,
173  LoaderBlock->NtBootPathName);
174  Buffer[strlen(Buffer) - 1] = ANSI_NULL;
175 
176  /* Convert it to Unicode */
179  &TargetString,
180  TRUE);
181  if (!NT_SUCCESS(Status))
182  {
183  /* We failed, bugcheck */
184  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 4, 0, 0);
185  }
186 
187  /* Create it */
188  Status = NtCreateSymbolicLinkObject(&LinkHandle,
191  &TargetName);
192 
193  /* Free the strings */
194  RtlFreeUnicodeString(&LinkName);
196 
197  /* Check if creating the link failed */
198  if (!NT_SUCCESS(Status))
199  {
200  /* Failed */
201  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 5, 0, 0);
202  }
203 
204  /* Close the handle and return success */
205  ObCloseHandle(LinkHandle, KernelMode);
206  return STATUS_SUCCESS;
207 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define SYMBOLIC_LINK_ALL_ACCESS
Definition: nt_native.h:1267
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define L(x)
Definition: ntvdm.h:50
#define ANSI_NULL
_In_z_ PCHAR TargetString
Definition: cdrom.h:954
Definition: bufpool.h:45
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3401
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3378
#define OBJ_PERMANENT
Definition: winternl.h:226
WCHAR TargetName[256]
Definition: arping.c:27
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
NTSTATUS NTAPI NtCreateDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: obdir.c:765
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define DIRECTORY_ALL_ACCESS
Definition: nt_native.h:1259
#define NULL
Definition: types.h:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
PSECURITY_DESCRIPTOR SePublicDefaultUnrestrictedSd
Definition: sd.c:17

Referenced by Phase1InitializationDiscard().

◆ ExpInitializeExecutive()

VOID NTAPI ExpInitializeExecutive ( IN ULONG  Cpu,
IN PLOADER_PARAMETER_BLOCK  LoaderBlock 
)

Definition at line 921 of file init.c.

923 {
924  PNLS_DATA_BLOCK NlsData;
925  CHAR Buffer[256];
926  ANSI_STRING AnsiPath;
928  PCHAR CommandLine, PerfMem;
929  ULONG PerfMemUsed;
930  PLDR_DATA_TABLE_ENTRY NtosEntry;
931  PMESSAGE_RESOURCE_ENTRY MsgEntry;
932  ANSI_STRING CSDString;
933  size_t Remaining = 0;
934  PCHAR RcEnd = NULL;
935  CHAR VersionBuffer[65];
936 
937  /* Validate Loader */
938  if (!ExpIsLoaderValid(LoaderBlock))
939  {
940  /* Invalid loader version */
941  KeBugCheckEx(MISMATCHED_HAL,
942  3,
943  LoaderBlock->Extension->Size,
944  LoaderBlock->Extension->MajorVersion,
945  LoaderBlock->Extension->MinorVersion);
946  }
947 
948  /* Initialize PRCB pool lookaside pointers */
950 
951  /* Check if this is an application CPU */
952  if (Cpu)
953  {
954  /* Then simply initialize it with HAL */
955  if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
956  {
957  /* Initialization failed */
958  KeBugCheck(HAL_INITIALIZATION_FAILED);
959  }
960 
961  /* We're done */
962  return;
963  }
964 
965  /* Assume no text-mode or remote boot */
968 
969  /* Check if we have a setup loader block */
970  if (LoaderBlock->SetupLdrBlock)
971  {
972  /* Check if this is text-mode setup */
973  if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_TEXT_MODE)
975 
976  /* Check if this is network boot */
977  if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_REMOTE_BOOT)
978  {
979  /* Set variable */
981 
982  /* Make sure we're actually booting off the network */
983  ASSERT(!_memicmp(LoaderBlock->ArcBootDeviceName, "net(0)", 6));
984  }
985  }
986 
987  /* Set phase to 0 */
989 
990  /* Get boot command line */
991  CommandLine = LoaderBlock->LoadOptions;
992  if (CommandLine)
993  {
994  /* Upcase it for comparison and check if we're in performance mode */
995  _strupr(CommandLine);
996  PerfMem = strstr(CommandLine, "PERFMEM");
997  if (PerfMem)
998  {
999  /* Check if the user gave a number of bytes to use */
1000  PerfMem = strstr(PerfMem, "=");
1001  if (PerfMem)
1002  {
1003  /* Read the number of pages we'll use */
1004  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1005  if (PerfMemUsed)
1006  {
1007  /* FIXME: TODO */
1008  DPRINT1("BBT performance mode not yet supported."
1009  "/PERFMEM option ignored.\n");
1010  }
1011  }
1012  }
1013 
1014  /* Check if we're burning memory */
1015  PerfMem = strstr(CommandLine, "BURNMEMORY");
1016  if (PerfMem)
1017  {
1018  /* Check if the user gave a number of bytes to use */
1019  PerfMem = strstr(PerfMem, "=");
1020  if (PerfMem)
1021  {
1022  /* Read the number of pages we'll use */
1023  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1024  if (PerfMemUsed) ExBurnMemory(LoaderBlock, PerfMemUsed, LoaderBad);
1025  }
1026  }
1027  }
1028 
1029  /* Setup NLS Base and offsets */
1030  NlsData = LoaderBlock->NlsData;
1031  ExpNlsTableBase = NlsData->AnsiCodePageData;
1034  (ULONG_PTR)NlsData->AnsiCodePageData);
1036  (ULONG_PTR)NlsData->AnsiCodePageData);
1037 
1038  /* Initialize the NLS Tables */
1045  &ExpNlsTableInfo);
1047 
1048  /* Now initialize the HAL */
1049  if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
1050  {
1051  /* HAL failed to initialize, bugcheck */
1052  KeBugCheck(HAL_INITIALIZATION_FAILED);
1053  }
1054 
1055  /* Make sure interrupts are active now */
1056  _enable();
1057 
1058  /* Clear the crypto exponent */
1059  SharedUserData->CryptoExponent = 0;
1060 
1061  /* Set global flags for the checked build */
1062 #if DBG
1065 #endif
1066 
1067  /* Setup NT System Root Path */
1068  sprintf(Buffer, "C:%s", LoaderBlock->NtBootPathName);
1069 
1070  /* Convert to ANSI_STRING and null-terminate it */
1071  RtlInitString(&AnsiPath, Buffer);
1072  Buffer[--AnsiPath.Length] = ANSI_NULL;
1073 
1074  /* Get the string from KUSER_SHARED_DATA's buffer */
1075  RtlInitEmptyUnicodeString(&NtSystemRoot,
1076  SharedUserData->NtSystemRoot,
1077  sizeof(SharedUserData->NtSystemRoot));
1078 
1079  /* Now fill it in */
1081  if (!NT_SUCCESS(Status)) KeBugCheck(SESSION3_INITIALIZATION_FAILED);
1082 
1083  /* Setup bugcheck messages */
1085 
1086  /* Setup initial system settings */
1087  CmGetSystemControlValues(LoaderBlock->RegistryBase, CmControlVector);
1088 
1089  /* Set the Service Pack Number and add it to the CSD Version number if needed */
1091  if (((CmNtCSDVersion & 0xFFFF0000) == 0) && (CmNtCSDReleaseType == 1))
1092  {
1094  }
1095 
1096  /* Add loaded CmNtGlobalFlag value */
1098 
1099  /* Initialize the executive at phase 0 */
1100  if (!ExInitSystem()) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1101 
1102  /* Initialize the memory manager at phase 0 */
1103  if (!MmArmInitSystem(0, LoaderBlock)) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1104 
1105  /* Load boot symbols */
1106  ExpLoadBootSymbols(LoaderBlock);
1107 
1108  /* Check if we should break after symbol load */
1110 
1111  /* Check if this loader is compatible with NT 5.2 */
1112  if (LoaderBlock->Extension->Size >= sizeof(LOADER_PARAMETER_EXTENSION))
1113  {
1114  /* Setup headless terminal settings */
1115  HeadlessInit(LoaderBlock);
1116  }
1117 
1118  /* Set system ranges */
1119 #ifdef _M_AMD64
1122 #else
1125 #endif
1126 
1127  /* Make a copy of the NLS Tables */
1128  ExpInitNls(LoaderBlock);
1129 
1130  /* Get the kernel's load entry */
1131  NtosEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink,
1133  InLoadOrderLinks);
1134 
1135  /* Check if this is a service pack */
1136  if (CmNtCSDVersion & 0xFFFF)
1137  {
1138  /* Get the service pack string */
1139  Status = RtlFindMessage(NtosEntry->DllBase,
1140  11,
1141  0,
1142  WINDOWS_NT_CSD_STRING,
1143  &MsgEntry);
1144  if (NT_SUCCESS(Status))
1145  {
1146  /* Setup the string */
1147  RtlInitAnsiString(&CSDString, (PCHAR)MsgEntry->Text);
1148 
1149  /* Remove trailing newline */
1150  while ((CSDString.Length > 0) &&
1151  ((CSDString.Buffer[CSDString.Length - 1] == '\r') ||
1152  (CSDString.Buffer[CSDString.Length - 1] == '\n')))
1153  {
1154  /* Skip the trailing character */
1155  CSDString.Length--;
1156  }
1157 
1158  /* Fill the buffer with version information */
1160  sizeof(Buffer),
1161  "%Z %u%c",
1162  &CSDString,
1163  (CmNtCSDVersion & 0xFF00) >> 8,
1164  (CmNtCSDVersion & 0xFF) ?
1165  'A' + (CmNtCSDVersion & 0xFF) - 1 :
1166  ANSI_NULL);
1167  }
1168  else
1169  {
1170  /* Build default string */
1172  sizeof(Buffer),
1173  "CSD %04x",
1174  CmNtCSDVersion);
1175  }
1176 
1177  /* Check for success */
1178  if (!NT_SUCCESS(Status))
1179  {
1180  /* Fail */
1181  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1182  }
1183  }
1184  else
1185  {
1186  /* Then this is a beta */
1188  sizeof(Buffer),
1190  NULL,
1191  &Remaining,
1192  0);
1193  if (!NT_SUCCESS(Status))
1194  {
1195  /* Fail */
1196  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1197  }
1198 
1199  /* Update length */
1200  CmCSDVersionString.MaximumLength = sizeof(Buffer) - (USHORT)Remaining;
1201  }
1202 
1203  /* Check if we have an RC number */
1204  if ((CmNtCSDVersion & 0xFFFF0000) && (CmNtCSDReleaseType == 1))
1205  {
1206  /* Check if we have no version data yet */
1207  if (!(*Buffer))
1208  {
1209  /* Set defaults */
1210  Remaining = sizeof(Buffer);
1211  RcEnd = Buffer;
1212  }
1213  else
1214  {
1215  /* Add comma and space */
1217  sizeof(Buffer),
1218  ", ",
1219  &RcEnd,
1220  &Remaining,
1221  0);
1222  if (!NT_SUCCESS(Status))
1223  {
1224  /* Fail */
1225  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1226  }
1227  }
1228 
1229  /* Add the version format string */
1230  Status = RtlStringCbPrintfA(RcEnd,
1231  Remaining,
1232  "v.%u",
1233  (CmNtCSDVersion & 0xFFFF0000) >> 16);
1234  if (!NT_SUCCESS(Status))
1235  {
1236  /* Fail */
1237  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1238  }
1239  }
1240 
1241  /* Now setup the final string */
1242  RtlInitAnsiString(&CSDString, Buffer);
1244  &CSDString,
1245  TRUE);
1246  if (!NT_SUCCESS(Status))
1247  {
1248  /* Fail */
1249  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1250  }
1251 
1252  /* Add our version */
1253  Status = RtlStringCbPrintfA(VersionBuffer,
1254  sizeof(VersionBuffer),
1255  "%u.%u",
1258  if (!NT_SUCCESS(Status))
1259  {
1260  /* Fail */
1261  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1262  }
1263 
1264  /* Build the final version string */
1266 
1267  /* Check if the user wants a kernel stack trace database */
1269  {
1270  /* FIXME: TODO */
1271  DPRINT1("Kernel-mode stack trace support not yet present."
1272  "FLG_KERNEL_STACK_TRACE_DB flag ignored.\n");
1273  }
1274 
1275  /* Check if he wanted exception logging */
1277  {
1278  /* FIXME: TODO */
1279  DPRINT1("Kernel-mode exception logging support not yet present."
1280  "FLG_ENABLE_EXCEPTION_LOGGING flag ignored.\n");
1281  }
1282 
1283  /* Initialize the Handle Table */
1285 
1286 #if DBG
1287  /* On checked builds, allocate the system call count table */
1290  KiServiceLimit * sizeof(ULONG),
1291  'llaC');
1292 
1293  /* Use it for the shadow table too */
1295 
1296  /* Make sure allocation succeeded */
1298  {
1299  /* Zero the call counts to 0 */
1301  KiServiceLimit * sizeof(ULONG));
1302  }
1303 #endif
1304 
1305  /* Create the Basic Object Manager Types to allow new Object Types */
1306  if (!ObInitSystem()) KeBugCheck(OBJECT_INITIALIZATION_FAILED);
1307 
1308  /* Load basic Security for other Managers */
1309  if (!SeInitSystem()) KeBugCheck(SECURITY_INITIALIZATION_FAILED);
1310 
1311  /* Initialize the Process Manager */
1312  if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS_INITIALIZATION_FAILED);
1313 
1314  /* Initialize the PnP Manager */
1315  if (!PpInitSystem()) KeBugCheck(PP0_INITIALIZATION_FAILED);
1316 
1317  /* Initialize the User-Mode Debugging Subsystem */
1318  DbgkInitialize();
1319 
1320  /* Calculate the tick count multiplier */
1322  SharedUserData->TickCountMultiplier = ExpTickCountMultiplier;
1323 
1324  /* Set the OS Version */
1325  SharedUserData->NtMajorVersion = NtMajorVersion;
1326  SharedUserData->NtMinorVersion = NtMinorVersion;
1327 
1328  /* Set the machine type */
1329  SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_NATIVE;
1330  SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_NATIVE;
1331 }
#define VER_PRODUCTMAJORVERSION
Definition: ntverp.h:25
signed char * PCHAR
Definition: retypes.h:7
#define VER_PRODUCTBETA_STR
Definition: ieverp.h:10
ULONG KeMaximumIncrement
Definition: clock.c:20
VOID NTAPI ExpInitNls(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:212
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)
Definition: rtltypes.h:1895
UNICODE_STRING NtSystemRoot
Definition: init.c:75
NLSTABLEINFO ExpNlsTableInfo
Definition: init.c:87
USHORT MaximumLength
Definition: env_spec_w32.h:370
ULONG KiServiceLimit
Definition: krnlinit.c:26
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: psmgr.c:624
BOOLEAN NTAPI PpInitSystem(VOID)
Definition: pnpmgr.c:1712
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
char CHAR
Definition: xmlstorage.h:175
void __cdecl _enable(void)
Definition: intrin_arm.h:373
LONG NTSTATUS
Definition: precomp.h:26
NTSTRSAFEAPI RtlStringCbCatExA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc, _Outptr_opt_result_bytebuffer_(*pcbRemaining) NTSTRSAFE_PSTR *ppszDestEnd, _Out_opt_ size_t *pcbRemaining, _In_ STRSAFE_DWORD dwFlags)
Definition: ntstrsafe.h:718
#define SETUPLDR_REMOTE_BOOT
Definition: setupblk.h:8
NTSTRSAFEAPI RtlStringCbCopyExA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc, _Outptr_opt_result_bytebuffer_(*pcbRemaining) STRSAFE_LPSTR *ppszDestEnd, _Out_opt_ size_t *pcbRemaining, _In_ STRSAFE_DWORD dwFlags)
Definition: ntstrsafe.h:270
VOID NTAPI ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:794
NTSYSAPI NTSTATUS NTAPI RtlFindMessage(_In_ PVOID BaseAddress, _In_ ULONG Type, _In_ ULONG Language, _In_ ULONG MessageId, _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry)
#define VER_PRODUCTBUILD_QFE
Definition: ntverp.h:20
#define FLG_ENABLE_EXCEPTION_LOGGING
Definition: pstypes.h:82
BOOLEAN NTAPI MmArmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:2046
ULONG CmNtCSDReleaseType
Definition: init.c:60
PVOID AnsiCodePageData
Definition: arc.h:276
ULONG NtMajorVersion
Definition: init.c:45
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:65
PVOID DllBase
Definition: btrfs_drv.h:1870
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define FALSE
Definition: types.h:117
#define ANSI_NULL
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
Definition: arc.h:130
VOID NTAPI KiInitializeBugCheck(VOID)
Definition: bug.c:296
_Check_return_ _CRTIMP int __cdecl _memicmp(_In_reads_bytes_opt_(_Size) const void *_Buf1, _In_reads_bytes_opt_(_Size) const void *_Buf2, _In_ size_t _Size)
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES]
Definition: procobj.c:24
VOID NTAPI DbgkInitialize(VOID)
Definition: dbgkobj.c:1498
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
Definition: bufpool.h:45
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
ULONG CmNtSpBuildNumber
Definition: init.c:58
PVOID OemCodePageData
Definition: arc.h:277
Status
Definition: gdiplustypes.h:24
NTSYSAPI VOID NTAPI RtlInitNlsTables(_In_ PUSHORT AnsiTableBase, _In_ PUSHORT OemTableBase, _In_ PUSHORT CaseTableBase, _Out_ PNLSTABLEINFO NlsTable)
int Count
Definition: noreturn.cpp:7
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1899
#define ASSERT(a)
Definition: mode.c:44
VOID NTAPI ExpInitializeHandleTables(VOID)
Definition: handle.c:28
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID ExpNlsTableBase
Definition: init.c:84
ULONG NtMinorVersion
Definition: init.c:46
#define FLG_ENABLE_CLOSE_EXCEPTIONS
Definition: pstypes.h:81
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
CM_SYSTEM_CONTROL_VECTOR CmControlVector[]
BOOLEAN NTAPI ObInitSystem(VOID)
Definition: obinit.c:203
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define SharedUserData
PVOID MmHighestUserAddress
Definition: init.c:51
ULONG ExpUnicodeCaseTableDataOffset
Definition: init.c:86
UNICODE_STRING CmCSDVersionString
Definition: init.c:62
VOID NTAPI ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG_PTR PagesToDestroy, IN TYPE_OF_MEMORY MemoryType)
Definition: init.c:875
ULONG CmNtGlobalFlag
Definition: cmdata.c:19
Definition: btrfs_drv.h:1866
ULONG ExpInitializationPhase
Definition: init.c:68
UNICODE_STRING CmVersionString
Definition: init.c:61
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define MM_SYSTEM_RANGE_START_WOW64
Definition: mm.h:36
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
ULONG ExpOemCodePageDataOffset
Definition: init.c:85
BOOLEAN ExpInTextModeSetup
Definition: init.c:69
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define SETUPLDR_TEXT_MODE
Definition: setupblk.h:7
BOOLEAN NTAPI SeInitSystem(VOID)
Main security manager initialization function.
Definition: semgr.c:285
unsigned short USHORT
Definition: pedump.c:61
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
VOID NTAPI ExInitPoolLookasidePointers(VOID)
Definition: lookas.c:59
BOOLEAN NTAPI ExInitSystem(VOID)
Definition: init.c:742
#define NULL
Definition: types.h:112
VOID NTAPI CmGetSystemControlValues(IN PVOID SystemHiveData, IN PCM_SYSTEM_CONTROL_VECTOR ControlVector)
Definition: cmcontrl.c:104
#define FLG_ENABLE_KDEBUG_SYMBOL_LOAD
Definition: pstypes.h:73
BOOLEAN KdBreakAfterSymbolLoad
Definition: kddata.c:80
#define FLG_KERNEL_STACK_TRACE_DB
Definition: pstypes.h:68
VOID NTAPI HeadlessInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: hdlsterm.c:189
#define MM_HIGHEST_USER_ADDRESS_WOW64
Definition: mm.h:35
#define DPRINT1
Definition: precomp.h:8
#define DBG_STATUS_CONTROL_C
Definition: kdtypes.h:39
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable[SSDT_MAX_ENTRIES]
Definition: procobj.c:23
ULONG CmNtCSDVersion
Definition: init.c:59
ULONG ExpTickCountMultiplier
Definition: time.c:26
PVOID MmSystemRangeStart
Definition: init.c:52
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)
ULONG NtGlobalFlag
Definition: init.c:54
#define VER_PRODUCTMINORVERSION
Definition: ntverp.h:26
BOOLEAN NTAPI HalInitSystem(IN ULONG BootPhase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:43
PVOID UnicodeCodePageData
Definition: arc.h:278
BOOLEAN NTAPI ExpIsLoaderValid(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:768
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:85
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
ULONG NTAPI ExComputeTickCountMultiplier(IN ULONG ClockIncrement)
Definition: init.c:605
BOOLEAN IoRemoteBootClient
Definition: init.c:70

Referenced by KiInitializeKernel().

◆ ExpInitNls()

VOID NTAPI ExpInitNls ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 212 of file init.c.

213 {
214  LARGE_INTEGER SectionSize;
216  HANDLE NlsSection;
217  PVOID SectionBase = NULL;
218  SIZE_T ViewSize = 0;
219  LARGE_INTEGER SectionOffset = {{0, 0}};
220  PLIST_ENTRY ListHead, NextEntry;
222  ULONG NlsTablesEncountered = 0;
223  SIZE_T NlsTableSizes[3] = {0, 0, 0}; /* 3 NLS tables */
224 
225  /* Check if this is boot-time phase 0 initialization */
227  {
228  /* Loop the memory descriptors */
229  ListHead = &LoaderBlock->MemoryDescriptorListHead;
230  NextEntry = ListHead->Flink;
231  while (NextEntry != ListHead)
232  {
233  /* Get the current block */
234  MdBlock = CONTAINING_RECORD(NextEntry,
236  ListEntry);
237 
238  /* Check if this is an NLS block */
239  if (MdBlock->MemoryType == LoaderNlsData)
240  {
241  /* Increase the table size */
242  ExpNlsTableSize += MdBlock->PageCount * PAGE_SIZE;
243 
244  /* FreeLdr-specific */
245  NlsTableSizes[NlsTablesEncountered] = MdBlock->PageCount * PAGE_SIZE;
246  NlsTablesEncountered++;
247  ASSERT(NlsTablesEncountered < 4);
248  }
249 
250  /* Go to the next block */
251  NextEntry = MdBlock->ListEntry.Flink;
252  }
253 
254  /* Allocate the a new buffer since loader memory will be freed */
257  TAG_RTLI);
258  if (!ExpNlsTableBase) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
259 
260  /* Copy the codepage data in its new location. */
261  if (NlsTablesEncountered == 1)
262  {
263  /* Ntldr-way boot process */
265  LoaderBlock->NlsData->AnsiCodePageData,
267  }
268  else
269  {
270  /*
271  * In NT, the memory blocks are contiguous, but in ReactOS they aren't,
272  * so unless someone fixes FreeLdr, we'll have to use this icky hack.
273  */
275  LoaderBlock->NlsData->AnsiCodePageData,
276  NlsTableSizes[0]);
277 
278  RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0]),
279  LoaderBlock->NlsData->OemCodePageData,
280  NlsTableSizes[1]);
281 
282  RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0] +
283  NlsTableSizes[1]),
284  LoaderBlock->NlsData->UnicodeCodePageData,
285  NlsTableSizes[2]);
286  /* End of Hack */
287  }
288 
289  /* Initialize and reset the NLS TAbles */
296  &ExpNlsTableInfo);
298  return;
299  }
300 
301  /* Set the section size */
302  SectionSize.QuadPart = ExpNlsTableSize;
303 
304  /* Create the NLS Section */
305  Status = ZwCreateSection(&NlsSection,
307  NULL,
308  &SectionSize,
310  SEC_COMMIT | 0x1,
311  NULL);
312  if (!NT_SUCCESS(Status))
313  {
314  /* Failed */
315  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 1, 0, 0);
316  }
317 
318  /* Get a pointer to the section */
319  Status = ObReferenceObjectByHandle(NlsSection,
322  KernelMode,
324  NULL);
325  ObCloseHandle(NlsSection, KernelMode);
326  if (!NT_SUCCESS(Status))
327  {
328  /* Failed */
329  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 2, 0, 0);
330  }
331 
332  /* Map the NLS Section in system space */
334  &SectionBase,
335  &ExpNlsTableSize);
336  if (!NT_SUCCESS(Status))
337  {
338  /* Failed */
339  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 3, 0, 0);
340  }
341 
342  /* Copy the codepage data in its new location. */
343  ASSERT(SectionBase >= MmSystemRangeStart);
345 
346  /* Free the previously allocated buffer and set the new location */
348  ExpNlsTableBase = SectionBase;
349 
350  /* Initialize the NLS Tables */
357  &ExpNlsTableInfo);
359 
360  /* Reset the base to 0 */
361  SectionBase = NULL;
362 
363  /* Map the section in the system process */
366  &SectionBase,
367  0L,
368  0L,
369  &SectionOffset,
370  &ViewSize,
371  ViewShare,
372  0L,
374  if (!NT_SUCCESS(Status))
375  {
376  /* Failed */
377  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 5, 0, 0);
378  }
379 
380  /* Copy the table into the system process and set this as the base */
382  ExpNlsTableBase = SectionBase;
383 }
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)
NLSTABLEINFO ExpNlsTableInfo
Definition: init.c:87
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
LONG NTSTATUS
Definition: precomp.h:26
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define TAG_RTLI
Definition: tag.h:28
TYPE_OF_MEMORY MemoryType
Definition: arc.h:193
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define L(x)
Definition: ntvdm.h:50
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
#define SEC_COMMIT
Definition: mmtypes.h:99
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
#define PsGetCurrentProcess
Definition: psfuncs.h:17
NTSTATUS NTAPI MmMapViewOfSection(IN PVOID SectionObject, IN PEPROCESS Process, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
Definition: section.c:3907
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
Definition: mmfuncs.h:404
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
NTSYSAPI VOID NTAPI RtlInitNlsTables(_In_ PUSHORT AnsiTableBase, _In_ PUSHORT OemTableBase, _In_ PUSHORT CaseTableBase, _Out_ PNLSTABLEINFO NlsTable)
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID ExpNlsTableBase
Definition: init.c:84
PVOID ExpNlsSectionPointer
Definition: init.c:89
POBJECT_TYPE MmSectionObjectType
Definition: section.c:195
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS NTAPI MmMapViewInSystemSpace(IN PVOID SectionObject, OUT PVOID *MappedBase, IN OUT PSIZE_T ViewSize)
Definition: section.c:4337
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3378
ULONG ExpUnicodeCaseTableDataOffset
Definition: init.c:86
ULONG ExpInitializationPhase
Definition: init.c:68
SIZE_T ExpNlsTableSize
Definition: init.c:88
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:119
ULONG ExpOemCodePageDataOffset
Definition: init.c:85
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define NULL
Definition: types.h:112
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:404
PVOID MmSystemRangeStart
Definition: init.c:52
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:85
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
LONGLONG QuadPart
Definition: typedefs.h:114
#define PAGE_READWRITE
Definition: nt_native.h:1304

Referenced by ExpInitializeExecutive(), and Phase1InitializationDiscard().

◆ ExpInitSystemPhase0()

BOOLEAN NTAPI ExpInitSystemPhase0 ( VOID  )

Definition at line 638 of file init.c.

639 {
640  /* Initialize EXRESOURCE Support */
642 
643  /* Initialize the environment lock */
645 
646  /* Initialize the lookaside lists and locks */
648 
649  /* Initialize the Firmware Table resource and listhead */
652 
653  /* Set the suite mask to maximum and return */
654  ExSuiteMask = 0xFFFFFFFF;
655  return TRUE;
656 }
ERESOURCE ExpFirmwareTableResource
Definition: sysinfo.c:30
#define TRUE
Definition: types.h:120
FAST_MUTEX ExpEnvironmentLock
Definition: sysinfo.c:29
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
ULONG ExSuiteMask
Definition: init.c:55
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
VOID NTAPI ExpResourceInitialization(VOID)
Definition: resource.c:169
VOID ExpInitLookasideLists()
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LIST_ENTRY ExpFirmwareTableProviderListHead
Definition: sysinfo.c:31

Referenced by ExInitSystem().

◆ ExpInitSystemPhase1()

BOOLEAN NTAPI ExpInitSystemPhase1 ( VOID  )

Definition at line 661 of file init.c.

662 {
663  /* Initialize worker threads */
665 
666  /* Initialize pushlocks */
668 
669  /* Initialize events and event pairs */
671  {
672  DPRINT1("Executive: Event initialization failed\n");
673  return FALSE;
674  }
676  {
677  DPRINT1("Executive: Event Pair initialization failed\n");
678  return FALSE;
679  }
680 
681  /* Initialize mutants */
683  {
684  DPRINT1("Executive: Mutant initialization failed\n");
685  return FALSE;
686  }
687 
688  /* Initialize callbacks */
689  if (ExpInitializeCallbacks() == FALSE)
690  {
691  DPRINT1("Executive: Callback initialization failed\n");
692  return FALSE;
693  }
694 
695  /* Initialize semaphores */
697  {
698  DPRINT1("Executive: Semaphore initialization failed\n");
699  return FALSE;
700  }
701 
702  /* Initialize timers */
704  {
705  DPRINT1("Executive: Timer initialization failed\n");
706  return FALSE;
707  }
708 
709  /* Initialize profiling */
711  {
712  DPRINT1("Executive: Profile initialization failed\n");
713  return FALSE;
714  }
715 
716  /* Initialize UUIDs */
717  if (ExpUuidInitialization() == FALSE)
718  {
719  DPRINT1("Executive: Uuid initialization failed\n");
720  return FALSE;
721  }
722 
723  /* Initialize keyed events */
725  {
726  DPRINT1("Executive: Keyed event initialization failed\n");
727  return FALSE;
728  }
729 
730  /* Initialize Win32K */
731  if (ExpWin32kInit() == FALSE)
732  {
733  DPRINT1("Executive: Win32 initialization failed\n");
734  return FALSE;
735  }
736  return TRUE;
737 }
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI ExpInitializeMutantImplementation(VOID)
Definition: mutant.c:52
BOOLEAN NTAPI ExpInitializeProfileImplementation(VOID)
Definition: profile.c:62
#define FALSE
Definition: types.h:117
BOOLEAN NTAPI ExpUuidInitialization(VOID)
Definition: uuid.c:53
BOOLEAN NTAPI ExpWin32kInit(VOID)
Definition: win32k.c:259
VOID NTAPI ExpInitializeWorkerThreads(VOID)
Definition: work.c:522
BOOLEAN NTAPI ExpInitializeKeyedEventImplementation(VOID)
BOOLEAN NTAPI ExpInitializeSemaphoreImplementation(VOID)
Definition: sem.c:43
BOOLEAN NTAPI ExpInitializeTimerImplementation(VOID)
Definition: timer.c:223
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI ExpInitializeCallbacks(VOID)
Definition: callback.c:256
BOOLEAN NTAPI ExpInitializeEventImplementation(VOID)
Definition: event.c:39
VOID NTAPI ExpInitializePushLocks(VOID)
Definition: pushlock.c:45
BOOLEAN NTAPI ExpInitializeEventPairImplementation(VOID)
Definition: evtpair.c:33

Referenced by ExInitSystem().

◆ ExpIsLoaderValid()

BOOLEAN NTAPI ExpIsLoaderValid ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 768 of file init.c.

769 {
771 
772  /* Get the loader extension */
773  Extension = LoaderBlock->Extension;
774 
775  /* Validate the size (Windows 2003 loader doesn't provide more) */
777 
778  /* Don't validate upper versions */
779  if (Extension->MajorVersion > VER_PRODUCTMAJORVERSION) return TRUE;
780 
781  /* Fail if this is NT 4 */
782  if (Extension->MajorVersion < VER_PRODUCTMAJORVERSION) return FALSE;
783 
784  /* Fail if this is XP */
785  if (Extension->MinorVersion < VER_PRODUCTMINORVERSION) return FALSE;
786 
787  /* This is 2003 or newer, approve it */
788  return TRUE;
789 }
#define VER_PRODUCTMAJORVERSION
Definition: ntverp.h:25
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define VER_PRODUCTMINORVERSION
Definition: ntverp.h:26
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
#define LOADER_PARAMETER_EXTENSION_MIN_SIZE
Definition: init.c:20

Referenced by ExpInitializeExecutive().

◆ ExpLoadBootSymbols()

VOID NTAPI ExpLoadBootSymbols ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 794 of file init.c.

795 {
796  ULONG i = 0;
797  PLIST_ENTRY NextEntry;
798  ULONG Count, Length;
799  PWCHAR Name;
800  PLDR_DATA_TABLE_ENTRY LdrEntry;
801  CHAR NameBuffer[256];
802  STRING SymbolString;
804 
805  /* Loop the driver list */
806  NextEntry = LoaderBlock->LoadOrderListHead.Flink;
807  while (NextEntry != &LoaderBlock->LoadOrderListHead)
808  {
809  /* Skip the first two images */
810  if (i >= 2)
811  {
812  /* Get the entry */
813  LdrEntry = CONTAINING_RECORD(NextEntry,
815  InLoadOrderLinks);
816  if (LdrEntry->FullDllName.Buffer[0] == L'\\')
817  {
818  /* We have a name, read its data */
819  Name = LdrEntry->FullDllName.Buffer;
820  Length = LdrEntry->FullDllName.Length / sizeof(WCHAR);
821 
822  /* Check if our buffer can hold it */
823  if (sizeof(NameBuffer) < Length + sizeof(ANSI_NULL))
824  {
825  /* It's too long */
827  }
828  else
829  {
830  /* Copy the name */
831  Count = 0;
832  do
833  {
834  /* Copy the character */
835  NameBuffer[Count++] = (CHAR)*Name++;
836  } while (Count < Length);
837 
838  /* Null-terminate */
839  NameBuffer[Count] = ANSI_NULL;
841  }
842  }
843  else
844  {
845  /* Safely print the string into our buffer */
846  Status = RtlStringCbPrintfA(NameBuffer,
847  sizeof(NameBuffer),
848  "%S\\System32\\Drivers\\%wZ",
849  &SharedUserData->NtSystemRoot[2],
850  &LdrEntry->BaseDllName);
851  }
852 
853  /* Check if the buffer was ok */
854  if (NT_SUCCESS(Status))
855  {
856  /* Initialize the STRING for the debugger */
857  RtlInitString(&SymbolString, NameBuffer);
858 
859  /* Load the symbols */
860  DbgLoadImageSymbols(&SymbolString,
861  LdrEntry->DllBase,
863  }
864  }
865 
866  /* Go to the next entry */
867  i++;
868  NextEntry = NextEntry->Flink;
869  }
870 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:65
PVOID DllBase
Definition: btrfs_drv.h:1870
#define L(x)
Definition: ntvdm.h:50
#define ANSI_NULL
struct NameRec_ * Name
Definition: cdprocs.h:459
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
int Count
Definition: noreturn.cpp:7
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
std::wstring STRING
Definition: fontsub.cpp:33
#define SharedUserData
Definition: btrfs_drv.h:1866
Definition: typedefs.h:119
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
UNICODE_STRING FullDllName
Definition: btrfs_drv.h:1872
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
HANDLE NTAPI PsGetCurrentProcessId(VOID)
Definition: process.c:1123
VOID NTAPI DbgLoadImageSymbols(_In_ PSTRING Name, _In_ PVOID Base, _In_ ULONG_PTR ProcessId)
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define CHAR(Char)

Referenced by ExpInitializeExecutive().

◆ ExpLoadInitialProcess()

VOID NTAPI ExpLoadInitialProcess ( IN PINIT_BUFFER  InitBuffer,
OUT PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
OUT PCHAR ProcessEnvironment 
)

Definition at line 388 of file init.c.

391 {
393  SIZE_T Size;
394  PWSTR p;
395  UNICODE_STRING NullString = RTL_CONSTANT_STRING(L"");
396  UNICODE_STRING SmssName, Environment, SystemDriveString, DebugString;
397  PVOID EnvironmentPtr = NULL;
398  PRTL_USER_PROCESS_INFORMATION ProcessInformation;
399  PRTL_USER_PROCESS_PARAMETERS ProcessParams = NULL;
400 
401  NullString.Length = sizeof(WCHAR);
402 
403  /* Use the initial buffer, after the strings */
404  ProcessInformation = &InitBuffer->ProcessInfo;
405 
406  /* Allocate memory for the process parameters */
407  Size = sizeof(*ProcessParams) + ((MAX_WIN32_PATH * 6) * sizeof(WCHAR));
408  Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
409  (PVOID*)&ProcessParams,
410  0,
411  &Size,
414  if (!NT_SUCCESS(Status))
415  {
416  /* Failed, display error */
417  _snwprintf(InitBuffer->DebugBuffer,
418  sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
419  L"INIT: Unable to allocate Process Parameters. 0x%lx",
420  Status);
421  RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
423 
424  /* Bugcheck the system */
425  KeBugCheckEx(SESSION1_INITIALIZATION_FAILED, Status, 0, 0, 0);
426  }
427 
428  /* Setup the basic header, and give the process the low 1MB to itself */
429  ProcessParams->Length = (ULONG)Size;
430  ProcessParams->MaximumLength = (ULONG)Size;
433 
434  /* Allocate a page for the environment */
435  Size = PAGE_SIZE;
436  Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
437  &EnvironmentPtr,
438  0,
439  &Size,
442  if (!NT_SUCCESS(Status))
443  {
444  /* Failed, display error */
445  _snwprintf(InitBuffer->DebugBuffer,
446  sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
447  L"INIT: Unable to allocate Process Environment. 0x%lx",
448  Status);
449  RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
451 
452  /* Bugcheck the system */
453  KeBugCheckEx(SESSION2_INITIALIZATION_FAILED, Status, 0, 0, 0);
454  }
455 
456  /* Write the pointer */
457  ProcessParams->Environment = EnvironmentPtr;
458 
459  /* Make a buffer for the DOS path */
460  p = (PWSTR)(ProcessParams + 1);
461  ProcessParams->CurrentDirectory.DosPath.Buffer = p;
463  sizeof(WCHAR);
464 
465  /* Copy the DOS path */
467  &NtSystemRoot);
468 
469  /* Make a buffer for the DLL Path */
470  p = (PWSTR)((PCHAR)ProcessParams->CurrentDirectory.DosPath.Buffer +
471  ProcessParams->CurrentDirectory.DosPath.MaximumLength);
472  ProcessParams->DllPath.Buffer = p;
473  ProcessParams->DllPath.MaximumLength = MAX_WIN32_PATH * sizeof(WCHAR);
474 
475  /* Copy the DLL path and append the system32 directory */
476  RtlCopyUnicodeString(&ProcessParams->DllPath,
477  &ProcessParams->CurrentDirectory.DosPath);
478  RtlAppendUnicodeToString(&ProcessParams->DllPath, L"\\System32");
479 
480  /* Make a buffer for the image name */
481  p = (PWSTR)((PCHAR)ProcessParams->DllPath.Buffer +
482  ProcessParams->DllPath.MaximumLength);
483  ProcessParams->ImagePathName.Buffer = p;
484  ProcessParams->ImagePathName.MaximumLength = MAX_WIN32_PATH * sizeof(WCHAR);
485 
486  /* Make sure the buffer is a valid string which within the given length */
491  sizeof(NtInitialUserProcessBuffer) - sizeof(WCHAR)))))
492  {
493  /* Invalid initial process string, bugcheck */
494  KeBugCheckEx(SESSION2_INITIALIZATION_FAILED,
499  }
500 
501  /* Cut out anything after a space */
503  while ((*p) && (*p != L' ')) p++;
504 
505  /* Set the image path length */
506  ProcessParams->ImagePathName.Length =
508 
509  /* Copy the actual buffer */
510  RtlCopyMemory(ProcessParams->ImagePathName.Buffer,
512  ProcessParams->ImagePathName.Length);
513 
514  /* Null-terminate it */
515  ProcessParams->ImagePathName.Buffer[ProcessParams->ImagePathName.Length /
516  sizeof(WCHAR)] = UNICODE_NULL;
517 
518  /* Make a buffer for the command line */
519  p = (PWSTR)((PCHAR)ProcessParams->ImagePathName.Buffer +
520  ProcessParams->ImagePathName.MaximumLength);
521  ProcessParams->CommandLine.Buffer = p;
522  ProcessParams->CommandLine.MaximumLength = MAX_WIN32_PATH * sizeof(WCHAR);
523 
524  /* Add the image name to the command line */
525  RtlAppendUnicodeToString(&ProcessParams->CommandLine,
527 
528  /* Create the environment string */
529  RtlInitEmptyUnicodeString(&Environment,
530  ProcessParams->Environment,
531  (USHORT)Size);
532 
533  /* Append the DLL path to it */
537 
538  /* Create the system drive string */
539  SystemDriveString = NtSystemRoot;
540  SystemDriveString.Length = 2 * sizeof(WCHAR);
541 
542  /* Append it to the environment */
543  RtlAppendUnicodeToString(&Environment, L"SystemDrive=");
544  RtlAppendUnicodeStringToString(&Environment, &SystemDriveString);
546 
547  /* Append the system root to the environment */
548  RtlAppendUnicodeToString(&Environment, L"SystemRoot=");
551 
552  /* Prepare the prefetcher */
553  //CcPfBeginBootPhase(150);
554 
555  /* Create SMSS process */
556  SmssName = ProcessParams->ImagePathName;
557  Status = RtlCreateUserProcess(&SmssName,
559  RtlDeNormalizeProcessParams(ProcessParams),
560  NULL,
561  NULL,
562  NULL,
563  FALSE,
564  NULL,
565  NULL,
566  ProcessInformation);
567  if (!NT_SUCCESS(Status))
568  {
569  /* Failed, display error */
570  _snwprintf(InitBuffer->DebugBuffer,
571  sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
572  L"INIT: Unable to create Session Manager. 0x%lx",
573  Status);
574  RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
576 
577  /* Bugcheck the system */
578  KeBugCheckEx(SESSION3_INITIALIZATION_FAILED, Status, 0, 0, 0);
579  }
580 
581  /* Resume the thread */
582  Status = ZwResumeThread(ProcessInformation->ThreadHandle, NULL);
583  if (!NT_SUCCESS(Status))
584  {
585  /* Failed, display error */
586  _snwprintf(InitBuffer->DebugBuffer,
587  sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
588  L"INIT: Unable to resume Session Manager. 0x%lx",
589  Status);
590  RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
592 
593  /* Bugcheck the system */
594  KeBugCheckEx(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0);
595  }
596 
597  /* Return success */
598  *ProcessParameters = ProcessParams;
599  *ProcessEnvironment = EnvironmentPtr;
600 }
signed char * PCHAR
Definition: retypes.h:7
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:47
UNICODE_STRING NtSystemRoot
Definition: init.c:75
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
uint16_t * PWSTR
Definition: typedefs.h:56
LONG NTSTATUS
Definition: precomp.h:26
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
NTSYSAPI NTSTATUS NTAPI ZwDisplayString(_In_ PUNICODE_STRING DisplayString)
#define MEM_COMMIT
Definition: nt_native.h:1313
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
#define MEM_RESERVE
Definition: nt_native.h:1314
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
NTSYSAPI NTSTATUS NTAPI RtlCreateUserProcess(_In_ PUNICODE_STRING ImageFileName, _In_ ULONG Attributes, _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters, _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor, _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor, _In_opt_ HANDLE ParentProcess, _In_ BOOLEAN CurrentDirectory, _In_opt_ HANDLE DebugPort, _In_opt_ HANDLE ExceptionPort, _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo)
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define PCHAR
Definition: match.c:90
Status
Definition: gdiplustypes.h:24
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
#define RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB
Definition: rtltypes.h:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
WCHAR NtInitialUserProcessBuffer[128]
Definition: init.c:78
NTSYSAPI NTSTATUS NTAPI ZwResumeThread(_In_ HANDLE ThreadHandle, _Out_opt_ PULONG SuspendCount)
UNICODE_STRING ImagePathName
Definition: btrfs_drv.h:1891
ULONG NtInitialUserProcessBufferType
Definition: init.c:81
#define PAGE_SIZE
Definition: env_spec_w32.h:49
UNICODE_STRING CommandLine
Definition: btrfs_drv.h:1892
#define MAXULONG
Definition: typedefs.h:251
#define MAX_WIN32_PATH
Definition: ntoskrnl.h:119
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned short USHORT
Definition: pedump.c:61
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define NULL
Definition: types.h:112
NTSYSAPI PRTL_USER_PROCESS_PARAMETERS NTAPI RtlDeNormalizeProcessParams(_In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters)
UNICODE_STRING DosPath
Definition: rtltypes.h:1368
ULONG NtInitialUserProcessBufferLength
Definition: init.c:79
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
CCHAR DebugString[256]
Definition: cmdline.c:22
#define RTL_USER_PROCESS_PARAMETERS_NORMALIZED
Definition: rtltypes.h:41
GLfloat GLfloat p
Definition: glext.h:8902
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define REG_SZ
Definition: layer.c:22

Referenced by Phase1InitializationDiscard().

◆ MmArmInitSystem()

BOOLEAN NTAPI MmArmInitSystem ( IN ULONG  Phase,
IN PLOADER_PARAMETER_BLOCK  LoaderBlock 
)

Definition at line 2046 of file mminit.c.

2048 {
2049  ULONG i;
2050  BOOLEAN IncludeType[LoaderMaximum];
2051  PVOID Bitmap;
2053  PFN_NUMBER PageCount;
2054 #if DBG
2055  ULONG j;
2056  PMMPTE PointerPte, TestPte;
2057  MMPTE TempPte;
2058 #endif
2059 
2060  /* Dump memory descriptors */
2062 
2063  //
2064  // Instantiate memory that we don't consider RAM/usable
2065  // We use the same exclusions that Windows does, in order to try to be
2066  // compatible with WinLDR-style booting
2067  //
2068  for (i = 0; i < LoaderMaximum; i++) IncludeType[i] = TRUE;
2069  IncludeType[LoaderBad] = FALSE;
2070  IncludeType[LoaderFirmwarePermanent] = FALSE;
2071  IncludeType[LoaderSpecialMemory] = FALSE;
2072  IncludeType[LoaderBBTMemory] = FALSE;
2073  if (Phase == 0)
2074  {
2075  /* Count physical pages on the system */
2076  MiScanMemoryDescriptors(LoaderBlock);
2077 
2078  /* Initialize the phase 0 temporary event */
2080 
2081  /* Set all the events to use the temporary event for now */
2088 
2089  //
2090  // Default throttling limits for Cc
2091  // May be ajusted later on depending on system type
2092  //
2093  MmThrottleTop = 450;
2094  MmThrottleBottom = 127;
2095 
2096  //
2097  // Define the basic user vs. kernel address space separation
2098  //
2102 
2103  /* Highest PTE and PDE based on the addresses above */
2106 #if (_MI_PAGING_LEVELS >= 3)
2107  MiHighestUserPpe = MiAddressToPpe(MmHighestUserAddress);
2108 #if (_MI_PAGING_LEVELS >= 4)
2109  MiHighestUserPxe = MiAddressToPxe(MmHighestUserAddress);
2110 #endif
2111 #endif
2112  //
2113  // Get the size of the boot loader's image allocations and then round
2114  // that region up to a PDE size, so that any PDEs we might create for
2115  // whatever follows are separate from the PDEs that boot loader might've
2116  // already created (and later, we can blow all that away if we want to).
2117  //
2122 
2123  /* Initialize session space address layout */
2125 
2126  /* Set the based section highest address */
2128 
2129  /* Loop all 8 standby lists */
2130  for (i = 0; i < 8; i++)
2131  {
2132  /* Initialize them */
2137  }
2138 
2139  /* Initialize the user mode image list */
2141 
2142  /* Initalize the Working set list */
2144 
2145  /* Initialize critical section timeout value (relative time is negative) */
2147 
2148  /* Initialize the paged pool mutex and the section commit mutex */
2152 
2153  /* Initialize the Loader Lock */
2155 
2156  /* Set up the zero page event */
2158 
2159  /* Initialize the dead stack S-LIST */
2161 
2162  //
2163  // Check if this is a machine with less than 19MB of RAM
2164  //
2165  PageCount = MmNumberOfPhysicalPages;
2166  if (PageCount < MI_MIN_PAGES_FOR_SYSPTE_TUNING)
2167  {
2168  //
2169  // Use the very minimum of system PTEs
2170  //
2171  MmNumberOfSystemPtes = 7000;
2172  }
2173  else
2174  {
2175  //
2176  // Use the default
2177  //
2178  MmNumberOfSystemPtes = 11000;
2179  if (PageCount > MI_MIN_PAGES_FOR_SYSPTE_BOOST)
2180  {
2181  //
2182  // Double the amount of system PTEs
2183  //
2184  MmNumberOfSystemPtes <<= 1;
2185  }
2186  if (PageCount > MI_MIN_PAGES_FOR_SYSPTE_BOOST_BOOST)
2187  {
2188  //
2189  // Double the amount of system PTEs
2190  //
2191  MmNumberOfSystemPtes <<= 1;
2192  }
2193  if (MmSpecialPoolTag != 0 && MmSpecialPoolTag != -1)
2194  {
2195  //
2196  // Add some extra PTEs for special pool
2197  //
2198  MmNumberOfSystemPtes += 0x6000;
2199  }
2200  }
2201 
2202  DPRINT("System PTE count has been tuned to %lu (%lu bytes)\n",
2204 
2205  /* Check if no values are set for the heap limits */
2206  if (MmHeapSegmentReserve == 0)
2207  {
2208  MmHeapSegmentReserve = 2 * _1MB;
2209  }
2210 
2211  if (MmHeapSegmentCommit == 0)
2212  {
2214  }
2215 
2217  {
2219  }
2220 
2222  {
2224  }
2225 
2226  /* Initialize the working set lock */
2228 
2229  /* Set commit limit */
2230  MmTotalCommitLimit = (2 * _1GB) >> PAGE_SHIFT;
2232 
2233  /* Has the allocation fragment been setup? */
2234  if (!MmAllocationFragment)
2235  {
2236  /* Use the default value */
2238  if (PageCount < ((256 * _1MB) / PAGE_SIZE))
2239  {
2240  /* On memory systems with less than 256MB, divide by 4 */
2242  }
2243  else if (PageCount < (_1GB / PAGE_SIZE))
2244  {
2245  /* On systems with less than 1GB, divide by 2 */
2247  }
2248  }
2249  else
2250  {
2251  /* Convert from 1KB fragments to pages */
2254 
2255  /* Don't let it past the maximum */
2258 
2259  /* Don't let it too small either */
2262  }
2263 
2264  /* Check for kernel stack size that's too big */
2266  {
2267  /* Sanitize to default value */
2269  }
2270  else
2271  {
2272  /* Take the registry setting, and convert it into bytes */
2274 
2275  /* Now align it to a page boundary */
2277 
2278  /* Sanity checks */
2280  ASSERT((MmLargeStackSize & (PAGE_SIZE - 1)) == 0);
2281 
2282  /* Make sure it's not too low */
2284  }
2285 
2286  /* Compute color information (L2 cache-separated paging lists) */
2288 
2289  // Calculate the number of bytes for the PFN database
2290  // then add the color tables and convert to pages
2291  MxPfnAllocation = (MmHighestPhysicalPage + 1) * sizeof(MMPFN);
2294 
2295  // We have to add one to the count here, because in the process of
2296  // shifting down to the page size, we actually ended up getting the
2297  // lower aligned size (so say, 0x5FFFF bytes is now 0x5F pages).
2298  // Later on, we'll shift this number back into bytes, which would cause
2299  // us to end up with only 0x5F000 bytes -- when we actually want to have
2300  // 0x60000 bytes.
2301  MxPfnAllocation++;
2302 
2303  /* Initialize the platform-specific parts */
2304  MiInitMachineDependent(LoaderBlock);
2305 
2306 #if DBG
2307  /* Prototype PTEs are assumed to be in paged pool, so check if the math works */
2308  PointerPte = (PMMPTE)MmPagedPoolStart;
2309  MI_MAKE_PROTOTYPE_PTE(&TempPte, PointerPte);
2310  TestPte = MiProtoPteToPte(&TempPte);
2311  ASSERT(PointerPte == TestPte);
2312 
2313  /* Try the last nonpaged pool address */
2314  PointerPte = (PMMPTE)MI_NONPAGED_POOL_END;
2315  MI_MAKE_PROTOTYPE_PTE(&TempPte, PointerPte);
2316  TestPte = MiProtoPteToPte(&TempPte);
2317  ASSERT(PointerPte == TestPte);
2318 
2319  /* Try a bunch of random addresses near the end of the address space */
2320  PointerPte = (PMMPTE)((ULONG_PTR)MI_HIGHEST_SYSTEM_ADDRESS - 0x37FFF);
2321  for (j = 0; j < 20; j += 1)
2322  {
2323  MI_MAKE_PROTOTYPE_PTE(&TempPte, PointerPte);
2324  TestPte = MiProtoPteToPte(&TempPte);
2325  ASSERT(PointerPte == TestPte);
2326  PointerPte++;
2327  }
2328 
2329  /* Subsection PTEs are always in nonpaged pool, pick a random address to try */
2331  MI_MAKE_SUBSECTION_PTE(&TempPte, PointerPte);
2333  ASSERT(PointerPte == TestPte);
2334 #endif
2335 
2336  //
2337  // Build the physical memory block
2338  //
2340  IncludeType);
2341 
2342  //
2343  // Allocate enough buffer for the PFN bitmap
2344  // Align it up to a 32-bit boundary
2345  //
2347  (((MmHighestPhysicalPage + 1) + 31) / 32) * 4,
2348  TAG_MM);
2349  if (!Bitmap)
2350  {
2351  //
2352  // This is critical
2353  //
2354  KeBugCheckEx(INSTALL_MORE_MEMORY,
2358  0x101);
2359  }
2360 
2361  //
2362  // Initialize it and clear all the bits to begin with
2363  //
2365  Bitmap,
2368 
2369  //
2370  // Loop physical memory runs
2371  //
2372  for (i = 0; i < MmPhysicalMemoryBlock->NumberOfRuns; i++)
2373  {
2374  //
2375  // Get the run
2376  //
2378  DPRINT("PHYSICAL RAM [0x%08p to 0x%08p]\n",
2379  Run->BasePage << PAGE_SHIFT,
2380  (Run->BasePage + Run->PageCount) << PAGE_SHIFT);
2381 
2382  //
2383  // Make sure it has pages inside it
2384  //
2385  if (Run->PageCount)
2386  {
2387  //
2388  // Set the bits in the PFN bitmap
2389  //
2390  RtlSetBits(&MiPfnBitMap, (ULONG)Run->BasePage, (ULONG)Run->PageCount);
2391  }
2392  }
2393 
2394  /* Look for large page cache entries that need caching */
2396 
2397  /* Loop for HAL Heap I/O device mappings that need coherency tracking */
2399 
2400  /* Set the initial resident page count */
2402 
2403  /* Initialize large page structures on PAE/x64, and MmProcessList on x86 */
2405 
2406  /* Check if the registry says any drivers should be loaded with large pages */
2408 
2409  /* Relocate the boot drivers into system PTE space and fixup their PFNs */
2410  MiReloadBootLoadedDrivers(LoaderBlock);
2411 
2412  /* FIXME: Call out into Driver Verifier for initialization */
2413 
2414  /* Check how many pages the system has */
2415  if (MmNumberOfPhysicalPages <= ((13 * _1MB) / PAGE_SIZE))
2416  {
2417  /* Set small system */
2420  }
2421  else if (MmNumberOfPhysicalPages <= ((19 * _1MB) / PAGE_SIZE))
2422  {
2423  /* Set small system and add 100 pages for the cache */
2425  MmSystemCacheWsMinimum += 100;
2427  }
2428  else
2429  {
2430  /* Set medium system and add 400 pages for the cache */
2432  MmSystemCacheWsMinimum += 400;
2434  }
2435 
2436  /* Check for less than 24MB */
2437  if (MmNumberOfPhysicalPages < ((24 * _1MB) / PAGE_SIZE))
2438  {
2439  /* No more than 32 pages */
2441  }
2442 
2443  /* Check for more than 32MB */
2444  if (MmNumberOfPhysicalPages >= ((32 * _1MB) / PAGE_SIZE))
2445  {
2446  /* Check for product type being "Wi" for WinNT */
2447  if (MmProductType == '\0i\0W')
2448  {
2449  /* Then this is a large system */
2451  }
2452  else
2453  {
2454  /* For servers, we need 64MB to consider this as being large */
2455  if (MmNumberOfPhysicalPages >= ((64 * _1MB) / PAGE_SIZE))
2456  {
2457  /* Set it as large */
2459  }
2460  }
2461  }
2462 
2463  /* Check for more than 33 MB */
2464  if (MmNumberOfPhysicalPages > ((33 * _1MB) / PAGE_SIZE))
2465  {
2466  /* Add another 500 pages to the cache */
2467  MmSystemCacheWsMinimum += 500;
2468  }
2469 
2470  /* Now setup the shared user data fields */
2471  ASSERT(SharedUserData->NumberOfPhysicalPages == 0);
2472  SharedUserData->NumberOfPhysicalPages = MmNumberOfPhysicalPages;
2473  SharedUserData->LargePageMinimum = 0;
2474 
2475  /* Check for workstation (Wi for WinNT) */
2476  if (MmProductType == '\0i\0W')
2477  {
2478  /* Set Windows NT Workstation product type */
2479  SharedUserData->NtProductType = NtProductWinNt;
2480  MmProductType = 0;
2481 
2482  /* For this product, we wait till the last moment to throttle */
2483  MmThrottleTop = 250;
2484  MmThrottleBottom = 30;
2485  }
2486  else
2487  {
2488  /* Check for LanMan server (La for LanmanNT) */
2489  if (MmProductType == '\0a\0L')
2490  {
2491  /* This is a domain controller */
2492  SharedUserData->NtProductType = NtProductLanManNt;
2493  }
2494  else
2495  {
2496  /* Otherwise it must be a normal server (Se for ServerNT) */
2497  SharedUserData->NtProductType = NtProductServer;
2498  }
2499 
2500  /* Set the product type, and make the system more aggressive with low memory */
2501  MmProductType = 1;
2502  MmMinimumFreePages = 81;
2503 
2504  /* We will throttle earlier to preserve memory */
2505  MmThrottleTop = 450;
2506  MmThrottleBottom = 80;
2507  }
2508 
2509  /* Update working set tuning parameters */
2511 
2512  /* Finetune the page count by removing working set and NP expansion */
2516  if (MmResidentAvailablePages <= 0)
2517  {
2518  /* This should not happen */
2519  DPRINT1("System cache working set too big\n");
2520  return FALSE;
2521  }
2522 
2523  /* Define limits for system cache */
2524 #ifdef _M_AMD64
2526 #else
2528 #endif
2530 #ifdef _M_AMD64
2532 #else
2534 #endif
2535 
2536  /* Initialize the system cache */
2537  //MiInitializeSystemCache(MmSystemCacheWsMinimum, MmAvailablePages);
2538 
2539  /* Update the commit limit */
2541  if (MmTotalCommitLimit > 1024) MmTotalCommitLimit -= 1024;
2543 
2544  /* Size up paged pool and build the shadow system page directory */
2545  MiBuildPagedPool();
2546 
2547  /* Debugger physical memory support is now ready to be used */
2549 
2550  /* Initialize the loaded module list */
2551  MiInitializeLoadedModuleList(LoaderBlock);
2552  }
2553 
2554  //
2555  // Always return success for now
2556  //
2557  return TRUE;
2558 }
MMSUPPORT MmSystemCacheWs
Definition: mminit.c:246
PFN_NUMBER MmResidentAvailableAtInit
Definition: freelist.c:28
Definition: bidi.c:433
PFN_NUMBER MmResidentAvailablePages
Definition: freelist.c:27
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define max(a, b)
Definition: svc.c:63
SIZE_T MmHeapDeCommitTotalFreeThreshold
Definition: mminit.c:368
VOID NTAPI MiInitializeDriverLargePageList(VOID)
Definition: largepag.c:68
MMPFNLIST MmStandbyPageListByPriority[8]
Definition: pfnlist.c:44
#define MI_MIN_PAGES_FOR_SYSPTE_BOOST
Definition: mm.h:56
#define LL
Definition: tui.h:150
#define MI_DEFAULT_SYSTEM_RANGE_START
Definition: mm.h:11
#define MI_MIN_PAGES_FOR_SYSPTE_BOOST_BOOST
Definition: mm.h:57
#define MI_MAX_ALLOCATION_FRAGMENT
Definition: mm.h:72
VOID NTAPI MiComputeColorInformation(VOID)
Definition: mminit.c:508
#define MiAddressToPde(x)
Definition: mmx86.c:20
#define MI_NONPAGED_POOL_END
Definition: mm.h:29
KGUARDED_MUTEX MmSectionBasedMutex
Definition: section.c:110
#define TRUE
Definition: types.h:120
struct _MMCOLOR_TABLES MMCOLOR_TABLES
BOOLEAN NTAPI MiInitializeLoadedModuleList(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: sysldr.c:2204
PLOADER_PARAMETER_EXTENSION Extension
Definition: arc.h:512
VOID NTAPI KeInitializeMutant(IN PKMUTANT Mutant, IN BOOLEAN InitialOwner)
Definition: mutex.c:22
MMLISTS ListName
Definition: mm.h:444
PFN_COUNT MmNumberOfPhysicalPages
Definition: mminit.c:212
BOOLEAN MiDbgEnableMdDump
Definition: mminit.c:373
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
FORCEINLINE PMMPTE MiAddressToPpe(PVOID Address)
Definition: mm.h:161
ULONG MmCritsectTimeoutSeconds
Definition: mminit.c:387
PKEVENT MiLowPagedPoolEvent
Definition: mminit.c:294
SIZE_T MmTotalCommitLimitMaximum
Definition: mminit.c:360
ULONG MmLargeStackSize
Definition: mminit.c:262
VOID NTAPI MiScanMemoryDescriptors(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:403
#define _1KB
Definition: miarm.h:18
#define KERNEL_LARGE_STACK_SIZE
PFN_COUNT MiExpansionPoolPagesInitialCharge
Definition: pool.c:21
PHYSICAL_MEMORY_RUN Run[1]
Definition: miarm.h:431
PFN_NUMBER MmAvailablePages
Definition: freelist.c:26
KMUTANT MmSystemLoadLock
Definition: sysldr.c:39
PFN_NUMBER MmSystemCacheWsMinimum
Definition: mminit.c:336
SIZE_T MmSizeOfNonPagedPoolInBytes
Definition: mminit.c:26
PFN_NUMBER Flink
Definition: mm.h:445
PKEVENT MiHighPagedPoolEvent
Definition: mminit.c:295
uint32_t ULONG_PTR
Definition: typedefs.h:65
PFN_NUMBER MxPfnAllocation
Definition: mminit.c:187
#define MI_USER_PROBE_ADDRESS
Definition: mm.h:10
PFN_NUMBER MmLowestPhysicalPage
Definition: mminit.c:211
#define MiAddressToPte(x)
Definition: mmx86.c:19
ULONG MmSpecialPoolTag
Definition: pool.c:29
PPHYSICAL_MEMORY_DESCRIPTOR NTAPI MmInitializeMemoryLimits(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PBOOLEAN IncludeType)
Definition: mminit.c:1622
ULONG PFN_NUMBER
Definition: ke.h:9
VOID NTAPI MiInitializeSessionSpaceLayout(VOID)
Definition: init.c:63
#define TAG_MM
Definition: tag.h:110
VOID NTAPI MiAddHalIoMappings(VOID)
Definition: mminit.c:1418
#define FALSE
Definition: types.h:117
Definition: arc.h:130
PFN_NUMBER Blink
Definition: mm.h:446
PVOID MmHighestUserAddress
Definition: mminit.c:229
SIZE_T MmBootImageSize
Definition: mminit.c:222
unsigned char BOOLEAN
#define MiProtoPteToPte(x)
Definition: mm.h:316
PVOID MmSystemRangeStart
Definition: mminit.c:230
struct tagRun Run
KEVENT MmZeroingPageEvent
Definition: zeropage.c:20
#define ExInitializePushLock
Definition: ex.h:1011
FORCEINLINE VOID MI_MAKE_SUBSECTION_PTE(_Out_ PMMPTE NewPte, _In_ PVOID Segment)
Definition: mm.h:328
void * PVOID
Definition: retypes.h:9
PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock
Definition: mminit.c:206
PLOADER_PARAMETER_BLOCK KeLoaderBlock
Definition: krnlinit.c:29
ULONG_PTR LoaderPagesSpanned
Definition: arc.h:356
#define MM_EMPTY_LIST
Definition: mm.h:88
FORCEINLINE VOID InitializeSListHead(_Out_ PSLIST_HEADER SListHead)
Definition: rtlfuncs.h:3351
NTSTATUS NTAPI MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:697
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
PMMPTE MiHighestUserPte
Definition: mminit.c:233
SIZE_T MmTotalCommitLimit
Definition: mminit.c:359
PMMPTE MmDebugPte
Definition: mmdbg.c:31
VOID NTAPI MiDbgDumpMemoryDescriptors(VOID)
Definition: mminit.c:1994
FORCEINLINE PMMPTE MiAddressToPxe(PVOID Address)
Definition: mm.h:171
ULONG_PTR MmUserProbeAddress
Definition: mminit.c:228
EX_PUSH_LOCK WorkingSetMutex
Definition: mmtypes.h:958
PFN_COUNT MmNumberOfSystemPtes
Definition: mminit.c:181
PVOID MmSystemCacheEnd
Definition: mminit.c:244
#define ASSERT(a)
Definition: mode.c:44
SIZE_T MmHeapDeCommitFreeBlockThreshold
Definition: mminit.c:369
#define MI_HIGHEST_USER_ADDRESS
Definition: mmtypes.h:43
PVOID MiDebugMapping
Definition: mmdbg.c:30
struct _MMPTE * PMMPTE
PMMPDE MiHighestUserPde
Definition: mminit.c:234
PFN_NUMBER MmHighestPhysicalPage
Definition: mminit.c:211
PKEVENT MiHighNonPagedPoolEvent
Definition: mminit.c:297
ULONG MmThrottleTop
Definition: mminit.c:396
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:76
#define KERNEL_STACK_SIZE
PVOID MmPagedPoolStart
Definition: mminit.c:104
PVOID MmHighSectionBase
Definition: section.c:111
LIST_ENTRY MmLoadedUserImageList
Definition: sysldr.c:35
#define MiSubsectionPteToSubsection(x)
Definition: mm.h:323
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define SharedUserData
PKEVENT MiLowMemoryEvent
Definition: mminit.c:292
KEVENT MiTempEvent
Definition: mminit.c:289
MM_SYSTEMSIZE MmSystemSize
Definition: mminit.c:326
SIZE_T MmHeapSegmentReserve
Definition: mminit.c:366
RTL_BITMAP MiPfnBitMap
Definition: mminit.c:201
LARGE_INTEGER MmCriticalSectionTimeout
Definition: mminit.c:388
SLIST_HEADER MmDeadStackSListHead
Definition: procsup.c:22
Definition: mm.h:373
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define _1MB
Definition: miarm.h:19
VOID NTAPI MiInitializeLargePageSupport(VOID)
Definition: largepag.c:34
#define MI_MIN_PAGES_FOR_SYSPTE_TUNING
Definition: mm.h:55
PKEVENT MiLowNonPagedPoolEvent
Definition: mminit.c:296
LIST_ENTRY MmWorkingSetExpansionHead
Definition: session.c:30
#define MI_PAGED_POOL_START
Definition: mm.h:21
PVOID MmSystemCacheStart
Definition: mminit.c:243
VOID NTAPI MiAdjustWorkingSetManagerParameters(IN BOOLEAN Client)
Definition: mminit.c:1203
VOID NTAPI MiBuildPagedPool(VOID)
Definition: mminit.c:1751
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
ULONG_PTR MmSizeOfSystemCacheInPages
Definition: mminit.c:245
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ROUND_TO_PAGES(Size)
#define MI_SYSTEM_CACHE_START
Definition: mm.h:26
FORCEINLINE VOID MI_MAKE_PROTOTYPE_PTE(IN PMMPTE NewPte, IN PMMPTE PointerPte)
Definition: mm.h:342
PFN_NUMBER Total
Definition: mm.h:443
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
SIZE_T MmHeapSegmentCommit
Definition: mminit.c:367
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
#define min(a, b)
Definition: monoChain.cc:55
#define PAGE_ROUND_UP(x)
Definition: mmtypes.h:38
NTSYSAPI void WINAPI RtlClearAllBits(PRTL_BITMAP)
VOID NTAPI MiReloadBootLoadedDrivers(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: sysldr.c:1693
#define DPRINT1
Definition: precomp.h:8
ULONG MmMaximumDeadKernelStacks
Definition: procsup.c:21
ULONG MmProductType
Definition: mminit.c:325
unsigned int ULONG
Definition: retypes.h:1
#define PDE_MAPPED_VA
Definition: mm.h:39
#define ULONG_PTR
Definition: config.h:101
KGUARDED_MUTEX MmPagedPoolMutex
Definition: pool.c:24
ULONG MmThrottleBottom
Definition: mminit.c:397
#define DPRINT
Definition: sndvol32.h:71
PVOID MmNonPagedPoolStart
Definition: mminit.c:97
VOID NTAPI MiSyncCachedRanges(VOID)
Definition: largepag.c:54
#define MI_ALLOCATION_FRAGMENT
Definition: mm.h:71
KGUARDED_MUTEX MmSectionCommitMutex
Definition: section.c:108
#define MI_SYSTEM_CACHE_END
Definition: mm.h:27
#define MI_MIN_ALLOCATION_FRAGMENT
Definition: mm.h:70
#define MI_HIGHEST_SYSTEM_ADDRESS
Definition: mm.h:31
PKEVENT MiHighMemoryEvent
Definition: mminit.c:293
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
PFN_NUMBER MmMinimumFreePages
Definition: mminit.c:314
LONGLONG QuadPart
Definition: typedefs.h:114
#define _1GB
Definition: miarm.h:20
ULONG MmSecondaryColors
Definition: mminit.c:256
SIZE_T MmAllocationFragment
Definition: mminit.c:352

Referenced by ExpInitializeExecutive(), and Phase1InitializationDiscard().

◆ MmFreeLoaderBlock()

VOID NTAPI MmFreeLoaderBlock ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 1093 of file mminit.c.

1094 {
1095  PLIST_ENTRY NextMd;
1097  ULONG_PTR i;
1098  PFN_NUMBER BasePage, LoaderPages;
1099  PMMPFN Pfn1;
1100  KIRQL OldIrql;
1102 
1103  /* Loop the descriptors in order to count them */
1104  i = 0;
1105  NextMd = LoaderBlock->MemoryDescriptorListHead.Flink;
1106  while (NextMd != &LoaderBlock->MemoryDescriptorListHead)
1107  {
1108  MdBlock = CONTAINING_RECORD(NextMd,
1110  ListEntry);
1111  i++;
1112  NextMd = MdBlock->ListEntry.Flink;
1113  }
1114 
1115  /* Allocate a structure to hold the physical runs */
1117  i * sizeof(PHYSICAL_MEMORY_RUN),
1118  'lMmM');
1119  ASSERT(Buffer != NULL);
1120  Entry = Buffer;
1121 
1122  /* Loop the descriptors again */
1123  NextMd = LoaderBlock->MemoryDescriptorListHead.Flink;
1124  while (NextMd != &LoaderBlock->MemoryDescriptorListHead)
1125  {
1126  /* Check what kind this was */
1127  MdBlock = CONTAINING_RECORD(NextMd,
1129  ListEntry);
1130  switch (MdBlock->MemoryType)
1131  {
1132  /* Registry, NLS, and heap data */
1133  case LoaderRegistryData:
1134  case LoaderOsloaderHeap:
1135  case LoaderNlsData:
1136  /* Are all a candidate for deletion */
1137  Entry->BasePage = MdBlock->BasePage;
1138  Entry->PageCount = MdBlock->PageCount;
1139  Entry++;
1140 
1141  /* We keep the rest */
1142  default:
1143  break;
1144  }
1145 
1146  /* Move to the next descriptor */
1147  NextMd = MdBlock->ListEntry.Flink;
1148  }
1149 
1150  /* Acquire the PFN lock */
1151  OldIrql = MiAcquirePfnLock();
1152 
1153  /* Loop the runs */
1154  LoaderPages = 0;
1155  while (--Entry >= Buffer)
1156  {
1157  /* See how many pages are in this run */
1158  i = Entry->PageCount;
1159  BasePage = Entry->BasePage;
1160 
1161  /* Loop each page */
1162  Pfn1 = MiGetPfnEntry(BasePage);
1163  while (i--)
1164  {
1165  /* Check if it has references or is in any kind of list */
1166  if (!(Pfn1->u3.e2.ReferenceCount) && (!Pfn1->u1.Flink))
1167  {
1168  /* Set the new PTE address and put this page into the free list */
1169  Pfn1->PteAddress = (PMMPTE)(BasePage << PAGE_SHIFT);
1170  MiInsertPageInFreeList(BasePage);
1171  LoaderPages++;
1172  }
1173  else if (BasePage)
1174  {
1175  /* It has a reference, so simply drop it */
1177 
1178  /* Drop a dereference on this page, which should delete it */
1179  Pfn1->PteAddress->u.Long = 0;
1180  MI_SET_PFN_DELETED(Pfn1);
1181  MiDecrementShareCount(Pfn1, BasePage);
1182  LoaderPages++;
1183  }
1184 
1185  /* Move to the next page */
1186  Pfn1++;
1187  BasePage++;
1188  }
1189  }
1190 
1191  /* Release the PFN lock and flush the TLB */
1192  DPRINT("Loader pages freed: %lx\n", LoaderPages);
1193  MiReleasePfnLock(OldIrql);
1194  KeFlushCurrentTb();
1195 
1196  /* Free our run structure */
1197  ExFreePoolWithTag(Buffer, 'lMmM');
1198 }
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
VOID NTAPI MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:603
struct _Entry Entry
Definition: kefuncs.h:629
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
PFN_NUMBER Flink
Definition: mm.h:377
struct _MMPFN::@1752::@1758 e2
union _MMPTE::@2283 u
uint32_t ULONG_PTR
Definition: typedefs.h:65
UCHAR KIRQL
Definition: env_spec_w32.h:591
TYPE_OF_MEMORY MemoryType
Definition: arc.h:193
ULONG PFN_NUMBER
Definition: ke.h:9
#define FALSE
Definition: types.h:117
VOID NTAPI MiDecrementShareCount(IN PMMPFN Pfn1, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:1133
Definition: bufpool.h:45
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define ASSERT(a)
Definition: mode.c:44
struct _MMPTE * PMMPTE
union _MMPFN::@1750 u1
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
Definition: mm.h:373
Definition: typedefs.h:119
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:1020
ULONG_PTR Long
Definition: mmtypes.h:215
union _MMPFN::@1752 u3
#define MI_SET_PFN_DELETED(x)
Definition: miarm.h:194
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PMMPTE PteAddress
Definition: mm.h:386
#define NULL
Definition: types.h:112
#define DPRINT
Definition: sndvol32.h:71
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:208
FORCEINLINE BOOLEAN MI_IS_PHYSICAL_ADDRESS(IN PVOID Address)
Definition: miarm.h:950
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
base of all file and directory entries
Definition: entries.h:82
VOID NTAPI KeFlushCurrentTb(VOID)
Definition: cpu.c:347

Referenced by Phase1InitializationDiscard().

◆ Phase1Initialization()

VOID NTAPI Phase1Initialization ( IN PVOID  Context)

Definition at line 2017 of file init.c.

2018 {
2019  /* Do the .INIT part of Phase 1 which we can free later */
2021 
2022  /* Jump into zero page thread */
2023  MmZeroPageThread();
2024 }
VOID NTAPI MmZeroPageThread(VOID)
Definition: zeropage.c:36
VOID NTAPI Phase1InitializationDiscard(IN PVOID Context)
Definition: init.c:1340

Referenced by PspInitPhase0().

◆ Phase1InitializationDiscard()

VOID NTAPI Phase1InitializationDiscard ( IN PVOID  Context)

Definition at line 1340 of file init.c.

1341 {
1342  PLOADER_PARAMETER_BLOCK LoaderBlock = Context;
1343  NTSTATUS Status, MsgStatus;
1345  LARGE_INTEGER SystemBootTime, UniversalBootTime, OldTime, Timeout;
1346  BOOLEAN SosEnabled, NoGuiBoot, ResetBias = FALSE, AlternateShell = FALSE;
1347  PLDR_DATA_TABLE_ENTRY NtosEntry;
1348  PMESSAGE_RESOURCE_ENTRY MsgEntry;
1349  PCHAR CommandLine, Y2KHackRequired, SafeBoot, Environment;
1350  PCHAR StringBuffer, EndBuffer, BeginBuffer, MpString = "";
1351  PINIT_BUFFER InitBuffer;
1352  ANSI_STRING TempString;
1353  ULONG LastTzBias, Length, YearHack = 0, Disposition, MessageCode = 0;
1354  SIZE_T Size;
1355  size_t Remaining;
1356  PRTL_USER_PROCESS_INFORMATION ProcessInfo;
1357  KEY_VALUE_PARTIAL_INFORMATION KeyPartialInfo;
1360  HANDLE KeyHandle, OptionHandle;
1361  PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
1362 
1363  /* Allocate the initialization buffer */
1364  InitBuffer = ExAllocatePoolWithTag(NonPagedPool,
1365  sizeof(INIT_BUFFER),
1366  TAG_INIT);
1367  if (!InitBuffer)
1368  {
1369  /* Bugcheck */
1370  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, STATUS_NO_MEMORY, 8, 0, 0);
1371  }
1372 
1373  /* Set to phase 1 */
1375 
1376  /* Set us at maximum priority */
1378 
1379  /* Do Phase 1 HAL Initialization */
1380  if (!HalInitSystem(1, LoaderBlock)) KeBugCheck(HAL1_INITIALIZATION_FAILED);
1381 
1382  /* Get the command line and upcase it */
1383  CommandLine = (LoaderBlock->LoadOptions ? _strupr(LoaderBlock->LoadOptions) : NULL);
1384 
1385  /* Check if GUI Boot is enabled */
1386  NoGuiBoot = (CommandLine && strstr(CommandLine, "NOGUIBOOT") != NULL);
1387 
1388  /* Get the SOS setting */
1389  SosEnabled = (CommandLine && strstr(CommandLine, "SOS") != NULL);
1390 
1391  /* Setup the boot driver */
1392  InbvEnableBootDriver(!NoGuiBoot);
1393  InbvDriverInitialize(LoaderBlock, IDB_MAX_RESOURCE);
1394 
1395  /* Check if GUI boot is enabled */
1396  if (!NoGuiBoot)
1397  {
1398  /* It is, display the boot logo and enable printing strings */
1401  }
1402  else
1403  {
1404  /* Release display ownership if not using GUI boot */
1406 
1407  /* Don't allow boot-time strings */
1409  }
1410 
1411  /* Check if this is LiveCD (WinPE) mode */
1412  if (CommandLine && strstr(CommandLine, "MININT") != NULL)
1413  {
1414  /* Setup WinPE Settings */
1416  InitWinPEModeType |= (strstr(CommandLine, "INRAM") != NULL) ? 0x80000000 : 0x00000001;
1417  }
1418 
1419  /* Get the kernel's load entry */
1420  NtosEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink,
1422  InLoadOrderLinks);
1423 
1424  /* Find the banner message */
1425  MsgStatus = RtlFindMessage(NtosEntry->DllBase,
1426  11,
1427  0,
1428  WINDOWS_NT_BANNER,
1429  &MsgEntry);
1430 
1431  /* Setup defaults and check if we have a version string */
1432  StringBuffer = InitBuffer->VersionBuffer;
1433  BeginBuffer = StringBuffer;
1434  EndBuffer = StringBuffer;
1435  Remaining = sizeof(InitBuffer->VersionBuffer);
1437  {
1438  /* Print the version string */
1440  Remaining,
1441  &EndBuffer,
1442  &Remaining,
1443  0,
1444  ": %wZ",
1446  if (!NT_SUCCESS(Status))
1447  {
1448  /* Bugcheck */
1449  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
1450  }
1451  }
1452  else
1453  {
1454  /* No version */
1455  *EndBuffer = ANSI_NULL; /* Null-terminate the string */
1456  }
1457 
1458  /* Skip over the null-terminator to start a new string */
1459  ++EndBuffer;
1460  --Remaining;
1461 
1462  /* Build the version number */
1463  StringBuffer = InitBuffer->VersionNumber;
1465  sizeof(InitBuffer->VersionNumber),
1466  "%u.%u",
1469  if (!NT_SUCCESS(Status))
1470  {
1471  /* Bugcheck */
1472  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
1473  }
1474 
1475  /* Check if we had found a banner message */
1476  if (NT_SUCCESS(MsgStatus))
1477  {
1478  /* Create the banner message */
1479  /* ReactOS specific: Report ReactOS version, NtBuildLab information and reported NT kernel version */
1480  Status = RtlStringCbPrintfA(EndBuffer,
1481  Remaining,
1482  (PCHAR)MsgEntry->Text,
1483  KERNEL_VERSION_STR,
1484  NtBuildLab,
1485  StringBuffer,
1486  NtBuildNumber & 0xFFFF,
1487  BeginBuffer);
1488  if (!NT_SUCCESS(Status))
1489  {
1490  /* Bugcheck */
1491  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
1492  }
1493  }
1494  else
1495  {
1496  /* Use hard-coded banner message */
1497  Status = RtlStringCbCopyA(EndBuffer, Remaining, "REACTOS (R)\r\n");
1498  if (!NT_SUCCESS(Status))
1499  {
1500  /* Bugcheck */
1501  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
1502  }
1503  }
1504 
1505  /* Display the version string on-screen */
1506  InbvDisplayString(EndBuffer);
1507 
1508  /* Initialize Power Subsystem in Phase 0 */
1509  if (!PoInitSystem(0)) KeBugCheck(INTERNAL_POWER_ERROR);
1510 
1511  /* Check for Y2K hack */
1512  Y2KHackRequired = CommandLine ? strstr(CommandLine, "YEAR") : NULL;
1513  if (Y2KHackRequired) Y2KHackRequired = strstr(Y2KHackRequired, "=");
1514  if (Y2KHackRequired) YearHack = atol(Y2KHackRequired + 1);
1515 
1516  /* Query the clock */
1518  {
1519  /* Check if we're using the Y2K hack */
1520  if (Y2KHackRequired) TimeFields.Year = (CSHORT)YearHack;
1521 
1522  /* Convert to time fields */
1523  RtlTimeFieldsToTime(&TimeFields, &SystemBootTime);
1524  UniversalBootTime = SystemBootTime;
1525 
1526  /* Check if real time is GMT */
1528  {
1529  /* Check if we don't have a valid bias */
1531  {
1532  /* Reset */
1533  ResetBias = TRUE;
1535  }
1536 
1537  /* Calculate the bias in seconds */
1539  10000000);
1540 
1541  /* Set the boot time-zone bias */
1542  SharedUserData->TimeZoneBias.High2Time = ExpTimeZoneBias.HighPart;
1543  SharedUserData->TimeZoneBias.LowPart = ExpTimeZoneBias.LowPart;
1544  SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.HighPart;
1545 
1546  /* Convert the boot time to local time, and set it */
1547  UniversalBootTime.QuadPart = SystemBootTime.QuadPart +
1549  }
1550 
1551  /* Update the system time */
1552  KeSetSystemTime(&UniversalBootTime, &OldTime, FALSE, NULL);
1553 
1554  /* Do system callback */
1556 
1557  /* Remember this as the boot time */
1558  KeBootTime = UniversalBootTime;
1559  KeBootTimeBias = 0;
1560  }
1561 
1562  /* Initialize all processors */
1563  if (!HalAllProcessorsStarted()) KeBugCheck(HAL1_INITIALIZATION_FAILED);
1564 
1565 #ifdef CONFIG_SMP
1566  /* HACK: We should use RtlFindMessage and not only fallback to this */
1567  MpString = "MultiProcessor Kernel\r\n";
1568 #endif
1569 
1570  /* Setup the "MP" String */
1571  RtlInitAnsiString(&TempString, MpString);
1572 
1573  /* Make sure to remove the \r\n if we actually have a string */
1574  while ((TempString.Length > 0) &&
1575  ((TempString.Buffer[TempString.Length - 1] == '\r') ||
1576  (TempString.Buffer[TempString.Length - 1] == '\n')))
1577  {
1578  /* Skip the trailing character */
1579  TempString.Length--;
1580  }
1581 
1582  /* Get the information string from our resource file */
1583  MsgStatus = RtlFindMessage(NtosEntry->DllBase,
1584  11,
1585  0,
1586  KeNumberProcessors > 1 ?
1587  WINDOWS_NT_INFO_STRING_PLURAL :
1588  WINDOWS_NT_INFO_STRING,
1589  &MsgEntry);
1590 
1591  /* Get total RAM size, in MiB */
1592  /* Round size up. Assumed to better match actual physical RAM size */
1593  Size = ALIGN_UP_BY(MmNumberOfPhysicalPages * PAGE_SIZE, 1024 * 1024) / (1024 * 1024);
1594 
1595  /* Create the string */
1596  StringBuffer = InitBuffer->VersionBuffer;
1598  sizeof(InitBuffer->VersionBuffer),
1599  NT_SUCCESS(MsgStatus) ?
1600  (PCHAR)MsgEntry->Text :
1601  "%u System Processor [%Iu MB Memory] %Z\r\n",
1603  Size,
1604  &TempString);
1605  if (!NT_SUCCESS(Status))
1606  {
1607  /* Bugcheck */
1608  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 4, 0, 0);
1609  }
1610 
1611  /* Display RAM and CPU count */
1613 
1614  /* Update the progress bar */
1616 
1617  /* Call OB initialization again */
1618  if (!ObInitSystem()) KeBugCheck(OBJECT1_INITIALIZATION_FAILED);
1619 
1620  /* Initialize Basic System Objects and Worker Threads */
1621  if (!ExInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 1, 0);
1622 
1623  /* Initialize the later stages of the kernel */
1624  if (!KeInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 2, 0);
1625 
1626  /* Call KD Providers at Phase 1 */
1628  {
1629  /* Failed, bugcheck */
1630  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 3, 0);
1631  }
1632 
1633  /* Initialize the SRM in Phase 1 */
1634  if (!SeInitSystem()) KeBugCheck(SECURITY1_INITIALIZATION_FAILED);
1635 
1636  /* Update the progress bar */
1638 
1639  /* Create SystemRoot Link */
1640  Status = ExpCreateSystemRootLink(LoaderBlock);
1641  if (!NT_SUCCESS(Status))
1642  {
1643  /* Failed to create the system root link */
1644  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 0, 0, 0);
1645  }
1646 
1647  /* Set up Region Maps, Sections and the Paging File */
1648  if (!MmInitSystem(1, LoaderBlock)) KeBugCheck(MEMORY1_INITIALIZATION_FAILED);
1649 
1650  /* Create NLS section */
1651  ExpInitNls(LoaderBlock);
1652 
1653  /* Initialize Cache Views */
1654  if (!CcInitializeCacheManager()) KeBugCheck(CACHE_INITIALIZATION_FAILED);
1655 
1656  /* Initialize the Registry */
1657  if (!CmInitSystem1()) KeBugCheck(CONFIG_INITIALIZATION_FAILED);
1658 
1659  /* Initialize Prefetcher */
1661 
1662  /* Update progress bar */
1664 
1665  /* Update timezone information */
1666  LastTzBias = ExpLastTimeZoneBias;
1667  ExRefreshTimeZoneInformation(&SystemBootTime);
1668 
1669  /* Check if we're resetting timezone data */
1670  if (ResetBias)
1671  {
1672  /* Convert the local time to system time */
1673  ExLocalTimeToSystemTime(&SystemBootTime, &UniversalBootTime);
1674  KeBootTime = UniversalBootTime;
1675  KeBootTimeBias = 0;
1676 
1677  /* Set the new time */
1678  KeSetSystemTime(&UniversalBootTime, &OldTime, FALSE, NULL);
1679  }
1680  else
1681  {
1682  /* Check if the timezone switched and update the time */
1683  if (LastTzBias != ExpLastTimeZoneBias) ZwSetSystemTime(NULL, NULL);
1684  }
1685 
1686  /* Initialize the File System Runtime Library */
1687  if (!FsRtlInitSystem()) KeBugCheck(FILE_INITIALIZATION_FAILED);
1688 
1689  /* Initialize range lists */
1691 
1692  /* Report all resources used by HAL */
1694 
1695  /* Call the debugger DLL */
1696  KdDebuggerInitialize1(LoaderBlock);
1697 
1698  /* Setup PnP Manager in phase 1 */
1699  if (!PpInitSystem()) KeBugCheck(PP1_INITIALIZATION_FAILED);
1700 
1701  /* Update progress bar */
1703 
1704  /* Initialize LPC */
1705  if (!LpcInitSystem()) KeBugCheck(LPC_INITIALIZATION_FAILED);
1706 
1707  /* Make sure we have a command line */
1708  if (CommandLine)
1709  {
1710  /* Check if this is a safe mode boot */
1711  SafeBoot = strstr(CommandLine, "SAFEBOOT:");
1712  if (SafeBoot)
1713  {
1714  /* Check what kind of boot this is */
1715  SafeBoot += 9;
1716  if (!strncmp(SafeBoot, "MINIMAL", 7))
1717  {
1718  /* Minimal mode */
1719  InitSafeBootMode = 1;
1720  SafeBoot += 7;
1721  MessageCode = BOOTING_IN_SAFEMODE_MINIMAL;
1722  }
1723  else if (!strncmp(SafeBoot, "NETWORK", 7))
1724  {
1725  /* With Networking */
1726  InitSafeBootMode = 2;
1727  SafeBoot += 7;
1728  MessageCode = BOOTING_IN_SAFEMODE_NETWORK;
1729  }
1730  else if (!strncmp(SafeBoot, "DSREPAIR", 8))
1731  {
1732  /* Domain Server Repair */
1733  InitSafeBootMode = 3;
1734  SafeBoot += 8;
1735  MessageCode = BOOTING_IN_SAFEMODE_DSREPAIR;
1736 
1737  }
1738  else
1739  {
1740  /* Invalid */
1741  InitSafeBootMode = 0;
1742  }
1743 
1744  /* Check if there's any settings left */
1745  if (*SafeBoot)
1746  {
1747  /* Check if an alternate shell was requested */
1748  if (!strncmp(SafeBoot, "(ALTERNATESHELL)", 16))
1749  {
1750  /* Remember this for later */
1751  AlternateShell = TRUE;
1752  }
1753  }
1754 
1755  /* Find the message to print out */
1756  Status = RtlFindMessage(NtosEntry->DllBase,
1757  11,
1758  0,
1759  MessageCode,
1760  &MsgEntry);
1761  if (NT_SUCCESS(Status))
1762  {
1763  /* Display it */
1764  InbvDisplayString((PCHAR)MsgEntry->Text);
1765  }
1766  }
1767  }
1768 
1769  /* Make sure we have a command line */
1770  if (CommandLine)
1771  {
1772  /* Check if bootlogging is enabled */
1773  if (strstr(CommandLine, "BOOTLOG"))
1774  {
1775  /* Find the message to print out */
1776  Status = RtlFindMessage(NtosEntry->DllBase,
1777  11,
1778  0,
1779  BOOTLOG_ENABLED,
1780  &MsgEntry);
1781  if (NT_SUCCESS(Status))
1782  {
1783  /* Display it */
1784  InbvDisplayString((PCHAR)MsgEntry->Text);
1785  }
1786 
1787  /* Setup boot logging */
1788  //IopInitializeBootLogging(LoaderBlock, InitBuffer->BootlogHeader);
1789  }
1790  }
1791 
1792  /* Setup the Executive in Phase 2 */
1793  //ExInitSystemPhase2();
1794 
1795  /* Update progress bar */
1797 
1798  /* No KD Time Slip is pending */
1799  KdpTimeSlipPending = 0;
1800 
1801  /* Initialize in-place execution support */
1802  XIPInit(LoaderBlock);
1803 
1804  /* Set maximum update to 75% */
1805  InbvSetProgressBarSubset(25, 75);
1806 
1807  /* Initialize the I/O Subsystem */
1808  if (!IoInitSystem(LoaderBlock)) KeBugCheck(IO1_INITIALIZATION_FAILED);
1809 
1810  /* Set maximum update to 100% */
1811  InbvSetProgressBarSubset(0, 100);
1812 
1813  /* Are we in safe mode? */
1814  if (InitSafeBootMode)
1815  {
1816  /* Open the safe boot key */
1818  L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET"
1819  L"\\CONTROL\\SAFEBOOT");
1821  &KeyName,
1823  NULL,
1824  NULL);
1826  if (NT_SUCCESS(Status))
1827  {
1828  /* First check if we have an alternate shell */
1829  if (AlternateShell)
1830  {
1831  /* Make sure that the registry has one setup */
1832  RtlInitUnicodeString(&KeyName, L"AlternateShell");
1834  &KeyName,
1836  &KeyPartialInfo,
1837  sizeof(KeyPartialInfo),
1838  &Length);
1840  {
1841  AlternateShell = FALSE;
1842  }
1843  }
1844 
1845  /* Create the option key */
1846  RtlInitUnicodeString(&KeyName, L"Option");
1848  &KeyName,
1850  KeyHandle,
1851  NULL);
1852  Status = ZwCreateKey(&OptionHandle,
1855  0,
1856  NULL,
1858  &Disposition);
1859  NtClose(KeyHandle);
1860 
1861  /* Check if the key create worked */
1862  if (NT_SUCCESS(Status))
1863  {
1864  /* Write the safe boot type */
1865  RtlInitUnicodeString(&KeyName, L"OptionValue");
1866  NtSetValueKey(OptionHandle,
1867  &KeyName,
1868  0,
1869  REG_DWORD,
1871  sizeof(InitSafeBootMode));
1872 
1873  /* Check if we have to use an alternate shell */
1874  if (AlternateShell)
1875  {
1876  /* Remember this for later */
1877  Disposition = TRUE;
1878  RtlInitUnicodeString(&KeyName, L"UseAlternateShell");
1879  NtSetValueKey(OptionHandle,
1880  &KeyName,
1881  0,
1882  REG_DWORD,
1883  &Disposition,
1884  sizeof(Disposition));
1885  }
1886 
1887  /* Close the options key handle */
1888  NtClose(OptionHandle);
1889  }
1890  }
1891  }
1892 
1893  /* Are we in Win PE mode? */
1894  if (InitIsWinPEMode)
1895  {
1896  /* Open the safe control key */
1898  L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET"
1899  L"\\CONTROL");
1901  &KeyName,
1903  NULL,
1904  NULL);
1906  if (!NT_SUCCESS(Status))
1907  {
1908  /* Bugcheck */
1909  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 6, 0, 0);
1910  }
1911 
1912  /* Create the MiniNT key */
1913  RtlInitUnicodeString(&KeyName, L"MiniNT");
1915  &KeyName,
1917  KeyHandle,
1918  NULL);
1919  Status = ZwCreateKey(&OptionHandle,
1922  0,
1923  NULL,
1925  &Disposition);
1926  if (!NT_SUCCESS(Status))
1927  {
1928  /* Bugcheck */
1929  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 6, 0, 0);
1930  }
1931 
1932  /* Close the handles */
1933  NtClose(KeyHandle);
1934  NtClose(OptionHandle);
1935  }
1936 
1937  /* FIXME: This doesn't do anything for now */
1938  MmArmInitSystem(2, LoaderBlock);
1939 
1940  /* Update progress bar */
1942 
1943  /* Initialize VDM support */
1944 #if defined(_M_IX86)
1946 #endif
1947 
1948  /* Initialize Power Subsystem in Phase 1*/
1949  if (!PoInitSystem(1)) KeBugCheck(INTERNAL_POWER_ERROR);
1950 
1951  /* Update progress bar */
1953 
1954  /* Initialize the Process Manager at Phase 1 */
1955  if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS1_INITIALIZATION_FAILED);
1956 
1957  /* Make sure nobody touches the loader block again */
1958  if (LoaderBlock == KeLoaderBlock) KeLoaderBlock = NULL;
1959  MmFreeLoaderBlock(LoaderBlock);
1960  LoaderBlock = Context = NULL;
1961 
1962  /* Initialize the SRM in phase 1 */
1963  if (!SeRmInitPhase1()) KeBugCheck(PROCESS1_INITIALIZATION_FAILED);
1964 
1965  /* Update progress bar */
1966  InbvUpdateProgressBar(100);
1967 
1968  /* Clear the screen */
1970 
1971  /* Allow strings to be displayed */
1973 
1974  /* Launch initial process */
1975  ProcessInfo = &InitBuffer->ProcessInfo;
1976  ExpLoadInitialProcess(InitBuffer, &ProcessParameters, &Environment);
1977 
1978  /* Wait 5 seconds for initial process to initialize */
1979  Timeout.QuadPart = Int32x32To64(5, -10000000);
1980  Status = ZwWaitForSingleObject(ProcessInfo->ProcessHandle, FALSE, &Timeout);
1981  if (Status == STATUS_SUCCESS)
1982  {
1983  /* Failed, display error */
1984  DPRINT1("INIT: Session Manager terminated.\n");
1985 
1986  /* Bugcheck the system if SMSS couldn't initialize */
1987  KeBugCheck(SESSION5_INITIALIZATION_FAILED);
1988  }
1989 
1990  /* Close process handles */
1991  ZwClose(ProcessInfo->ThreadHandle);
1992  ZwClose(ProcessInfo->ProcessHandle);
1993 
1994  /* Free the initial process environment */
1995  Size = 0;
1996  ZwFreeVirtualMemory(NtCurrentProcess(),
1997  (PVOID*)&Environment,
1998  &Size,
1999  MEM_RELEASE);
2000 
2001  /* Free the initial process parameters */
2002  Size = 0;
2003  ZwFreeVirtualMemory(NtCurrentProcess(),
2004  (PVOID*)&ProcessParameters,
2005  &Size,
2006  MEM_RELEASE);
2007 
2008  /* Increase init phase */
2010 
2011  /* Free the boot buffer */
2012  ExFreePoolWithTag(InitBuffer, TAG_INIT);
2013 }
VOID NTAPI HalReportResourceUsage(VOID)
Definition: usage.c:67
#define VER_PRODUCTMAJORVERSION
Definition: ntverp.h:25
signed char * PCHAR
Definition: retypes.h:7
VOID NTAPI XIPInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: xipdisp.c:55
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
VOID NTAPI ExpInitNls(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:212
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:47
Definition: rtltypes.h:1895
BOOLEAN NTAPI IoInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: iomgr.c:465
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTRSAFEVAPI RtlStringCbPrintfExA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _Outptr_opt_result_bytebuffer_(*pcbRemaining) NTSTRSAFE_PSTR *ppszDestEnd, _Out_opt_ size_t *pcbRemaining, _In_ STRSAFE_DWORD dwFlags, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1294
ULONGLONG KeBootTimeBias
Definition: clock.c:18
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
BOOLEAN SosEnabled
Definition: winldr.c:33
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
BOOLEAN NTAPI HalQueryRealTimeClock(IN PTIME_FIELDS Time)
Definition: rtc.c:24
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI LpcInitSystem(VOID)
Definition: port.c:37
BOOLEAN NTAPI PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: psmgr.c:624
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
BOOLEAN NTAPI PpInitSystem(VOID)
Definition: pnpmgr.c:1712
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
NTSTATUS NTAPI ExpCreateSystemRootLink(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:100
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CcInitializeCacheManager(VOID)
Definition: fssup.c:83
NTSYSAPI NTSTATUS NTAPI RtlFindMessage(_In_ PVOID BaseAddress, _In_ ULONG Type, _In_ ULONG Language, _In_ ULONG MessageId, _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
BOOLEAN NTAPI CmInitSystem1(VOID)
Definition: cmsysini.c:1511
VOID NTAPI InbvNotifyDisplayOwnershipLost(_In_ INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:403
#define IDB_MAX_RESOURCE
Definition: resource.h:46
BOOLEAN NTAPI MmArmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:2046
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156
LONG KdpTimeSlipPending
Definition: kddata.c:119
LARGE_INTEGER KeBootTime
Definition: clock.c:17
PVOID DllBase
Definition: btrfs_drv.h:1870
#define L(x)
Definition: ntvdm.h:50
VOID NTAPI InbvUpdateProgressBar(_In_ ULONG Percentage)
Updates the progress bar percentage, relative to the current percentage sub-range previously set by I...
Definition: inbv.c:689
#define FALSE
Definition: types.h:117
#define ANSI_NULL
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
LARGE_INTEGER ExpTimeZoneBias
Definition: time.c:23
RTL_USER_PROCESS_INFORMATION ProcessInfo
Definition: init.c:38
NTSTATUS NTAPI KdDebuggerInitialize1(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
Definition: kdcom.c:283
unsigned char BOOLEAN
VOID NTAPI PoNotifySystemTimeSet(VOID)
Definition: events.c:39
BOOLEAN ExCmosClockIsSane
Definition: init.c:92
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
#define HIGH_PRIORITY
PLOADER_PARAMETER_BLOCK KeLoaderBlock
Definition: krnlinit.c:29
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
#define NtCurrentProcess()
Definition: nt_native.h:1657
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
VOID NTAPI RtlInitializeRangeListPackage(VOID)
Definition: libsupp.c:62
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1899
VOID NTAPI FinalizeBootLogo(VOID)
Definition: bootanim.c:754
BOOLEAN ExpRealTimeIsUniversal
Definition: init.c:93
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI MmFreeLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:1093
BOOLEAN NTAPI MmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:202
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
BOOLEAN NTAPI InbvDisplayString(_In_ PCHAR String)
Definition: inbv.c:331
BOOLEAN NTAPI HalAllProcessorsStarted(VOID)
Definition: processor.c:60
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
VOID NTAPI DisplayBootBitmap(_In_ BOOLEAN TextMode)
Definition: bootanim.c:471
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3401
VOID NTAPI InbvSetProgressBarSubset(_In_ ULONG Floor, _In_ ULONG Ceiling)
Specifies a progress percentage sub-range. Further calls to InbvIndicateProgress() or InbvUpdateProgr...
Definition: inbv.c:663
BOOLEAN NTAPI InbvEnableDisplayString(_In_ BOOLEAN Enable)
Definition: inbv.c:369
BOOLEAN NTAPI ObInitSystem(VOID)
Definition: obinit.c:203
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define SharedUserData
UNICODE_STRING CmCSDVersionString
Definition: init.c:62
Definition: btrfs_drv.h:1866
ULONG LowPart
Definition: typedefs.h:106
ULONG ExpInitializationPhase
Definition: init.c:68
#define PAGE_SIZE
Definition: env_spec_w32.h:49
BOOLEAN SafeBoot
Definition: winldr.c:34
ULONG InitSafeBootMode
Definition: init.c:71
VOID NTAPI CcPfInitializePrefetcher(VOID)
Definition: fssup.c:114
LIST_ENTRY LoadOrderListHead
Definition: arc.h:493
CHAR VersionBuffer[256]
Definition: init.c:35
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
BOOLEAN NTAPI InbvDriverInitialize(_In_ PLOADER_PARAMETER_BLOCK LoaderBlock, _In_ ULONG Count)
Definition: inbv.c:175
ULONG ExpLastTimeZoneBias
Definition: time.c:22
#define MAXULONG
Definition: typedefs.h:251
ULONG_PTR SIZE_T
Definition: typedefs.h:80
static ULONG Timeout
Definition: ping.c:61
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
BOOLEAN NTAPI KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock)
BOOLEAN NTAPI SeInitSystem(VOID)
Main security manager initialization function.
Definition: semgr.c:285
KPRIORITY NTAPI KeSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
Definition: thrdobj.c:1327
#define ExLocalTimeToSystemTime(LocTime, SysTime)
Definition: env_spec_w32.h:738
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
BOOLEAN NTAPI ExRefreshTimeZoneInformation(IN PLARGE_INTEGER CurrentBootTime)
Definition: time.c:226
VOID NTAPI ExpLoadInitialProcess(IN PINIT_BUFFER InitBuffer, OUT PRTL_USER_PROCESS_PARAMETERS *ProcessParameters, OUT PCHAR *ProcessEnvironment)
Definition: init.c:388
BOOLEAN NTAPI ExInitSystem(VOID)
Definition: init.c:742
#define NULL
Definition: types.h:112
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: ntapi.c:859
ULONG MmNumberOfPhysicalPages
Definition: init.c:48
BOOLEAN NTAPI PoInitSystem(IN ULONG BootPhase)
Definition: power.c:397
#define DPRINT1
Definition: precomp.h:8
CHAR VersionNumber[24]
Definition: init.c:37
#define MEM_RELEASE
Definition: nt_native.h:1316
VOID NTAPI KeI386VdmInitialize(VOID)
Definition: vdmmain.c:42
struct tagContext Context
Definition: acpixf.h:1034
BOOLEAN NTAPI KeInitSystem(VOID)
Definition: krnlinit.c:293
VOID NTAPI InbvEnableBootDriver(_In_ BOOLEAN Enable)
Definition: inbv.c:257
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI NTSTATUS NTAPI ZwSetSystemTime(_In_ PLARGE_INTEGER SystemTime, _In_opt_ PLARGE_INTEGER NewSystemTime)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ALIGN_UP_BY(size, align)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
BOOLEAN NTAPI SeRmInitPhase1(VOID)
Manages the phase 1 initialization of the security reference monitoring module of the kernel.
Definition: srm.c:211
#define TAG_INIT
Definition: tag.h:27
#define STATUS_SUCCESS
Definition: shellext.h:65
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
VOID NTAPI KeSetSystemTime(IN PLARGE_INTEGER NewSystemTime, OUT PLARGE_INTEGER OldSystemTime, IN BOOLEAN FixInterruptTime, IN PLARGE_INTEGER HalTime)
Definition: clock.c:28
BOOLEAN InbvBootDriverInstalled
Definition: inbv.c:39
#define KeGetCurrentThread
Definition: hal.h:55
ULONG ExpAltTimeZoneBias
Definition: time.c:24
BOOLEAN RtlTimeFieldsToTime(IN PTIME_FIELDS TimeFields, IN PLARGE_INTEGER Time)
static PTIME_FIELDS TimeFields
Definition: time.c:104
#define VER_PRODUCTMINORVERSION
Definition: ntverp.h:26
BOOLEAN InitWinPEModeType
Definition: init.c:72
BOOLEAN NTAPI HalInitSystem(IN ULONG BootPhase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:43
short CSHORT
Definition: umtypes.h:127
#define REG_DWORD
Definition: sdbapi.c:596
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
WCHAR StringBuffer[156]
Definition: ldrinit.c:41
ULONG NtBuildNumber
Definition: init.c:50
#define Int32x32To64(a, b)
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
BOOLEAN InitIsWinPEMode
Definition: init.c:72
CHAR NtBuildLab[]
Definition: init.c:64
LONGLONG QuadPart
Definition: typedefs.h:114
BOOLEAN NTAPI FsRtlInitSystem(VOID)
Definition: fsrtlpc.c:161

Referenced by Phase1Initialization().

Variable Documentation

◆ CmCSDVersionString

UNICODE_STRING CmCSDVersionString

◆ CmNtCSDReleaseType

ULONG CmNtCSDReleaseType

Definition at line 60 of file init.c.

Referenced by ExpInitializeExecutive().

◆ CmNtCSDVersion

ULONG CmNtCSDVersion

Definition at line 59 of file init.c.

Referenced by ExpInitializeExecutive(), MmCreatePeb(), and RtlGetVersion().

◆ CmNtSpBuildNumber

ULONG CmNtSpBuildNumber

Definition at line 58 of file init.c.

Referenced by CmpSetVersionData(), and ExpInitializeExecutive().

◆ CmVersionString

UNICODE_STRING CmVersionString

Definition at line 61 of file init.c.

Referenced by CmpSetVersionData(), and ExpInitializeExecutive().

◆ ExCmosClockIsSane

BOOLEAN ExCmosClockIsSane = TRUE

Definition at line 92 of file init.c.

Referenced by KeSetSystemTime(), and Phase1InitializationDiscard().

◆ ExpAnsiCodePageDataOffset

ULONG ExpAnsiCodePageDataOffset

Definition at line 85 of file init.c.

Referenced by ExpInitializeExecutive(), ExpInitNls(), and MmCreatePeb().

◆ ExpInitializationPhase

◆ ExpInTextModeSetup

BOOLEAN ExpInTextModeSetup

◆ ExpNlsSectionPointer

PVOID ExpNlsSectionPointer

Definition at line 89 of file init.c.

Referenced by ExpInitNls(), and MmCreatePeb().

◆ ExpNlsTableBase

PVOID ExpNlsTableBase

Definition at line 84 of file init.c.

Referenced by ExpInitializeExecutive(), and ExpInitNls().

◆ ExpNlsTableInfo

NLSTABLEINFO ExpNlsTableInfo

Definition at line 87 of file init.c.

Referenced by ExpInitializeExecutive(), and ExpInitNls().

◆ ExpNlsTableSize

SIZE_T ExpNlsTableSize

Definition at line 88 of file init.c.

Referenced by ExpInitNls().

◆ ExpOemCodePageDataOffset

ULONG ExpOemCodePageDataOffset

Definition at line 85 of file init.c.

Referenced by ExpInitializeExecutive(), ExpInitNls(), and MmCreatePeb().

◆ ExpRealTimeIsUniversal

BOOLEAN ExpRealTimeIsUniversal

Definition at line 93 of file init.c.

Referenced by Phase1InitializationDiscard().

◆ ExpUnicodeCaseTableDataOffset

ULONG ExpUnicodeCaseTableDataOffset

Definition at line 86 of file init.c.

Referenced by ExpInitializeExecutive(), ExpInitNls(), and MmCreatePeb().

◆ ExSuiteMask

ULONG ExSuiteMask

Definition at line 55 of file init.c.

Referenced by ExpInitSystemPhase0().

◆ InitIsWinPEMode

BOOLEAN InitIsWinPEMode

Definition at line 72 of file init.c.

Referenced by CmInitSystem1(), and Phase1InitializationDiscard().

◆ InitSafeBootMode

◆ InitWinPEModeType

BOOLEAN InitWinPEModeType

Definition at line 72 of file init.c.

Referenced by Phase1InitializationDiscard().

◆ IoRemoteBootClient

BOOLEAN IoRemoteBootClient

Definition at line 70 of file init.c.

Referenced by ExpInitializeExecutive(), IopCreateArcNames(), and xHalIoAssignDriveLetters().

◆ NtBuildLab

CHAR NtBuildLab[]
Initial value:
= KERNEL_VERSION_BUILD_STR "."
REACTOS_COMPILER_NAME "_" REACTOS_COMPILER_VERSION

Definition at line 64 of file init.c.

Referenced by CmpSetVersionData(), and Phase1InitializationDiscard().

◆ NtBuildNumber

◆ NtGlobalFlag

◆ NtInitialUserProcessBuffer

WCHAR NtInitialUserProcessBuffer[128] = L"\\SystemRoot\\System32\\smss.exe"

Definition at line 78 of file init.c.

Referenced by ExpLoadInitialProcess().

◆ NtInitialUserProcessBufferLength

ULONG NtInitialUserProcessBufferLength
Initial value:
sizeof(WCHAR)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR NtInitialUserProcessBuffer[128]
Definition: init.c:78

Definition at line 79 of file init.c.

Referenced by ExpLoadInitialProcess().

◆ NtInitialUserProcessBufferType

ULONG NtInitialUserProcessBufferType = REG_SZ

Definition at line 81 of file init.c.

Referenced by ExpLoadInitialProcess().

◆ NtMajorVersion

ULONG NtMajorVersion = VER_PRODUCTMAJORVERSION

Definition at line 45 of file init.c.

Referenced by ExpInitializeExecutive(), MmCreatePeb(), PsGetVersion(), and RtlGetVersion().

◆ NtMinorVersion

ULONG NtMinorVersion = VER_PRODUCTMINORVERSION

Definition at line 46 of file init.c.

Referenced by ExpInitializeExecutive(), MmCreatePeb(), PsGetVersion(), and RtlGetVersion().

◆ NtSystemRoot