ReactOS  r75636
init.c File Reference
#include <ntoskrnl.h>
#include <reactos/buildno.h>
#include <debug.h>
Include dependency graph for init.c:

Go to the source code of this file.

Classes

struct  _INIT_BUFFER
 

Macros

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

Typedefs

typedef struct _INIT_BUFFER INIT_BUFFER
 
typedef struct _INIT_BUFFERPINIT_BUFFER
 

Functions

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

#define LOADER_PARAMETER_EXTENSION_MIN_SIZE   RTL_SIZEOF_THROUGH_FIELD(LOADER_PARAMETER_EXTENSION, AcpiTableSize)

Definition at line 18 of file init.c.

Referenced by ExpIsLoaderValid().

#define NDEBUG

Definition at line 14 of file init.c.

Typedef Documentation

Function Documentation

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

Definition at line 868 of file init.c.

Referenced by ExpInitializeExecutive().

871 {
872  PLIST_ENTRY ListEntry;
873  PMEMORY_ALLOCATION_DESCRIPTOR MemDescriptor;
874 
875  DPRINT1("Burn RAM amount: %lu pages\n", PagesToDestroy);
876 
877  /* Loop the memory descriptors, beginning at the end */
878  for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Blink;
879  ListEntry != &LoaderBlock->MemoryDescriptorListHead;
880  ListEntry = ListEntry->Blink)
881  {
882  /* Get the memory descriptor structure */
883  MemDescriptor = CONTAINING_RECORD(ListEntry,
885  ListEntry);
886 
887  /* Is memory free there or is it temporary? */
888  if (MemDescriptor->MemoryType == LoaderFree ||
889  MemDescriptor->MemoryType == LoaderFirmwareTemporary)
890  {
891  /* Check if the descriptor has more pages than we want */
892  if (MemDescriptor->PageCount > PagesToDestroy)
893  {
894  /* Change block's page count, ntoskrnl doesn't care much */
895  MemDescriptor->PageCount -= PagesToDestroy;
896  break;
897  }
898  else
899  {
900  /* Change block type */
901  MemDescriptor->MemoryType = MemoryType;
902  PagesToDestroy -= MemDescriptor->PageCount;
903 
904  /* Check if we are done */
905  if (PagesToDestroy == 0) break;
906  }
907  }
908  }
909 }
struct _LIST_ENTRY * Blink
Definition: typedefs.h:121
ACPI_EFI_MEMORY_TYPE MemoryType
Definition: acefiex.h:530
TYPE_OF_MEMORY MemoryType
Definition: arc.h:193
Definition: typedefs.h:118
#define DPRINT1
Definition: precomp.h:8
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
ULONG NTAPI INIT_FUNCTION ExComputeTickCountMultiplier ( IN ULONG  ClockIncrement)

Definition at line 602 of file init.c.

Referenced by ExpInitializeExecutive().

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 }
GLenum GLclampf GLint i
Definition: glfuncs.h:14
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN NTAPI INIT_FUNCTION ExInitSystem ( VOID  )

Definition at line 735 of file init.c.

Referenced by ExpInitializeExecutive(), and Phase1InitializationDiscard().

736 {
737  /* Check the initialization phase */
738  switch (ExpInitializationPhase)
739  {
740  case 0:
741 
742  /* Do Phase 0 */
743  return ExpInitSystemPhase0();
744 
745  case 1:
746 
747  /* Do Phase 1 */
748  return ExpInitSystemPhase1();
749 
750  default:
751 
752  /* Don't know any other phase! Bugcheck! */
753  KeBugCheck(UNEXPECTED_INITIALIZATION_CALL);
754  return FALSE;
755  }
756 }
#define FALSE
Definition: types.h:117
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1469
ULONG ExpInitializationPhase
Definition: init.c:65
BOOLEAN NTAPI INIT_FUNCTION ExpInitSystemPhase0(VOID)
Definition: init.c:635
BOOLEAN NTAPI INIT_FUNCTION ExpInitSystemPhase1(VOID)
Definition: init.c:658
NTSTATUS NTAPI INIT_FUNCTION ExpCreateSystemRootLink ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 97 of file init.c.

Referenced by Phase1InitializationDiscard().

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");
110  InitializeObjectAttributes(&ObjectAttributes,
111  &LinkName,
113  NULL,
115 
116  /* Create it */
117  Status = NtCreateDirectoryObject(&LinkHandle,
119  &ObjectAttributes);
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");
131  InitializeObjectAttributes(&ObjectAttributes,
132  &LinkName,
134  NULL,
136 
137  /* Create it */
138  Status = NtCreateDirectoryObject(&LinkHandle,
140  &ObjectAttributes);
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 */
160  InitializeObjectAttributes(&ObjectAttributes,
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);
175  Status = RtlAnsiStringToUnicodeString(&TargetName,
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,
187  &ObjectAttributes,
188  &TargetName);
189 
190  /* Free the strings */
191  RtlFreeUnicodeString(&LinkName);
192  RtlFreeUnicodeString(&TargetName);
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 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
Definition: bidi.c:75
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
#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:513
Definition: bufpool.h:45
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3392
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3369
WCHAR TargetName[256]
Definition: arping.c:27
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
NTSTATUS NTAPI NtCreateDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: obdir.c:731
DWORD *typedef HANDLE
Definition: winlogon.h:52
LONG NTSTATUS
Definition: DriverTester.h:11
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
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:90
PSECURITY_DESCRIPTOR SePublicDefaultUnrestrictedSd
Definition: sd.c:23
VOID NTAPI INIT_FUNCTION ExpInitializeExecutive ( IN ULONG  Cpu,
IN PLOADER_PARAMETER_BLOCK  LoaderBlock 
)

Definition at line 914 of file init.c.

Referenced by KiInitializeKernel().

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

Definition at line 209 of file init.c.

Referenced by ExpInitializeExecutive(), and Phase1InitializationDiscard().

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 }
DWORD *typedef PVOID
Definition: winlogon.h:52
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
Definition: bidi.c:75
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
uint32_t ULONG_PTR
Definition: typedefs.h:64
#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:388
#define SEC_COMMIT
Definition: mmtypes.h:99
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:513
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:4491
_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:120
NTSYSAPI VOID NTAPI RtlInitNlsTables(_In_ PUSHORT AnsiTableBase, _In_ PUSHORT OemTableBase, _In_ PUSHORT CaseTableBase, _Out_ PNLSTABLEINFO NlsTable)
PVOID ExpNlsTableBase
Definition: init.c:81
PVOID ExpNlsSectionPointer
Definition: init.c:86
POBJECT_TYPE MmSectionObjectType
Definition: section.c:136
#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:4836
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3369
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:118
Status
Definition: gdiplustypes.h:24
ULONG ExpOemCodePageDataOffset
Definition: init.c:82
ULONG_PTR SIZE_T
Definition: typedefs.h:79
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
DWORD *typedef HANDLE
Definition: winlogon.h:52
LONG NTSTATUS
Definition: DriverTester.h:11
_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 CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
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:90
LONGLONG QuadPart
Definition: typedefs.h:113
#define PAGE_READWRITE
Definition: nt_native.h:1304
BOOLEAN NTAPI INIT_FUNCTION ExpInitSystemPhase0 ( VOID  )

Definition at line 635 of file init.c.

Referenced by ExInitSystem().

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:24
#define TRUE
Definition: types.h:120
FAST_MUTEX ExpEnvironmentLock
Definition: sysinfo.c:23
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
LIST_ENTRY ExpFirmwareTableProviderListHead
Definition: sysinfo.c:25
VOID NTAPI INIT_FUNCTION ExpResourceInitialization(VOID)
Definition: resource.c:169
BOOLEAN NTAPI INIT_FUNCTION ExpInitSystemPhase1 ( VOID  )

Definition at line 658 of file init.c.

Referenced by ExInitSystem().

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  ExpInitUuids();
715 
716  /* Initialize keyed events */
718  {
719  DPRINT1("Executive: Keyed event initialization failed\n");
720  return FALSE;
721  }
722 
723  /* Initialize Win32K */
724  if (ExpWin32kInit() == FALSE)
725  {
726  DPRINT1("Executive: Win32 initialization failed\n");
727  return FALSE;
728  }
729  return TRUE;
730 }
VOID INIT_FUNCTION NTAPI ExpInitUuids(VOID)
Definition: uuid.c:51
#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
#define FALSE
Definition: types.h:117
VOID INIT_FUNCTION NTAPI ExpInitializeWorkerThreads(VOID)
Definition: work.c:520
BOOLEAN INIT_FUNCTION NTAPI ExpInitializeCallbacks(VOID)
Definition: callback.c:256
BOOLEAN NTAPI ExpInitializeKeyedEventImplementation(VOID)
BOOLEAN INIT_FUNCTION NTAPI ExpInitializeEventPairImplementation(VOID)
Definition: evtpair.c:37
BOOLEAN INIT_FUNCTION NTAPI ExpWin32kInit(VOID)
Definition: win32k.c:263
#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
VOID NTAPI INIT_FUNCTION ExpInitializePushLocks(VOID)
Definition: pushlock.c:45
BOOLEAN NTAPI INIT_FUNCTION ExpIsLoaderValid ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 761 of file init.c.

Referenced by ExpInitializeExecutive().

762 {
764 
765  /* Get the loader extension */
766  Extension = LoaderBlock->Extension;
767 
768  /* Validate the size (Windows 2003 loader doesn't provide more) */
769  if (Extension->Size < LOADER_PARAMETER_EXTENSION_MIN_SIZE) return FALSE;
770 
771  /* Don't validate upper versions */
772  if (Extension->MajorVersion > VER_PRODUCTMAJORVERSION) return TRUE;
773 
774  /* Fail if this is NT 4 */
775  if (Extension->MajorVersion < VER_PRODUCTMAJORVERSION) return FALSE;
776 
777  /* Fail if this is XP */
778  if (Extension->MinorVersion < VER_PRODUCTMINORVERSION) return FALSE;
779 
780  /* This is 2003 or newer, approve it */
781  return TRUE;
782 }
#define VER_PRODUCTMAJORVERSION
Definition: ntverp.h:25
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define VER_PRODUCTMINORVERSION
Definition: ntverp.h:26
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
#define LOADER_PARAMETER_EXTENSION_MIN_SIZE
Definition: init.c:18
VOID NTAPI INIT_FUNCTION ExpLoadBootSymbols ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 787 of file init.c.

Referenced by ExpInitializeExecutive().

788 {
789  ULONG i = 0;
790  PLIST_ENTRY NextEntry;
791  ULONG Count, Length;
792  PWCHAR Name;
793  PLDR_DATA_TABLE_ENTRY LdrEntry;
794  CHAR NameBuffer[256];
795  STRING SymbolString;
797 
798  /* Loop the driver list */
799  NextEntry = LoaderBlock->LoadOrderListHead.Flink;
800  while (NextEntry != &LoaderBlock->LoadOrderListHead)
801  {
802  /* Skip the first two images */
803  if (i >= 2)
804  {
805  /* Get the entry */
806  LdrEntry = CONTAINING_RECORD(NextEntry,
808  InLoadOrderLinks);
809  if (LdrEntry->FullDllName.Buffer[0] == L'\\')
810  {
811  /* We have a name, read its data */
812  Name = LdrEntry->FullDllName.Buffer;
813  Length = LdrEntry->FullDllName.Length / sizeof(WCHAR);
814 
815  /* Check if our buffer can hold it */
816  if (sizeof(NameBuffer) < Length + sizeof(ANSI_NULL))
817  {
818  /* It's too long */
819  Status = STATUS_BUFFER_OVERFLOW;
820  }
821  else
822  {
823  /* Copy the name */
824  Count = 0;
825  do
826  {
827  /* Copy the character */
828  NameBuffer[Count++] = (CHAR)*Name++;
829  } while (Count < Length);
830 
831  /* Null-terminate */
832  NameBuffer[Count] = ANSI_NULL;
833  Status = STATUS_SUCCESS;
834  }
835  }
836  else
837  {
838  /* Safely print the string into our buffer */
839  Status = RtlStringCbPrintfA(NameBuffer,
840  sizeof(NameBuffer),
841  "%S\\System32\\Drivers\\%wZ",
842  &SharedUserData->NtSystemRoot[2],
843  &LdrEntry->BaseDllName);
844  }
845 
846  /* Check if the buffer was ok */
847  if (NT_SUCCESS(Status))
848  {
849  /* Initialize the STRING for the debugger */
850  RtlInitString(&SymbolString, NameBuffer);
851 
852  /* Load the symbols */
853  DbgLoadImageSymbols(&SymbolString,
854  LdrEntry->DllBase,
856  }
857  }
858 
859  /* Go to the next entry */
860  i++;
861  NextEntry = NextEntry->Flink;
862  }
863 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
Definition: bidi.c:75
char CHAR
Definition: xmlstorage.h:175
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
uint16_t * PWCHAR
Definition: typedefs.h:55
#define WCHAR
Definition: msvc.h:43
uint32_t ULONG_PTR
Definition: typedefs.h:64
PVOID DllBase
Definition: ldrtypes.h:139
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define ANSI_NULL
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
std::wstring STRING
Definition: fontsub.cpp:33
_In_ PUNICODE_STRING Name
Definition: mrx.h:218
#define SharedUserData
VOID UINTN Length
Definition: acefiex.h:744
Definition: ntddk_ex.h:202
Definition: typedefs.h:118
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
UNICODE_STRING FullDllName
Definition: ldrtypes.h:142
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:143
HANDLE NTAPI PsGetCurrentProcessId(VOID)
Definition: process.c:1123
VOID NTAPI DbgLoadImageSymbols(_In_ PSTRING Name, _In_ PVOID Base, _In_ ULONG_PTR ProcessId)
unsigned int ULONG
Definition: retypes.h:1
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
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)
#define STATUS_BUFFER_OVERFLOW
Definition: udferr_usr.h:127
VOID NTAPI INIT_FUNCTION ExpLoadInitialProcess ( IN PINIT_BUFFER  InitBuffer,
OUT PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
OUT PCHAR ProcessEnvironment 
)

Definition at line 385 of file init.c.

Referenced by Phase1InitializationDiscard().

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);
419  ZwDisplayString(&DebugString);
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);
447  ZwDisplayString(&DebugString);
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,
508  NtInitialUserProcessBuffer,
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,
523  NtInitialUserProcessBuffer);
524 
525  /* Create the environment string */
526  RtlInitEmptyUnicodeString(&Environment,
527  ProcessParams->Environment,
528  (USHORT)Size);
529 
530  /* Append the DLL path to it */
531  RtlAppendUnicodeToString(&Environment, L"Path=");
532  RtlAppendUnicodeStringToString(&Environment, &ProcessParams->DllPath);
533  RtlAppendUnicodeStringToString(&Environment, &NullString);
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);
542  RtlAppendUnicodeStringToString(&Environment, &NullString);
543 
544  /* Append the system root to the environment */
545  RtlAppendUnicodeToString(&Environment, L"SystemRoot=");
547  RtlAppendUnicodeStringToString(&Environment, &NullString);
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);
572  ZwDisplayString(&DebugString);
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);
588  ZwDisplayString(&DebugString);
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 }
DWORD *typedef PVOID
Definition: winlogon.h:52
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:56
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
Definition: bidi.c:75
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
__wchar_t WCHAR
Definition: xmlstorage.h:180
PVOID *typedef PWSTR
Definition: winlogon.h:57
_CRTIMP int __cdecl _snwprintf(wchar_t *_Dest, size_t _Count, const wchar_t *_Format,...)
NTSYSAPI NTSTATUS NTAPI ZwDisplayString(_In_ PUNICODE_STRING DisplayString)
#define WCHAR
Definition: msvc.h:43
#define MEM_COMMIT
Definition: nt_native.h:1313
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
#define MEM_RESERVE
Definition: nt_native.h:1314
smooth NULL
Definition: ftsmooth.c:513
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
UINTN Size
Definition: acefiex.h:555
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
#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: rtltypes.h:1398
ULONG NtInitialUserProcessBufferType
Definition: init.c:78
#define PAGE_SIZE
Definition: env_spec_w32.h:49
UNICODE_STRING CommandLine
Definition: rtltypes.h:1399
Status
Definition: gdiplustypes.h:24
#define MAXULONG
Definition: typedefs.h:251
ULONG_PTR SIZE_T
Definition: typedefs.h:79
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
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:1247
ULONG NtInitialUserProcessBufferLength
Definition: init.c:76
signed char * PCHAR
Definition: retypes.h:7
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:90
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define REG_SZ
Definition: layer.c:33
BOOLEAN NTAPI MmArmInitSystem ( IN ULONG  Phase,
IN PLOADER_PARAMETER_BLOCK  LoaderBlock 
)

Definition at line 2028 of file mminit.c.

Referenced by ExpInitializeExecutive(), and Phase1InitializationDiscard().

2030 {
2031  ULONG i;
2032  BOOLEAN IncludeType[LoaderMaximum];
2033  PVOID Bitmap;
2035  PFN_NUMBER PageCount;
2036 #if DBG
2037  ULONG j;
2038  PMMPTE PointerPte, TestPte;
2039  MMPTE TempPte;
2040 #endif
2041 
2042  /* Dump memory descriptors */
2044 
2045  //
2046  // Instantiate memory that we don't consider RAM/usable
2047  // We use the same exclusions that Windows does, in order to try to be
2048  // compatible with WinLDR-style booting
2049  //
2050  for (i = 0; i < LoaderMaximum; i++) IncludeType[i] = TRUE;
2051  IncludeType[LoaderBad] = FALSE;
2052  IncludeType[LoaderFirmwarePermanent] = FALSE;
2053  IncludeType[LoaderSpecialMemory] = FALSE;
2054  IncludeType[LoaderBBTMemory] = FALSE;
2055  if (Phase == 0)
2056  {
2057  /* Count physical pages on the system */
2058  MiScanMemoryDescriptors(LoaderBlock);
2059 
2060  /* Initialize the phase 0 temporary event */
2062 
2063  /* Set all the events to use the temporary event for now */
2070 
2071  //
2072  // Define the basic user vs. kernel address space separation
2073  //
2077 
2078  /* Highest PTE and PDE based on the addresses above */
2081 #if (_MI_PAGING_LEVELS >= 3)
2082  MiHighestUserPpe = MiAddressToPpe(MmHighestUserAddress);
2083 #if (_MI_PAGING_LEVELS >= 4)
2084  MiHighestUserPxe = MiAddressToPxe(MmHighestUserAddress);
2085 #endif
2086 #endif
2087  //
2088  // Get the size of the boot loader's image allocations and then round
2089  // that region up to a PDE size, so that any PDEs we might create for
2090  // whatever follows are separate from the PDEs that boot loader might've
2091  // already created (and later, we can blow all that away if we want to).
2092  //
2097 
2098  /* Initialize session space address layout */
2100 
2101  /* Set the based section highest address */
2103 
2104 #if DBG
2105  /* The subection PTE format depends on things being 8-byte aligned */
2106  ASSERT((sizeof(CONTROL_AREA) % 8) == 0);
2107  ASSERT((sizeof(SUBSECTION) % 8) == 0);
2108 
2109  /* Prototype PTEs are assumed to be in paged pool, so check if the math works */
2110  PointerPte = (PMMPTE)MmPagedPoolStart;
2111  MI_MAKE_PROTOTYPE_PTE(&TempPte, PointerPte);
2112  TestPte = MiProtoPteToPte(&TempPte);
2113  ASSERT(PointerPte == TestPte);
2114 
2115  /* Try the last nonpaged pool address */
2116  PointerPte = (PMMPTE)MI_NONPAGED_POOL_END;
2117  MI_MAKE_PROTOTYPE_PTE(&TempPte, PointerPte);
2118  TestPte = MiProtoPteToPte(&TempPte);
2119  ASSERT(PointerPte == TestPte);
2120 
2121  /* Try a bunch of random addresses near the end of the address space */
2122  PointerPte = (PMMPTE)0xFFFC8000;
2123  for (j = 0; j < 20; j += 1)
2124  {
2125  MI_MAKE_PROTOTYPE_PTE(&TempPte, PointerPte);
2126  TestPte = MiProtoPteToPte(&TempPte);
2127  ASSERT(PointerPte == TestPte);
2128  PointerPte++;
2129  }
2130 
2131  /* Subsection PTEs are always in nonpaged pool, pick a random address to try */
2132  PointerPte = (PMMPTE)0xFFAACBB8;
2133  MI_MAKE_SUBSECTION_PTE(&TempPte, PointerPte);
2134  TestPte = MiSubsectionPteToSubsection(&TempPte);
2135  ASSERT(PointerPte == TestPte);
2136 #endif
2137 
2138  /* Loop all 8 standby lists */
2139  for (i = 0; i < 8; i++)
2140  {
2141  /* Initialize them */
2146  }
2147 
2148  /* Initialize the user mode image list */
2150 
2151  /* Initialize critical section timeout value (relative time is negative) */
2153 
2154  /* Initialize the paged pool mutex and the section commit mutex */
2158 
2159  /* Initialize the Loader Lock */
2161 
2162  /* Set the zero page event */
2165 
2166  /* Initialize the dead stack S-LIST */
2168 
2169  //
2170  // Check if this is a machine with less than 19MB of RAM
2171  //
2172  PageCount = MmNumberOfPhysicalPages;
2173  if (PageCount < MI_MIN_PAGES_FOR_SYSPTE_TUNING)
2174  {
2175  //
2176  // Use the very minimum of system PTEs
2177  //
2178  MmNumberOfSystemPtes = 7000;
2179  }
2180  else
2181  {
2182  //
2183  // Use the default
2184  //
2185  MmNumberOfSystemPtes = 11000;
2186  if (PageCount > MI_MIN_PAGES_FOR_SYSPTE_BOOST)
2187  {
2188  //
2189  // Double the amount of system PTEs
2190  //
2191  MmNumberOfSystemPtes <<= 1;
2192  }
2193  if (PageCount > MI_MIN_PAGES_FOR_SYSPTE_BOOST_BOOST)
2194  {
2195  //
2196  // Double the amount of system PTEs
2197  //
2198  MmNumberOfSystemPtes <<= 1;
2199  }
2200  if (MmSpecialPoolTag != 0 && MmSpecialPoolTag != -1)
2201  {
2202  //
2203  // Add some extra PTEs for special pool
2204  //
2205  MmNumberOfSystemPtes += 0x6000;
2206  }
2207  }
2208 
2209  DPRINT("System PTE count has been tuned to %lu (%lu bytes)\n",
2211 
2212  /* Check if no values are set for the heap limits */
2213  if (MmHeapSegmentReserve == 0)
2214  {
2215  MmHeapSegmentReserve = 2 * _1MB;
2216  }
2217 
2218  if (MmHeapSegmentCommit == 0)
2219  {
2221  }
2222 
2224  {
2226  }
2227 
2229  {
2231  }
2232 
2233  /* Initialize the working set lock */
2235 
2236  /* Set commit limit */
2237  MmTotalCommitLimit = 2 * _1GB;
2239 
2240  /* Has the allocation fragment been setup? */
2241  if (!MmAllocationFragment)
2242  {
2243  /* Use the default value */
2245  if (PageCount < ((256 * _1MB) / PAGE_SIZE))
2246  {
2247  /* On memory systems with less than 256MB, divide by 4 */
2249  }
2250  else if (PageCount < (_1GB / PAGE_SIZE))
2251  {
2252  /* On systems with less than 1GB, divide by 2 */
2254  }
2255  }
2256  else
2257  {
2258  /* Convert from 1KB fragments to pages */
2261 
2262  /* Don't let it past the maximum */
2265 
2266  /* Don't let it too small either */
2269  }
2270 
2271  /* Check for kernel stack size that's too big */
2273  {
2274  /* Sanitize to default value */
2276  }
2277  else
2278  {
2279  /* Take the registry setting, and convert it into bytes */
2281 
2282  /* Now align it to a page boundary */
2284 
2285  /* Sanity checks */
2287  ASSERT((MmLargeStackSize & (PAGE_SIZE - 1)) == 0);
2288 
2289  /* Make sure it's not too low */
2291  }
2292 
2293  /* Compute color information (L2 cache-separated paging lists) */
2295 
2296  // Calculate the number of bytes for the PFN database
2297  // then add the color tables and convert to pages
2298  MxPfnAllocation = (MmHighestPhysicalPage + 1) * sizeof(MMPFN);
2301 
2302  // We have to add one to the count here, because in the process of
2303  // shifting down to the page size, we actually ended up getting the
2304  // lower aligned size (so say, 0x5FFFF bytes is now 0x5F pages).
2305  // Later on, we'll shift this number back into bytes, which would cause
2306  // us to end up with only 0x5F000 bytes -- when we actually want to have
2307  // 0x60000 bytes.
2308  MxPfnAllocation++;
2309 
2310  /* Initialize the platform-specific parts */
2311  MiInitMachineDependent(LoaderBlock);
2312 
2313  //
2314  // Build the physical memory block
2315  //
2317  IncludeType);
2318 
2319  //
2320  // Allocate enough buffer for the PFN bitmap
2321  // Align it up to a 32-bit boundary
2322  //
2324  (((MmHighestPhysicalPage + 1) + 31) / 32) * 4,
2325  TAG_MM);
2326  if (!Bitmap)
2327  {
2328  //
2329  // This is critical
2330  //
2331  KeBugCheckEx(INSTALL_MORE_MEMORY,
2335  0x101);
2336  }
2337 
2338  //
2339  // Initialize it and clear all the bits to begin with
2340  //
2342  Bitmap,
2345 
2346  //
2347  // Loop physical memory runs
2348  //
2349  for (i = 0; i < MmPhysicalMemoryBlock->NumberOfRuns; i++)
2350  {
2351  //
2352  // Get the run
2353  //
2354  Run = &MmPhysicalMemoryBlock->Run[i];
2355  DPRINT("PHYSICAL RAM [0x%08p to 0x%08p]\n",
2356  Run->BasePage << PAGE_SHIFT,
2357  (Run->BasePage + Run->PageCount) << PAGE_SHIFT);
2358 
2359  //
2360  // Make sure it has pages inside it
2361  //
2362  if (Run->PageCount)
2363  {
2364  //
2365  // Set the bits in the PFN bitmap
2366  //
2368  }
2369  }
2370 
2371  /* Look for large page cache entries that need caching */
2373 
2374  /* Loop for HAL Heap I/O device mappings that need coherency tracking */
2376 
2377  /* Set the initial resident page count */
2379 
2380  /* Initialize large page structures on PAE/x64, and MmProcessList on x86 */
2382 
2383  /* Check if the registry says any drivers should be loaded with large pages */
2385 
2386  /* Relocate the boot drivers into system PTE space and fixup their PFNs */
2387  MiReloadBootLoadedDrivers(LoaderBlock);
2388 
2389  /* FIXME: Call out into Driver Verifier for initialization */
2390 
2391  /* Check how many pages the system has */
2392  if (MmNumberOfPhysicalPages <= ((13 * _1MB) / PAGE_SIZE))
2393  {
2394  /* Set small system */
2397  }
2398  else if (MmNumberOfPhysicalPages <= ((19 * _1MB) / PAGE_SIZE))
2399  {
2400  /* Set small system and add 100 pages for the cache */
2402  MmSystemCacheWsMinimum += 100;
2404  }
2405  else
2406  {
2407  /* Set medium system and add 400 pages for the cache */
2409  MmSystemCacheWsMinimum += 400;
2411  }
2412 
2413  /* Check for less than 24MB */
2414  if (MmNumberOfPhysicalPages < ((24 * _1MB) / PAGE_SIZE))
2415  {
2416  /* No more than 32 pages */
2418  }
2419 
2420  /* Check for more than 32MB */
2421  if (MmNumberOfPhysicalPages >= ((32 * _1MB) / PAGE_SIZE))
2422  {
2423  /* Check for product type being "Wi" for WinNT */
2424  if (MmProductType == '\0i\0W')
2425  {
2426  /* Then this is a large system */
2428  }
2429  else
2430  {
2431  /* For servers, we need 64MB to consider this as being large */
2432  if (MmNumberOfPhysicalPages >= ((64 * _1MB) / PAGE_SIZE))
2433  {
2434  /* Set it as large */
2436  }
2437  }
2438  }
2439 
2440  /* Check for more than 33 MB */
2441  if (MmNumberOfPhysicalPages > ((33 * _1MB) / PAGE_SIZE))
2442  {
2443  /* Add another 500 pages to the cache */
2444  MmSystemCacheWsMinimum += 500;
2445  }
2446 
2447  /* Now setup the shared user data fields */
2448  ASSERT(SharedUserData->NumberOfPhysicalPages == 0);
2449  SharedUserData->NumberOfPhysicalPages = MmNumberOfPhysicalPages;
2450  SharedUserData->LargePageMinimum = 0;
2451 
2452  /* Check for workstation (Wi for WinNT) */
2453  if (MmProductType == '\0i\0W')
2454  {
2455  /* Set Windows NT Workstation product type */
2456  SharedUserData->NtProductType = NtProductWinNt;
2457  MmProductType = 0;
2458  }
2459  else
2460  {
2461  /* Check for LanMan server (La for LanmanNT) */
2462  if (MmProductType == '\0a\0L')
2463  {
2464  /* This is a domain controller */
2465  SharedUserData->NtProductType = NtProductLanManNt;
2466  }
2467  else
2468  {
2469  /* Otherwise it must be a normal server (Se for ServerNT) */
2470  SharedUserData->NtProductType = NtProductServer;
2471  }
2472 
2473  /* Set the product type, and make the system more aggressive with low memory */
2474  MmProductType = 1;
2475  MmMinimumFreePages = 81;
2476  }
2477 
2478  /* Update working set tuning parameters */
2480 
2481  /* Finetune the page count by removing working set and NP expansion */
2485  if (MmResidentAvailablePages <= 0)
2486  {
2487  /* This should not happen */
2488  DPRINT1("System cache working set too big\n");
2489  return FALSE;
2490  }
2491 
2492  /* Initialize the system cache */
2493  //MiInitializeSystemCache(MmSystemCacheWsMinimum, MmAvailablePages);
2494 
2495  /* Update the commit limit */
2497  if (MmTotalCommitLimit > 1024) MmTotalCommitLimit -= 1024;
2499 
2500  /* Size up paged pool and build the shadow system page directory */
2501  MiBuildPagedPool();
2502 
2503  /* Debugger physical memory support is now ready to be used */
2505 
2506  /* Initialize the loaded module list */
2507  MiInitializeLoadedModuleList(LoaderBlock);
2508  }
2509 
2510  //
2511  // Always return success for now
2512  //
2513  return TRUE;
2514 }
DWORD *typedef PVOID
Definition: winlogon.h:52
MMSUPPORT MmSystemCacheWs
Definition: mminit.c:245
PFN_NUMBER MmResidentAvailableAtInit
Definition: freelist.c:28
PFN_NUMBER MmResidentAvailablePages
Definition: freelist.c:27
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define max(a, b)
Definition: svc.c:63
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
SIZE_T MmHeapDeCommitTotalFreeThreshold
Definition: mminit.c:367
#define TRUE
Definition: types.h:120
VOID NTAPI INIT_FUNCTION MiSyncCachedRanges(VOID)
Definition: largepag.c:54
MMPFNLIST MmStandbyPageListByPriority[8]
Definition: pfnlist.c:44
#define MI_MIN_PAGES_FOR_SYSPTE_BOOST
Definition: mm.h:46
#define LL
Definition: tui.h:72
#define MI_DEFAULT_SYSTEM_RANGE_START
Definition: mm.h:10
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
NTSTATUS NTAPI INIT_FUNCTION MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:675
#define MI_MIN_PAGES_FOR_SYSPTE_BOOST_BOOST
Definition: mm.h:47
#define MI_MAX_ALLOCATION_FRAGMENT
Definition: mm.h:62
#define MiAddressToPde(x)
Definition: mmx86.c:20
#define MI_NONPAGED_POOL_END
Definition: mm.h:23
KGUARDED_MUTEX MmSectionBasedMutex
Definition: section.c:110
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
struct _MMCOLOR_TABLES MMCOLOR_TABLES
BOOLEAN NTAPI MiInitializeLoadedModuleList(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: sysldr.c:2188
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:368
PFN_COUNT MmNumberOfPhysicalPages
Definition: mminit.c:212
BOOLEAN MiDbgEnableMdDump
Definition: mminit.c:372
PFN_NUMBER PageCount
Definition: miarm.h:396
ULONG MmCritsectTimeoutSeconds
Definition: mminit.c:386
PKEVENT MiLowPagedPoolEvent
Definition: mminit.c:293
SIZE_T MmTotalCommitLimitMaximum
Definition: mminit.c:359
ULONG MmLargeStackSize
Definition: mminit.c:261
VOID NTAPI MiScanMemoryDescriptors(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:393
#define _1KB
Definition: miarm.h:12
#define KERNEL_LARGE_STACK_SIZE
PMMPTE FORCEINLINE MiAddressToPpe(PVOID Address)
Definition: mm.h:138
PFN_COUNT MiExpansionPoolPagesInitialCharge
Definition: pool.c:21
PHYSICAL_MEMORY_RUN Run[1]
Definition: miarm.h:403
PFN_NUMBER MmAvailablePages
Definition: freelist.c:26
KMUTANT MmSystemLoadLock
Definition: sysldr.c:39
PFN_NUMBER MmSystemCacheWsMinimum
Definition: mminit.c:335
#define PAGE_ROUND_UP(x)
Definition: scsiport_int.h:13
PFN_NUMBER Flink
Definition: mm.h:369
PKEVENT MiHighPagedPoolEvent
Definition: mminit.c:294
VOID NTAPI INIT_FUNCTION MiInitializeLargePageSupport(VOID)
Definition: largepag.c:34
uint32_t ULONG_PTR
Definition: typedefs.h:64
PFN_NUMBER MxPfnAllocation
Definition: mminit.c:187
#define MI_USER_PROBE_ADDRESS
Definition: mm.h:9
PFN_NUMBER MmLowestPhysicalPage
Definition: mminit.c:211
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#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
#define TAG_MM
Definition: tag.h:136
#define FALSE
Definition: types.h:117
PFN_NUMBER BasePage
Definition: miarm.h:395
Definition: arc.h:130
PFN_NUMBER Blink
Definition: mm.h:370
VOID NTAPI INIT_FUNCTION MiInitializeSessionSpaceLayout(VOID)
Definition: init.c:65
PVOID MmHighestUserAddress
Definition: mminit.c:229
SIZE_T MmBootImageSize
Definition: mminit.c:222
FORCEINLINE VOID MI_MAKE_SUBSECTION_PTE(IN PMMPTE NewPte, IN PVOID Segment)
Definition: mm.h:245
#define MiProtoPteToPte(x)
Definition: mm.h:234
PVOID MmSystemRangeStart
Definition: mminit.c:230
KEVENT MmZeroingPageEvent
Definition: zeropage.c:21
void DPRINT(...)
Definition: polytest.cpp:61
#define ExInitializePushLock
Definition: ex.h:943
PPHYSICAL_MEMORY_DESCRIPTOR NTAPI INIT_FUNCTION MmInitializeMemoryLimits(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PBOOLEAN IncludeType)
Definition: mminit.c:1612
PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock
Definition: mminit.c:206
PLOADER_PARAMETER_BLOCK KeLoaderBlock
Definition: krnlinit.c:29
ULONG_PTR LoaderPagesSpanned
Definition: arc.h:356
VOID NTAPI INIT_FUNCTION MiBuildPagedPool(VOID)
Definition: mminit.c:1741
#define MM_EMPTY_LIST
Definition: mm.h:78
PMMPTE MiHighestUserPte
Definition: mminit.c:233
SIZE_T MmTotalCommitLimit
Definition: mminit.c:358
PMMPTE MmDebugPte
Definition: mmdbg.c:33
NTSYSAPI void WINAPI RtlClearAllBits(PRTL_BITMAP)
VOID NTAPI INIT_FUNCTION MiAdjustWorkingSetManagerParameters(IN BOOLEAN Client)
Definition: mminit.c:1193
#define PDE_MAPPED_VA
Definition: miarm.h:20
unsigned char BOOLEAN
ULONG_PTR MmUserProbeAddress
Definition: mminit.c:228
EX_PUSH_LOCK WorkingSetMutex
Definition: mmtypes.h:935
PFN_COUNT MmNumberOfSystemPtes
Definition: mminit.c:181
SIZE_T MmHeapDeCommitFreeBlockThreshold
Definition: mminit.c:368
#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:296
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:75
#define KERNEL_STACK_SIZE
PVOID MmPagedPoolStart
Definition: mminit.c:104
PVOID MmHighSectionBase
Definition: section.c:111
struct tagRun Run
LIST_ENTRY MmLoadedUserImageList
Definition: sysldr.c:35
#define MiSubsectionPteToSubsection(x)
Definition: mm.h:240
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define SharedUserData
PKEVENT MiLowMemoryEvent
Definition: mminit.c:291
KEVENT MiTempEvent
Definition: mminit.c:288
MM_SYSTEMSIZE MmSystemSize
Definition: mminit.c:325
SIZE_T MmHeapSegmentReserve
Definition: mminit.c:365
RTL_BITMAP MiPfnBitMap
Definition: mminit.c:201
LARGE_INTEGER MmCriticalSectionTimeout
Definition: mminit.c:387
SLIST_HEADER MmDeadStackSListHead
Definition: procsup.c:23
Definition: mm.h:301
PMMPTE FORCEINLINE MiAddressToPxe(PVOID Address)
Definition: mm.h:148
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define _1MB
Definition: miarm.h:13
#define MI_MIN_PAGES_FOR_SYSPTE_TUNING
Definition: mm.h:45
PKEVENT MiLowNonPagedPoolEvent
Definition: mminit.c:295
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define ROUND_TO_PAGES(Size)
FORCEINLINE VOID MI_MAKE_PROTOTYPE_PTE(IN PMMPTE NewPte, IN PMMPTE PointerPte)
Definition: mm.h:253
PFN_NUMBER Total
Definition: mm.h:367
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
SIZE_T MmHeapSegmentCommit
Definition: mminit.c:366
VOID NTAPI INIT_FUNCTION MiInitializeDriverLargePageList(VOID)
Definition: largepag.c:68
VOID NTAPI INIT_FUNCTION MiAddHalIoMappings(VOID)
Definition: mminit.c:1408
#define min(a, b)
Definition: monoChain.cc:55
VOID NTAPI INIT_FUNCTION MiComputeColorInformation(VOID)
Definition: mminit.c:498
VOID NTAPI MiReloadBootLoadedDrivers(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: sysldr.c:1673
#define DPRINT1
Definition: precomp.h:8
ULONG MmMaximumDeadKernelStacks
Definition: procsup.c:22
ULONG MmProductType
Definition: mminit.c:324
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI INIT_FUNCTION MiDbgDumpMemoryDescriptors(VOID)
Definition: mminit.c:1976
#define ULONG_PTR
Definition: config.h:101
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
KGUARDED_MUTEX MmPagedPoolMutex
Definition: pool.c:24
#define MI_ALLOCATION_FRAGMENT
Definition: mm.h:61
KGUARDED_MUTEX MmSectionCommitMutex
Definition: section.c:108
#define MI_MIN_ALLOCATION_FRAGMENT
Definition: mm.h:60
PKEVENT MiHighMemoryEvent
Definition: mminit.c:292
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:90
PFN_NUMBER MmMinimumFreePages
Definition: mminit.c:313
LONGLONG QuadPart
Definition: typedefs.h:113
#define _1GB
Definition: miarm.h:14
WINBASEAPI VOID WINAPI InitializeSListHead(_Out_ PSLIST_HEADER ListHead)
Definition: rtlfuncs.h:3353
ULONG MmSecondaryColors
Definition: mminit.c:255
SIZE_T MmAllocationFragment
Definition: mminit.c:351
VOID NTAPI MmFreeLoaderBlock ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 1083 of file mminit.c.

Referenced by Phase1InitializationDiscard().

1084 {
1085  PLIST_ENTRY NextMd;
1087  ULONG_PTR i;
1088  PFN_NUMBER BasePage, LoaderPages;
1089  PMMPFN Pfn1;
1090  KIRQL OldIrql;
1092 
1093  /* Loop the descriptors in order to count them */
1094  i = 0;
1095  NextMd = LoaderBlock->MemoryDescriptorListHead.Flink;
1096  while (NextMd != &LoaderBlock->MemoryDescriptorListHead)
1097  {
1098  MdBlock = CONTAINING_RECORD(NextMd,
1100  ListEntry);
1101  i++;
1102  NextMd = MdBlock->ListEntry.Flink;
1103  }
1104 
1105  /* Allocate a structure to hold the physical runs */
1107  i * sizeof(PHYSICAL_MEMORY_RUN),
1108  'lMmM');
1109  ASSERT(Buffer != NULL);
1110  Entry = Buffer;
1111 
1112  /* Loop the descriptors again */
1113  NextMd = LoaderBlock->MemoryDescriptorListHead.Flink;
1114  while (NextMd != &LoaderBlock->MemoryDescriptorListHead)
1115  {
1116  /* Check what kind this was */
1117  MdBlock = CONTAINING_RECORD(NextMd,
1119  ListEntry);
1120  switch (MdBlock->MemoryType)
1121  {
1122  /* Registry, NLS, and heap data */
1123  case LoaderRegistryData:
1124  case LoaderOsloaderHeap:
1125  case LoaderNlsData:
1126  /* Are all a candidate for deletion */
1127  Entry->BasePage = MdBlock->BasePage;
1128  Entry->PageCount = MdBlock->PageCount;
1129  Entry++;
1130 
1131  /* We keep the rest */
1132  default:
1133  break;
1134  }
1135 
1136  /* Move to the next descriptor */
1137  NextMd = MdBlock->ListEntry.Flink;
1138  }
1139 
1140  /* Acquire the PFN lock */
1142 
1143  /* Loop the runs */
1144  LoaderPages = 0;
1145  while (--Entry >= Buffer)
1146  {
1147  /* See how many pages are in this run */
1148  i = Entry->PageCount;
1149  BasePage = Entry->BasePage;
1150 
1151  /* Loop each page */
1152  Pfn1 = MiGetPfnEntry(BasePage);
1153  while (i--)
1154  {
1155  /* Check if it has references or is in any kind of list */
1156  if (!(Pfn1->u3.e2.ReferenceCount) && (!Pfn1->u1.Flink))
1157  {
1158  /* Set the new PTE address and put this page into the free list */
1159  Pfn1->PteAddress = (PMMPTE)(BasePage << PAGE_SHIFT);
1160  MiInsertPageInFreeList(BasePage);
1161  LoaderPages++;
1162  }
1163  else if (BasePage)
1164  {
1165  /* It has a reference, so simply drop it */
1167 
1168  /* Drop a dereference on this page, which should delete it */
1169  Pfn1->PteAddress->u.Long = 0;
1170  MI_SET_PFN_DELETED(Pfn1);
1171  MiDecrementShareCount(Pfn1, BasePage);
1172  LoaderPages++;
1173  }
1174 
1175  /* Move to the next page */
1176  Pfn1++;
1177  BasePage++;
1178  }
1179  }
1180 
1181  /* Release the PFN lock and flush the TLB */
1182  DPRINT("Loader pages freed: %lx\n", LoaderPages);
1184  KeFlushCurrentTb();
1185 
1186  /* Free our run structure */
1187  ExFreePoolWithTag(Buffer, 'lMmM');
1188 }
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
union _MMPFN::@1576 u1
VOID NTAPI MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:604
struct _Entry Entry
Definition: kefuncs.h:640
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
PFN_NUMBER PageCount
Definition: miarm.h:396
PFN_NUMBER Flink
Definition: mm.h:305
uint32_t ULONG_PTR
Definition: typedefs.h:64
UCHAR KIRQL
Definition: env_spec_w32.h:591
TYPE_OF_MEMORY MemoryType
Definition: arc.h:193
GLenum GLclampf GLint i
Definition: glfuncs.h:14
ULONG PFN_NUMBER
Definition: ke.h:8
#define FALSE
Definition: types.h:117
PFN_NUMBER BasePage
Definition: miarm.h:395
smooth NULL
Definition: ftsmooth.c:513
PVOID FORCEINLINE MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:185
void DPRINT(...)
Definition: polytest.cpp:61
VOID NTAPI MiDecrementShareCount(IN PMMPFN Pfn1, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:1133
struct _MMPFN::@1578::@1584 e2
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
struct _MMPTE * PMMPTE
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
UINTN VOID * Buffer
Definition: acefiex.h:370
#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:301
Definition: typedefs.h:118
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:873
ULONG_PTR Long
Definition: mmtypes.h:215
#define MI_SET_PFN_DELETED(x)
Definition: miarm.h:161
PMMPTE PteAddress
Definition: mm.h:314
union _MMPFN::@1578 u3
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
union _MMPTE::@2063 u
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
FORCEINLINE BOOLEAN MI_IS_PHYSICAL_ADDRESS(IN PVOID Address)
Definition: miarm.h:900
VOID NTAPI KeFlushCurrentTb(VOID)
Definition: cpu.c:332
VOID NTAPI Phase1Initialization ( IN PVOID  Context)

Definition at line 2012 of file init.c.

Referenced by PspInitPhase0().

2013 {
2014  /* Do the .INIT part of Phase 1 which we can free later */
2016 
2017  /* Jump into zero page thread */
2018  MmZeroPageThread();
2019 }
VOID NTAPI MmZeroPageThread(VOID)
Definition: zeropage.c:37
VOID NTAPI INIT_FUNCTION Phase1InitializationDiscard(IN PVOID Context)
Definition: init.c:1332
VOID NTAPI INIT_FUNCTION Phase1InitializationDiscard ( IN PVOID  Context)

Definition at line 1332 of file init.c.

Referenced by Phase1Initialization().

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

Variable Documentation

UNICODE_STRING CmCSDVersionString

Definition at line 59 of file init.c.

Referenced by CmpSetVersionData(), and PsGetVersion().

ULONG CmNtCSDReleaseType

Definition at line 57 of file init.c.

Referenced by ExpInitializeExecutive().

ULONG CmNtCSDVersion

Definition at line 56 of file init.c.

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

ULONG CmNtSpBuildNumber

Definition at line 55 of file init.c.

Referenced by CmpSetVersionData(), and ExpInitializeExecutive().

UNICODE_STRING CmVersionString

Definition at line 58 of file init.c.

Referenced by CmpSetVersionData().

BOOLEAN ExCmosClockIsSane = TRUE

Definition at line 89 of file init.c.

Referenced by KeSetSystemTime().

ULONG ExpAnsiCodePageDataOffset

Definition at line 82 of file init.c.

Referenced by MmCreatePeb().

PVOID ExpNlsSectionPointer

Definition at line 86 of file init.c.

Referenced by MmCreatePeb().

PVOID ExpNlsTableBase

Definition at line 81 of file init.c.

NLSTABLEINFO ExpNlsTableInfo

Definition at line 84 of file init.c.

SIZE_T ExpNlsTableSize

Definition at line 85 of file init.c.

Referenced by ExpInitNls().

ULONG ExpOemCodePageDataOffset

Definition at line 82 of file init.c.

Referenced by MmCreatePeb().

BOOLEAN ExpRealTimeIsUniversal

Definition at line 90 of file init.c.

ULONG ExpUnicodeCaseTableDataOffset

Definition at line 83 of file init.c.

Referenced by MmCreatePeb().

ULONG ExSuiteMask

Definition at line 52 of file init.c.

Referenced by ExpInitSystemPhase0().

BOOLEAN InitIsWinPEMode

Definition at line 69 of file init.c.

Referenced by CmInitSystem1(), and Phase1InitializationDiscard().

BOOLEAN InitWinPEModeType

Definition at line 69 of file init.c.

Referenced by Phase1InitializationDiscard().

BOOLEAN IoRemoteBootClient

Definition at line 67 of file init.c.

Referenced by ExpInitializeExecutive(), and IopCreateArcNames().

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().

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

Definition at line 75 of file init.c.

Referenced by ExpLoadInitialProcess().

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().

ULONG NtInitialUserProcessBufferType = REG_SZ

Definition at line 78 of file init.c.