ReactOS  0.4.15-dev-1389-g828d5fa
init.c File Reference
#include <ntoskrnl.h>
#include <reactos/buildno.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 18 of file init.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 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 873 of file init.c.

876 {
877  PLIST_ENTRY ListEntry;
878  PMEMORY_ALLOCATION_DESCRIPTOR MemDescriptor;
879 
880  DPRINT1("Burn RAM amount: %lu pages\n", PagesToDestroy);
881 
882  /* Loop the memory descriptors, beginning at the end */
883  for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Blink;
884  ListEntry != &LoaderBlock->MemoryDescriptorListHead;
885  ListEntry = ListEntry->Blink)
886  {
887  /* Get the memory descriptor structure */
888  MemDescriptor = CONTAINING_RECORD(ListEntry,
890  ListEntry);
891 
892  /* Is memory free there or is it temporary? */
893  if (MemDescriptor->MemoryType == LoaderFree ||
894  MemDescriptor->MemoryType == LoaderFirmwareTemporary)
895  {
896  /* Check if the descriptor has more pages than we want */
897  if (MemDescriptor->PageCount > PagesToDestroy)
898  {
899  /* Change block's page count, ntoskrnl doesn't care much */
900  MemDescriptor->PageCount -= PagesToDestroy;
901  break;
902  }
903  else
904  {
905  /* Change block type */
906  MemDescriptor->MemoryType = MemoryType;
907  PagesToDestroy -= MemDescriptor->PageCount;
908 
909  /* Check if we are done */
910  if (PagesToDestroy == 0) break;
911  }
912  }
913  }
914 }
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 603 of file init.c.

604 {
605  ULONG MsRemainder = 0, MsIncrement;
606  ULONG IncrementRemainder;
607  ULONG i;
608 
609  /* Count the number of milliseconds for each clock interrupt */
610  MsIncrement = ClockIncrement / (10 * 1000);
611 
612  /* Count the remainder from the division above, with 24-bit precision */
613  IncrementRemainder = ClockIncrement - (MsIncrement * (10 * 1000));
614  for (i= 0; i < 24; i++)
615  {
616  /* Shift the remainders */
617  MsRemainder <<= 1;
618  IncrementRemainder <<= 1;
619 
620  /* Check if we've went past 1 ms */
621  if (IncrementRemainder >= (10 * 1000))
622  {
623  /* Increase the remainder by one, and substract from increment */
624  IncrementRemainder -= (10 * 1000);
625  MsRemainder |= 1;
626  }
627  }
628 
629  /* Return the increment */
630  return (MsIncrement << 24) | MsRemainder;
631 }
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 740 of file init.c.

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

Referenced by ExpInitializeExecutive(), and Phase1InitializationDiscard().

◆ ExpCreateSystemRootLink()

NTSTATUS NTAPI ExpCreateSystemRootLink ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 98 of file init.c.

99 {
100  UNICODE_STRING LinkName;
102  HANDLE LinkHandle;
104  ANSI_STRING AnsiName;
105  CHAR Buffer[256];
108 
109  /* Initialize the ArcName tree */
110  RtlInitUnicodeString(&LinkName, L"\\ArcName");
112  &LinkName,
114  NULL,
116 
117  /* Create it */
118  Status = NtCreateDirectoryObject(&LinkHandle,
121  if (!NT_SUCCESS(Status))
122  {
123  /* Failed */
124  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 1, 0, 0);
125  }
126 
127  /* Close the LinkHandle */
128  NtClose(LinkHandle);
129 
130  /* Initialize the Device tree */
131  RtlInitUnicodeString(&LinkName, L"\\Device");
133  &LinkName,
135  NULL,
137 
138  /* Create it */
139  Status = NtCreateDirectoryObject(&LinkHandle,
142  if (!NT_SUCCESS(Status))
143  {
144  /* Failed */
145  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 2, 0, 0);
146  }
147 
148  /* Close the LinkHandle */
149  ObCloseHandle(LinkHandle, KernelMode);
150 
151  /* Create the system root symlink name */
152  RtlInitAnsiString(&AnsiName, "\\SystemRoot");
153  Status = RtlAnsiStringToUnicodeString(&LinkName, &AnsiName, TRUE);
154  if (!NT_SUCCESS(Status))
155  {
156  /* Failed */
157  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 3, 0, 0);
158  }
159 
160  /* Initialize the attributes for the link */
162  &LinkName,
164  NULL,
166 
167  /* Build the ARC name */
168  sprintf(Buffer,
169  "\\ArcName\\%s%s",
170  LoaderBlock->ArcBootDeviceName,
171  LoaderBlock->NtBootPathName);
172  Buffer[strlen(Buffer) - 1] = ANSI_NULL;
173 
174  /* Convert it to Unicode */
177  &TargetString,
178  TRUE);
179  if (!NT_SUCCESS(Status))
180  {
181  /* We failed, bugcheck */
182  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 4, 0, 0);
183  }
184 
185  /* Create it */
186  Status = NtCreateSymbolicLinkObject(&LinkHandle,
189  &TargetName);
190 
191  /* Free the strings */
192  RtlFreeUnicodeString(&LinkName);
194 
195  /* Check if creating the link failed */
196  if (!NT_SUCCESS(Status))
197  {
198  /* Failed */
199  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 5, 0, 0);
200  }
201 
202  /* Close the handle and return success */
203  ObCloseHandle(LinkHandle, KernelMode);
204  return STATUS_SUCCESS;
205 }
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 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:3399
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
static const WCHAR L[]
Definition: oid.c:1250
#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:773
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:19

Referenced by Phase1InitializationDiscard().

◆ ExpInitializeExecutive()

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

Definition at line 919 of file init.c.

921 {
922  PNLS_DATA_BLOCK NlsData;
923  CHAR Buffer[256];
924  ANSI_STRING AnsiPath;
926  PCHAR CommandLine, PerfMem;
927  ULONG PerfMemUsed;
928  PLDR_DATA_TABLE_ENTRY NtosEntry;
929  PMESSAGE_RESOURCE_ENTRY MsgEntry;
930  ANSI_STRING CSDString;
931  size_t Remaining = 0;
932  PCHAR RcEnd = NULL;
933  CHAR VersionBuffer[65];
934 
935  /* Validate Loader */
936  if (!ExpIsLoaderValid(LoaderBlock))
937  {
938  /* Invalid loader version */
939  KeBugCheckEx(MISMATCHED_HAL,
940  3,
941  LoaderBlock->Extension->Size,
942  LoaderBlock->Extension->MajorVersion,
943  LoaderBlock->Extension->MinorVersion);
944  }
945 
946  /* Initialize PRCB pool lookaside pointers */
948 
949  /* Check if this is an application CPU */
950  if (Cpu)
951  {
952  /* Then simply initialize it with HAL */
953  if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
954  {
955  /* Initialization failed */
956  KeBugCheck(HAL_INITIALIZATION_FAILED);
957  }
958 
959  /* We're done */
960  return;
961  }
962 
963  /* Assume no text-mode or remote boot */
966 
967  /* Check if we have a setup loader block */
968  if (LoaderBlock->SetupLdrBlock)
969  {
970  /* Check if this is text-mode setup */
971  if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_TEXT_MODE)
973 
974  /* Check if this is network boot */
975  if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_REMOTE_BOOT)
976  {
977  /* Set variable */
979 
980  /* Make sure we're actually booting off the network */
981  ASSERT(!_memicmp(LoaderBlock->ArcBootDeviceName, "net(0)", 6));
982  }
983  }
984 
985  /* Set phase to 0 */
987 
988  /* Get boot command line */
989  CommandLine = LoaderBlock->LoadOptions;
990  if (CommandLine)
991  {
992  /* Upcase it for comparison and check if we're in performance mode */
993  _strupr(CommandLine);
994  PerfMem = strstr(CommandLine, "PERFMEM");
995  if (PerfMem)
996  {
997  /* Check if the user gave a number of bytes to use */
998  PerfMem = strstr(PerfMem, "=");
999  if (PerfMem)
1000  {
1001  /* Read the number of pages we'll use */
1002  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1003  if (PerfMemUsed)
1004  {
1005  /* FIXME: TODO */
1006  DPRINT1("BBT performance mode not yet supported."
1007  "/PERFMEM option ignored.\n");
1008  }
1009  }
1010  }
1011 
1012  /* Check if we're burning memory */
1013  PerfMem = strstr(CommandLine, "BURNMEMORY");
1014  if (PerfMem)
1015  {
1016  /* Check if the user gave a number of bytes to use */
1017  PerfMem = strstr(PerfMem, "=");
1018  if (PerfMem)
1019  {
1020  /* Read the number of pages we'll use */
1021  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1022  if (PerfMemUsed) ExBurnMemory(LoaderBlock, PerfMemUsed, LoaderBad);
1023  }
1024  }
1025  }
1026 
1027  /* Setup NLS Base and offsets */
1028  NlsData = LoaderBlock->NlsData;
1029  ExpNlsTableBase = NlsData->AnsiCodePageData;
1032  (ULONG_PTR)NlsData->AnsiCodePageData);
1034  (ULONG_PTR)NlsData->AnsiCodePageData);
1035 
1036  /* Initialize the NLS Tables */
1043  &ExpNlsTableInfo);
1045 
1046  /* Now initialize the HAL */
1047  if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
1048  {
1049  /* HAL failed to initialize, bugcheck */
1050  KeBugCheck(HAL_INITIALIZATION_FAILED);
1051  }
1052 
1053  /* Make sure interrupts are active now */
1054  _enable();
1055 
1056  /* Clear the crypto exponent */
1057  SharedUserData->CryptoExponent = 0;
1058 
1059  /* Set global flags for the checked build */
1060 #if DBG
1063 #endif
1064 
1065  /* Setup NT System Root Path */
1066  sprintf(Buffer, "C:%s", LoaderBlock->NtBootPathName);
1067 
1068  /* Convert to ANSI_STRING and null-terminate it */
1069  RtlInitString(&AnsiPath, Buffer);
1070  Buffer[--AnsiPath.Length] = ANSI_NULL;
1071 
1072  /* Get the string from KUSER_SHARED_DATA's buffer */
1073  RtlInitEmptyUnicodeString(&NtSystemRoot,
1074  SharedUserData->NtSystemRoot,
1075  sizeof(SharedUserData->NtSystemRoot));
1076 
1077  /* Now fill it in */
1079  if (!NT_SUCCESS(Status)) KeBugCheck(SESSION3_INITIALIZATION_FAILED);
1080 
1081  /* Setup bugcheck messages */
1083 
1084  /* Setup initial system settings */
1085  CmGetSystemControlValues(LoaderBlock->RegistryBase, CmControlVector);
1086 
1087  /* Set the Service Pack Number and add it to the CSD Version number if needed */
1089  if (((CmNtCSDVersion & 0xFFFF0000) == 0) && (CmNtCSDReleaseType == 1))
1090  {
1092  }
1093 
1094  /* Add loaded CmNtGlobalFlag value */
1096 
1097  /* Initialize the executive at phase 0 */
1098  if (!ExInitSystem()) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1099 
1100  /* Initialize the memory manager at phase 0 */
1101  if (!MmArmInitSystem(0, LoaderBlock)) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1102 
1103  /* Load boot symbols */
1104  ExpLoadBootSymbols(LoaderBlock);
1105 
1106  /* Check if we should break after symbol load */
1108 
1109  /* Check if this loader is compatible with NT 5.2 */
1110  if (LoaderBlock->Extension->Size >= sizeof(LOADER_PARAMETER_EXTENSION))
1111  {
1112  /* Setup headless terminal settings */
1113  HeadlessInit(LoaderBlock);
1114  }
1115 
1116  /* Set system ranges */
1117 #ifdef _M_AMD64
1120 #else
1123 #endif
1124 
1125  /* Make a copy of the NLS Tables */
1126  ExpInitNls(LoaderBlock);
1127 
1128  /* Get the kernel's load entry */
1129  NtosEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink,
1131  InLoadOrderLinks);
1132 
1133  /* Check if this is a service pack */
1134  if (CmNtCSDVersion & 0xFFFF)
1135  {
1136  /* Get the service pack string */
1137  Status = RtlFindMessage(NtosEntry->DllBase,
1138  11,
1139  0,
1140  WINDOWS_NT_CSD_STRING,
1141  &MsgEntry);
1142  if (NT_SUCCESS(Status))
1143  {
1144  /* Setup the string */
1145  RtlInitAnsiString(&CSDString, (PCHAR)MsgEntry->Text);
1146 
1147  /* Remove trailing newline */
1148  while ((CSDString.Length > 0) &&
1149  ((CSDString.Buffer[CSDString.Length - 1] == '\r') ||
1150  (CSDString.Buffer[CSDString.Length - 1] == '\n')))
1151  {
1152  /* Skip the trailing character */
1153  CSDString.Length--;
1154  }
1155 
1156  /* Fill the buffer with version information */
1158  sizeof(Buffer),
1159  "%Z %u%c",
1160  &CSDString,
1161  (CmNtCSDVersion & 0xFF00) >> 8,
1162  (CmNtCSDVersion & 0xFF) ?
1163  'A' + (CmNtCSDVersion & 0xFF) - 1 :
1164  ANSI_NULL);
1165  }
1166  else
1167  {
1168  /* Build default string */
1170  sizeof(Buffer),
1171  "CSD %04x",
1172  CmNtCSDVersion);
1173  }
1174 
1175  /* Check for success */
1176  if (!NT_SUCCESS(Status))
1177  {
1178  /* Fail */
1179  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1180  }
1181  }
1182  else
1183  {
1184  /* Then this is a beta */
1186  sizeof(Buffer),
1188  NULL,
1189  &Remaining,
1190  0);
1191  if (!NT_SUCCESS(Status))
1192  {
1193  /* Fail */
1194  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1195  }
1196 
1197  /* Update length */
1198  CmCSDVersionString.MaximumLength = sizeof(Buffer) - (USHORT)Remaining;
1199  }
1200 
1201  /* Check if we have an RC number */
1202  if ((CmNtCSDVersion & 0xFFFF0000) && (CmNtCSDReleaseType == 1))
1203  {
1204  /* Check if we have no version data yet */
1205  if (!(*Buffer))
1206  {
1207  /* Set defaults */
1208  Remaining = sizeof(Buffer);
1209  RcEnd = Buffer;
1210  }
1211  else
1212  {
1213  /* Add comma and space */
1215  sizeof(Buffer),
1216  ", ",
1217  &RcEnd,
1218  &Remaining,
1219  0);
1220  if (!NT_SUCCESS(Status))
1221  {
1222  /* Fail */
1223  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1224  }
1225  }
1226 
1227  /* Add the version format string */
1228  Status = RtlStringCbPrintfA(RcEnd,
1229  Remaining,
1230  "v.%u",
1231  (CmNtCSDVersion & 0xFFFF0000) >> 16);
1232  if (!NT_SUCCESS(Status))
1233  {
1234  /* Fail */
1235  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1236  }
1237  }
1238 
1239  /* Now setup the final string */
1240  RtlInitAnsiString(&CSDString, Buffer);
1242  &CSDString,
1243  TRUE);
1244  if (!NT_SUCCESS(Status))
1245  {
1246  /* Fail */
1247  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1248  }
1249 
1250  /* Add our version */
1251  Status = RtlStringCbPrintfA(VersionBuffer,
1252  sizeof(VersionBuffer),
1253  "%u.%u",
1256  if (!NT_SUCCESS(Status))
1257  {
1258  /* Fail */
1259  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1260  }
1261 
1262  /* Build the final version string */
1264 
1265  /* Check if the user wants a kernel stack trace database */
1267  {
1268  /* FIXME: TODO */
1269  DPRINT1("Kernel-mode stack trace support not yet present."
1270  "FLG_KERNEL_STACK_TRACE_DB flag ignored.\n");
1271  }
1272 
1273  /* Check if he wanted exception logging */
1275  {
1276  /* FIXME: TODO */
1277  DPRINT1("Kernel-mode exception logging support not yet present."
1278  "FLG_ENABLE_EXCEPTION_LOGGING flag ignored.\n");
1279  }
1280 
1281  /* Initialize the Handle Table */
1283 
1284 #if DBG
1285  /* On checked builds, allocate the system call count table */
1288  KiServiceLimit * sizeof(ULONG),
1289  'llaC');
1290 
1291  /* Use it for the shadow table too */
1293 
1294  /* Make sure allocation succeeded */
1296  {
1297  /* Zero the call counts to 0 */
1299  KiServiceLimit * sizeof(ULONG));
1300  }
1301 #endif
1302 
1303  /* Create the Basic Object Manager Types to allow new Object Types */
1304  if (!ObInitSystem()) KeBugCheck(OBJECT_INITIALIZATION_FAILED);
1305 
1306  /* Load basic Security for other Managers */
1307  if (!SeInitSystem()) KeBugCheck(SECURITY_INITIALIZATION_FAILED);
1308 
1309  /* Initialize the Process Manager */
1310  if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS_INITIALIZATION_FAILED);
1311 
1312  /* Initialize the PnP Manager */
1313  if (!PpInitSystem()) KeBugCheck(PP0_INITIALIZATION_FAILED);
1314 
1315  /* Initialize the User-Mode Debugging Subsystem */
1316  DbgkInitialize();
1317 
1318  /* Calculate the tick count multiplier */
1320  SharedUserData->TickCountMultiplier = ExpTickCountMultiplier;
1321 
1322  /* Set the OS Version */
1323  SharedUserData->NtMajorVersion = NtMajorVersion;
1324  SharedUserData->NtMinorVersion = NtMinorVersion;
1325 
1326  /* Set the machine type */
1327  SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_NATIVE;
1328  SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_NATIVE;
1329 }
#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:210
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)
Definition: rtltypes.h:1891
UNICODE_STRING NtSystemRoot
Definition: init.c:73
NLSTABLEINFO ExpNlsTableInfo
Definition: init.c:85
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:1856
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:792
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:58
PVOID AnsiCodePageData
Definition: arc.h:276
ULONG NtMajorVersion
Definition: init.c:43
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:65
PVOID DllBase
Definition: btrfs_drv.h:1926
#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:297
_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:56
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:1895
#define ASSERT(a)
Definition: mode.c:45
VOID NTAPI ExpInitializeHandleTables(VOID)
Definition: handle.c:28
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID ExpNlsTableBase
Definition: init.c:82
ULONG NtMinorVersion
Definition: init.c:44
#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:84
UNICODE_STRING CmCSDVersionString
Definition: init.c:60
VOID NTAPI ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG_PTR PagesToDestroy, IN TYPE_OF_MEMORY MemoryType)
Definition: init.c:873
ULONG CmNtGlobalFlag
Definition: cmdata.c:19
Definition: btrfs_drv.h:1922
ULONG ExpInitializationPhase
Definition: init.c:66
UNICODE_STRING CmVersionString
Definition: init.c:59
#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:83
BOOLEAN ExpInTextModeSetup
Definition: init.c:67
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define SETUPLDR_TEXT_MODE
Definition: setupblk.h:7
BOOLEAN NTAPI SeInitSystem(VOID)
Definition: semgr.c:239
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:740
#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:57
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:52
#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:766
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:83
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:603
BOOLEAN IoRemoteBootClient
Definition: init.c:68

Referenced by KiInitializeKernel().

◆ ExpInitNls()

VOID NTAPI ExpInitNls ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 210 of file init.c.

211 {
212  LARGE_INTEGER SectionSize;
214  HANDLE NlsSection;
215  PVOID SectionBase = NULL;
216  SIZE_T ViewSize = 0;
217  LARGE_INTEGER SectionOffset = {{0, 0}};
218  PLIST_ENTRY ListHead, NextEntry;
220  ULONG NlsTablesEncountered = 0;
221  SIZE_T NlsTableSizes[3] = {0, 0, 0}; /* 3 NLS tables */
222 
223  /* Check if this is boot-time phase 0 initialization */
225  {
226  /* Loop the memory descriptors */
227  ListHead = &LoaderBlock->MemoryDescriptorListHead;
228  NextEntry = ListHead->Flink;
229  while (NextEntry != ListHead)
230  {
231  /* Get the current block */
232  MdBlock = CONTAINING_RECORD(NextEntry,
234  ListEntry);
235 
236  /* Check if this is an NLS block */
237  if (MdBlock->MemoryType == LoaderNlsData)
238  {
239  /* Increase the table size */
240  ExpNlsTableSize += MdBlock->PageCount * PAGE_SIZE;
241 
242  /* FreeLdr-specific */
243  NlsTableSizes[NlsTablesEncountered] = MdBlock->PageCount * PAGE_SIZE;
244  NlsTablesEncountered++;
245  ASSERT(NlsTablesEncountered < 4);
246  }
247 
248  /* Go to the next block */
249  NextEntry = MdBlock->ListEntry.Flink;
250  }
251 
252  /* Allocate the a new buffer since loader memory will be freed */
255  TAG_RTLI);
256  if (!ExpNlsTableBase) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
257 
258  /* Copy the codepage data in its new location. */
259  if (NlsTablesEncountered == 1)
260  {
261  /* Ntldr-way boot process */
263  LoaderBlock->NlsData->AnsiCodePageData,
265  }
266  else
267  {
268  /*
269  * In NT, the memory blocks are contiguous, but in ReactOS they aren't,
270  * so unless someone fixes FreeLdr, we'll have to use this icky hack.
271  */
273  LoaderBlock->NlsData->AnsiCodePageData,
274  NlsTableSizes[0]);
275 
276  RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0]),
277  LoaderBlock->NlsData->OemCodePageData,
278  NlsTableSizes[1]);
279 
280  RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0] +
281  NlsTableSizes[1]),
282  LoaderBlock->NlsData->UnicodeCodePageData,
283  NlsTableSizes[2]);
284  /* End of Hack */
285  }
286 
287  /* Initialize and reset the NLS TAbles */
294  &ExpNlsTableInfo);
296  return;
297  }
298 
299  /* Set the section size */
300  SectionSize.QuadPart = ExpNlsTableSize;
301 
302  /* Create the NLS Section */
303  Status = ZwCreateSection(&NlsSection,
305  NULL,
306  &SectionSize,
308  SEC_COMMIT | 0x1,
309  NULL);
310  if (!NT_SUCCESS(Status))
311  {
312  /* Failed */
313  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 1, 0, 0);
314  }
315 
316  /* Get a pointer to the section */
317  Status = ObReferenceObjectByHandle(NlsSection,
320  KernelMode,
322  NULL);
323  ObCloseHandle(NlsSection, KernelMode);
324  if (!NT_SUCCESS(Status))
325  {
326  /* Failed */
327  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 2, 0, 0);
328  }
329 
330  /* Map the NLS Section in system space */
332  &SectionBase,
333  &ExpNlsTableSize);
334  if (!NT_SUCCESS(Status))
335  {
336  /* Failed */
337  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 3, 0, 0);
338  }
339 
340  /* Copy the codepage data in its new location. */
341  ASSERT(SectionBase >= MmSystemRangeStart);
343 
344  /* Free the previously allocated buffer and set the new location */
346  ExpNlsTableBase = SectionBase;
347 
348  /* Initialize the NLS Tables */
355  &ExpNlsTableInfo);
357 
358  /* Reset the base to 0 */
359  SectionBase = NULL;
360 
361  /* Map the section in the system process */
364  &SectionBase,
365  0L,
366  0L,
367  &SectionOffset,
368  &ViewSize,
369  ViewShare,
370  0L,
372  if (!NT_SUCCESS(Status))
373  {
374  /* Failed */
375  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 5, 0, 0);
376  }
377 
378  /* Copy the table into the system process and set this as the base */
380  ExpNlsTableBase = SectionBase;
381 }
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)
NLSTABLEINFO ExpNlsTableInfo
Definition: init.c:85
_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:27
TYPE_OF_MEMORY MemoryType
Definition: arc.h:193
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
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:496
#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:4500
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:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID ExpNlsTableBase
Definition: init.c:82
PVOID ExpNlsSectionPointer
Definition: init.c:87
POBJECT_TYPE MmSectionObjectType
Definition: section.c:130
#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:4845
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
static const WCHAR L[]
Definition: oid.c:1250
ULONG ExpUnicodeCaseTableDataOffset
Definition: init.c:84
ULONG ExpInitializationPhase
Definition: init.c:66
SIZE_T ExpNlsTableSize
Definition: init.c:86
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:119
ULONG ExpOemCodePageDataOffset
Definition: init.c:83
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:83
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 636 of file init.c.

637 {
638  /* Initialize EXRESOURCE Support */
640 
641  /* Initialize the environment lock */
643 
644  /* Initialize the lookaside lists and locks */
646 
647  /* Initialize the Firmware Table resource and listhead */
650 
651  /* Set the suite mask to maximum and return */
652  ExSuiteMask = 0xFFFFFFFF;
653  return TRUE;
654 }
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:53
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 659 of file init.c.

660 {
661  /* Initialize worker threads */
663 
664  /* Initialize pushlocks */
666 
667  /* Initialize events and event pairs */
669  {
670  DPRINT1("Executive: Event initialization failed\n");
671  return FALSE;
672  }
674  {
675  DPRINT1("Executive: Event Pair initialization failed\n");
676  return FALSE;
677  }
678 
679  /* Initialize mutants */
681  {
682  DPRINT1("Executive: Mutant initialization failed\n");
683  return FALSE;
684  }
685 
686  /* Initialize callbacks */
687  if (ExpInitializeCallbacks() == FALSE)
688  {
689  DPRINT1("Executive: Callback initialization failed\n");
690  return FALSE;
691  }
692 
693  /* Initialize semaphores */
695  {
696  DPRINT1("Executive: Semaphore initialization failed\n");
697  return FALSE;
698  }
699 
700  /* Initialize timers */
702  {
703  DPRINT1("Executive: Timer initialization failed\n");
704  return FALSE;
705  }
706 
707  /* Initialize profiling */
709  {
710  DPRINT1("Executive: Profile initialization failed\n");
711  return FALSE;
712  }
713 
714  /* Initialize UUIDs */
715  if (ExpUuidInitialization() == FALSE)
716  {
717  DPRINT1("Executive: Uuid initialization failed\n");
718  return FALSE;
719  }
720 
721  /* Initialize keyed events */
723  {
724  DPRINT1("Executive: Keyed event initialization failed\n");
725  return FALSE;
726  }
727 
728  /* Initialize Win32K */
729  if (ExpWin32kInit() == FALSE)
730  {
731  DPRINT1("Executive: Win32 initialization failed\n");
732  return FALSE;
733  }
734  return TRUE;
735 }
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI ExpInitializeMutantImplementation(VOID)
Definition: mutant.c:52
BOOLEAN NTAPI ExpInitializeProfileImplementation(VOID)
Definition: profile.c:64
#define FALSE
Definition: types.h:117
BOOLEAN NTAPI ExpUuidInitialization(VOID)
Definition: uuid.c:52
BOOLEAN NTAPI ExpWin32kInit(VOID)
Definition: win32k.c:259
VOID NTAPI ExpInitializeWorkerThreads(VOID)
Definition: work.c:515
BOOLEAN NTAPI ExpInitializeKeyedEventImplementation(VOID)
BOOLEAN NTAPI ExpInitializeSemaphoreImplementation(VOID)
Definition: sem.c:39
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 766 of file init.c.

767 {
769 
770  /* Get the loader extension */
771  Extension = LoaderBlock->Extension;
772 
773  /* Validate the size (Windows 2003 loader doesn't provide more) */
775 
776  /* Don't validate upper versions */
777  if (Extension->MajorVersion > VER_PRODUCTMAJORVERSION) return TRUE;
778 
779  /* Fail if this is NT 4 */
780  if (Extension->MajorVersion < VER_PRODUCTMAJORVERSION) return FALSE;
781 
782  /* Fail if this is XP */
783  if (Extension->MinorVersion < VER_PRODUCTMINORVERSION) return FALSE;
784 
785  /* This is 2003 or newer, approve it */
786  return TRUE;
787 }
#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:18

Referenced by ExpInitializeExecutive().

◆ ExpLoadBootSymbols()

VOID NTAPI ExpLoadBootSymbols ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 792 of file init.c.

793 {
794  ULONG i = 0;
795  PLIST_ENTRY NextEntry;
796  ULONG Count, Length;
797  PWCHAR Name;
798  PLDR_DATA_TABLE_ENTRY LdrEntry;
799  CHAR NameBuffer[256];
800  STRING SymbolString;
802 
803  /* Loop the driver list */
804  NextEntry = LoaderBlock->LoadOrderListHead.Flink;
805  while (NextEntry != &LoaderBlock->LoadOrderListHead)
806  {
807  /* Skip the first two images */
808  if (i >= 2)
809  {
810  /* Get the entry */
811  LdrEntry = CONTAINING_RECORD(NextEntry,
813  InLoadOrderLinks);
814  if (LdrEntry->FullDllName.Buffer[0] == L'\\')
815  {
816  /* We have a name, read its data */
817  Name = LdrEntry->FullDllName.Buffer;
818  Length = LdrEntry->FullDllName.Length / sizeof(WCHAR);
819 
820  /* Check if our buffer can hold it */
821  if (sizeof(NameBuffer) < Length + sizeof(ANSI_NULL))
822  {
823  /* It's too long */
825  }
826  else
827  {
828  /* Copy the name */
829  Count = 0;
830  do
831  {
832  /* Copy the character */
833  NameBuffer[Count++] = (CHAR)*Name++;
834  } while (Count < Length);
835 
836  /* Null-terminate */
837  NameBuffer[Count] = ANSI_NULL;
839  }
840  }
841  else
842  {
843  /* Safely print the string into our buffer */
844  Status = RtlStringCbPrintfA(NameBuffer,
845  sizeof(NameBuffer),
846  "%S\\System32\\Drivers\\%wZ",
847  &SharedUserData->NtSystemRoot[2],
848  &LdrEntry->BaseDllName);
849  }
850 
851  /* Check if the buffer was ok */
852  if (NT_SUCCESS(Status))
853  {
854  /* Initialize the STRING for the debugger */
855  RtlInitString(&SymbolString, NameBuffer);
856 
857  /* Load the symbols */
858  DbgLoadImageSymbols(&SymbolString,
859  LdrEntry->DllBase,
861  }
862  }
863 
864  /* Go to the next entry */
865  i++;
866  NextEntry = NextEntry->Flink;
867  }
868 }
_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:1926
#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
static const WCHAR L[]
Definition: oid.c:1250
Definition: btrfs_drv.h:1922
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:1928
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 386 of file init.c.

389 {
391  SIZE_T Size;
392  PWSTR p;
393  UNICODE_STRING NullString = RTL_CONSTANT_STRING(L"");
394  UNICODE_STRING SmssName, Environment, SystemDriveString, DebugString;
395  PVOID EnvironmentPtr = NULL;
396  PRTL_USER_PROCESS_INFORMATION ProcessInformation;
397  PRTL_USER_PROCESS_PARAMETERS ProcessParams = NULL;
398 
399  NullString.Length = sizeof(WCHAR);
400 
401  /* Use the initial buffer, after the strings */
402  ProcessInformation = &InitBuffer->ProcessInfo;
403 
404  /* Allocate memory for the process parameters */
405  Size = sizeof(*ProcessParams) + ((MAX_WIN32_PATH * 6) * sizeof(WCHAR));
406  Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
407  (PVOID*)&ProcessParams,
408  0,
409  &Size,
412  if (!NT_SUCCESS(Status))
413  {
414  /* Failed, display error */
415  _snwprintf(InitBuffer->DebugBuffer,
416  sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
417  L"INIT: Unable to allocate Process Parameters. 0x%lx",
418  Status);
419  RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
421 
422  /* Bugcheck the system */
423  KeBugCheckEx(SESSION1_INITIALIZATION_FAILED, Status, 0, 0, 0);
424  }
425 
426  /* Setup the basic header, and give the process the low 1MB to itself */
427  ProcessParams->Length = (ULONG)Size;
428  ProcessParams->MaximumLength = (ULONG)Size;
431 
432  /* Allocate a page for the environment */
433  Size = PAGE_SIZE;
434  Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
435  &EnvironmentPtr,
436  0,
437  &Size,
440  if (!NT_SUCCESS(Status))
441  {
442  /* Failed, display error */
443  _snwprintf(InitBuffer->DebugBuffer,
444  sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
445  L"INIT: Unable to allocate Process Environment. 0x%lx",
446  Status);
447  RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
449 
450  /* Bugcheck the system */
451  KeBugCheckEx(SESSION2_INITIALIZATION_FAILED, Status, 0, 0, 0);
452  }
453 
454  /* Write the pointer */
455  ProcessParams->Environment = EnvironmentPtr;
456 
457  /* Make a buffer for the DOS path */
458  p = (PWSTR)(ProcessParams + 1);
459  ProcessParams->CurrentDirectory.DosPath.Buffer = p;
461  sizeof(WCHAR);
462 
463  /* Copy the DOS path */
465  &NtSystemRoot);
466 
467  /* Make a buffer for the DLL Path */
468  p = (PWSTR)((PCHAR)ProcessParams->CurrentDirectory.DosPath.Buffer +
469  ProcessParams->CurrentDirectory.DosPath.MaximumLength);
470  ProcessParams->DllPath.Buffer = p;
471  ProcessParams->DllPath.MaximumLength = MAX_WIN32_PATH * sizeof(WCHAR);
472 
473  /* Copy the DLL path and append the system32 directory */
474  RtlCopyUnicodeString(&ProcessParams->DllPath,
475  &ProcessParams->CurrentDirectory.DosPath);
476  RtlAppendUnicodeToString(&ProcessParams->DllPath, L"\\System32");
477 
478  /* Make a buffer for the image name */
479  p = (PWSTR)((PCHAR)ProcessParams->DllPath.Buffer +
480  ProcessParams->DllPath.MaximumLength);
481  ProcessParams->ImagePathName.Buffer = p;
482  ProcessParams->ImagePathName.MaximumLength = MAX_WIN32_PATH * sizeof(WCHAR);
483 
484  /* Make sure the buffer is a valid string which within the given length */
489  sizeof(NtInitialUserProcessBuffer) - sizeof(WCHAR)))))
490  {
491  /* Invalid initial process string, bugcheck */
492  KeBugCheckEx(SESSION2_INITIALIZATION_FAILED,
497  }
498 
499  /* Cut out anything after a space */
501  while ((*p) && (*p != L' ')) p++;
502 
503  /* Set the image path length */
504  ProcessParams->ImagePathName.Length =
506 
507  /* Copy the actual buffer */
508  RtlCopyMemory(ProcessParams->ImagePathName.Buffer,
510  ProcessParams->ImagePathName.Length);
511 
512  /* Null-terminate it */
513  ProcessParams->ImagePathName.Buffer[ProcessParams->ImagePathName.Length /
514  sizeof(WCHAR)] = UNICODE_NULL;
515 
516  /* Make a buffer for the command line */
517  p = (PWSTR)((PCHAR)ProcessParams->ImagePathName.Buffer +
518  ProcessParams->ImagePathName.MaximumLength);
519  ProcessParams->CommandLine.Buffer = p;
520  ProcessParams->CommandLine.MaximumLength = MAX_WIN32_PATH * sizeof(WCHAR);
521 
522  /* Add the image name to the command line */
523  RtlAppendUnicodeToString(&ProcessParams->CommandLine,
525 
526  /* Create the environment string */
527  RtlInitEmptyUnicodeString(&Environment,
528  ProcessParams->Environment,
529  (USHORT)Size);
530 
531  /* Append the DLL path to it */
535 
536  /* Create the system drive string */
537  SystemDriveString = NtSystemRoot;
538  SystemDriveString.Length = 2 * sizeof(WCHAR);
539 
540  /* Append it to the environment */
541  RtlAppendUnicodeToString(&Environment, L"SystemDrive=");
542  RtlAppendUnicodeStringToString(&Environment, &SystemDriveString);
544 
545  /* Append the system root to the environment */
546  RtlAppendUnicodeToString(&Environment, L"SystemRoot=");
549 
550  /* Prepare the prefetcher */
551  //CcPfBeginBootPhase(150);
552 
553  /* Create SMSS process */
554  SmssName = ProcessParams->ImagePathName;
555  Status = RtlCreateUserProcess(&SmssName,
557  RtlDeNormalizeProcessParams(ProcessParams),
558  NULL,
559  NULL,
560  NULL,
561  FALSE,
562  NULL,
563  NULL,
564  ProcessInformation);
565  if (!NT_SUCCESS(Status))
566  {
567  /* Failed, display error */
568  _snwprintf(InitBuffer->DebugBuffer,
569  sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
570  L"INIT: Unable to create Session Manager. 0x%lx",
571  Status);
572  RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
574 
575  /* Bugcheck the system */
576  KeBugCheckEx(SESSION3_INITIALIZATION_FAILED, Status, 0, 0, 0);
577  }
578 
579  /* Resume the thread */
580  Status = ZwResumeThread(ProcessInformation->ThreadHandle, NULL);
581  if (!NT_SUCCESS(Status))
582  {
583  /* Failed, display error */
584  _snwprintf(InitBuffer->DebugBuffer,
585  sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
586  L"INIT: Unable to resume Session Manager. 0x%lx",
587  Status);
588  RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
590 
591  /* Bugcheck the system */
592  KeBugCheckEx(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0);
593  }
594 
595  /* Return success */
596  *ProcessParameters = ProcessParams;
597  *ProcessEnvironment = EnvironmentPtr;
598 }
signed char * PCHAR
Definition: retypes.h:7
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:45
UNICODE_STRING NtSystemRoot
Definition: init.c:73
#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 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:76
NTSYSAPI NTSTATUS NTAPI ZwResumeThread(_In_ HANDLE ThreadHandle, _Out_opt_ PULONG SuspendCount)
UNICODE_STRING ImagePathName
Definition: btrfs_drv.h:1947
static const WCHAR L[]
Definition: oid.c:1250
ULONG NtInitialUserProcessBufferType
Definition: init.c:79
#define PAGE_SIZE
Definition: env_spec_w32.h:49
UNICODE_STRING CommandLine
Definition: btrfs_drv.h:1948
#define MAXULONG
Definition: typedefs.h:251
#define MAX_WIN32_PATH
Definition: ntoskrnl.h:113
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:1366
ULONG NtInitialUserProcessBufferLength
Definition: init.c:77
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  /* Initialize critical section timeout value (relative time is negative) */
2144 
2145  /* Initialize the paged pool mutex and the section commit mutex */
2149 
2150  /* Initialize the Loader Lock */
2152 
2153  /* Set up the zero page event */
2155 
2156  /* Initialize the dead stack S-LIST */
2158 
2159  //
2160  // Check if this is a machine with less than 19MB of RAM
2161  //
2162  PageCount = MmNumberOfPhysicalPages;
2163  if (PageCount < MI_MIN_PAGES_FOR_SYSPTE_TUNING)
2164  {
2165  //
2166  // Use the very minimum of system PTEs
2167  //
2168  MmNumberOfSystemPtes = 7000;
2169  }
2170  else
2171  {
2172  //
2173  // Use the default
2174  //
2175  MmNumberOfSystemPtes = 11000;
2176  if (PageCount > MI_MIN_PAGES_FOR_SYSPTE_BOOST)
2177  {
2178  //
2179  // Double the amount of system PTEs
2180  //
2181  MmNumberOfSystemPtes <<= 1;
2182  }
2183  if (PageCount > MI_MIN_PAGES_FOR_SYSPTE_BOOST_BOOST)
2184  {
2185  //
2186  // Double the amount of system PTEs
2187  //
2188  MmNumberOfSystemPtes <<= 1;
2189  }
2190  if (MmSpecialPoolTag != 0 && MmSpecialPoolTag != -1)
2191  {
2192  //
2193  // Add some extra PTEs for special pool
2194  //
2195  MmNumberOfSystemPtes += 0x6000;
2196  }
2197  }
2198 
2199  DPRINT("System PTE count has been tuned to %lu (%lu bytes)\n",
2201 
2202  /* Check if no values are set for the heap limits */
2203  if (MmHeapSegmentReserve == 0)
2204  {
2205  MmHeapSegmentReserve = 2 * _1MB;
2206  }
2207 
2208  if (MmHeapSegmentCommit == 0)
2209  {
2211  }
2212 
2214  {
2216  }
2217 
2219  {
2221  }
2222 
2223  /* Initialize the working set lock */
2225 
2226  /* Set commit limit */
2227  MmTotalCommitLimit = (2 * _1GB) >> PAGE_SHIFT;
2229 
2230  /* Has the allocation fragment been setup? */
2231  if (!MmAllocationFragment)
2232  {
2233  /* Use the default value */
2235  if (PageCount < ((256 * _1MB) / PAGE_SIZE))
2236  {
2237  /* On memory systems with less than 256MB, divide by 4 */
2239  }
2240  else if (PageCount < (_1GB / PAGE_SIZE))
2241  {
2242  /* On systems with less than 1GB, divide by 2 */
2244  }
2245  }
2246  else
2247  {
2248  /* Convert from 1KB fragments to pages */
2251 
2252  /* Don't let it past the maximum */
2255 
2256  /* Don't let it too small either */
2259  }
2260 
2261  /* Check for kernel stack size that's too big */
2263  {
2264  /* Sanitize to default value */
2266  }
2267  else
2268  {
2269  /* Take the registry setting, and convert it into bytes */
2271 
2272  /* Now align it to a page boundary */
2274 
2275  /* Sanity checks */
2277  ASSERT((MmLargeStackSize & (PAGE_SIZE - 1)) == 0);
2278 
2279  /* Make sure it's not too low */
2281  }
2282 
2283  /* Compute color information (L2 cache-separated paging lists) */
2285 
2286  // Calculate the number of bytes for the PFN database
2287  // then add the color tables and convert to pages
2288  MxPfnAllocation = (MmHighestPhysicalPage + 1) * sizeof(MMPFN);
2291 
2292  // We have to add one to the count here, because in the process of
2293  // shifting down to the page size, we actually ended up getting the
2294  // lower aligned size (so say, 0x5FFFF bytes is now 0x5F pages).
2295  // Later on, we'll shift this number back into bytes, which would cause
2296  // us to end up with only 0x5F000 bytes -- when we actually want to have
2297  // 0x60000 bytes.
2298  MxPfnAllocation++;
2299 
2300  /* Initialize the platform-specific parts */
2301  MiInitMachineDependent(LoaderBlock);
2302 
2303 #if DBG
2304  /* Prototype PTEs are assumed to be in paged pool, so check if the math works */
2305  PointerPte = (PMMPTE)MmPagedPoolStart;
2306  MI_MAKE_PROTOTYPE_PTE(&TempPte, PointerPte);
2307  TestPte = MiProtoPteToPte(&TempPte);
2308  ASSERT(PointerPte == TestPte);
2309 
2310  /* Try the last nonpaged pool address */
2311  PointerPte = (PMMPTE)MI_NONPAGED_POOL_END;
2312  MI_MAKE_PROTOTYPE_PTE(&TempPte, PointerPte);
2313  TestPte = MiProtoPteToPte(&TempPte);
2314  ASSERT(PointerPte == TestPte);
2315 
2316  /* Try a bunch of random addresses near the end of the address space */
2317  PointerPte = (PMMPTE)((ULONG_PTR)MI_HIGHEST_SYSTEM_ADDRESS - 0x37FFF);
2318  for (j = 0; j < 20; j += 1)
2319  {
2320  MI_MAKE_PROTOTYPE_PTE(&TempPte, PointerPte);
2321  TestPte = MiProtoPteToPte(&TempPte);
2322  ASSERT(PointerPte == TestPte);
2323  PointerPte++;
2324  }
2325 
2326  /* Subsection PTEs are always in nonpaged pool, pick a random address to try */
2328  MI_MAKE_SUBSECTION_PTE(&TempPte, PointerPte);
2330  ASSERT(PointerPte == TestPte);
2331 #endif
2332 
2333  //
2334  // Build the physical memory block
2335  //
2337  IncludeType);
2338 
2339  //
2340  // Allocate enough buffer for the PFN bitmap
2341  // Align it up to a 32-bit boundary
2342  //
2344  (((MmHighestPhysicalPage + 1) + 31) / 32) * 4,
2345  TAG_MM);
2346  if (!Bitmap)
2347  {
2348  //
2349  // This is critical
2350  //
2351  KeBugCheckEx(INSTALL_MORE_MEMORY,
2355  0x101);
2356  }
2357 
2358  //
2359  // Initialize it and clear all the bits to begin with
2360  //
2362  Bitmap,
2365 
2366  //
2367  // Loop physical memory runs
2368  //
2369  for (i = 0; i < MmPhysicalMemoryBlock->NumberOfRuns; i++)
2370  {
2371  //
2372  // Get the run
2373  //
2375  DPRINT("PHYSICAL RAM [0x%08p to 0x%08p]\n",
2376  Run->BasePage << PAGE_SHIFT,
2377  (Run->BasePage + Run->PageCount) << PAGE_SHIFT);
2378 
2379  //
2380  // Make sure it has pages inside it
2381  //
2382  if (Run->PageCount)
2383  {
2384  //
2385  // Set the bits in the PFN bitmap
2386  //
2387  RtlSetBits(&MiPfnBitMap, (ULONG)Run->BasePage, (ULONG)Run->PageCount);
2388  }
2389  }
2390 
2391  /* Look for large page cache entries that need caching */
2393 
2394  /* Loop for HAL Heap I/O device mappings that need coherency tracking */
2396 
2397  /* Set the initial resident page count */
2399 
2400  /* Initialize large page structures on PAE/x64, and MmProcessList on x86 */
2402 
2403  /* Check if the registry says any drivers should be loaded with large pages */
2405 
2406  /* Relocate the boot drivers into system PTE space and fixup their PFNs */
2407  MiReloadBootLoadedDrivers(LoaderBlock);
2408 
2409  /* FIXME: Call out into Driver Verifier for initialization */
2410 
2411  /* Check how many pages the system has */
2412  if (MmNumberOfPhysicalPages <= ((13 * _1MB) / PAGE_SIZE))
2413  {
2414  /* Set small system */
2417  }
2418  else if (MmNumberOfPhysicalPages <= ((19 * _1MB) / PAGE_SIZE))
2419  {
2420  /* Set small system and add 100 pages for the cache */
2422  MmSystemCacheWsMinimum += 100;
2424  }
2425  else
2426  {
2427  /* Set medium system and add 400 pages for the cache */
2429  MmSystemCacheWsMinimum += 400;
2431  }
2432 
2433  /* Check for less than 24MB */
2434  if (MmNumberOfPhysicalPages < ((24 * _1MB) / PAGE_SIZE))
2435  {
2436  /* No more than 32 pages */
2438  }
2439 
2440  /* Check for more than 32MB */
2441  if (MmNumberOfPhysicalPages >= ((32 * _1MB) / PAGE_SIZE))
2442  {
2443  /* Check for product type being "Wi" for WinNT */
2444  if (MmProductType == '\0i\0W')
2445  {
2446  /* Then this is a large system */
2448  }
2449  else
2450  {
2451  /* For servers, we need 64MB to consider this as being large */
2452  if (MmNumberOfPhysicalPages >= ((64 * _1MB) / PAGE_SIZE))
2453  {
2454  /* Set it as large */
2456  }
2457  }
2458  }
2459 
2460  /* Check for more than 33 MB */
2461  if (MmNumberOfPhysicalPages > ((33 * _1MB) / PAGE_SIZE))
2462  {
2463  /* Add another 500 pages to the cache */
2464  MmSystemCacheWsMinimum += 500;
2465  }
2466 
2467  /* Now setup the shared user data fields */
2468  ASSERT(SharedUserData->NumberOfPhysicalPages == 0);
2469  SharedUserData->NumberOfPhysicalPages = MmNumberOfPhysicalPages;
2470  SharedUserData->LargePageMinimum = 0;
2471 
2472  /* Check for workstation (Wi for WinNT) */
2473  if (MmProductType == '\0i\0W')
2474  {
2475  /* Set Windows NT Workstation product type */
2476  SharedUserData->NtProductType = NtProductWinNt;
2477  MmProductType = 0;
2478 
2479  /* For this product, we wait till the last moment to throttle */
2480  MmThrottleTop = 250;
2481  MmThrottleBottom = 30;
2482  }
2483  else
2484  {
2485  /* Check for LanMan server (La for LanmanNT) */
2486  if (MmProductType == '\0a\0L')
2487  {
2488  /* This is a domain controller */
2489  SharedUserData->NtProductType = NtProductLanManNt;
2490  }
2491  else
2492  {
2493  /* Otherwise it must be a normal server (Se for ServerNT) */
2494  SharedUserData->NtProductType = NtProductServer;
2495  }
2496 
2497  /* Set the product type, and make the system more aggressive with low memory */
2498  MmProductType = 1;
2499  MmMinimumFreePages = 81;
2500 
2501  /* We will throttle earlier to preserve memory */
2502  MmThrottleTop = 450;
2503  MmThrottleBottom = 80;
2504  }
2505 
2506  /* Update working set tuning parameters */
2508 
2509  /* Finetune the page count by removing working set and NP expansion */
2513  if (MmResidentAvailablePages <= 0)
2514  {
2515  /* This should not happen */
2516  DPRINT1("System cache working set too big\n");
2517  return FALSE;
2518  }
2519 
2520  /* Define limits for system cache */
2521 #ifdef _M_AMD64
2523 #else
2525 #endif
2527 #ifdef _M_AMD64
2529 #else
2531 #endif
2532 
2533  /* Initialize the system cache */
2534  //MiInitializeSystemCache(MmSystemCacheWsMinimum, MmAvailablePages);
2535 
2536  /* Update the commit limit */
2538  if (MmTotalCommitLimit > 1024) MmTotalCommitLimit -= 1024;
2540 
2541  /* Size up paged pool and build the shadow system page directory */
2542  MiBuildPagedPool();
2543 
2544  /* Debugger physical memory support is now ready to be used */
2546 
2547  /* Initialize the loaded module list */
2548  MiInitializeLoadedModuleList(LoaderBlock);
2549  }
2550 
2551  //
2552  // Always return success for now
2553  //
2554  return TRUE;
2555 }
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:84
#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:2205
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:378
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:154
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:14
#define KERNEL_LARGE_STACK_SIZE
PFN_COUNT MiExpansionPoolPagesInitialCharge
Definition: pool.c:21
PHYSICAL_MEMORY_RUN Run[1]
Definition: miarm.h:432
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:379
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:27
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:136
VOID NTAPI MiAddHalIoMappings(VOID)
Definition: mminit.c:1418
#define FALSE
Definition: types.h:117
Definition: arc.h:130
PFN_NUMBER Blink
Definition: mm.h:380
PVOID MmHighestUserAddress
Definition: mminit.c:229
SIZE_T MmBootImageSize
Definition: mminit.c:222
unsigned char BOOLEAN
#define MiProtoPteToPte(x)
Definition: mm.h:250
PVOID MmSystemRangeStart
Definition: mminit.c:230
struct tagRun Run
KEVENT MmZeroingPageEvent
Definition: zeropage.c:20
void DPRINT(...)
Definition: polytest.cpp:61
#define ExInitializePushLock
Definition: ex.h:987
FORCEINLINE VOID MI_MAKE_SUBSECTION_PTE(_Out_ PMMPTE NewPte, _In_ PVOID Segment)
Definition: mm.h:262
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:3353
NTSTATUS NTAPI MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:695
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:164
ULONG_PTR MmUserProbeAddress
Definition: mminit.c:228
EX_PUSH_LOCK WorkingSetMutex
Definition: mmtypes.h:944
PFN_COUNT MmNumberOfSystemPtes
Definition: mminit.c:181
PVOID MmSystemCacheEnd
Definition: mminit.c:244
#define ASSERT(a)
Definition: mode.c:45
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:257
#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:23
Definition: mm.h:311
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define _1MB
Definition: miarm.h:15
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
#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:276
PFN_NUMBER Total
Definition: mm.h:377
#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:1694
#define DPRINT1
Definition: precomp.h:8
ULONG MmMaximumDeadKernelStacks
Definition: procsup.c:22
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
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:16
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 */
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);
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:604
struct _Entry Entry
Definition: kefuncs.h:627
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
union _MMPTE::@2312 u
PFN_NUMBER Flink
Definition: mm.h:315
FORCEINLINE KIRQL MiAcquirePfnLock(VOID)
Definition: mm.h:900
FORCEINLINE VOID MiReleasePfnLock(_In_ KIRQL OldIrql)
Definition: mm.h:907
uint32_t ULONG_PTR
Definition: typedefs.h:65
union _MMPFN::@1784 u1
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 DPRINT(...)
Definition: polytest.cpp:61
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 _MMPFN::@1786::@1792 e2
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define ASSERT(a)
Definition: mode.c:45
struct _MMPTE * PMMPTE
#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:790
Definition: mm.h:311
Definition: typedefs.h:119
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:939
ULONG_PTR Long
Definition: mmtypes.h:215
#define MI_SET_PFN_DELETED(x)
Definition: miarm.h:190
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:324
#define NULL
Definition: types.h:112
union _MMPFN::@1786 u3
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201
FORCEINLINE BOOLEAN MI_IS_PHYSICAL_ADDRESS(IN PVOID Address)
Definition: miarm.h:928
base of all file and directory entries
Definition: entries.h:82
VOID NTAPI KeFlushCurrentTb(VOID)
Definition: cpu.c:325

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:1338

Referenced by PspInitPhase0().

◆ Phase1InitializationDiscard()

VOID NTAPI Phase1InitializationDiscard ( IN PVOID  Context)

Definition at line 1338 of file init.c.

1339 {
1340  PLOADER_PARAMETER_BLOCK LoaderBlock = Context;
1341  NTSTATUS Status, MsgStatus;
1343  LARGE_INTEGER SystemBootTime, UniversalBootTime, OldTime, Timeout;
1344  BOOLEAN SosEnabled, NoGuiBoot, ResetBias = FALSE, AlternateShell = FALSE;
1345  PLDR_DATA_TABLE_ENTRY NtosEntry;
1346  PMESSAGE_RESOURCE_ENTRY MsgEntry;
1347  PCHAR CommandLine, Y2KHackRequired, SafeBoot, Environment;
1348  PCHAR StringBuffer, EndBuffer, BeginBuffer, MpString = "";
1349  PINIT_BUFFER InitBuffer;
1350  ANSI_STRING TempString;
1351  ULONG LastTzBias, Length, YearHack = 0, Disposition, MessageCode = 0;
1352  SIZE_T Size;
1353  size_t Remaining;
1354  PRTL_USER_PROCESS_INFORMATION ProcessInfo;
1355  KEY_VALUE_PARTIAL_INFORMATION KeyPartialInfo;
1358  HANDLE KeyHandle, OptionHandle;
1359  PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
1360 
1361  /* Allocate the initialization buffer */
1362  InitBuffer = ExAllocatePoolWithTag(NonPagedPool,
1363  sizeof(INIT_BUFFER),
1364  TAG_INIT);
1365  if (!InitBuffer)
1366  {
1367  /* Bugcheck */
1368  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, STATUS_NO_MEMORY, 8, 0, 0);
1369  }
1370 
1371  /* Set to phase 1 */
1373 
1374  /* Set us at maximum priority */
1376 
1377  /* Do Phase 1 HAL Initialization */
1378  if (!HalInitSystem(1, LoaderBlock)) KeBugCheck(HAL1_INITIALIZATION_FAILED);
1379 
1380  /* Get the command line and upcase it */
1381  CommandLine = (LoaderBlock->LoadOptions ? _strupr(LoaderBlock->LoadOptions) : NULL);
1382 
1383  /* Check if GUI Boot is enabled */
1384  NoGuiBoot = (CommandLine && strstr(CommandLine, "NOGUIBOOT") != NULL);
1385 
1386  /* Get the SOS setting */
1387  SosEnabled = (CommandLine && strstr(CommandLine, "SOS") != NULL);
1388 
1389  /* Setup the boot driver */
1390  InbvEnableBootDriver(!NoGuiBoot);
1391  InbvDriverInitialize(LoaderBlock, IDB_MAX_RESOURCE);
1392 
1393  /* Check if GUI boot is enabled */
1394  if (!NoGuiBoot)
1395  {
1396  /* It is, display the boot logo and enable printing strings */
1399  }
1400  else
1401  {
1402  /* Release display ownership if not using GUI boot */
1404 
1405  /* Don't allow boot-time strings */
1407  }
1408 
1409  /* Check if this is LiveCD (WinPE) mode */
1410  if (CommandLine && strstr(CommandLine, "MININT") != NULL)
1411  {
1412  /* Setup WinPE Settings */
1414  InitWinPEModeType |= (strstr(CommandLine, "INRAM") != NULL) ? 0x80000000 : 0x00000001;
1415  }
1416 
1417  /* Get the kernel's load entry */
1418  NtosEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink,
1420  InLoadOrderLinks);
1421 
1422  /* Find the banner message */
1423  MsgStatus = RtlFindMessage(NtosEntry->DllBase,
1424  11,
1425  0,
1426  WINDOWS_NT_BANNER,
1427  &MsgEntry);
1428 
1429  /* Setup defaults and check if we have a version string */
1430  StringBuffer = InitBuffer->VersionBuffer;
1431  BeginBuffer = StringBuffer;
1432  EndBuffer = StringBuffer;
1433  Remaining = sizeof(InitBuffer->VersionBuffer);
1435  {
1436  /* Print the version string */
1438  Remaining,
1439  &EndBuffer,
1440  &Remaining,
1441  0,
1442  ": %wZ",
1444  if (!NT_SUCCESS(Status))
1445  {
1446  /* Bugcheck */
1447  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
1448  }
1449  }
1450  else
1451  {
1452  /* No version */
1453  *EndBuffer = ANSI_NULL; /* Null-terminate the string */
1454  }
1455 
1456  /* Skip over the null-terminator to start a new string */
1457  ++EndBuffer;
1458  --Remaining;
1459 
1460  /* Build the version number */
1461  StringBuffer = InitBuffer->VersionNumber;
1463  sizeof(InitBuffer->VersionNumber),
1464  "%u.%u",
1467  if (!NT_SUCCESS(Status))
1468  {
1469  /* Bugcheck */
1470  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
1471  }
1472 
1473  /* Check if we had found a banner message */
1474  if (NT_SUCCESS(MsgStatus))
1475  {
1476  /* Create the banner message */
1477  /* ReactOS specific: Report ReactOS version, NtBuildLab information and reported NT kernel version */
1478  Status = RtlStringCbPrintfA(EndBuffer,
1479  Remaining,
1480  (PCHAR)MsgEntry->Text,
1481  KERNEL_VERSION_STR,
1482  NtBuildLab,
1483  StringBuffer,
1484  NtBuildNumber & 0xFFFF,
1485  BeginBuffer);
1486  if (!NT_SUCCESS(Status))
1487  {
1488  /* Bugcheck */
1489  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
1490  }
1491  }
1492  else
1493  {
1494  /* Use hard-coded banner message */
1495  Status = RtlStringCbCopyA(EndBuffer, Remaining, "REACTOS (R)\r\n");
1496  if (!NT_SUCCESS(Status))
1497  {
1498  /* Bugcheck */
1499  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
1500  }
1501  }
1502 
1503  /* Display the version string on-screen */
1504  InbvDisplayString(EndBuffer);
1505 
1506  /* Initialize Power Subsystem in Phase 0 */
1507  if (!PoInitSystem(0)) KeBugCheck(INTERNAL_POWER_ERROR);
1508 
1509  /* Check for Y2K hack */
1510  Y2KHackRequired = CommandLine ? strstr(CommandLine, "YEAR") : NULL;
1511  if (Y2KHackRequired) Y2KHackRequired = strstr(Y2KHackRequired, "=");
1512  if (Y2KHackRequired) YearHack = atol(Y2KHackRequired + 1);
1513 
1514  /* Query the clock */
1516  {
1517  /* Check if we're using the Y2K hack */
1518  if (Y2KHackRequired) TimeFields.Year = (CSHORT)YearHack;
1519 
1520  /* Convert to time fields */
1521  RtlTimeFieldsToTime(&TimeFields, &SystemBootTime);
1522  UniversalBootTime = SystemBootTime;
1523 
1524  /* Check if real time is GMT */
1526  {
1527  /* Check if we don't have a valid bias */
1529  {
1530  /* Reset */
1531  ResetBias = TRUE;
1533  }
1534 
1535  /* Calculate the bias in seconds */
1537  10000000);
1538 
1539  /* Set the boot time-zone bias */
1540  SharedUserData->TimeZoneBias.High2Time = ExpTimeZoneBias.HighPart;
1541  SharedUserData->TimeZoneBias.LowPart = ExpTimeZoneBias.LowPart;
1542  SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.HighPart;
1543 
1544  /* Convert the boot time to local time, and set it */
1545  UniversalBootTime.QuadPart = SystemBootTime.QuadPart +
1547  }
1548 
1549  /* Update the system time */
1550  KeSetSystemTime(&UniversalBootTime, &OldTime, FALSE, NULL);
1551 
1552  /* Do system callback */
1554 
1555  /* Remember this as the boot time */
1556  KeBootTime = UniversalBootTime;
1557  KeBootTimeBias = 0;
1558  }
1559 
1560  /* Initialize all processors */
1561  if (!HalAllProcessorsStarted()) KeBugCheck(HAL1_INITIALIZATION_FAILED);
1562 
1563 #ifdef CONFIG_SMP
1564  /* HACK: We should use RtlFindMessage and not only fallback to this */
1565  MpString = "MultiProcessor Kernel\r\n";
1566 #endif
1567 
1568  /* Setup the "MP" String */
1569  RtlInitAnsiString(&TempString, MpString);
1570 
1571  /* Make sure to remove the \r\n if we actually have a string */
1572  while ((TempString.Length > 0) &&
1573  ((TempString.Buffer[TempString.Length - 1] == '\r') ||
1574  (TempString.Buffer[TempString.Length - 1] == '\n')))
1575  {
1576  /* Skip the trailing character */
1577  TempString.Length--;
1578  }
1579 
1580  /* Get the information string from our resource file */
1581  MsgStatus = RtlFindMessage(NtosEntry->DllBase,
1582  11,
1583  0,
1584  KeNumberProcessors > 1 ?
1585  WINDOWS_NT_INFO_STRING_PLURAL :
1586  WINDOWS_NT_INFO_STRING,
1587  &MsgEntry);
1588 
1589  /* Get total RAM size, in MiB */
1590  /* Round size up. Assumed to better match actual physical RAM size */
1591  Size = ALIGN_UP_BY(MmNumberOfPhysicalPages * PAGE_SIZE, 1024 * 1024) / (1024 * 1024);
1592 
1593  /* Create the string */
1594  StringBuffer = InitBuffer->VersionBuffer;
1596  sizeof(InitBuffer->VersionBuffer),
1597  NT_SUCCESS(MsgStatus) ?
1598  (PCHAR)MsgEntry->Text :
1599  "%u System Processor [%Iu MB Memory] %Z\r\n",
1601  Size,
1602  &TempString);
1603  if (!NT_SUCCESS(Status))
1604  {
1605  /* Bugcheck */
1606  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 4, 0, 0);
1607  }
1608 
1609  /* Display RAM and CPU count */
1611 
1612  /* Update the progress bar */
1614 
1615  /* Call OB initialization again */
1616  if (!ObInitSystem()) KeBugCheck(OBJECT1_INITIALIZATION_FAILED);
1617 
1618  /* Initialize Basic System Objects and Worker Threads */
1619  if (!ExInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 1, 0);
1620 
1621  /* Initialize the later stages of the kernel */
1622  if (!KeInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 2, 0);
1623 
1624  /* Call KD Providers at Phase 1 */
1626  {
1627  /* Failed, bugcheck */
1628  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 3, 0);
1629  }
1630 
1631  /* Initialize the SRM in Phase 1 */
1632  if (!SeInitSystem()) KeBugCheck(SECURITY1_INITIALIZATION_FAILED);
1633 
1634  /* Update the progress bar */
1636 
1637  /* Create SystemRoot Link */
1638  Status = ExpCreateSystemRootLink(LoaderBlock);
1639  if (!NT_SUCCESS(Status))
1640  {
1641  /* Failed to create the system root link */
1642  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 0, 0, 0);
1643  }
1644 
1645  /* Set up Region Maps, Sections and the Paging File */
1646  if (!MmInitSystem(1, LoaderBlock)) KeBugCheck(MEMORY1_INITIALIZATION_FAILED);
1647 
1648  /* Create NLS section */
1649  ExpInitNls(LoaderBlock);
1650 
1651  /* Initialize Cache Views */
1652  if (!CcInitializeCacheManager()) KeBugCheck(CACHE_INITIALIZATION_FAILED);
1653 
1654  /* Initialize the Registry */
1655  if (!CmInitSystem1()) KeBugCheck(CONFIG_INITIALIZATION_FAILED);
1656 
1657  /* Initialize Prefetcher */
1659 
1660  /* Update progress bar */
1662 
1663  /* Update timezone information */
1664  LastTzBias = ExpLastTimeZoneBias;
1665  ExRefreshTimeZoneInformation(&SystemBootTime);
1666 
1667  /* Check if we're resetting timezone data */
1668  if (ResetBias)
1669  {
1670  /* Convert the local time to system time */
1671  ExLocalTimeToSystemTime(&SystemBootTime, &UniversalBootTime);
1672  KeBootTime = UniversalBootTime;
1673  KeBootTimeBias = 0;
1674 
1675  /* Set the new time */
1676  KeSetSystemTime(&UniversalBootTime, &OldTime, FALSE, NULL);
1677  }
1678  else
1679  {
1680  /* Check if the timezone switched and update the time */
1681  if (LastTzBias != ExpLastTimeZoneBias) ZwSetSystemTime(NULL, NULL);
1682  }
1683 
1684  /* Initialize the File System Runtime Library */
1685  if (!FsRtlInitSystem()) KeBugCheck(FILE_INITIALIZATION_FAILED);
1686 
1687  /* Initialize range lists */
1689 
1690  /* Report all resources used by HAL */
1692 
1693  /* Call the debugger DLL */
1694  KdDebuggerInitialize1(LoaderBlock);
1695 
1696  /* Setup PnP Manager in phase 1 */
1697  if (!PpInitSystem()) KeBugCheck(PP1_INITIALIZATION_FAILED);
1698 
1699  /* Update progress bar */
1701 
1702  /* Initialize LPC */
1703  if (!LpcInitSystem()) KeBugCheck(LPC_INITIALIZATION_FAILED);
1704 
1705  /* Make sure we have a command line */
1706  if (CommandLine)
1707  {
1708  /* Check if this is a safe mode boot */
1709  SafeBoot = strstr(CommandLine, "SAFEBOOT:");
1710  if (SafeBoot)
1711  {
1712  /* Check what kind of boot this is */
1713  SafeBoot += 9;
1714  if (!strncmp(SafeBoot, "MINIMAL", 7))
1715  {
1716  /* Minimal mode */
1717  InitSafeBootMode = 1;
1718  SafeBoot += 7;
1719  MessageCode = BOOTING_IN_SAFEMODE_MINIMAL;
1720  }
1721  else if (!strncmp(SafeBoot, "NETWORK", 7))
1722  {
1723  /* With Networking */
1724  InitSafeBootMode = 2;
1725  SafeBoot += 7;
1726  MessageCode = BOOTING_IN_SAFEMODE_NETWORK;
1727  }
1728  else if (!strncmp(SafeBoot, "DSREPAIR", 8))
1729  {
1730  /* Domain Server Repair */
1731  InitSafeBootMode = 3;
1732  SafeBoot += 8;
1733  MessageCode = BOOTING_IN_SAFEMODE_DSREPAIR;
1734 
1735  }
1736  else
1737  {
1738  /* Invalid */
1739  InitSafeBootMode = 0;
1740  }
1741 
1742  /* Check if there's any settings left */
1743  if (*SafeBoot)
1744  {
1745  /* Check if an alternate shell was requested */
1746  if (!strncmp(SafeBoot, "(ALTERNATESHELL)", 16))
1747  {
1748  /* Remember this for later */
1749  AlternateShell = TRUE;
1750  }
1751  }
1752 
1753  /* Find the message to print out */
1754  Status = RtlFindMessage(NtosEntry->DllBase,
1755  11,
1756  0,
1757  MessageCode,
1758  &MsgEntry);
1759  if (NT_SUCCESS(Status))
1760  {
1761  /* Display it */
1762  InbvDisplayString((PCHAR)MsgEntry->Text);
1763  }
1764  }
1765  }
1766 
1767  /* Make sure we have a command line */
1768  if (CommandLine)
1769  {
1770  /* Check if bootlogging is enabled */
1771  if (strstr(CommandLine, "BOOTLOG"))
1772  {
1773  /* Find the message to print out */
1774  Status = RtlFindMessage(NtosEntry->DllBase,
1775  11,
1776  0,
1777  BOOTLOG_ENABLED,
1778  &MsgEntry);
1779  if (NT_SUCCESS(Status))
1780  {
1781  /* Display it */
1782  InbvDisplayString((PCHAR)MsgEntry->Text);
1783  }
1784 
1785  /* Setup boot logging */
1786  //IopInitializeBootLogging(LoaderBlock, InitBuffer->BootlogHeader);
1787  }
1788  }
1789 
1790  /* Setup the Executive in Phase 2 */
1791  //ExInitSystemPhase2();
1792 
1793  /* Update progress bar */
1795 
1796  /* No KD Time Slip is pending */
1797  KdpTimeSlipPending = 0;
1798 
1799  /* Initialize in-place execution support */
1800  XIPInit(LoaderBlock);
1801 
1802  /* Set maximum update to 75% */
1803  InbvSetProgressBarSubset(25, 75);
1804 
1805  /* Initialize the I/O Subsystem */
1806  if (!IoInitSystem(LoaderBlock)) KeBugCheck(IO1_INITIALIZATION_FAILED);
1807 
1808  /* Set maximum update to 100% */
1809  InbvSetProgressBarSubset(0, 100);
1810 
1811  /* Are we in safe mode? */
1812  if (InitSafeBootMode)
1813  {
1814  /* Open the safe boot key */
1816  L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET"
1817  L"\\CONTROL\\SAFEBOOT");
1819  &KeyName,
1821  NULL,
1822  NULL);
1824  if (NT_SUCCESS(Status))
1825  {
1826  /* First check if we have an alternate shell */
1827  if (AlternateShell)
1828  {
1829  /* Make sure that the registry has one setup */
1830  RtlInitUnicodeString(&KeyName, L"AlternateShell");
1832  &KeyName,
1834  &KeyPartialInfo,
1835  sizeof(KeyPartialInfo),
1836  &Length);
1838  {
1839  AlternateShell = FALSE;
1840  }
1841  }
1842 
1843  /* Create the option key */
1844  RtlInitUnicodeString(&KeyName, L"Option");
1846  &KeyName,
1848  KeyHandle,
1849  NULL);
1850  Status = ZwCreateKey(&OptionHandle,
1853  0,
1854  NULL,
1856  &Disposition);
1857  NtClose(KeyHandle);
1858 
1859  /* Check if the key create worked */
1860  if (NT_SUCCESS(Status))
1861  {
1862  /* Write the safe boot type */
1863  RtlInitUnicodeString(&KeyName, L"OptionValue");
1864  NtSetValueKey(OptionHandle,
1865  &KeyName,
1866  0,
1867  REG_DWORD,
1869  sizeof(InitSafeBootMode));
1870 
1871  /* Check if we have to use an alternate shell */
1872  if (AlternateShell)
1873  {
1874  /* Remember this for later */
1875  Disposition = TRUE;
1876  RtlInitUnicodeString(&KeyName, L"UseAlternateShell");
1877  NtSetValueKey(OptionHandle,
1878  &KeyName,
1879  0,
1880  REG_DWORD,
1881  &Disposition,
1882  sizeof(Disposition));
1883  }
1884 
1885  /* Close the options key handle */
1886  NtClose(OptionHandle);
1887  }
1888  }
1889  }
1890 
1891  /* Are we in Win PE mode? */
1892  if (InitIsWinPEMode)
1893  {
1894  /* Open the safe control key */
1896  L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET"
1897  L"\\CONTROL");
1899  &KeyName,
1901  NULL,
1902  NULL);
1904  if (!NT_SUCCESS(Status))
1905  {
1906  /* Bugcheck */
1907  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 6, 0, 0);
1908  }
1909 
1910  /* Create the MiniNT key */
1911  RtlInitUnicodeString(&KeyName, L"MiniNT");
1913  &KeyName,
1915  KeyHandle,
1916  NULL);
1917  Status = ZwCreateKey(&OptionHandle,
1920  0,
1921  NULL,
1923  &Disposition);
1924  if (!NT_SUCCESS(Status))
1925  {
1926  /* Bugcheck */
1927  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 6, 0, 0);
1928  }
1929 
1930  /* Close the handles */
1931  NtClose(KeyHandle);
1932  NtClose(OptionHandle);
1933  }
1934 
1935  /* FIXME: This doesn't do anything for now */
1936  MmArmInitSystem(2, LoaderBlock);
1937 
1938  /* Update progress bar */
1940 
1941  /* Initialize VDM support */
1942 #if defined(_M_IX86)
1944 #endif
1945 
1946  /* Initialize Power Subsystem in Phase 1*/
1947  if (!PoInitSystem(1)) KeBugCheck(INTERNAL_POWER_ERROR);
1948 
1949  /* Update progress bar */
1951 
1952  /* Initialize the Process Manager at Phase 1 */
1953  if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS1_INITIALIZATION_FAILED);
1954 
1955  /* Make sure nobody touches the loader block again */
1956  if (LoaderBlock == KeLoaderBlock) KeLoaderBlock = NULL;
1957  MmFreeLoaderBlock(LoaderBlock);
1958  LoaderBlock = Context = NULL;
1959 
1960  /* Initialize the SRM in phase 1 */
1961  if (!SeRmInitPhase1()) KeBugCheck(PROCESS1_INITIALIZATION_FAILED);
1962 
1963  /* Update progress bar */
1964  InbvUpdateProgressBar(100);
1965 
1966  /* Clear the screen */
1968 
1969  /* Allow strings to be displayed */
1971 
1972  /* Launch initial process */
1973  DPRINT("Free non-cache pages: %lx\n", MmAvailablePages + MiMemoryConsumers[MC_CACHE].PagesUsed);
1974  ProcessInfo = &InitBuffer->ProcessInfo;
1975  ExpLoadInitialProcess(InitBuffer, &ProcessParameters, &Environment);
1976 
1977  /* Wait 5 seconds for initial process to initialize */
1978  Timeout.QuadPart = Int32x32To64(5, -10000000);
1979  Status = ZwWaitForSingleObject(ProcessInfo->ProcessHandle, FALSE, &Timeout);
1980  if (Status == STATUS_SUCCESS)
1981  {
1982  /* Failed, display error */
1983  DPRINT1("INIT: Session Manager terminated.\n");
1984 
1985  /* Bugcheck the system if SMSS couldn't initialize */
1986  KeBugCheck(SESSION5_INITIALIZATION_FAILED);
1987  }
1988 
1989  /* Close process handles */
1990  ZwClose(ProcessInfo->ThreadHandle);
1991  ZwClose(ProcessInfo->ProcessHandle);
1992 
1993  /* Free the initial process environment */
1994  Size = 0;
1995  ZwFreeVirtualMemory(NtCurrentProcess(),
1996  (PVOID*)&Environment,
1997  &Size,
1998  MEM_RELEASE);
1999 
2000  /* Free the initial process parameters */
2001  Size = 0;
2002  ZwFreeVirtualMemory(NtCurrentProcess(),
2003  (PVOID*)&ProcessParameters,
2004  &Size,
2005  MEM_RELEASE);
2006 
2007  /* Increase init phase */
2009 
2010  /* Free the boot buffer */
2011  ExFreePoolWithTag(InitBuffer, TAG_INIT);
2012  DPRINT("Free non-cache pages: %lx\n", MmAvailablePages + MiMemoryConsumers[MC_CACHE].PagesUsed);
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 InbvSetProgressBarSubset(IN ULONG Floor, IN ULONG Ceiling)
Definition: inbv.c:868
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:210
VOID NTAPI InbvNotifyDisplayOwnershipLost(IN INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:638
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:45
Definition: rtltypes.h:1891
BOOLEAN NTAPI IoInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: iomgr.c:466
MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM]
Definition: balance.c:29
_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:31
_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
VOID NTAPI DisplayBootBitmap(IN BOOLEAN TextMode)
Definition: inbv.c:1086
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
BOOLEAN NTAPI PpInitSystem(VOID)
Definition: pnpmgr.c:1856
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
BOOLEAN NTAPI InbvDisplayString(IN PCHAR String)
Definition: inbv.c:569
VOID NTAPI InbvEnableBootDriver(IN BOOLEAN Enable)
Definition: inbv.c:497
NTSTATUS NTAPI ExpCreateSystemRootLink(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:98
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
PFN_NUMBER MmAvailablePages
Definition: freelist.c:26
#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:1926
#define FALSE
Definition: types.h:117
#define ANSI_NULL
VOID NTAPI InbvUpdateProgressBar(IN ULONG Progress)
Definition: inbv.c:762
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:36
NTSTATUS NTAPI KdDebuggerInitialize1(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
Definition: kdcom.c:283
BOOLEAN NTAPI InbvDriverInitialize(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG Count)
Definition: inbv.c:418
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
VOID NTAPI PoNotifySystemTimeSet(VOID)
Definition: events.c:39
BOOLEAN ExCmosClockIsSane
Definition: init.c:90
_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:58
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1895
BOOLEAN ExpRealTimeIsUniversal
Definition: init.c:91
#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:204
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
BOOLEAN NTAPI HalAllProcessorsStarted(VOID)
Definition: processor.c:60
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
VOID NTAPI FinalizeBootLogo(VOID)
Definition: inbv.c:1394
BOOLEAN NTAPI ObInitSystem(VOID)
Definition: obinit.c:203
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define SharedUserData
static const WCHAR L[]
Definition: oid.c:1250
UNICODE_STRING CmCSDVersionString
Definition: init.c:60
Definition: btrfs_drv.h:1922
ULONG LowPart
Definition: typedefs.h:106
ULONG ExpInitializationPhase
Definition: init.c:66
#define PAGE_SIZE
Definition: env_spec_w32.h:49
BOOLEAN SafeBoot
Definition: winldr.c:34
ULONG InitSafeBootMode
Definition: init.c:69
VOID NTAPI CcPfInitializePrefetcher(VOID)
Definition: fssup.c:114
LIST_ENTRY LoadOrderListHead
Definition: arc.h:493
CHAR VersionBuffer[256]
Definition: init.c:33
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
ULONG ExpLastTimeZoneBias
Definition: time.c:22
#define MAXULONG
Definition: typedefs.h:251
BOOLEAN NTAPI InbvEnableDisplayString(IN BOOLEAN Enable)
Definition: inbv.c:606
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)
Definition: semgr.c:239
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:386
BOOLEAN NTAPI ExInitSystem(VOID)
Definition: init.c:740
#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:390
#define DPRINT1
Definition: precomp.h:8
CHAR VersionNumber[24]
Definition: init.c:35
#define MEM_RELEASE
Definition: nt_native.h:1316
VOID NTAPI KeI386VdmInitialize(VOID)
Definition: stubs.c:156
#define MC_CACHE
Definition: mm.h:93
struct tagContext Context
Definition: acpixf.h:1034
BOOLEAN NTAPI KeInitSystem(VOID)
Definition: krnlinit.c:293
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)
Definition: srm.c:182
#define TAG_INIT
Definition: tag.h:26
#define STATUS_SUCCESS
Definition: shellext.h:65
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#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:83
#define KeGetCurrentThread
Definition: hal.h:44
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:70
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
WCHAR StringBuffer[156]
Definition: ldrinit.c:41
ULONG NtBuildNumber
Definition: init.c:48
#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:70
CHAR NtBuildLab[]
Definition: init.c:62
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 58 of file init.c.

Referenced by ExpInitializeExecutive().

◆ CmNtCSDVersion

ULONG CmNtCSDVersion

Definition at line 57 of file init.c.

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

◆ CmNtSpBuildNumber

ULONG CmNtSpBuildNumber

Definition at line 56 of file init.c.

Referenced by CmpSetVersionData(), and ExpInitializeExecutive().

◆ CmVersionString

UNICODE_STRING CmVersionString

Definition at line 59 of file init.c.

Referenced by CmpSetVersionData(), and ExpInitializeExecutive().

◆ ExCmosClockIsSane

BOOLEAN ExCmosClockIsSane = TRUE

Definition at line 90 of file init.c.

Referenced by KeSetSystemTime(), and Phase1InitializationDiscard().

◆ ExpAnsiCodePageDataOffset

ULONG ExpAnsiCodePageDataOffset

Definition at line 83 of file init.c.

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

◆ ExpInitializationPhase

◆ ExpInTextModeSetup

◆ ExpNlsSectionPointer

PVOID ExpNlsSectionPointer

Definition at line 87 of file init.c.

Referenced by ExpInitNls(), and MmCreatePeb().

◆ ExpNlsTableBase

PVOID ExpNlsTableBase

Definition at line 82 of file init.c.

Referenced by ExpInitializeExecutive(), and ExpInitNls().

◆ ExpNlsTableInfo

NLSTABLEINFO ExpNlsTableInfo

Definition at line 85 of file init.c.

Referenced by ExpInitializeExecutive(), and ExpInitNls().

◆ ExpNlsTableSize

SIZE_T ExpNlsTableSize

Definition at line 86 of file init.c.

Referenced by ExpInitNls().

◆ ExpOemCodePageDataOffset

ULONG ExpOemCodePageDataOffset

Definition at line 83 of file init.c.

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

◆ ExpRealTimeIsUniversal

BOOLEAN ExpRealTimeIsUniversal

Definition at line 91 of file init.c.

Referenced by Phase1InitializationDiscard().

◆ ExpUnicodeCaseTableDataOffset

ULONG ExpUnicodeCaseTableDataOffset

Definition at line 84 of file init.c.

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

◆ ExSuiteMask

ULONG ExSuiteMask

Definition at line 53 of file init.c.

Referenced by ExpInitSystemPhase0().

◆ InitIsWinPEMode

BOOLEAN InitIsWinPEMode

Definition at line 70 of file init.c.

Referenced by CmInitSystem1(), and Phase1InitializationDiscard().

◆ InitSafeBootMode

◆ InitWinPEModeType

BOOLEAN InitWinPEModeType

Definition at line 70 of file init.c.

Referenced by Phase1InitializationDiscard().

◆ IoRemoteBootClient

BOOLEAN IoRemoteBootClient

Definition at line 68 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 62 of file init.c.

Referenced by CmpSetVersionData(), and Phase1InitializationDiscard().

◆ NtBuildNumber

◆ NtGlobalFlag

◆ NtInitialUserProcessBuffer

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

Definition at line 76 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:76

Definition at line 77 of file init.c.

Referenced by ExpLoadInitialProcess().

◆ NtInitialUserProcessBufferType

ULONG NtInitialUserProcessBufferType = REG_SZ

Definition at line 79 of file init.c.

Referenced by ExpLoadInitialProcess().

◆ NtMajorVersion

ULONG NtMajorVersion = VER_PRODUCTMAJORVERSION

Definition at line 43 of file init.c.

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

◆ NtMinorVersion

ULONG NtMinorVersion = VER_PRODUCTMINORVERSION

Definition at line 44 of file init.c.

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

◆ NtSystemRoot