ReactOS  0.4.12-dev-919-gfc3b8d5
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)
 
INIT_FUNCTION NTSTATUS NTAPI ExpCreateSystemRootLink (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
INIT_FUNCTION VOID NTAPI ExpInitNls (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
INIT_FUNCTION VOID NTAPI ExpLoadInitialProcess (IN PINIT_BUFFER InitBuffer, OUT PRTL_USER_PROCESS_PARAMETERS *ProcessParameters, OUT PCHAR *ProcessEnvironment)
 
INIT_FUNCTION ULONG NTAPI ExComputeTickCountMultiplier (IN ULONG ClockIncrement)
 
INIT_FUNCTION BOOLEAN NTAPI ExpInitSystemPhase0 (VOID)
 
INIT_FUNCTION BOOLEAN NTAPI ExpInitSystemPhase1 (VOID)
 
INIT_FUNCTION BOOLEAN NTAPI ExInitSystem (VOID)
 
INIT_FUNCTION BOOLEAN NTAPI ExpIsLoaderValid (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
INIT_FUNCTION VOID NTAPI ExpLoadBootSymbols (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
INIT_FUNCTION VOID NTAPI ExBurnMemory (IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG_PTR PagesToDestroy, IN TYPE_OF_MEMORY MemoryType)
 
INIT_FUNCTION VOID NTAPI ExpInitializeExecutive (IN ULONG Cpu, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI MmFreeLoaderBlock (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
INIT_FUNCTION 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()

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

Definition at line 872 of file init.c.

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

Referenced by ExpInitializeExecutive().

◆ ExComputeTickCountMultiplier()

INIT_FUNCTION ULONG NTAPI ExComputeTickCountMultiplier ( IN ULONG  ClockIncrement)

Definition at line 602 of file init.c.

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

INIT_FUNCTION BOOLEAN NTAPI ExInitSystem ( VOID  )

Definition at line 739 of file init.c.

740 {
741  /* Check the initialization phase */
742  switch (ExpInitializationPhase)
743  {
744  case 0:
745 
746  /* Do Phase 0 */
747  return ExpInitSystemPhase0();
748 
749  case 1:
750 
751  /* Do Phase 1 */
752  return ExpInitSystemPhase1();
753 
754  default:
755 
756  /* Don't know any other phase! Bugcheck! */
757  KeBugCheck(UNEXPECTED_INITIALIZATION_CALL);
758  return FALSE;
759  }
760 }
INIT_FUNCTION BOOLEAN NTAPI ExpInitSystemPhase0(VOID)
Definition: init.c:635
INIT_FUNCTION BOOLEAN NTAPI ExpInitSystemPhase1(VOID)
Definition: init.c:658
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1469
ULONG ExpInitializationPhase
Definition: init.c:65

Referenced by ExpInitializeExecutive(), and Phase1InitializationDiscard().

◆ ExpCreateSystemRootLink()

INIT_FUNCTION NTSTATUS NTAPI ExpCreateSystemRootLink ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 97 of file init.c.

98 {
99  UNICODE_STRING LinkName;
101  HANDLE LinkHandle;
103  ANSI_STRING AnsiName;
104  CHAR Buffer[256];
105  ANSI_STRING TargetString;
107 
108  /* Initialize the ArcName tree */
109  RtlInitUnicodeString(&LinkName, L"\\ArcName");
111  &LinkName,
113  NULL,
115 
116  /* Create it */
117  Status = NtCreateDirectoryObject(&LinkHandle,
120  if (!NT_SUCCESS(Status))
121  {
122  /* Failed */
123  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 1, 0, 0);
124  }
125 
126  /* Close the LinkHandle */
127  NtClose(LinkHandle);
128 
129  /* Initialize the Device tree */
130  RtlInitUnicodeString(&LinkName, L"\\Device");
132  &LinkName,
134  NULL,
136 
137  /* Create it */
138  Status = NtCreateDirectoryObject(&LinkHandle,
141  if (!NT_SUCCESS(Status))
142  {
143  /* Failed */
144  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 2, 0, 0);
145  }
146 
147  /* Close the LinkHandle */
148  ObCloseHandle(LinkHandle, KernelMode);
149 
150  /* Create the system root symlink name */
151  RtlInitAnsiString(&AnsiName, "\\SystemRoot");
152  Status = RtlAnsiStringToUnicodeString(&LinkName, &AnsiName, TRUE);
153  if (!NT_SUCCESS(Status))
154  {
155  /* Failed */
156  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 3, 0, 0);
157  }
158 
159  /* Initialize the attributes for the link */
161  &LinkName,
163  NULL,
165 
166  /* Build the ARC name */
167  sprintf(Buffer,
168  "\\ArcName\\%s%s",
169  LoaderBlock->ArcBootDeviceName,
170  LoaderBlock->NtBootPathName);
171  Buffer[strlen(Buffer) - 1] = ANSI_NULL;
172 
173  /* Convert it to Unicode */
174  RtlInitString(&TargetString, Buffer);
176  &TargetString,
177  TRUE);
178  if (!NT_SUCCESS(Status))
179  {
180  /* We failed, bugcheck */
181  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 4, 0, 0);
182  }
183 
184  /* Create it */
185  Status = NtCreateSymbolicLinkObject(&LinkHandle,
188  &TargetName);
189 
190  /* Free the strings */
191  RtlFreeUnicodeString(&LinkName);
193 
194  /* Check if creating the link failed */
195  if (!NT_SUCCESS(Status))
196  {
197  /* Failed */
198  KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 5, 0, 0);
199  }
200 
201  /* Close the handle and return success */
202  ObCloseHandle(LinkHandle, KernelMode);
203  return STATUS_SUCCESS;
204 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_PERMANENT
Definition: winternl.h:226
#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
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#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
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
static const WCHAR L[]
Definition: oid.c:1250
WCHAR TargetName[256]
Definition: arping.c:27
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtCreateDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: obdir.c:731
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define DIRECTORY_ALL_ACCESS
Definition: nt_native.h:1259
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
return STATUS_SUCCESS
Definition: btrfs.c:2725
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:107
PSECURITY_DESCRIPTOR SePublicDefaultUnrestrictedSd
Definition: sd.c:23

Referenced by Phase1InitializationDiscard().

◆ ExpInitializeExecutive()

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

Definition at line 918 of file init.c.

920 {
921  PNLS_DATA_BLOCK NlsData;
922  CHAR Buffer[256];
923  ANSI_STRING AnsiPath;
925  PCHAR CommandLine, PerfMem;
926  ULONG PerfMemUsed;
927  PLDR_DATA_TABLE_ENTRY NtosEntry;
928  PMESSAGE_RESOURCE_ENTRY MsgEntry;
929  ANSI_STRING CSDString;
930  size_t Remaining = 0;
931  PCHAR RcEnd = NULL;
932  CHAR VersionBuffer[65];
933 
934  /* Validate Loader */
935  if (!ExpIsLoaderValid(LoaderBlock))
936  {
937  /* Invalid loader version */
938  KeBugCheckEx(MISMATCHED_HAL,
939  3,
940  LoaderBlock->Extension->Size,
941  LoaderBlock->Extension->MajorVersion,
942  LoaderBlock->Extension->MinorVersion);
943  }
944 
945  /* Initialize PRCB pool lookaside pointers */
947 
948  /* Check if this is an application CPU */
949  if (Cpu)
950  {
951  /* Then simply initialize it with HAL */
952  if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
953  {
954  /* Initialization failed */
955  KeBugCheck(HAL_INITIALIZATION_FAILED);
956  }
957 
958  /* We're done */
959  return;
960  }
961 
962  /* Assume no text-mode or remote boot */
965 
966  /* Check if we have a setup loader block */
967  if (LoaderBlock->SetupLdrBlock)
968  {
969  /* Check if this is text-mode setup */
970  if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_TEXT_MODE)
972 
973  /* Check if this is network boot */
974  if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_REMOTE_BOOT)
975  {
976  /* Set variable */
978 
979  /* Make sure we're actually booting off the network */
980  ASSERT(!_memicmp(LoaderBlock->ArcBootDeviceName, "net(0)", 6));
981  }
982  }
983 
984  /* Set phase to 0 */
986 
987  /* Get boot command line */
988  CommandLine = LoaderBlock->LoadOptions;
989  if (CommandLine)
990  {
991  /* Upcase it for comparison and check if we're in performance mode */
992  _strupr(CommandLine);
993  PerfMem = strstr(CommandLine, "PERFMEM");
994  if (PerfMem)
995  {
996  /* Check if the user gave a number of bytes to use */
997  PerfMem = strstr(PerfMem, "=");
998  if (PerfMem)
999  {
1000  /* Read the number of pages we'll use */
1001  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1002  if (PerfMem)
1003  {
1004  /* FIXME: TODO */
1005  DPRINT1("BBT performance mode not yet supported."
1006  "/PERFMEM option ignored.\n");
1007  }
1008  }
1009  }
1010 
1011  /* Check if we're burning memory */
1012  PerfMem = strstr(CommandLine, "BURNMEMORY");
1013  if (PerfMem)
1014  {
1015  /* Check if the user gave a number of bytes to use */
1016  PerfMem = strstr(PerfMem, "=");
1017  if (PerfMem)
1018  {
1019  /* Read the number of pages we'll use */
1020  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1021  if (PerfMemUsed) ExBurnMemory(LoaderBlock, PerfMemUsed, LoaderBad);
1022  }
1023  }
1024  }
1025 
1026  /* Setup NLS Base and offsets */
1027  NlsData = LoaderBlock->NlsData;
1028  ExpNlsTableBase = NlsData->AnsiCodePageData;
1031  (ULONG_PTR)NlsData->AnsiCodePageData);
1033  (ULONG_PTR)NlsData->AnsiCodePageData);
1034 
1035  /* Initialize the NLS Tables */
1042  &ExpNlsTableInfo);
1044 
1045  /* Now initialize the HAL */
1046  if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
1047  {
1048  /* HAL failed to initialize, bugcheck */
1049  KeBugCheck(HAL_INITIALIZATION_FAILED);
1050  }
1051 
1052  /* Make sure interrupts are active now */
1053  _enable();
1054 
1055  /* Clear the crypto exponent */
1056  SharedUserData->CryptoExponent = 0;
1057 
1058  /* Set global flags for the checked build */
1059 #if DBG
1062 #endif
1063 
1064  /* Setup NT System Root Path */
1065  sprintf(Buffer, "C:%s", LoaderBlock->NtBootPathName);
1066 
1067  /* Convert to ANSI_STRING and null-terminate it */
1068  RtlInitString(&AnsiPath, Buffer);
1069  Buffer[--AnsiPath.Length] = ANSI_NULL;
1070 
1071  /* Get the string from KUSER_SHARED_DATA's buffer */
1072  RtlInitEmptyUnicodeString(&NtSystemRoot,
1073  SharedUserData->NtSystemRoot,
1074  sizeof(SharedUserData->NtSystemRoot));
1075 
1076  /* Now fill it in */
1078  if (!NT_SUCCESS(Status)) KeBugCheck(SESSION3_INITIALIZATION_FAILED);
1079 
1080  /* Setup bugcheck messages */
1082 
1083  /* Setup initial system settings */
1084  CmGetSystemControlValues(LoaderBlock->RegistryBase, CmControlVector);
1085 
1086  /* Set the Service Pack Number and add it to the CSD Version number if needed */
1088  if (((CmNtCSDVersion & 0xFFFF0000) == 0) && (CmNtCSDReleaseType == 1))
1089  {
1091  }
1092 
1093  /* Add loaded CmNtGlobalFlag value */
1095 
1096  /* Initialize the executive at phase 0 */
1097  if (!ExInitSystem()) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1098 
1099  /* Initialize the memory manager at phase 0 */
1100  if (!MmArmInitSystem(0, LoaderBlock)) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1101 
1102  /* Load boot symbols */
1103  ExpLoadBootSymbols(LoaderBlock);
1104 
1105  /* Check if we should break after symbol load */
1107 
1108  /* Check if this loader is compatible with NT 5.2 */
1109  if (LoaderBlock->Extension->Size >= sizeof(LOADER_PARAMETER_EXTENSION))
1110  {
1111  /* Setup headless terminal settings */
1112  HeadlessInit(LoaderBlock);
1113  }
1114 
1115  /* Set system ranges */
1116 #ifdef _M_AMD64
1119 #else
1122 #endif
1123 
1124  /* Make a copy of the NLS Tables */
1125  ExpInitNls(LoaderBlock);
1126 
1127  /* Get the kernel's load entry */
1128  NtosEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink,
1130  InLoadOrderLinks);
1131 
1132  /* Check if this is a service pack */
1133  if (CmNtCSDVersion & 0xFFFF)
1134  {
1135  /* Get the service pack string */
1136  Status = RtlFindMessage(NtosEntry->DllBase,
1137  11,
1138  0,
1139  WINDOWS_NT_CSD_STRING,
1140  &MsgEntry);
1141  if (NT_SUCCESS(Status))
1142  {
1143  /* Setup the string */
1144  RtlInitAnsiString(&CSDString, (PCHAR)MsgEntry->Text);
1145 
1146  /* Remove trailing newline */
1147  while ((CSDString.Length > 0) &&
1148  ((CSDString.Buffer[CSDString.Length - 1] == '\r') ||
1149  (CSDString.Buffer[CSDString.Length - 1] == '\n')))
1150  {
1151  /* Skip the trailing character */
1152  CSDString.Length--;
1153  }
1154 
1155  /* Fill the buffer with version information */
1157  sizeof(Buffer),
1158  "%Z %u%c",
1159  &CSDString,
1160  (CmNtCSDVersion & 0xFF00) >> 8,
1161  (CmNtCSDVersion & 0xFF) ?
1162  'A' + (CmNtCSDVersion & 0xFF) - 1 :
1163  ANSI_NULL);
1164  }
1165  else
1166  {
1167  /* Build default string */
1169  sizeof(Buffer),
1170  "CSD %04x",
1171  CmNtCSDVersion);
1172  }
1173 
1174  /* Check for success */
1175  if (!NT_SUCCESS(Status))
1176  {
1177  /* Fail */
1178  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1179  }
1180  }
1181  else
1182  {
1183  /* Then this is a beta */
1185  sizeof(Buffer),
1187  NULL,
1188  &Remaining,
1189  0);
1190  if (!NT_SUCCESS(Status))
1191  {
1192  /* Fail */
1193  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1194  }
1195 
1196  /* Update length */
1197  CmCSDVersionString.MaximumLength = sizeof(Buffer) - (USHORT)Remaining;
1198  }
1199 
1200  /* Check if we have an RC number */
1201  if ((CmNtCSDVersion & 0xFFFF0000) && (CmNtCSDReleaseType == 1))
1202  {
1203  /* Check if we have no version data yet */
1204  if (!(*Buffer))
1205  {
1206  /* Set defaults */
1207  Remaining = sizeof(Buffer);
1208  RcEnd = Buffer;
1209  }
1210  else
1211  {
1212  /* Add comma and space */
1214  sizeof(Buffer),
1215  ", ",
1216  &RcEnd,
1217  &Remaining,
1218  0);
1219  if (!NT_SUCCESS(Status))
1220  {
1221  /* Fail */
1222  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1223  }
1224  }
1225 
1226  /* Add the version format string */
1227  Status = RtlStringCbPrintfA(RcEnd,
1228  Remaining,
1229  "v.%u",
1230  (CmNtCSDVersion & 0xFFFF0000) >> 16);
1231  if (!NT_SUCCESS(Status))
1232  {
1233  /* Fail */
1234  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1235  }
1236  }
1237 
1238  /* Now setup the final string */
1239  RtlInitAnsiString(&CSDString, Buffer);
1241  &CSDString,
1242  TRUE);
1243  if (!NT_SUCCESS(Status))
1244  {
1245  /* Fail */
1246  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1247  }
1248 
1249  /* Add our version */
1250  Status = RtlStringCbPrintfA(VersionBuffer,
1251  sizeof(VersionBuffer),
1252  "%u.%u",
1255  if (!NT_SUCCESS(Status))
1256  {
1257  /* Fail */
1258  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1259  }
1260 
1261  /* Build the final version string */
1263 
1264  /* Check if the user wants a kernel stack trace database */
1266  {
1267  /* FIXME: TODO */
1268  DPRINT1("Kernel-mode stack trace support not yet present."
1269  "FLG_KERNEL_STACK_TRACE_DB flag ignored.\n");
1270  }
1271 
1272  /* Check if he wanted exception logging */
1274  {
1275  /* FIXME: TODO */
1276  DPRINT1("Kernel-mode exception logging support not yet present."
1277  "FLG_ENABLE_EXCEPTION_LOGGING flag ignored.\n");
1278  }
1279 
1280  /* Initialize the Handle Table */
1282 
1283 #if DBG
1284  /* On checked builds, allocate the system call count table */
1287  KiServiceLimit * sizeof(ULONG),
1288  'llaC');
1289 
1290  /* Use it for the shadow table too */
1292 
1293  /* Make sure allocation succeeded */
1295  {
1296  /* Zero the call counts to 0 */
1298  KiServiceLimit * sizeof(ULONG));
1299  }
1300 #endif
1301 
1302  /* Create the Basic Object Manager Types to allow new Object Types */
1303  if (!ObInitSystem()) KeBugCheck(OBJECT_INITIALIZATION_FAILED);
1304 
1305  /* Load basic Security for other Managers */
1306  if (!SeInitSystem()) KeBugCheck(SECURITY_INITIALIZATION_FAILED);
1307 
1308  /* Initialize the Process Manager */
1309  if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS_INITIALIZATION_FAILED);
1310 
1311  /* Initialize the PnP Manager */
1312  if (!PpInitSystem()) KeBugCheck(PP0_INITIALIZATION_FAILED);
1313 
1314  /* Initialize the User-Mode Debugging Subsystem */
1315  DbgkInitialize();
1316 
1317  /* Calculate the tick count multiplier */
1319  SharedUserData->TickCountMultiplier = ExpTickCountMultiplier;
1320 
1321  /* Set the OS Version */
1322  SharedUserData->NtMajorVersion = NtMajorVersion;
1323  SharedUserData->NtMinorVersion = NtMinorVersion;
1324 
1325  /* Set the machine type */
1326  SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_NATIVE;
1327  SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_NATIVE;
1328 }
#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
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)
Definition: rtltypes.h:1827
#define TRUE
Definition: types.h:120
UNICODE_STRING NtSystemRoot
Definition: init.c:72
INIT_FUNCTION VOID NTAPI ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:791
NLSTABLEINFO ExpNlsTableInfo
Definition: init.c:84
USHORT MaximumLength
Definition: env_spec_w32.h:370
ULONG KiServiceLimit
Definition: krnlinit.c:26
BOOLEAN NTAPI PpInitSystem(VOID)
Definition: pnpmgr.c:3919
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
INIT_FUNCTION BOOLEAN NTAPI SeInitSystem(VOID)
Definition: semgr.c:239
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:700
#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
NTSYSAPI NTSTATUS NTAPI RtlFindMessage(_In_ PVOID BaseAddress, _In_ ULONG Type, _In_ ULONG Language, _In_ ULONG MessageId, _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry)
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define VER_PRODUCTBUILD_QFE
Definition: ntverp.h:20
INIT_FUNCTION VOID NTAPI ExpInitializeHandleTables(VOID)
Definition: handle.c:28
#define FLG_ENABLE_EXCEPTION_LOGGING
Definition: pstypes.h:82
BOOLEAN NTAPI MmArmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:2043
ULONG CmNtCSDReleaseType
Definition: init.c:57
PVOID AnsiCodePageData
Definition: arc.h:276
ULONG NtMajorVersion
Definition: init.c:42
INIT_FUNCTION BOOLEAN NTAPI ObInitSystem(VOID)
Definition: obinit.c:199
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:63
PVOID DllBase
Definition: btrfs_drv.h:1805
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define ANSI_NULL
Definition: arc.h:130
_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)
VOID INIT_FUNCTION NTAPI DbgkInitialize(VOID)
Definition: dbgkobj.c:1498
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES]
Definition: procobj.c:24
smooth NULL
Definition: ftsmooth.c:416
INIT_FUNCTION VOID NTAPI KiInitializeBugCheck(VOID)
Definition: bug.c:368
INIT_FUNCTION BOOLEAN NTAPI ExpIsLoaderValid(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:765
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1469
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
ULONG CmNtSpBuildNumber
Definition: init.c:55
PVOID OemCodePageData
Definition: arc.h:277
INIT_FUNCTION VOID NTAPI ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG_PTR PagesToDestroy, IN TYPE_OF_MEMORY MemoryType)
Definition: init.c:872
NTSYSAPI VOID NTAPI RtlInitNlsTables(_In_ PUSHORT AnsiTableBase, _In_ PUSHORT OemTableBase, _In_ PUSHORT CaseTableBase, _Out_ PNLSTABLEINFO NlsTable)
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1831
INIT_FUNCTION BOOLEAN NTAPI ExInitSystem(VOID)
Definition: init.c:739
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID ExpNlsTableBase
Definition: init.c:81
ULONG NtMinorVersion
Definition: init.c:43
#define FLG_ENABLE_CLOSE_EXCEPTIONS
Definition: pstypes.h:81
INIT_FUNCTION BOOLEAN NTAPI PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: psmgr.c:626
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
INIT_FUNCTION VOID NTAPI ExInitPoolLookasidePointers(VOID)
Definition: lookas.c:63
#define SharedUserData
PVOID MmHighestUserAddress
Definition: init.c:51
ULONG ExpUnicodeCaseTableDataOffset
Definition: init.c:83
UNICODE_STRING CmCSDVersionString
Definition: init.c:59
ULONG CmNtGlobalFlag
Definition: cmdata.c:19
Definition: btrfs_drv.h:1801
ULONG ExpInitializationPhase
Definition: init.c:65
UNICODE_STRING CmVersionString
Definition: init.c:58
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define MM_SYSTEM_RANGE_START_WOW64
Definition: mm.h:36
INIT_FUNCTION VOID NTAPI HeadlessInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: hdlsterm.c:189
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
Status
Definition: gdiplustypes.h:24
ULONG ExpOemCodePageDataOffset
Definition: init.c:82
BOOLEAN ExpInTextModeSetup
Definition: init.c:66
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define SETUPLDR_TEXT_MODE
Definition: setupblk.h:7
unsigned short USHORT
Definition: pedump.c:61
INIT_FUNCTION VOID NTAPI CmGetSystemControlValues(IN PVOID SystemHiveData, IN PCM_SYSTEM_CONTROL_VECTOR ControlVector)
Definition: cmcontrl.c:104
INIT_FUNCTION VOID NTAPI ExpInitNls(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:209
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define FLG_ENABLE_KDEBUG_SYMBOL_LOAD
Definition: pstypes.h:73
INIT_FUNCTION ULONG NTAPI ExComputeTickCountMultiplier(IN ULONG ClockIncrement)
Definition: init.c:602
#define FLG_KERNEL_STACK_TRACE_DB
Definition: pstypes.h:68
#define MM_HIGHEST_USER_ADDRESS_WOW64
Definition: mm.h:35
#define DPRINT1
Definition: precomp.h:8
INIT_SECTION CM_SYSTEM_CONTROL_VECTOR CmControlVector[]
Definition: cmdata.c:139
#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:56
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:261
#define ULONG_PTR
Definition: config.h:101
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
ULONG NtGlobalFlag
Definition: init.c:51
#define VER_PRODUCTMINORVERSION
Definition: ntverp.h:26
static __inline NTSTATUS 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:1099
BOOLEAN NTAPI HalInitSystem(IN ULONG BootPhase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:43
PVOID UnicodeCodePageData
Definition: arc.h:278
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:82
BOOLEAN KdBreakAfterSymbolLoad
Definition: kdmain.c:19
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:107
BOOLEAN IoRemoteBootClient
Definition: init.c:67

Referenced by KiInitializeKernel().

◆ ExpInitNls()

INIT_FUNCTION VOID NTAPI ExpInitNls ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 209 of file init.c.

210 {
211  LARGE_INTEGER SectionSize;
213  HANDLE NlsSection;
214  PVOID SectionBase = NULL;
215  SIZE_T ViewSize = 0;
216  LARGE_INTEGER SectionOffset = {{0, 0}};
217  PLIST_ENTRY ListHead, NextEntry;
219  ULONG NlsTablesEncountered = 0;
220  SIZE_T NlsTableSizes[3] = {0, 0, 0}; /* 3 NLS tables */
221 
222  /* Check if this is boot-time phase 0 initialization */
224  {
225  /* Loop the memory descriptors */
226  ListHead = &LoaderBlock->MemoryDescriptorListHead;
227  NextEntry = ListHead->Flink;
228  while (NextEntry != ListHead)
229  {
230  /* Get the current block */
231  MdBlock = CONTAINING_RECORD(NextEntry,
233  ListEntry);
234 
235  /* Check if this is an NLS block */
236  if (MdBlock->MemoryType == LoaderNlsData)
237  {
238  /* Increase the table size */
239  ExpNlsTableSize += MdBlock->PageCount * PAGE_SIZE;
240 
241  /* FreeLdr-specific */
242  NlsTableSizes[NlsTablesEncountered] = MdBlock->PageCount * PAGE_SIZE;
243  NlsTablesEncountered++;
244  ASSERT(NlsTablesEncountered < 4);
245  }
246 
247  /* Go to the next block */
248  NextEntry = MdBlock->ListEntry.Flink;
249  }
250 
251  /* Allocate the a new buffer since loader memory will be freed */
254  TAG_RTLI);
255  if (!ExpNlsTableBase) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
256 
257  /* Copy the codepage data in its new location. */
258  if (NlsTablesEncountered == 1)
259  {
260  /* Ntldr-way boot process */
262  LoaderBlock->NlsData->AnsiCodePageData,
264  }
265  else
266  {
267  /*
268  * In NT, the memory blocks are contiguous, but in ReactOS they aren't,
269  * so unless someone fixes FreeLdr, we'll have to use this icky hack.
270  */
272  LoaderBlock->NlsData->AnsiCodePageData,
273  NlsTableSizes[0]);
274 
275  RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0]),
276  LoaderBlock->NlsData->OemCodePageData,
277  NlsTableSizes[1]);
278 
279  RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0] +
280  NlsTableSizes[1]),
281  LoaderBlock->NlsData->UnicodeCodePageData,
282  NlsTableSizes[2]);
283  /* End of Hack */
284  }
285 
286  /* Initialize and reset the NLS TAbles */
293  &ExpNlsTableInfo);
295  return;
296  }
297 
298  /* Set the section size */
299  SectionSize.QuadPart = ExpNlsTableSize;
300 
301  /* Create the NLS Section */
302  Status = ZwCreateSection(&NlsSection,
304  NULL,
305  &SectionSize,
307  SEC_COMMIT | 0x1,
308  NULL);
309  if (!NT_SUCCESS(Status))
310  {
311  /* Failed */
312  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 1, 0, 0);
313  }
314 
315  /* Get a pointer to the section */
316  Status = ObReferenceObjectByHandle(NlsSection,
319  KernelMode,
321  NULL);
322  ObCloseHandle(NlsSection, KernelMode);
323  if (!NT_SUCCESS(Status))
324  {
325  /* Failed */
326  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 2, 0, 0);
327  }
328 
329  /* Map the NLS Section in system space */
331  &SectionBase,
332  &ExpNlsTableSize);
333  if (!NT_SUCCESS(Status))
334  {
335  /* Failed */
336  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 3, 0, 0);
337  }
338 
339  /* Copy the codepage data in its new location. */
340  ASSERT(SectionBase >= MmSystemRangeStart);
342 
343  /* Free the previously allocated buffer and set the new location */
345  ExpNlsTableBase = SectionBase;
346 
347  /* Initialize the NLS Tables */
354  &ExpNlsTableInfo);
356 
357  /* Reset the base to 0 */
358  SectionBase = NULL;
359 
360  /* Map the section in the system process */
363  &SectionBase,
364  0L,
365  0L,
366  &SectionOffset,
367  &ViewSize,
368  ViewShare,
369  0L,
371  if (!NT_SUCCESS(Status))
372  {
373  /* Failed */
374  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 5, 0, 0);
375  }
376 
377  /* Copy the table into the system process and set this as the base */
379  ExpNlsTableBase = SectionBase;
380 }
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
NLSTABLEINFO ExpNlsTableInfo
Definition: init.c:84
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
LONG NTSTATUS
Definition: precomp.h:26
uint32_t ULONG_PTR
Definition: typedefs.h:63
#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
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1469
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:4496
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
NTSYSAPI VOID NTAPI RtlInitNlsTables(_In_ PUSHORT AnsiTableBase, _In_ PUSHORT OemTableBase, _In_ PUSHORT CaseTableBase, _Out_ PNLSTABLEINFO NlsTable)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID ExpNlsTableBase
Definition: init.c:81
PVOID ExpNlsSectionPointer
Definition: init.c:86
POBJECT_TYPE MmSectionObjectType
Definition: section.c:136
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#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:4841
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:83
ULONG ExpInitializationPhase
Definition: init.c:65
SIZE_T ExpNlsTableSize
Definition: init.c:85
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
ULONG ExpOemCodePageDataOffset
Definition: init.c:82
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_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 ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:82
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:107
LONGLONG QuadPart
Definition: typedefs.h:112
#define PAGE_READWRITE
Definition: nt_native.h:1304

Referenced by ExpInitializeExecutive(), and Phase1InitializationDiscard().

◆ ExpInitSystemPhase0()

INIT_FUNCTION BOOLEAN NTAPI ExpInitSystemPhase0 ( VOID  )

Definition at line 635 of file init.c.

636 {
637  /* Initialize EXRESOURCE Support */
639 
640  /* Initialize the environment lock */
642 
643  /* Initialize the lookaside lists and locks */
645 
646  /* Initialize the Firmware Table resource and listhead */
649 
650  /* Set the suite mask to maximum and return */
651  ExSuiteMask = 0xFFFFFFFF;
652  return TRUE;
653 }
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:52
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
VOID ExpInitLookasideLists()
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
INIT_FUNCTION VOID NTAPI ExpResourceInitialization(VOID)
Definition: resource.c:169
LIST_ENTRY ExpFirmwareTableProviderListHead
Definition: sysinfo.c:31

Referenced by ExInitSystem().

◆ ExpInitSystemPhase1()

INIT_FUNCTION BOOLEAN NTAPI ExpInitSystemPhase1 ( VOID  )

Definition at line 658 of file init.c.

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

Referenced by ExInitSystem().

◆ ExpIsLoaderValid()

INIT_FUNCTION BOOLEAN NTAPI ExpIsLoaderValid ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 765 of file init.c.

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

INIT_FUNCTION VOID NTAPI ExpLoadBootSymbols ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 791 of file init.c.

792 {
793  ULONG i = 0;
794  PLIST_ENTRY NextEntry;
795  ULONG Count, Length;
796  PWCHAR Name;
797  PLDR_DATA_TABLE_ENTRY LdrEntry;
798  CHAR NameBuffer[256];
799  STRING SymbolString;
801 
802  /* Loop the driver list */
803  NextEntry = LoaderBlock->LoadOrderListHead.Flink;
804  while (NextEntry != &LoaderBlock->LoadOrderListHead)
805  {
806  /* Skip the first two images */
807  if (i >= 2)
808  {
809  /* Get the entry */
810  LdrEntry = CONTAINING_RECORD(NextEntry,
812  InLoadOrderLinks);
813  if (LdrEntry->FullDllName.Buffer[0] == L'\\')
814  {
815  /* We have a name, read its data */
816  Name = LdrEntry->FullDllName.Buffer;
817  Length = LdrEntry->FullDllName.Length / sizeof(WCHAR);
818 
819  /* Check if our buffer can hold it */
820  if (sizeof(NameBuffer) < Length + sizeof(ANSI_NULL))
821  {
822  /* It's too long */
824  }
825  else
826  {
827  /* Copy the name */
828  Count = 0;
829  do
830  {
831  /* Copy the character */
832  NameBuffer[Count++] = (CHAR)*Name++;
833  } while (Count < Length);
834 
835  /* Null-terminate */
836  NameBuffer[Count] = ANSI_NULL;
838  }
839  }
840  else
841  {
842  /* Safely print the string into our buffer */
843  Status = RtlStringCbPrintfA(NameBuffer,
844  sizeof(NameBuffer),
845  "%S\\System32\\Drivers\\%wZ",
846  &SharedUserData->NtSystemRoot[2],
847  &LdrEntry->BaseDllName);
848  }
849 
850  /* Check if the buffer was ok */
851  if (NT_SUCCESS(Status))
852  {
853  /* Initialize the STRING for the debugger */
854  RtlInitString(&SymbolString, NameBuffer);
855 
856  /* Load the symbols */
857  DbgLoadImageSymbols(&SymbolString,
858  LdrEntry->DllBase,
860  }
861  }
862 
863  /* Go to the next entry */
864  i++;
865  NextEntry = NextEntry->Flink;
866  }
867 }
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
uint16_t * PWCHAR
Definition: typedefs.h:54
uint32_t ULONG_PTR
Definition: typedefs.h:63
PVOID DllBase
Definition: btrfs_drv.h:1805
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 ANSI_NULL
struct NameRec_ * Name
Definition: cdprocs.h:464
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
std::wstring STRING
Definition: fontsub.cpp:33
#define SharedUserData
static const WCHAR L[]
Definition: oid.c:1250
Definition: btrfs_drv.h:1801
Definition: typedefs.h:117
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
UNICODE_STRING FullDllName
Definition: btrfs_drv.h:1807
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:144
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
return STATUS_SUCCESS
Definition: btrfs.c:2725
static __inline NTSTATUS 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:1099
#define CHAR(Char)

Referenced by ExpInitializeExecutive().

◆ ExpLoadInitialProcess()

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

Definition at line 385 of file init.c.

388 {
390  SIZE_T Size;
391  PWSTR p;
392  UNICODE_STRING NullString = RTL_CONSTANT_STRING(L"");
393  UNICODE_STRING SmssName, Environment, SystemDriveString, DebugString;
394  PVOID EnvironmentPtr = NULL;
395  PRTL_USER_PROCESS_INFORMATION ProcessInformation;
396  PRTL_USER_PROCESS_PARAMETERS ProcessParams = NULL;
397 
398  NullString.Length = sizeof(WCHAR);
399 
400  /* Use the initial buffer, after the strings */
401  ProcessInformation = &InitBuffer->ProcessInfo;
402 
403  /* Allocate memory for the process parameters */
404  Size = sizeof(*ProcessParams) + ((MAX_PATH * 6) * sizeof(WCHAR));
405  Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
406  (PVOID*)&ProcessParams,
407  0,
408  &Size,
411  if (!NT_SUCCESS(Status))
412  {
413  /* Failed, display error */
414  _snwprintf(InitBuffer->DebugBuffer,
415  sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
416  L"INIT: Unable to allocate Process Parameters. 0x%lx",
417  Status);
418  RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
420 
421  /* Bugcheck the system */
422  KeBugCheckEx(SESSION1_INITIALIZATION_FAILED, Status, 0, 0, 0);
423  }
424 
425  /* Setup the basic header, and give the process the low 1MB to itself */
426  ProcessParams->Length = (ULONG)Size;
427  ProcessParams->MaximumLength = (ULONG)Size;
430 
431  /* Allocate a page for the environment */
432  Size = PAGE_SIZE;
433  Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
434  &EnvironmentPtr,
435  0,
436  &Size,
439  if (!NT_SUCCESS(Status))
440  {
441  /* Failed, display error */
442  _snwprintf(InitBuffer->DebugBuffer,
443  sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
444  L"INIT: Unable to allocate Process Environment. 0x%lx",
445  Status);
446  RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
448 
449  /* Bugcheck the system */
450  KeBugCheckEx(SESSION2_INITIALIZATION_FAILED, Status, 0, 0, 0);
451  }
452 
453  /* Write the pointer */
454  ProcessParams->Environment = EnvironmentPtr;
455 
456  /* Make a buffer for the DOS path */
457  p = (PWSTR)(ProcessParams + 1);
458  ProcessParams->CurrentDirectory.DosPath.Buffer = p;
460  sizeof(WCHAR);
461 
462  /* Copy the DOS path */
464  &NtSystemRoot);
465 
466  /* Make a buffer for the DLL Path */
467  p = (PWSTR)((PCHAR)ProcessParams->CurrentDirectory.DosPath.Buffer +
468  ProcessParams->CurrentDirectory.DosPath.MaximumLength);
469  ProcessParams->DllPath.Buffer = p;
470  ProcessParams->DllPath.MaximumLength = MAX_PATH * sizeof(WCHAR);
471 
472  /* Copy the DLL path and append the system32 directory */
473  RtlCopyUnicodeString(&ProcessParams->DllPath,
474  &ProcessParams->CurrentDirectory.DosPath);
475  RtlAppendUnicodeToString(&ProcessParams->DllPath, L"\\System32");
476 
477  /* Make a buffer for the image name */
478  p = (PWSTR)((PCHAR)ProcessParams->DllPath.Buffer +
479  ProcessParams->DllPath.MaximumLength);
480  ProcessParams->ImagePathName.Buffer = p;
481  ProcessParams->ImagePathName.MaximumLength = MAX_PATH * sizeof(WCHAR);
482 
483  /* Make sure the buffer is a valid string which within the given length */
488  sizeof(NtInitialUserProcessBuffer) - sizeof(WCHAR)))))
489  {
490  /* Invalid initial process string, bugcheck */
491  KeBugCheckEx(SESSION2_INITIALIZATION_FAILED,
496  }
497 
498  /* Cut out anything after a space */
500  while ((*p) && (*p != L' ')) p++;
501 
502  /* Set the image path length */
503  ProcessParams->ImagePathName.Length =
505 
506  /* Copy the actual buffer */
507  RtlCopyMemory(ProcessParams->ImagePathName.Buffer,
509  ProcessParams->ImagePathName.Length);
510 
511  /* Null-terminate it */
512  ProcessParams->ImagePathName.Buffer[ProcessParams->ImagePathName.Length /
513  sizeof(WCHAR)] = UNICODE_NULL;
514 
515  /* Make a buffer for the command line */
516  p = (PWSTR)((PCHAR)ProcessParams->ImagePathName.Buffer +
517  ProcessParams->ImagePathName.MaximumLength);
518  ProcessParams->CommandLine.Buffer = p;
519  ProcessParams->CommandLine.MaximumLength = MAX_PATH * sizeof(WCHAR);
520 
521  /* Add the image name to the command line */
522  RtlAppendUnicodeToString(&ProcessParams->CommandLine,
524 
525  /* Create the environment string */
526  RtlInitEmptyUnicodeString(&Environment,
527  ProcessParams->Environment,
528  (USHORT)Size);
529 
530  /* Append the DLL path to it */
534 
535  /* Create the system drive string */
536  SystemDriveString = NtSystemRoot;
537  SystemDriveString.Length = 2 * sizeof(WCHAR);
538 
539  /* Append it to the environment */
540  RtlAppendUnicodeToString(&Environment, L"SystemDrive=");
541  RtlAppendUnicodeStringToString(&Environment, &SystemDriveString);
543 
544  /* Append the system root to the environment */
545  RtlAppendUnicodeToString(&Environment, L"SystemRoot=");
548 
549  /* Prepare the prefetcher */
550  //CcPfBeginBootPhase(150);
551 
552  /* Create SMSS process */
553  SmssName = ProcessParams->ImagePathName;
554  Status = RtlCreateUserProcess(&SmssName,
556  RtlDeNormalizeProcessParams(ProcessParams),
557  NULL,
558  NULL,
559  NULL,
560  FALSE,
561  NULL,
562  NULL,
563  ProcessInformation);
564  if (!NT_SUCCESS(Status))
565  {
566  /* Failed, display error */
567  _snwprintf(InitBuffer->DebugBuffer,
568  sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
569  L"INIT: Unable to create Session Manager. 0x%lx",
570  Status);
571  RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
573 
574  /* Bugcheck the system */
575  KeBugCheckEx(SESSION3_INITIALIZATION_FAILED, Status, 0, 0, 0);
576  }
577 
578  /* Resume the thread */
579  Status = ZwResumeThread(ProcessInformation->ThreadHandle, NULL);
580  if (!NT_SUCCESS(Status))
581  {
582  /* Failed, display error */
583  _snwprintf(InitBuffer->DebugBuffer,
584  sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
585  L"INIT: Unable to resume Session Manager. 0x%lx",
586  Status);
587  RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
589 
590  /* Bugcheck the system */
591  KeBugCheckEx(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0);
592  }
593 
594  /* Return success */
595  *ProcessParameters = ProcessParams;
596  *ProcessEnvironment = EnvironmentPtr;
597 }
signed char * PCHAR
Definition: retypes.h:7
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:45
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
UNICODE_STRING NtSystemRoot
Definition: init.c:72
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
uint16_t * PWSTR
Definition: typedefs.h:54
LONG NTSTATUS
Definition: precomp.h:26
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 UNICODE_NULL
#define MEM_RESERVE
Definition: nt_native.h:1314
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
smooth NULL
Definition: ftsmooth.c:416
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
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
#define MAX_PATH
Definition: compat.h:26
WCHAR NtInitialUserProcessBuffer[128]
Definition: init.c:75
NTSYSAPI NTSTATUS NTAPI ZwResumeThread(_In_ HANDLE ThreadHandle, _Out_opt_ PULONG SuspendCount)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
UNICODE_STRING ImagePathName
Definition: btrfs_drv.h:1826
static const WCHAR L[]
Definition: oid.c:1250
ULONG NtInitialUserProcessBufferType
Definition: init.c:78
#define PAGE_SIZE
Definition: env_spec_w32.h:49
UNICODE_STRING CommandLine
Definition: btrfs_drv.h:1827
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
#define MAXULONG
Definition: typedefs.h:250
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned short USHORT
Definition: pedump.c:61
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI PRTL_USER_PROCESS_PARAMETERS NTAPI RtlDeNormalizeProcessParams(_In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters)
UNICODE_STRING DosPath
Definition: rtltypes.h:1362
ULONG NtInitialUserProcessBufferLength
Definition: init.c:76
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
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:107
#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 2043 of file mminit.c.

2045 {
2046  ULONG i;
2047  BOOLEAN IncludeType[LoaderMaximum];
2048  PVOID Bitmap;
2050  PFN_NUMBER PageCount;
2051 #if DBG
2052  ULONG j;
2053  PMMPTE PointerPte, TestPte;
2054  MMPTE TempPte;
2055 #endif
2056 
2057  /* Dump memory descriptors */
2059 
2060  //
2061  // Instantiate memory that we don't consider RAM/usable
2062  // We use the same exclusions that Windows does, in order to try to be
2063  // compatible with WinLDR-style booting
2064  //
2065  for (i = 0; i < LoaderMaximum; i++) IncludeType[i] = TRUE;
2066  IncludeType[LoaderBad] = FALSE;
2067  IncludeType[LoaderFirmwarePermanent] = FALSE;
2068  IncludeType[LoaderSpecialMemory] = FALSE;
2069  IncludeType[LoaderBBTMemory] = FALSE;
2070  if (Phase == 0)
2071  {
2072  /* Count physical pages on the system */
2073  MiScanMemoryDescriptors(LoaderBlock);
2074 
2075  /* Initialize the phase 0 temporary event */
2077 
2078  /* Set all the events to use the temporary event for now */
2085 
2086  //
2087  // Default throttling limits for Cc
2088  // May be ajusted later on depending on system type
2089  //
2090  MmThrottleTop = 450;
2091  MmThrottleBottom = 127;
2092 
2093  //
2094  // Define the basic user vs. kernel address space separation
2095  //
2099 
2100  /* Highest PTE and PDE based on the addresses above */
2103 #if (_MI_PAGING_LEVELS >= 3)
2104  MiHighestUserPpe = MiAddressToPpe(MmHighestUserAddress);
2105 #if (_MI_PAGING_LEVELS >= 4)
2106  MiHighestUserPxe = MiAddressToPxe(MmHighestUserAddress);
2107 #endif
2108 #endif
2109  //
2110  // Get the size of the boot loader's image allocations and then round
2111  // that region up to a PDE size, so that any PDEs we might create for
2112  // whatever follows are separate from the PDEs that boot loader might've
2113  // already created (and later, we can blow all that away if we want to).
2114  //
2119 
2120  /* Initialize session space address layout */
2122 
2123  /* Set the based section highest address */
2125 
2126 #if DBG
2127  /* The subection PTE format depends on things being 8-byte aligned */
2128  ASSERT((sizeof(CONTROL_AREA) % 8) == 0);
2129  ASSERT((sizeof(SUBSECTION) % 8) == 0);
2130 
2131  /* Prototype PTEs are assumed to be in paged pool, so check if the math works */
2132  PointerPte = (PMMPTE)MmPagedPoolStart;
2133  MI_MAKE_PROTOTYPE_PTE(&TempPte, PointerPte);
2134  TestPte = MiProtoPteToPte(&TempPte);
2135  ASSERT(PointerPte == TestPte);
2136 
2137  /* Try the last nonpaged pool address */
2138  PointerPte = (PMMPTE)MI_NONPAGED_POOL_END;
2139  MI_MAKE_PROTOTYPE_PTE(&TempPte, PointerPte);
2140  TestPte = MiProtoPteToPte(&TempPte);
2141  ASSERT(PointerPte == TestPte);
2142 
2143  /* Try a bunch of random addresses near the end of the address space */
2144  PointerPte = (PMMPTE)((ULONG_PTR)MI_HIGHEST_SYSTEM_ADDRESS - 0x37FFF);
2145  for (j = 0; j < 20; j += 1)
2146  {
2147  MI_MAKE_PROTOTYPE_PTE(&TempPte, PointerPte);
2148  TestPte = MiProtoPteToPte(&TempPte);
2149  ASSERT(PointerPte == TestPte);
2150  PointerPte++;
2151  }
2152 
2153  /* Subsection PTEs are always in nonpaged pool, pick a random address to try */
2155  MI_MAKE_SUBSECTION_PTE(&TempPte, PointerPte);
2157  ASSERT(PointerPte == TestPte);
2158 #endif
2159 
2160  /* Loop all 8 standby lists */
2161  for (i = 0; i < 8; i++)
2162  {
2163  /* Initialize them */
2168  }
2169 
2170  /* Initialize the user mode image list */
2172 
2173  /* Initialize critical section timeout value (relative time is negative) */
2175 
2176  /* Initialize the paged pool mutex and the section commit mutex */
2180 
2181  /* Initialize the Loader Lock */
2183 
2184  /* Set the zero page event */
2187 
2188  /* Initialize the dead stack S-LIST */
2190 
2191  //
2192  // Check if this is a machine with less than 19MB of RAM
2193  //
2194  PageCount = MmNumberOfPhysicalPages;
2195  if (PageCount < MI_MIN_PAGES_FOR_SYSPTE_TUNING)
2196  {
2197  //
2198  // Use the very minimum of system PTEs
2199  //
2200  MmNumberOfSystemPtes = 7000;
2201  }
2202  else
2203  {
2204  //
2205  // Use the default
2206  //
2207  MmNumberOfSystemPtes = 11000;
2208  if (PageCount > MI_MIN_PAGES_FOR_SYSPTE_BOOST)
2209  {
2210  //
2211  // Double the amount of system PTEs
2212  //
2213  MmNumberOfSystemPtes <<= 1;
2214  }
2215  if (PageCount > MI_MIN_PAGES_FOR_SYSPTE_BOOST_BOOST)
2216  {
2217  //
2218  // Double the amount of system PTEs
2219  //
2220  MmNumberOfSystemPtes <<= 1;
2221  }
2222  if (MmSpecialPoolTag != 0 && MmSpecialPoolTag != -1)
2223  {
2224  //
2225  // Add some extra PTEs for special pool
2226  //
2227  MmNumberOfSystemPtes += 0x6000;
2228  }
2229  }
2230 
2231  DPRINT("System PTE count has been tuned to %lu (%lu bytes)\n",
2233 
2234  /* Check if no values are set for the heap limits */
2235  if (MmHeapSegmentReserve == 0)
2236  {
2237  MmHeapSegmentReserve = 2 * _1MB;
2238  }
2239 
2240  if (MmHeapSegmentCommit == 0)
2241  {
2243  }
2244 
2246  {
2248  }
2249 
2251  {
2253  }
2254 
2255  /* Initialize the working set lock */
2257 
2258  /* Set commit limit */
2259  MmTotalCommitLimit = (2 * _1GB) >> PAGE_SHIFT;
2261 
2262  /* Has the allocation fragment been setup? */
2263  if (!MmAllocationFragment)
2264  {
2265  /* Use the default value */
2267  if (PageCount < ((256 * _1MB) / PAGE_SIZE))
2268  {
2269  /* On memory systems with less than 256MB, divide by 4 */
2271  }
2272  else if (PageCount < (_1GB / PAGE_SIZE))
2273  {
2274  /* On systems with less than 1GB, divide by 2 */
2276  }
2277  }
2278  else
2279  {
2280  /* Convert from 1KB fragments to pages */
2283 
2284  /* Don't let it past the maximum */
2287 
2288  /* Don't let it too small either */
2291  }
2292 
2293  /* Check for kernel stack size that's too big */
2295  {
2296  /* Sanitize to default value */
2298  }
2299  else
2300  {
2301  /* Take the registry setting, and convert it into bytes */
2303 
2304  /* Now align it to a page boundary */
2306 
2307  /* Sanity checks */
2309  ASSERT((MmLargeStackSize & (PAGE_SIZE - 1)) == 0);
2310 
2311  /* Make sure it's not too low */
2313  }
2314 
2315  /* Compute color information (L2 cache-separated paging lists) */
2317 
2318  // Calculate the number of bytes for the PFN database
2319  // then add the color tables and convert to pages
2320  MxPfnAllocation = (MmHighestPhysicalPage + 1) * sizeof(MMPFN);
2323 
2324  // We have to add one to the count here, because in the process of
2325  // shifting down to the page size, we actually ended up getting the
2326  // lower aligned size (so say, 0x5FFFF bytes is now 0x5F pages).
2327  // Later on, we'll shift this number back into bytes, which would cause
2328  // us to end up with only 0x5F000 bytes -- when we actually want to have
2329  // 0x60000 bytes.
2330  MxPfnAllocation++;
2331 
2332  /* Initialize the platform-specific parts */
2333  MiInitMachineDependent(LoaderBlock);
2334 
2335  //
2336  // Build the physical memory block
2337  //
2339  IncludeType);
2340 
2341  //
2342  // Allocate enough buffer for the PFN bitmap
2343  // Align it up to a 32-bit boundary
2344  //
2346  (((MmHighestPhysicalPage + 1) + 31) / 32) * 4,
2347  TAG_MM);
2348  if (!Bitmap)
2349  {
2350  //
2351  // This is critical
2352  //
2353  KeBugCheckEx(INSTALL_MORE_MEMORY,
2357  0x101);
2358  }
2359 
2360  //
2361  // Initialize it and clear all the bits to begin with
2362  //
2364  Bitmap,
2367 
2368  //
2369  // Loop physical memory runs
2370  //
2371  for (i = 0; i < MmPhysicalMemoryBlock->NumberOfRuns; i++)
2372  {
2373  //
2374  // Get the run
2375  //
2377  DPRINT("PHYSICAL RAM [0x%08p to 0x%08p]\n",
2378  Run->BasePage << PAGE_SHIFT,
2379  (Run->BasePage + Run->PageCount) << PAGE_SHIFT);
2380 
2381  //
2382  // Make sure it has pages inside it
2383  //
2384  if (Run->PageCount)
2385  {
2386  //
2387  // Set the bits in the PFN bitmap
2388  //
2389  RtlSetBits(&MiPfnBitMap, (ULONG)Run->BasePage, (ULONG)Run->PageCount);
2390  }
2391  }
2392 
2393  /* Look for large page cache entries that need caching */
2395 
2396  /* Loop for HAL Heap I/O device mappings that need coherency tracking */
2398 
2399  /* Set the initial resident page count */
2401 
2402  /* Initialize large page structures on PAE/x64, and MmProcessList on x86 */
2404 
2405  /* Check if the registry says any drivers should be loaded with large pages */
2407 
2408  /* Relocate the boot drivers into system PTE space and fixup their PFNs */
2409  MiReloadBootLoadedDrivers(LoaderBlock);
2410 
2411  /* FIXME: Call out into Driver Verifier for initialization */
2412 
2413  /* Check how many pages the system has */
2414  if (MmNumberOfPhysicalPages <= ((13 * _1MB) / PAGE_SIZE))
2415  {
2416  /* Set small system */
2419  }
2420  else if (MmNumberOfPhysicalPages <= ((19 * _1MB) / PAGE_SIZE))
2421  {
2422  /* Set small system and add 100 pages for the cache */
2424  MmSystemCacheWsMinimum += 100;
2426  }
2427  else
2428  {
2429  /* Set medium system and add 400 pages for the cache */
2431  MmSystemCacheWsMinimum += 400;
2433  }
2434 
2435  /* Check for less than 24MB */
2436  if (MmNumberOfPhysicalPages < ((24 * _1MB) / PAGE_SIZE))
2437  {
2438  /* No more than 32 pages */
2440  }
2441 
2442  /* Check for more than 32MB */
2443  if (MmNumberOfPhysicalPages >= ((32 * _1MB) / PAGE_SIZE))
2444  {
2445  /* Check for product type being "Wi" for WinNT */
2446  if (MmProductType == '\0i\0W')
2447  {
2448  /* Then this is a large system */
2450  }
2451  else
2452  {
2453  /* For servers, we need 64MB to consider this as being large */
2454  if (MmNumberOfPhysicalPages >= ((64 * _1MB) / PAGE_SIZE))
2455  {
2456  /* Set it as large */
2458  }
2459  }
2460  }
2461 
2462  /* Check for more than 33 MB */
2463  if (MmNumberOfPhysicalPages > ((33 * _1MB) / PAGE_SIZE))
2464  {
2465  /* Add another 500 pages to the cache */
2466  MmSystemCacheWsMinimum += 500;
2467  }
2468 
2469  /* Now setup the shared user data fields */
2470  ASSERT(SharedUserData->NumberOfPhysicalPages == 0);
2471  SharedUserData->NumberOfPhysicalPages = MmNumberOfPhysicalPages;
2472  SharedUserData->LargePageMinimum = 0;
2473 
2474  /* Check for workstation (Wi for WinNT) */
2475  if (MmProductType == '\0i\0W')
2476  {
2477  /* Set Windows NT Workstation product type */
2478  SharedUserData->NtProductType = NtProductWinNt;
2479  MmProductType = 0;
2480 
2481  /* For this product, we wait till the last moment to throttle */
2482  MmThrottleTop = 250;
2483  MmThrottleBottom = 30;
2484  }
2485  else
2486  {
2487  /* Check for LanMan server (La for LanmanNT) */
2488  if (MmProductType == '\0a\0L')
2489  {
2490  /* This is a domain controller */
2491  SharedUserData->NtProductType = NtProductLanManNt;
2492  }
2493  else
2494  {
2495  /* Otherwise it must be a normal server (Se for ServerNT) */
2496  SharedUserData->NtProductType = NtProductServer;
2497  }
2498 
2499  /* Set the product type, and make the system more aggressive with low memory */
2500  MmProductType = 1;
2501  MmMinimumFreePages = 81;
2502 
2503  /* We will throttle earlier to preserve memory */
2504  MmThrottleTop = 450;
2505  MmThrottleBottom = 80;
2506  }
2507 
2508  /* Update working set tuning parameters */
2510 
2511  /* Finetune the page count by removing working set and NP expansion */
2515  if (MmResidentAvailablePages <= 0)
2516  {
2517  /* This should not happen */
2518  DPRINT1("System cache working set too big\n");
2519  return FALSE;
2520  }
2521 
2522  /* Define limits for system cache */
2523 #ifdef _M_AMD64
2525 #else
2527 #endif
2529 
2530  /* Initialize the system cache */
2531  //MiInitializeSystemCache(MmSystemCacheWsMinimum, MmAvailablePages);
2532 
2533  /* Update the commit limit */
2535  if (MmTotalCommitLimit > 1024) MmTotalCommitLimit -= 1024;
2537 
2538  /* Size up paged pool and build the shadow system page directory */
2539  MiBuildPagedPool();
2540 
2541  /* Debugger physical memory support is now ready to be used */
2543 
2544  /* Initialize the loaded module list */
2545  MiInitializeLoadedModuleList(LoaderBlock);
2546  }
2547 
2548  //
2549  // Always return success for now
2550  //
2551  return TRUE;
2552 }
MMSUPPORT MmSystemCacheWs
Definition: mminit.c:246
PFN_NUMBER MmResidentAvailableAtInit
Definition: freelist.c:28
Definition: bidi.c:477
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
#define TRUE
Definition: types.h:120
MMPFNLIST MmStandbyPageListByPriority[8]
Definition: pfnlist.c:44
#define MI_MIN_PAGES_FOR_SYSPTE_BOOST
Definition: mm.h:53
#define LL
Definition: tui.h:72
#define MI_DEFAULT_SYSTEM_RANGE_START
Definition: mm.h:11
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
NTSTATUS NTAPI INIT_FUNCTION MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:672
#define MI_MIN_PAGES_FOR_SYSPTE_BOOST_BOOST
Definition: mm.h:54
#define MI_MAX_ALLOCATION_FRAGMENT
Definition: mm.h:69
#define MiAddressToPde(x)
Definition: mmx86.c:20
#define MI_NONPAGED_POOL_END
Definition: mm.h:29
KGUARDED_MUTEX MmSectionBasedMutex
Definition: section.c:110
struct _MMCOLOR_TABLES MMCOLOR_TABLES
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:372
PFN_COUNT MmNumberOfPhysicalPages
Definition: mminit.c:212
INIT_FUNCTION VOID NTAPI MiInitializeLargePageSupport(VOID)
Definition: largepag.c:34
BOOLEAN MiDbgEnableMdDump
Definition: mminit.c:373
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
PMMPTE FORCEINLINE MiAddressToPpe(PVOID Address)
Definition: mm.h:151
PFN_COUNT MiExpansionPoolPagesInitialCharge
Definition: pool.c:21
PHYSICAL_MEMORY_RUN Run[1]
Definition: miarm.h:440
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
ULONG MmSizeOfSystemCacheInPages
Definition: mminit.c:245
#define PAGE_ROUND_UP(x)
Definition: scsiport_int.h:13
PFN_NUMBER Flink
Definition: mm.h:373
PKEVENT MiHighPagedPoolEvent
Definition: mminit.c:295
uint32_t ULONG_PTR
Definition: typedefs.h:63
PFN_NUMBER MxPfnAllocation
Definition: mminit.c:187
#define MI_USER_PROBE_ADDRESS
Definition: mm.h:10
PFN_NUMBER MmLowestPhysicalPage
Definition: mminit.c:211
INIT_FUNCTION VOID NTAPI MiSyncCachedRanges(VOID)
Definition: largepag.c:54
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 MiAddressToPte(x)
Definition: mmx86.c:19
ULONG MmSpecialPoolTag
Definition: pool.c:27
BOOLEAN MmZeroingPageThreadActive
Definition: zeropage.c:20
ULONG PFN_NUMBER
Definition: ke.h:8
INIT_FUNCTION VOID NTAPI MiInitializeDriverLargePageList(VOID)
Definition: largepag.c:68
#define TAG_MM
Definition: tag.h:136
INIT_FUNCTION BOOLEAN NTAPI MiInitializeLoadedModuleList(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: sysldr.c:2200
Definition: arc.h:130
PFN_NUMBER Blink
Definition: mm.h:374
VOID NTAPI INIT_FUNCTION MiInitializeSessionSpaceLayout(VOID)
Definition: init.c:65
PVOID MmHighestUserAddress
Definition: mminit.c:229
SIZE_T MmBootImageSize
Definition: mminit.c:222
unsigned char BOOLEAN
#define MiProtoPteToPte(x)
Definition: mm.h:247
PVOID MmSystemRangeStart
Definition: mminit.c:230
struct tagRun Run
KEVENT MmZeroingPageEvent
Definition: zeropage.c:21
void DPRINT(...)
Definition: polytest.cpp:61
#define ExInitializePushLock
Definition: ex.h:999
FORCEINLINE VOID MI_MAKE_SUBSECTION_PTE(_Out_ PMMPTE NewPte, _In_ PVOID Segment)
Definition: mm.h:258
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:85
FORCEINLINE VOID InitializeSListHead(_Out_ PSLIST_HEADER SListHead)
Definition: rtlfuncs.h:3353
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:33
NTSYSAPI void WINAPI RtlClearAllBits(PRTL_BITMAP)
#define PDE_MAPPED_VA
Definition: miarm.h:22
ULONG_PTR MmUserProbeAddress
Definition: mminit.c:228
EX_PUSH_LOCK WorkingSetMutex
Definition: mmtypes.h:935
PFN_COUNT MmNumberOfSystemPtes
Definition: mminit.c:181
PVOID MmSystemCacheEnd
Definition: mminit.c:244
INIT_FUNCTION VOID NTAPI MiDbgDumpMemoryDescriptors(VOID)
Definition: mminit.c:1991
SIZE_T MmHeapDeCommitFreeBlockThreshold
Definition: mminit.c:369
#define MI_HIGHEST_USER_ADDRESS
Definition: mmtypes.h:43
PVOID MiDebugMapping
Definition: mmdbg.c:32
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:75
#define KERNEL_STACK_SIZE
PVOID MmPagedPoolStart
Definition: mminit.c:104
PVOID MmHighSectionBase
Definition: section.c:111
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
LIST_ENTRY MmLoadedUserImageList
Definition: sysldr.c:35
#define MiSubsectionPteToSubsection(x)
Definition: mm.h:253
#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:305
PMMPTE FORCEINLINE MiAddressToPxe(PVOID Address)
Definition: mm.h:161
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define _1MB
Definition: miarm.h:15
#define MI_MIN_PAGES_FOR_SYSPTE_TUNING
Definition: mm.h:52
PKEVENT MiLowNonPagedPoolEvent
Definition: mminit.c:296
#define MI_PAGED_POOL_START
Definition: mm.h:21
PVOID MmSystemCacheStart
Definition: mminit.c:243
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
INIT_FUNCTION VOID NTAPI MiReloadBootLoadedDrivers(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: sysldr.c:1685
#define ROUND_TO_PAGES(Size)
#define MI_SYSTEM_CACHE_START
Definition: mm.h:26
INIT_FUNCTION PPHYSICAL_MEMORY_DESCRIPTOR NTAPI MmInitializeMemoryLimits(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PBOOLEAN IncludeType)
Definition: mminit.c:1622
FORCEINLINE VOID MI_MAKE_PROTOTYPE_PTE(IN PMMPTE NewPte, IN PMMPTE PointerPte)
Definition: mm.h:272
INIT_FUNCTION VOID NTAPI MiAdjustWorkingSetManagerParameters(IN BOOLEAN Client)
Definition: mminit.c:1203
PFN_NUMBER Total
Definition: mm.h:371
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
SIZE_T MmHeapSegmentCommit
Definition: mminit.c:367
#define min(a, b)
Definition: monoChain.cc:55
#define DPRINT1
Definition: precomp.h:8
INIT_FUNCTION VOID NTAPI MiAddHalIoMappings(VOID)
Definition: mminit.c:1418
ULONG MmMaximumDeadKernelStacks
Definition: procsup.c:22
ULONG MmProductType
Definition: mminit.c:325
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
KGUARDED_MUTEX MmPagedPoolMutex
Definition: pool.c:24
ULONG MmThrottleBottom
Definition: mminit.c:397
INIT_FUNCTION VOID NTAPI MiComputeColorInformation(VOID)
Definition: mminit.c:508
PVOID MmNonPagedPoolStart
Definition: mminit.c:97
#define MI_ALLOCATION_FRAGMENT
Definition: mm.h:68
KGUARDED_MUTEX MmSectionCommitMutex
Definition: section.c:108
#define MI_SYSTEM_CACHE_END
Definition: mm.h:27
#define MI_MIN_ALLOCATION_FRAGMENT
Definition: mm.h:67
#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:107
PFN_NUMBER MmMinimumFreePages
Definition: mminit.c:314
LONGLONG QuadPart
Definition: typedefs.h:112
#define _1GB
Definition: miarm.h:16
INIT_FUNCTION VOID NTAPI MiBuildPagedPool(VOID)
Definition: mminit.c:1751
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:640
union _MMPTE::@2227 u
PFN_NUMBER Flink
Definition: mm.h:309
FORCEINLINE KIRQL MiAcquirePfnLock(VOID)
Definition: mm.h:901
union _MMPFN::@1721 u3
union _MMPFN::@1719 u1
FORCEINLINE VOID MiReleasePfnLock(_In_ KIRQL OldIrql)
Definition: mm.h:908
uint32_t ULONG_PTR
Definition: typedefs.h:63
struct _MMPFN::@1721::@1727 e2
UCHAR KIRQL
Definition: env_spec_w32.h:591
TYPE_OF_MEMORY MemoryType
Definition: arc.h:193
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
ULONG PFN_NUMBER
Definition: ke.h:8
smooth NULL
Definition: ftsmooth.c:416
PVOID FORCEINLINE MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:198
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 _LIST_ENTRY * Flink
Definition: typedefs.h:119
struct _MMPTE * PMMPTE
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#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:803
Definition: mm.h:305
Definition: typedefs.h:117
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:940
ULONG_PTR Long
Definition: mmtypes.h:215
#define MI_SET_PFN_DELETED(x)
Definition: miarm.h:198
PMMPTE PteAddress
Definition: mm.h:318
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
FORCEINLINE BOOLEAN MI_IS_PHYSICAL_ADDRESS(IN PVOID Address)
Definition: miarm.h:937
base of all file and directory entries
Definition: entries.h:82
VOID NTAPI KeFlushCurrentTb(VOID)
Definition: cpu.c:322

Referenced by Phase1InitializationDiscard().

◆ Phase1Initialization()

VOID NTAPI Phase1Initialization ( IN PVOID  Context)

Definition at line 2018 of file init.c.

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

Referenced by PspInitPhase0().

◆ Phase1InitializationDiscard()

INIT_FUNCTION VOID NTAPI Phase1InitializationDiscard ( IN PVOID  Context)

Definition at line 1337 of file init.c.

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

Referenced by Phase1Initialization().

Variable Documentation

◆ CmCSDVersionString

UNICODE_STRING CmCSDVersionString

◆ CmNtCSDReleaseType

ULONG CmNtCSDReleaseType

Definition at line 57 of file init.c.

Referenced by ExpInitializeExecutive().

◆ CmNtCSDVersion

ULONG CmNtCSDVersion

Definition at line 56 of file init.c.

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

◆ CmNtSpBuildNumber

ULONG CmNtSpBuildNumber

Definition at line 55 of file init.c.

Referenced by CmpSetVersionData(), and ExpInitializeExecutive().

◆ CmVersionString

UNICODE_STRING CmVersionString

Definition at line 58 of file init.c.

Referenced by CmpSetVersionData(), and ExpInitializeExecutive().

◆ ExCmosClockIsSane

BOOLEAN ExCmosClockIsSane = TRUE

Definition at line 89 of file init.c.

Referenced by KeSetSystemTime(), and Phase1InitializationDiscard().

◆ ExpAnsiCodePageDataOffset

ULONG ExpAnsiCodePageDataOffset

Definition at line 82 of file init.c.

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

◆ ExpInitializationPhase

◆ ExpInTextModeSetup

◆ ExpNlsSectionPointer

PVOID ExpNlsSectionPointer

Definition at line 86 of file init.c.

Referenced by ExpInitNls(), and MmCreatePeb().

◆ ExpNlsTableBase

PVOID ExpNlsTableBase

Definition at line 81 of file init.c.

Referenced by ExpInitializeExecutive(), and ExpInitNls().

◆ ExpNlsTableInfo

NLSTABLEINFO ExpNlsTableInfo

Definition at line 84 of file init.c.

Referenced by ExpInitializeExecutive(), and ExpInitNls().

◆ ExpNlsTableSize

SIZE_T ExpNlsTableSize

Definition at line 85 of file init.c.

Referenced by ExpInitNls().

◆ ExpOemCodePageDataOffset

ULONG ExpOemCodePageDataOffset

Definition at line 82 of file init.c.

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

◆ ExpRealTimeIsUniversal

BOOLEAN ExpRealTimeIsUniversal

Definition at line 90 of file init.c.

Referenced by Phase1InitializationDiscard().

◆ ExpUnicodeCaseTableDataOffset

ULONG ExpUnicodeCaseTableDataOffset

Definition at line 83 of file init.c.

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

◆ ExSuiteMask

ULONG ExSuiteMask

Definition at line 52 of file init.c.

Referenced by ExpInitSystemPhase0().

◆ InitIsWinPEMode

BOOLEAN InitIsWinPEMode

Definition at line 69 of file init.c.

Referenced by CmInitSystem1(), and Phase1InitializationDiscard().

◆ InitSafeBootMode

◆ InitWinPEModeType

BOOLEAN InitWinPEModeType

Definition at line 69 of file init.c.

Referenced by Phase1InitializationDiscard().

◆ IoRemoteBootClient

BOOLEAN IoRemoteBootClient

Definition at line 67 of file init.c.

Referenced by ExpInitializeExecutive(), and IopCreateArcNames().

◆ NtBuildLab

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

Definition at line 61 of file init.c.

Referenced by CmpSetVersionData(), and Phase1InitializationDiscard().

◆ NtBuildNumber

◆ NtGlobalFlag

◆ NtInitialUserProcessBuffer

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

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

Definition at line 76 of file init.c.

Referenced by ExpLoadInitialProcess().

◆ NtInitialUserProcessBufferType

ULONG NtInitialUserProcessBufferType = REG_SZ

Definition at line 78 of file init.c.

Referenced by ExpLoadInitialProcess().

◆ NtMajorVersion

ULONG NtMajorVersion = VER_PRODUCTMAJORVERSION

Definition at line 42 of file init.c.

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

◆ NtMinorVersion

ULONG NtMinorVersion = VER_PRODUCTMINORVERSION

Definition at line 43 of file init.c.

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

◆ NtSystemRoot