ReactOS  0.4.15-dev-1389-g828d5fa
sminit.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Windows-Compatible Session Manager
3  * LICENSE: BSD 2-Clause License
4  * FILE: base/system/smss/sminit.c
5  * PURPOSE: Main SMSS Code
6  * PROGRAMMERS: Alex Ionescu
7  */
8 
9 /* INCLUDES *******************************************************************/
10 
11 #include "smss.h"
12 
13 #define NDEBUG
14 #include <debug.h>
15 
16 /* GLOBALS ********************************************************************/
17 
23 
30 
34 
39 
42 
43 #define SMSS_CHECKPOINT(x, y) \
44 { \
45  SmpInitProgressByLine = __LINE__; \
46  SmpInitReturnStatus = (y); \
47  SmpInitLastCall = (x); \
48 }
49 
50 /* REGISTRY CONFIGURATION *****************************************************/
51 
53 NTAPI
55  IN PWSTR Name,
56  IN PWCHAR Value,
58 {
60  UNICODE_STRING NameString, ValueString;
61  ANSI_STRING AnsiValueString;
62  PLIST_ENTRY NextEntry;
63 
64  /* Convert to unicode strings */
65  RtlInitUnicodeString(&NameString, Name);
66  RtlInitUnicodeString(&ValueString, Value);
67 
68  /* In case this is the first value, initialize a new list/structure */
69  RegEntry = NULL;
70 
71  /* Check if we should do a duplicate check */
72  if (Flags)
73  {
74  /* Loop the current list */
75  NextEntry = ListAddress->Flink;
76  while (NextEntry != ListAddress)
77  {
78  /* Get each entry */
80 
81  /* Check if the value name matches */
82  if (!RtlCompareUnicodeString(&RegEntry->Name, &NameString, TRUE))
83  {
84  /* Check if the value is the exact same thing */
85  if (!RtlCompareUnicodeString(&RegEntry->Value, &ValueString, TRUE))
86  {
87  /* Fail -- the same setting is being set twice */
89  }
90 
91  /* We found the list, and this isn't a duplicate value */
92  break;
93  }
94 
95  /* This wasn't a match, keep going */
96  NextEntry = NextEntry->Flink;
97  RegEntry = NULL;
98  }
99  }
100 
101  /* Are we adding on, or creating a new entry */
102  if (!RegEntry)
103  {
104  /* A new entry -- allocate it */
105  RegEntry = RtlAllocateHeap(RtlGetProcessHeap(),
106  SmBaseTag,
107  sizeof(SMP_REGISTRY_VALUE) +
108  NameString.MaximumLength);
109  if (!RegEntry) return STATUS_NO_MEMORY;
110 
111  /* Initialize the list and set all values to NULL */
113  RegEntry->AnsiValue = NULL;
114  RegEntry->Value.Buffer = NULL;
115 
116  /* Copy and initialize the value name */
117  RegEntry->Name.Buffer = (PWCHAR)(RegEntry + 1);
118  RegEntry->Name.Length = NameString.Length;
119  RegEntry->Name.MaximumLength = NameString.MaximumLength;
120  RtlCopyMemory(RegEntry->Name.Buffer,
121  NameString.Buffer,
122  NameString.MaximumLength);
123 
124  /* Add this entry into the list */
125  InsertTailList(ListAddress, &RegEntry->Entry);
126  }
127 
128  /* Did we have an old value buffer? */
129  if (RegEntry->Value.Buffer)
130  {
131  /* Free it */
132  ASSERT(RegEntry->Value.Length != 0);
133  RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry->Value.Buffer);
134  }
135 
136  /* Is there no value associated? */
137  if (!Value)
138  {
139  /* We're done here */
141  return STATUS_SUCCESS;
142  }
143 
144  /* There is a value, so allocate a buffer for it */
145  RegEntry->Value.Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
146  SmBaseTag,
147  ValueString.MaximumLength);
148  if (!RegEntry->Value.Buffer)
149  {
150  /* Out of memory, undo */
152  RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry);
153  return STATUS_NO_MEMORY;
154  }
155 
156  /* Copy the value into the entry */
157  RegEntry->Value.Length = ValueString.Length;
158  RegEntry->Value.MaximumLength = ValueString.MaximumLength;
159  RtlCopyMemory(RegEntry->Value.Buffer,
160  ValueString.Buffer,
161  ValueString.MaximumLength);
162 
163  /* Now allocate memory for an ANSI copy of it */
164  RegEntry->AnsiValue = RtlAllocateHeap(RtlGetProcessHeap(),
165  SmBaseTag,
166  (ValueString.Length / sizeof(WCHAR)) +
167  sizeof(ANSI_NULL));
168  if (!RegEntry->AnsiValue)
169  {
170  /* Out of memory, undo */
171  RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry->Value.Buffer);
173  RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry);
174  return STATUS_NO_MEMORY;
175  }
176 
177  /* Convert the Unicode value string and return success */
178  RtlInitEmptyAnsiString(&AnsiValueString,
179  RegEntry->AnsiValue,
180  (ValueString.Length / sizeof(WCHAR)) +
181  sizeof(ANSI_NULL));
182  RtlUnicodeStringToAnsiString(&AnsiValueString, &ValueString, FALSE);
183  return STATUS_SUCCESS;
184 }
185 
187 NTAPI
190 {
192  UNICODE_STRING ValueString;
193  PLIST_ENTRY NextEntry;
194 
195  /* Initialize the value name sting */
196  RtlInitUnicodeString(&ValueString, ValueName);
197 
198  /* Loop the list */
199  NextEntry = List->Flink;
200  while (NextEntry != List)
201  {
202  /* Get each entry */
204 
205  /* Check if the value name matches */
206  if (!RtlCompareUnicodeString(&RegEntry->Name, &ValueString, TRUE)) break;
207 
208  /* It doesn't, move on */
209  NextEntry = NextEntry->Flink;
210  }
211 
212  /* If we looped back, return NULL, otherwise return the entry we found */
213  if (NextEntry == List) RegEntry = NULL;
214  return RegEntry;
215 }
216 
217 NTSTATUS
218 NTAPI
223  IN PVOID Context,
225 {
226  /* Make sure the value is valid */
227  if (ValueLength == sizeof(ULONG))
228  {
229  /* Read it */
231  }
232  else
233  {
234  /* Default is to protect stuff */
235  SmpProtectionMode = 1;
236  }
237 
238  /* Recreate the security descriptors to take into account security mode */
240  DPRINT("SmpProtectionMode: %lu\n", SmpProtectionMode);
241  return STATUS_SUCCESS;
242 }
243 
244 NTSTATUS
245 NTAPI
250  IN PVOID Context,
252 {
253  /* Make sure the value is valid */
254  if (ValueLength == sizeof(ULONG))
255  {
256  /* Read it */
258  }
259  else
260  {
261  /* Default is to not allow protected renames */
263  }
264 
265  DPRINT("SmpAllowProtectedRenames: %lu\n", SmpAllowProtectedRenames);
266  return STATUS_SUCCESS;
267 }
268 
269 NTSTATUS
270 NTAPI
275  IN PVOID Context,
277 {
278  PISECURITY_DESCRIPTOR SecDescriptor;
281  HANDLE DirHandle;
282  UNICODE_STRING RpcString, WindowsString, SearchString;
284 
285  /* Initialize the two strings we will be looking for */
286  RtlInitUnicodeString(&RpcString, L"\\RPC Control");
287  RtlInitUnicodeString(&WindowsString, L"\\Windows");
288 
289  /* Loop the registry data we received */
290  while (*SourceString)
291  {
292  /* Assume primary SD for most objects */
293  RtlInitUnicodeString(&SearchString, SourceString);
294  SecDescriptor = SmpPrimarySecurityDescriptor;
295 
296  /* But for these two always set the liberal descriptor */
297  if ((RtlEqualUnicodeString(&SearchString, &RpcString, TRUE)) ||
298  (RtlEqualUnicodeString(&SearchString, &WindowsString, TRUE)))
299  {
300  SecDescriptor = SmpLiberalSecurityDescriptor;
301  }
302 
303  /* Create the requested directory with the requested descriptor */
305  &SearchString,
307  OBJ_OPENIF |
309  NULL,
310  SecDescriptor);
311  DPRINT("Creating: %wZ directory\n", &SearchString);
312  Status = NtCreateDirectoryObject(&DirHandle,
315  if (!NT_SUCCESS(Status))
316  {
317  /* Failure case */
318  DPRINT1("SMSS: Unable to create %wZ object directory - Status == %lx\n",
319  &SearchString, Status);
320  }
321  else
322  {
323  /* It worked, now close the handle */
324  NtClose(DirHandle);
325  }
326 
327  /* Move to the next requested object */
329  }
330 
331  /* All done */
332  return STATUS_SUCCESS;
333 }
334 
335 NTSTATUS
336 NTAPI
341  IN PVOID Context,
343 {
344  /* Save this is into a list */
346 }
347 
348 NTSTATUS
349 NTAPI
354  IN PVOID Context,
356 {
358  static PWCHAR Canary = NULL;
359 
360  /* Check if this is the second call */
361  if (Canary)
362  {
363  /* Save the data into the list */
364  DPRINT("Renamed file: '%S' - '%S'\n", Canary, ValueData);
366  Canary = NULL;
367  }
368  else
369  {
370  /* This it the first call, do nothing until we get the second call */
371  Canary = ValueData;
373  }
374 
375  /* Return the status */
376  return Status;
377 }
378 
379 NTSTATUS
380 NTAPI
385  IN PVOID Context,
387 {
388  PWCHAR DllName;
390 
391  /* Make sure the value type is valid */
392  if ((ValueType == REG_MULTI_SZ) || (ValueType == REG_SZ))
393  {
394  /* Keep going for each DLL in the list */
395  DllName = ValueData;
396  while (*DllName)
397  {
398  /* Add this to the linked list */
399  DPRINT("Excluded DLL: %S\n", DllName);
401 
402  /* Bail out on failure or if only one DLL name was present */
403  if (!(NT_SUCCESS(Status)) || (ValueType == REG_SZ)) return Status;
404 
405  /* Otherwise, move to the next DLL name */
406  DllName += wcslen(DllName) + 1;
407  }
408  }
409 
410  /* All done */
411  return STATUS_SUCCESS;
412 }
413 
414 NTSTATUS
415 NTAPI
420  IN PVOID Context,
422 {
423  /* Save into linked list */
425 }
426 
427 NTSTATUS
428 NTAPI
430  IN PWCHAR Buffer,
431  IN ULONG Length)
432 {
434 
435  /* Allocate the buffer */
436  DllPath->Buffer = RtlAllocateHeap(RtlGetProcessHeap(), SmBaseTag, Length);
437  if (DllPath->Buffer)
438  {
439  /* Fill out the rest of the string */
440  DllPath->MaximumLength = (USHORT)Length;
441  DllPath->Length = (USHORT)Length - sizeof(UNICODE_NULL);
442 
443  /* Copy the actual path and return success */
444  RtlCopyMemory(DllPath->Buffer, Buffer, Length);
446  }
447  else
448  {
449  /* Fail with out of memory code */
451  }
452 
453  /* Return result */
454  return Status;
455 }
456 
457 NTSTATUS
458 NTAPI
463  IN PVOID Context,
465 {
466  /* Check which value is being set */
467  if (_wcsicmp(ValueName, L"DllDirectory") == 0)
468  {
469  /* This is the directory, initialize it */
470  DPRINT("KnownDll Path: %S\n", ValueData);
472  }
473  else
474  {
475  /* Add to the linked list -- this is a file */
477  }
478 }
479 
480 NTSTATUS
481 NTAPI
486  IN PVOID Context,
488 {
490  UNICODE_STRING ValueString, DataString;
491 
492  /* Convert the strings into UNICODE_STRING and set the variable defined */
493  RtlInitUnicodeString(&ValueString, ValueName);
494  RtlInitUnicodeString(&DataString, ValueData);
495  DPRINT("Setting %wZ = %wZ\n", &ValueString, &DataString);
496  Status = RtlSetEnvironmentVariable(0, &ValueString, &DataString);
497  if (!NT_SUCCESS(Status))
498  {
499  DPRINT1("SMSS: 'SET %wZ = %wZ' failed - Status == %lx\n",
500  &ValueString, &DataString, Status);
501  return Status;
502  }
503 
504  /* Check if the path is being set, and wait for the second instantiation */
505  if ((_wcsicmp(ValueName, L"Path") == 0) && (++SmpCalledConfigEnv == 2))
506  {
507  /* Allocate the path buffer */
508  SmpDefaultLibPathBuffer = RtlAllocateHeap(RtlGetProcessHeap(),
509  SmBaseTag,
510  ValueLength);
512 
513  /* Copy the data into it and create the UNICODE_STRING to hold it */
516  }
517 
518  /* All good */
519  return STATUS_SUCCESS;
520 }
521 
522 NTSTATUS
523 NTAPI
528  IN PVOID Context,
530 {
532  PWCHAR SubsystemName;
533 
534  /* Is this a required or optional subsystem? */
535  if ((_wcsicmp(ValueName, L"Required") != 0) &&
536  (_wcsicmp(ValueName, L"Optional") != 0))
537  {
538  /* It isn't, is this the PSI flag? */
539  if ((_wcsicmp(ValueName, L"PosixSingleInstance") != 0) ||
540  (ValueType != REG_DWORD))
541  {
542  /* It isn't, must be a subsystem entry, add it to the list */
543  DPRINT("Subsystem entry: %S-%S\n", ValueName, ValueData);
545  }
546 
547  /* This was the PSI flag, save it and exit */
549  return STATUS_SUCCESS;
550  }
551 
552  /* This should be one of the required/optional lists. Is the type valid? */
553  if (ValueType == REG_MULTI_SZ)
554  {
555  /* It is, get the first subsystem */
556  SubsystemName = ValueData;
557  while (*SubsystemName)
558  {
559  /* We should have already put it into the list when we found it */
560  DPRINT("Found subsystem: %S\n", SubsystemName);
561  RegEntry = SmpFindRegistryValue(EntryContext, SubsystemName);
562  if (!RegEntry)
563  {
564  /* This subsystem doesn't exist, so skip it */
565  DPRINT1("SMSS: Invalid subsystem name - %ws\n", SubsystemName);
566  }
567  else
568  {
569  /* Found it -- remove it from the main list */
571 
572  /* Figure out which list to put it in */
573  if (_wcsicmp(ValueName, L"Required") == 0)
574  {
575  /* Put it into the required list */
576  DPRINT("Required\n");
578  }
579  else
580  {
581  /* Put it into the optional list */
582  DPRINT("Optional\n");
584  }
585  }
586 
587  /* Move to the next name */
588  SubsystemName += wcslen(SubsystemName) + 1;
589  }
590  }
591 
592  /* All done! */
593  return STATUS_SUCCESS;
594 }
595 
598 {
599  {
601  0,
602  L"ProtectionMode",
603  NULL,
604  REG_DWORD,
605  NULL,
606  0
607  },
608 
609  {
612  L"AllowProtectedRenames",
613  NULL,
614  REG_DWORD,
615  NULL,
616  0
617  },
618 
619  {
621  0,
622  L"ObjectDirectories",
623  NULL,
624  REG_MULTI_SZ,
625  L"\\Windows\0\\RPC Control\0",
626  0
627  },
628 
629  {
631  0,
632  L"BootExecute",
634  REG_MULTI_SZ,
635  L"autocheck AutoChk.exe *\0",
636  0
637  },
638 
639  {
642  L"SetupExecute",
644  REG_NONE,
645  NULL,
646  0
647  },
648 
649  {
652  L"PendingFileRenameOperations",
654  REG_NONE,
655  NULL,
656  0
657  },
658 
659  {
662  L"PendingFileRenameOperations2",
664  REG_NONE,
665  NULL,
666  0
667  },
668 
669  {
671  0,
672  L"ExcludeFromKnownDlls",
674  REG_MULTI_SZ,
675  L"\0",
676  0
677  },
678 
679  {
680  NULL,
682  L"Memory Management",
683  NULL,
684  REG_NONE,
685  NULL,
686  0
687  },
688 
689  {
691  0,
692  L"PagingFiles",
694  REG_MULTI_SZ,
695  L"?:\\pagefile.sys\0",
696  0
697  },
698 
699  {
702  L"DOS Devices",
704  REG_NONE,
705  NULL,
706  0
707  },
708 
709  {
712  L"KnownDlls",
714  REG_NONE,
715  NULL,
716  0
717  },
718 
719  {
722  L"Environment",
723  NULL,
724  REG_NONE,
725  NULL,
726  0
727  },
728 
729  {
732  L"SubSystems",
734  REG_NONE,
735  NULL,
736  0
737  },
738 
739  {
742  L"Required",
744  REG_MULTI_SZ,
745  L"Debug\0Windows\0",
746  0
747  },
748 
749  {
752  L"Optional",
754  REG_NONE,
755  NULL,
756  0
757  },
758 
759  {
761  0,
762  L"Kmode",
764  REG_NONE,
765  NULL,
766  0
767  },
768 
769  {
772  L"Execute",
774  REG_NONE,
775  NULL,
776  0
777  },
778 
779  {0},
780 };
781 
782 /* FUNCTIONS ******************************************************************/
783 
784 VOID
785 NTAPI
787 {
791  HANDLE KeyHandle, LinkHandle;
793  size_t StrLength;
794  WCHAR LinkBuffer[MAX_PATH];
795  CHAR ValueBuffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 512];
796  PKEY_VALUE_PARTIAL_INFORMATION PartialInfo = (PVOID)ValueBuffer;
797  CHAR DirInfoBuffer[sizeof(OBJECT_DIRECTORY_INFORMATION) + 512];
798  POBJECT_DIRECTORY_INFORMATION DirInfo = (PVOID)DirInfoBuffer;
799 
800  /* Open the setup key */
801  RtlInitUnicodeString(&UnicodeString, L"\\Registry\\Machine\\System\\Setup");
803  &UnicodeString,
805  NULL,
806  NULL);
808  if (!NT_SUCCESS(Status))
809  {
810  DPRINT1("SMSS: Cannot open system setup key for reading: 0x%x\n", Status);
811  return;
812  }
813 
814  /* Query the system partition */
815  RtlInitUnicodeString(&UnicodeString, L"SystemPartition");
817  &UnicodeString,
819  PartialInfo,
820  sizeof(ValueBuffer),
821  &Length);
823  if (!NT_SUCCESS(Status) ||
824  ((PartialInfo->Type != REG_SZ) && (PartialInfo->Type != REG_EXPAND_SZ)))
825  {
826  DPRINT1("SMSS: Cannot query SystemPartition value (Type %lu, Status 0x%x)\n",
827  PartialInfo->Type, Status);
828  return;
829  }
830 
831  /* Initialize the system partition string */
832  RtlInitEmptyUnicodeString(&SystemPartition,
833  (PWCHAR)PartialInfo->Data,
834  PartialInfo->DataLength);
836  SystemPartition.MaximumLength,
837  &StrLength);
838  SystemPartition.Length = (USHORT)StrLength;
839 
840  /* Enumerate the directory looking for the symbolic link string */
841  RtlInitUnicodeString(&SearchString, L"SymbolicLink");
842  RtlInitEmptyUnicodeString(&LinkTarget, LinkBuffer, sizeof(LinkBuffer));
844  DirInfo,
845  sizeof(DirInfoBuffer),
846  TRUE,
847  TRUE,
848  &Context,
849  NULL);
850  if (!NT_SUCCESS(Status))
851  {
852  DPRINT1("SMSS: Cannot find drive letter for system partition\n");
853  return;
854  }
855 
856  /* Keep searching until we find it */
857  do
858  {
859  /* Is this it? */
860  if ((RtlEqualUnicodeString(&DirInfo->TypeName, &SearchString, TRUE)) &&
861  (DirInfo->Name.Length == 2 * sizeof(WCHAR)) &&
862  (DirInfo->Name.Buffer[1] == L':'))
863  {
864  /* Looks like we found it, open the link to get its target */
866  &DirInfo->Name,
869  NULL);
870  Status = NtOpenSymbolicLinkObject(&LinkHandle,
873  if (NT_SUCCESS(Status))
874  {
875  /* Open worked, query the target now */
876  Status = NtQuerySymbolicLinkObject(LinkHandle,
877  &LinkTarget,
878  NULL);
879  NtClose(LinkHandle);
880 
881  /* Check if it matches the string we had found earlier */
882  if ((NT_SUCCESS(Status)) &&
884  &LinkTarget,
885  TRUE)) ||
887  &LinkTarget,
888  TRUE)) &&
889  (LinkTarget.Buffer[SystemPartition.Length / sizeof(WCHAR)] == L'\\'))))
890  {
891  /* All done */
892  break;
893  }
894  }
895  }
896 
897  /* Couldn't find it, try again */
899  DirInfo,
900  sizeof(DirInfoBuffer),
901  TRUE,
902  FALSE,
903  &Context,
904  NULL);
905  } while (NT_SUCCESS(Status));
906  if (!NT_SUCCESS(Status))
907  {
908  DPRINT1("SMSS: Cannot find drive letter for system partition\n");
909  return;
910  }
911 
912  /* Open the setup key again, for full access this time */
914  L"\\Registry\\Machine\\Software\\Microsoft\\Windows\\CurrentVersion\\Setup");
916  &UnicodeString,
918  NULL,
919  NULL);
921  if (!NT_SUCCESS(Status))
922  {
923  DPRINT1("SMSS: Cannot open software setup key for writing: 0x%x\n",
924  Status);
925  return;
926  }
927 
928  /* Wrap up the end of the link buffer */
929  wcsncpy(LinkBuffer, DirInfo->Name.Buffer, 2);
930  LinkBuffer[2] = L'\\';
931  LinkBuffer[3] = L'\0';
932 
933  /* Now set this as the "BootDir" */
936  &UnicodeString,
937  0,
938  REG_SZ,
939  LinkBuffer,
940  4 * sizeof(WCHAR));
941  if (!NT_SUCCESS(Status))
942  {
943  DPRINT1("SMSS: couldn't write BootDir value: 0x%x\n", Status);
944  }
946 }
947 
948 NTSTATUS
949 NTAPI
951 {
953  PSID WorldSid = NULL, AdminSid = NULL, SystemSid = NULL;
954  PSID RestrictedSid = NULL, OwnerSid = NULL;
958  ULONG AclLength, SidLength;
959  PACL Acl;
961  BOOLEAN ProtectionRequired = FALSE;
962 
963  /* Check if this is the first call */
964  if (InitialCall)
965  {
966  /* Create and set the primary descriptor */
972  TRUE,
973  NULL,
974  FALSE);
976 
977  /* Create and set the liberal descriptor */
983  TRUE,
984  NULL,
985  FALSE);
987 
988  /* Create and set the \KnownDlls descriptor */
994  TRUE,
995  NULL,
996  FALSE);
998 
999  /* Create and Set the \ApiPort descriptor */
1005  TRUE,
1006  NULL,
1007  FALSE);
1009  }
1010 
1011  /* Check if protection was requested in the registry (on by default) */
1012  if (SmpProtectionMode & 1) ProtectionRequired = TRUE;
1013 
1014  /* Exit if there's nothing to do */
1015  if (!(InitialCall || ProtectionRequired)) return STATUS_SUCCESS;
1016 
1017  /* Build the world SID */
1020  0, 0, 0, 0, 0, 0, 0,
1021  &WorldSid);
1022  if (!NT_SUCCESS(Status))
1023  {
1024  WorldSid = NULL;
1025  goto Quickie;
1026  }
1027 
1028  /* Build the admin SID */
1032  0, 0, 0, 0, 0, 0,
1033  &AdminSid);
1034  if (!NT_SUCCESS(Status))
1035  {
1036  AdminSid = NULL;
1037  goto Quickie;
1038  }
1039 
1040  /* Build the owner SID */
1041  Status = RtlAllocateAndInitializeSid(&CreatorAuthority, 1,
1043  0, 0, 0, 0, 0, 0, 0,
1044  &OwnerSid);
1045  if (!NT_SUCCESS(Status))
1046  {
1047  OwnerSid = NULL;
1048  goto Quickie;
1049  }
1050 
1051  /* Build the restricted SID */
1054  0, 0, 0, 0, 0, 0, 0,
1055  &RestrictedSid);
1056  if (!NT_SUCCESS(Status))
1057  {
1058  RestrictedSid = NULL;
1059  goto Quickie;
1060  }
1061 
1062  /* Build the system SID */
1065  0, 0, 0, 0, 0, 0, 0,
1066  &SystemSid);
1067  if (!NT_SUCCESS(Status))
1068  {
1069  SystemSid = NULL;
1070  goto Quickie;
1071  }
1072 
1073  /* Now check if we're creating the core descriptors */
1074  if (!InitialCall)
1075  {
1076  /* We're skipping NextAcl so we have to do this here */
1077  SidLength = RtlLengthSid(WorldSid) + RtlLengthSid(RestrictedSid) + RtlLengthSid(AdminSid);
1078  SidLength *= 2;
1079  goto NotInitial;
1080  }
1081 
1082  /* Allocate an ACL with two ACEs with two SIDs each */
1083  SidLength = RtlLengthSid(SystemSid) + RtlLengthSid(AdminSid);
1084  AclLength = sizeof(ACL) + 2 * sizeof(ACCESS_ALLOWED_ACE) + SidLength;
1085  Acl = RtlAllocateHeap(RtlGetProcessHeap(), 0, AclLength);
1086  if (!Acl) Status = STATUS_NO_MEMORY;
1087  if (!NT_SUCCESS(Status)) goto NextAcl;
1088 
1089  /* Now build the ACL and add the two ACEs */
1096 
1097  /* Set this as the DACL */
1099  TRUE,
1100  Acl,
1101  FALSE);
1103 
1104 NextAcl:
1105  /* Allocate an ACL with 6 ACEs, two ACEs per SID */
1106  SidLength = RtlLengthSid(WorldSid) + RtlLengthSid(RestrictedSid) + RtlLengthSid(AdminSid);
1107  SidLength *= 2;
1108  AclLength = sizeof(ACL) + 6 * sizeof(ACCESS_ALLOWED_ACE) + SidLength;
1109  Acl = RtlAllocateHeap(RtlGetProcessHeap(), 0, AclLength);
1110  if (!Acl) Status = STATUS_NO_MEMORY;
1111  if (!NT_SUCCESS(Status)) goto NotInitial;
1112 
1113  /* Now build the ACL and add the six ACEs */
1128 
1129  /* Now edit the last three ACEs and make them inheritable */
1130  Status = RtlGetAce(Acl, 3, (PVOID)&Ace);
1133  Status = RtlGetAce(Acl, 4, (PVOID)&Ace);
1136  Status = RtlGetAce(Acl, 5, (PVOID)&Ace);
1139 
1140  /* Set this as the DACL */
1142  TRUE,
1143  Acl,
1144  FALSE);
1146 
1147 NotInitial:
1148  /* The initial ACLs have been created, are we also protecting objects? */
1149  if (!ProtectionRequired) goto Quickie;
1150 
1151  /* Allocate an ACL with 7 ACEs, two ACEs per SID, and one final owner ACE */
1152  SidLength += RtlLengthSid(OwnerSid);
1153  AclLength = sizeof(ACL) + 7 * sizeof (ACCESS_ALLOWED_ACE) + 2 * SidLength;
1154  Acl = RtlAllocateHeap(RtlGetProcessHeap(), 0, AclLength);
1155  if (!Acl) Status = STATUS_NO_MEMORY;
1156  if (!NT_SUCCESS(Status)) goto Quickie;
1157 
1158  /* Build the ACL and add the seven ACEs */
1175 
1176  /* Edit the last 4 ACEs to make then inheritable */
1177  Status = RtlGetAce(Acl, 3, (PVOID)&Ace);
1180  Status = RtlGetAce(Acl, 4, (PVOID)&Ace);
1183  Status = RtlGetAce(Acl, 5, (PVOID)&Ace);
1186  Status = RtlGetAce(Acl, 6, (PVOID)&Ace);
1189 
1190  /* Set this as the DACL for the primary SD */
1192  TRUE,
1193  Acl,
1194  FALSE);
1196 
1197  /* Allocate an ACL with 7 ACEs, two ACEs per SID, and one final owner ACE */
1198  AclLength = sizeof(ACL) + 7 * sizeof (ACCESS_ALLOWED_ACE) + 2 * SidLength;
1199  Acl = RtlAllocateHeap(RtlGetProcessHeap(), 0, AclLength);
1200  if (!Acl) Status = STATUS_NO_MEMORY;
1201  if (!NT_SUCCESS(Status)) goto Quickie;
1202 
1203  /* Build the ACL and add the seven ACEs */
1220 
1221  /* Edit the last 4 ACEs to make then inheritable */
1222  Status = RtlGetAce(Acl, 3, (PVOID)&Ace);
1225  Status = RtlGetAce(Acl, 4, (PVOID)&Ace);
1228  Status = RtlGetAce(Acl, 5, (PVOID)&Ace);
1231  Status = RtlGetAce(Acl, 6, (PVOID)&Ace);
1234 
1235  /* Now set this as the DACL for the liberal SD */
1237  TRUE,
1238  Acl,
1239  FALSE);
1241 
1242 Quickie:
1243  /* Cleanup the SIDs */
1244  if (OwnerSid) RtlFreeHeap(RtlGetProcessHeap(), 0, OwnerSid);
1245  if (AdminSid) RtlFreeHeap(RtlGetProcessHeap(), 0, AdminSid);
1246  if (WorldSid) RtlFreeHeap(RtlGetProcessHeap(), 0, WorldSid);
1247  if (SystemSid) RtlFreeHeap(RtlGetProcessHeap(), 0, SystemSid);
1248  if (RestrictedSid) RtlFreeHeap(RtlGetProcessHeap(), 0, RestrictedSid);
1249  return Status;
1250 }
1251 
1252 NTSTATUS
1253 NTAPI
1255 {
1256  NTSTATUS Status;
1258  SECURITY_DESCRIPTOR_CONTROL OldFlag = 0;
1261  HANDLE DirHandle;
1262  PLIST_ENTRY NextEntry, Head;
1263 
1264  /* Open the GLOBAL?? directory */
1269  NULL,
1270  NULL);
1273  &ObjectAttributes);
1274  if (!NT_SUCCESS(Status))
1275  {
1276  DPRINT1("SMSS: Unable to open %wZ directory - Status == %lx\n",
1278  return Status;
1279  }
1280 
1281  /* Loop the DOS devices */
1282  Head = &SmpDosDevicesList;
1283  while (!IsListEmpty(Head))
1284  {
1285  /* Get the entry and remove it */
1286  NextEntry = RemoveHeadList(Head);
1288 
1289  /* Initialize the attributes, and see which descriptor is being used */
1291  &RegEntry->Name,
1296  {
1297  /* Save the old flag and set it while we create this link */
1300  }
1301 
1302  /* Create the symbolic link */
1303  DPRINT("Creating symlink for %wZ to %wZ\n", &RegEntry->Name, &RegEntry->Value);
1304  Status = NtCreateSymbolicLinkObject(&DirHandle,
1307  &RegEntry->Value);
1309  {
1310  /* Make it temporary and get rid of the handle */
1311  NtMakeTemporaryObject(DirHandle);
1312  NtClose(DirHandle);
1313 
1314  /* Treat this as success, and see if we got a name back */
1316  if (RegEntry->Value.Length)
1317  {
1318  /* Create it now with this name */
1319  ObjectAttributes.Attributes &= ~OBJ_OPENIF;
1320  Status = NtCreateSymbolicLinkObject(&DirHandle,
1323  &RegEntry->Value);
1324  }
1325  }
1326 
1327  /* If we were using a security descriptor, restore the non-defaulted flag */
1328  if (ObjectAttributes.SecurityDescriptor)
1329  {
1331  }
1332 
1333  /* Print a failure if we failed to create the symbolic link */
1334  if (!NT_SUCCESS(Status))
1335  {
1336  DPRINT1("SMSS: Unable to create %wZ => %wZ symbolic link object - Status == 0x%lx\n",
1337  &RegEntry->Name,
1338  &RegEntry->Value,
1339  Status);
1340  break;
1341  }
1342 
1343  /* Close the handle */
1344  NtClose(DirHandle);
1345 
1346  /* Free this entry */
1347  if (RegEntry->AnsiValue) RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry->AnsiValue);
1348  if (RegEntry->Value.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry->Value.Buffer);
1349  RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry);
1350  }
1351 
1352  /* Return the status */
1353  return Status;
1354 }
1355 
1356 VOID
1357 NTAPI
1359  IN PCHAR ImportName)
1360 {
1361  ULONG Length = 0;
1363  PWCHAR DllName, DllValue;
1364  ANSI_STRING ImportString;
1365  UNICODE_STRING ImportUnicodeString;
1366  NTSTATUS Status;
1367 
1368  /* Skip NTDLL since it's already always mapped */
1369  if (!_stricmp(ImportName, "ntdll.dll")) return;
1370 
1371  /* Initialize our strings */
1372  RtlInitAnsiString(&ImportString, ImportName);
1373  RtlInitEmptyUnicodeString(&ImportUnicodeString, Buffer, sizeof(Buffer));
1374  Status = RtlAnsiStringToUnicodeString(&ImportUnicodeString, &ImportString, FALSE);
1375  if (!NT_SUCCESS(Status)) return;
1376 
1377  /* Loop to find the DLL file extension */
1378  while (Length < ImportUnicodeString.Length)
1379  {
1380  if (ImportUnicodeString.Buffer[Length / sizeof(WCHAR)] == L'.') break;
1381  Length += sizeof(WCHAR);
1382  }
1383 
1384  /*
1385  * Break up the values as needed; the buffer acquires the form:
1386  * "dll_name.dll\0dll_name\0"
1387  */
1388  DllValue = ImportUnicodeString.Buffer;
1389  DllName = &ImportUnicodeString.Buffer[(ImportUnicodeString.Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR)];
1390  RtlStringCbCopyNW(DllName,
1391  ImportUnicodeString.MaximumLength - (ImportUnicodeString.Length + sizeof(UNICODE_NULL)),
1392  ImportUnicodeString.Buffer, Length);
1393 
1394  /* Add the DLL to the list */
1395  SmpSaveRegistryValue(&SmpKnownDllsList, DllName, DllValue, TRUE);
1396 }
1397 
1398 NTSTATUS
1399 NTAPI
1402 {
1403  HANDLE DirFileHandle, DirHandle, SectionHandle, FileHandle, LinkHandle;
1406  NTSTATUS Status, Status1;
1407  PLIST_ENTRY NextEntry;
1409  ULONG_PTR ErrorParameters[3];
1410  UNICODE_STRING ErrorResponse;
1412  SECURITY_DESCRIPTOR_CONTROL OldFlag = 0;
1413  USHORT ImageCharacteristics;
1414 
1415  /* Initialize to NULL */
1416  DirFileHandle = NULL;
1417  DirHandle = NULL;
1418  NtPath.Buffer = NULL;
1419 
1420  /* Create the \KnownDLLs directory */
1422  Directory,
1424  NULL,
1426  Status = NtCreateDirectoryObject(&DirHandle,
1428  &ObjectAttributes);
1429  if (!NT_SUCCESS(Status))
1430  {
1431  /* Handle failure */
1432  DPRINT1("SMSS: Unable to create %wZ directory - Status == %lx\n",
1433  Directory, Status);
1434  return Status;
1435  }
1436 
1437  /* Convert the path to native format */
1438  if (!RtlDosPathNameToNtPathName_U(Path->Buffer, &NtPath, NULL, NULL))
1439  {
1440  /* Fail if this didn't work */
1441  DPRINT1("SMSS: Unable to to convert %wZ to an Nt path\n", Path);
1443  goto Quickie;
1444  }
1445 
1446  /* Open the path that was specified, which should be a directory */
1448  &NtPath,
1450  NULL,
1451  NULL);
1452  Status = NtOpenFile(&DirFileHandle,
1455  &IoStatusBlock,
1458  if (!NT_SUCCESS(Status))
1459  {
1460  /* Fail if we couldn't open it */
1461  DPRINT1("SMSS: Unable to open a handle to the KnownDll directory (%wZ)"
1462  "- Status == %lx\n",
1463  Path,
1464  Status);
1465  FileHandle = NULL;
1466  goto Quickie;
1467  }
1468 
1469  /* Temporarily hack the SD to use a default DACL for this symbolic link */
1471  {
1474  }
1475 
1476  /* Create a symbolic link to the directory in the object manager */
1477  RtlInitUnicodeString(&DestinationString, L"KnownDllPath");
1481  DirHandle,
1483  Status = NtCreateSymbolicLinkObject(&LinkHandle,
1486  Path);
1487 
1488  /* Undo the hack */
1490 
1491  /* Check if the symlink was created */
1492  if (!NT_SUCCESS(Status))
1493  {
1494  /* It wasn't, so bail out since the OS needs it to exist */
1495  DPRINT1("SMSS: Unable to create %wZ symbolic link - Status == %lx\n",
1497  LinkHandle = NULL;
1498  goto Quickie;
1499  }
1500 
1501  /* We created it permanent, we can go ahead and close the handle now */
1502  Status1 = NtClose(LinkHandle);
1503  ASSERT(NT_SUCCESS(Status1));
1504 
1505  /* Now loop the known DLLs */
1506  NextEntry = SmpKnownDllsList.Flink;
1507  while (NextEntry != &SmpKnownDllsList)
1508  {
1509  /* Get the entry and move on */
1511  NextEntry = NextEntry->Flink;
1512 
1513  DPRINT("Processing known DLL: %wZ-%wZ\n", &RegEntry->Name, &RegEntry->Value);
1514 
1515  /* Skip the entry if it's in the excluded list */
1517  RegEntry->Name.Buffer)) ||
1519  RegEntry->Value.Buffer)))
1520  {
1521  continue;
1522  }
1523 
1524  /* Open the actual file */
1526  &RegEntry->Value,
1528  DirFileHandle,
1529  NULL);
1530  Status1 = NtOpenFile(&FileHandle,
1533  &IoStatusBlock,
1537  /* If we failed, skip it */
1538  if (!NT_SUCCESS(Status1)) continue;
1539 
1540  /* Checksum it */
1543  RegEntry,
1544  &ImageCharacteristics);
1545  if (!NT_SUCCESS(Status))
1546  {
1547  /* Checksum failed, so don't even try going further -- kill SMSS */
1548  RtlInitUnicodeString(&ErrorResponse,
1549  L"Verification of a KnownDLL failed.");
1550  ErrorParameters[0] = (ULONG_PTR)&ErrorResponse;
1551  ErrorParameters[1] = Status;
1552  ErrorParameters[2] = (ULONG_PTR)&RegEntry->Value;
1553  SmpTerminate(ErrorParameters, 5, RTL_NUMBER_OF(ErrorParameters));
1554  }
1555  else if (!(ImageCharacteristics & IMAGE_FILE_DLL))
1556  {
1557  /* An invalid known DLL entry will also kill SMSS */
1558  RtlInitUnicodeString(&ErrorResponse,
1559  L"Non-DLL file included in KnownDLL list.");
1560  ErrorParameters[0] = (ULONG_PTR)&ErrorResponse;
1561  ErrorParameters[1] = STATUS_INVALID_IMPORT_OF_NON_DLL;
1562  ErrorParameters[2] = (ULONG_PTR)&RegEntry->Value;
1563  SmpTerminate(ErrorParameters, 5, RTL_NUMBER_OF(ErrorParameters));
1564  }
1565 
1566  /* Temporarily hack the SD to use a default DACL for this section */
1568  {
1571  }
1572 
1573  /* Create the section for this known DLL */
1575  &RegEntry->Value,
1576  OBJ_PERMANENT,
1577  DirHandle,
1579  Status = NtCreateSection(&SectionHandle,
1582  0,
1583  PAGE_EXECUTE,
1584  SEC_IMAGE,
1585  FileHandle);
1586 
1587  /* Undo the hack */
1589 
1590  /* Check if we created the section okay */
1591  if (NT_SUCCESS(Status))
1592  {
1593  /* We can close it now, since it's marked permanent */
1594  Status1 = NtClose(SectionHandle);
1595  ASSERT(NT_SUCCESS(Status1));
1596  }
1597  else
1598  {
1599  /* If we couldn't make it "known", that's fine and keep going */
1600  DPRINT1("SMSS: CreateSection for KnownDll %wZ failed - Status == %lx\n",
1601  &RegEntry->Value, Status);
1602  }
1603 
1604  /* Close the file since we can move on to the next one */
1605  Status1 = NtClose(FileHandle);
1606  ASSERT(NT_SUCCESS(Status1));
1607  }
1608 
1609 Quickie:
1610  /* Close both handles and free the NT path buffer */
1611  if (DirHandle)
1612  {
1613  Status1 = NtClose(DirHandle);
1614  ASSERT(NT_SUCCESS(Status1));
1615  }
1616  if (DirFileHandle)
1617  {
1618  Status1 = NtClose(DirFileHandle);
1619  ASSERT(NT_SUCCESS(Status1));
1620  }
1621  if (NtPath.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, NtPath.Buffer);
1622  return Status;
1623 }
1624 
1625 NTSTATUS
1626 NTAPI
1628 {
1629  NTSTATUS Status;
1632  PLIST_ENTRY Head, NextEntry;
1633 
1634  /* Call the internal function */
1635  RtlInitUnicodeString(&DestinationString, L"\\KnownDlls");
1637 
1638  /* Wipe out the list regardless of success */
1639  Head = &SmpKnownDllsList;
1640  while (!IsListEmpty(Head))
1641  {
1642  /* Remove this entry */
1643  NextEntry = RemoveHeadList(Head);
1644 
1645  /* Free it */
1647  RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry->AnsiValue);
1648  RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry->Value.Buffer);
1649  RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry);
1650  }
1651 
1652  /* All done */
1653  return Status;
1654 }
1655 
1656 NTSTATUS
1657 NTAPI
1659 {
1660  NTSTATUS Status;
1661  SYSTEM_BASIC_INFORMATION BasicInfo;
1662  SYSTEM_PROCESSOR_INFORMATION ProcessorInfo;
1665  HANDLE KeyHandle, KeyHandle2;
1666  PWCHAR ValueData;
1668  size_t StrLength;
1669  WCHAR ValueBuffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 512];
1670  WCHAR ValueBuffer2[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 512];
1671  PKEY_VALUE_PARTIAL_INFORMATION PartialInfo = (PVOID)ValueBuffer;
1672  PKEY_VALUE_PARTIAL_INFORMATION PartialInfo2 = (PVOID)ValueBuffer2;
1673 
1674  /* Get system basic information -- we'll need the CPU count */
1676  &BasicInfo,
1677  sizeof(BasicInfo),
1678  NULL);
1679  if (!NT_SUCCESS(Status))
1680  {
1681  /* Bail out on failure */
1682  DPRINT1("SMSS: Unable to query system basic information - %x\n", Status);
1683  return Status;
1684  }
1685 
1686  /* Get the processor information, we'll query a bunch of revision info */
1688  &ProcessorInfo,
1689  sizeof(ProcessorInfo),
1690  NULL);
1691  if (!NT_SUCCESS(Status))
1692  {
1693  /* Bail out on failure */
1694  DPRINT1("SMSS: Unable to query system processor information - %x\n", Status);
1695  return Status;
1696  }
1697 
1698  /* We'll be writing all these environment variables over here */
1700  L"\\Registry\\Machine\\System\\CurrentControlSet\\"
1701  L"Control\\Session Manager\\Environment");
1705  NULL,
1706  NULL);
1708  if (!NT_SUCCESS(Status))
1709  {
1710  /* Bail out on failure */
1711  DPRINT1("SMSS: Unable to open %wZ - %x\n", &DestinationString, Status);
1712  return Status;
1713  }
1714 
1715  /* First let's write the OS variable */
1717  ValueData = L"Windows_NT";
1718  DPRINT("Setting %wZ to %S\n", &ValueName, ValueData);
1720  &ValueName,
1721  0,
1722  REG_SZ,
1723  ValueData,
1724  (wcslen(ValueData) + 1) * sizeof(WCHAR));
1725  if (!NT_SUCCESS(Status))
1726  {
1727  DPRINT1("SMSS: Failed writing %wZ environment variable - %x\n",
1728  &ValueName, Status);
1729  NtClose(KeyHandle);
1730  return Status;
1731  }
1732 
1733  /* Next, let's write the CPU architecture variable */
1734  RtlInitUnicodeString(&ValueName, L"PROCESSOR_ARCHITECTURE");
1735  switch (ProcessorInfo.ProcessorArchitecture)
1736  {
1737  /* Pick the correct string that matches the architecture */
1739  ValueData = L"x86";
1740  break;
1741 
1743  ValueData = L"AMD64";
1744  break;
1745 
1747  ValueData = L"IA64";
1748  break;
1749 
1750  default:
1751  ValueData = L"Unknown";
1752  break;
1753  }
1754 
1755  /* Set it */
1756  DPRINT("Setting %wZ to %S\n", &ValueName, ValueData);
1758  &ValueName,
1759  0,
1760  REG_SZ,
1761  ValueData,
1762  (wcslen(ValueData) + 1) * sizeof(WCHAR));
1763  if (!NT_SUCCESS(Status))
1764  {
1765  DPRINT1("SMSS: Failed writing %wZ environment variable - %x\n",
1766  &ValueName, Status);
1767  NtClose(KeyHandle);
1768  return Status;
1769  }
1770 
1771  /* And now let's write the processor level */
1772  RtlInitUnicodeString(&ValueName, L"PROCESSOR_LEVEL");
1773  swprintf(ValueBuffer, L"%u", ProcessorInfo.ProcessorLevel);
1774  DPRINT("Setting %wZ to %S\n", &ValueName, ValueBuffer);
1776  &ValueName,
1777  0,
1778  REG_SZ,
1779  ValueBuffer,
1780  (wcslen(ValueBuffer) + 1) * sizeof(WCHAR));
1781  if (!NT_SUCCESS(Status))
1782  {
1783  DPRINT1("SMSS: Failed writing %wZ environment variable - %x\n",
1784  &ValueName, Status);
1785  NtClose(KeyHandle);
1786  return Status;
1787  }
1788 
1789  /* Now open the hardware CPU key */
1791  L"\\Registry\\Machine\\Hardware\\Description\\System\\"
1792  L"CentralProcessor\\0");
1796  NULL,
1797  NULL);
1798  Status = NtOpenKey(&KeyHandle2, KEY_READ, &ObjectAttributes);
1799  if (!NT_SUCCESS(Status))
1800  {
1801  DPRINT1("SMSS: Unable to open %wZ - %x\n", &DestinationString, Status);
1802  NtClose(KeyHandle);
1803  return Status;
1804  }
1805 
1806  /* So that we can read the identifier out of it... */
1807  RtlInitUnicodeString(&ValueName, L"Identifier");
1808  Status = NtQueryValueKey(KeyHandle2,
1809  &ValueName,
1811  PartialInfo,
1812  sizeof(ValueBuffer),
1813  &ResultLength);
1814  if (!NT_SUCCESS(Status) ||
1815  ((PartialInfo->Type != REG_SZ) && (PartialInfo->Type != REG_EXPAND_SZ)))
1816  {
1817  NtClose(KeyHandle2);
1818  NtClose(KeyHandle);
1819  DPRINT1("SMSS: Unable to read %wZ\\%wZ (Type %lu, Status 0x%x)\n",
1820  &DestinationString, &ValueName, PartialInfo->Type, Status);
1821  return Status;
1822  }
1823 
1824  /* Initialize the string so that it can be large enough
1825  * to contain both the identifier and the vendor strings. */
1826  RtlInitEmptyUnicodeString(&DestinationString,
1827  (PWCHAR)PartialInfo->Data,
1828  sizeof(ValueBuffer) -
1831  PartialInfo->DataLength,
1832  &StrLength);
1833  DestinationString.Length = (USHORT)StrLength;
1834 
1835  /* As well as the vendor... */
1836  RtlInitUnicodeString(&ValueName, L"VendorIdentifier");
1837  Status = NtQueryValueKey(KeyHandle2,
1838  &ValueName,
1840  PartialInfo2,
1841  sizeof(ValueBuffer2),
1842  &ResultLength);
1843  NtClose(KeyHandle2);
1844  if (NT_SUCCESS(Status) &&
1845  ((PartialInfo2->Type == REG_SZ) || (PartialInfo2->Type == REG_EXPAND_SZ)))
1846  {
1847  /* To combine it into a single string */
1850  L", %.*s",
1851  PartialInfo2->DataLength / sizeof(WCHAR),
1852  (PWCHAR)PartialInfo2->Data);
1854  }
1855 
1856  /* So that we can set this as the PROCESSOR_IDENTIFIER variable */
1857  RtlInitUnicodeString(&ValueName, L"PROCESSOR_IDENTIFIER");
1858  DPRINT("Setting %wZ to %wZ\n", &ValueName, &DestinationString);
1860  &ValueName,
1861  0,
1862  REG_SZ,
1865  if (!NT_SUCCESS(Status))
1866  {
1867  DPRINT1("SMSS: Failed writing %wZ environment variable - %x\n",
1868  &ValueName, Status);
1869  NtClose(KeyHandle);
1870  return Status;
1871  }
1872 
1873  /* Now let's get the processor architecture */
1874  RtlInitUnicodeString(&ValueName, L"PROCESSOR_REVISION");
1875  switch (ProcessorInfo.ProcessorArchitecture)
1876  {
1877  /* Check if this is an older Intel CPU */
1879  if ((ProcessorInfo.ProcessorRevision >> 8) == 0xFF)
1880  {
1881  /* These guys used a revision + stepping, so get the rev only */
1882  swprintf(ValueBuffer, L"%02x", ProcessorInfo.ProcessorRevision & 0xFF);
1883  _wcsupr(ValueBuffer);
1884  break;
1885  }
1886 
1887  /* Modern Intel, as well as 64-bit CPUs use a revision without stepping */
1890  swprintf(ValueBuffer, L"%04x", ProcessorInfo.ProcessorRevision);
1891  break;
1892 
1893  /* And anything else we'll just read the whole revision identifier */
1894  default:
1895  swprintf(ValueBuffer, L"%u", ProcessorInfo.ProcessorRevision);
1896  break;
1897  }
1898 
1899  /* Write the revision to the registry */
1900  DPRINT("Setting %wZ to %S\n", &ValueName, ValueBuffer);
1902  &ValueName,
1903  0,
1904  REG_SZ,
1905  ValueBuffer,
1906  (wcslen(ValueBuffer) + 1) * sizeof(WCHAR));
1907  if (!NT_SUCCESS(Status))
1908  {
1909  DPRINT1("SMSS: Failed writing %wZ environment variable - %x\n",
1910  &ValueName, Status);
1911  NtClose(KeyHandle);
1912  return Status;
1913  }
1914 
1915  /* And finally, write the number of CPUs */
1916  RtlInitUnicodeString(&ValueName, L"NUMBER_OF_PROCESSORS");
1917  swprintf(ValueBuffer, L"%d", BasicInfo.NumberOfProcessors);
1918  DPRINT("Setting %wZ to %S\n", &ValueName, ValueBuffer);
1920  &ValueName,
1921  0,
1922  REG_SZ,
1923  ValueBuffer,
1924  (wcslen(ValueBuffer) + 1) * sizeof(WCHAR));
1925  if (!NT_SUCCESS(Status))
1926  {
1927  DPRINT1("SMSS: Failed writing %wZ environment variable - %x\n",
1928  &ValueName, Status);
1929  NtClose(KeyHandle);
1930  return Status;
1931  }
1932 
1933  /* Now we need to write the safeboot option key in a different format */
1935  L"\\Registry\\Machine\\System\\CurrentControlSet\\"
1936  L"Control\\Safeboot\\Option");
1940  NULL,
1941  NULL);
1942  Status = NtOpenKey(&KeyHandle2, KEY_ALL_ACCESS, &ObjectAttributes);
1943  if (NT_SUCCESS(Status))
1944  {
1945  /* This was indeed a safeboot, so check what kind of safeboot it was */
1946  RtlInitUnicodeString(&ValueName, L"OptionValue");
1947  Status = NtQueryValueKey(KeyHandle2,
1948  &ValueName,
1950  PartialInfo,
1951  sizeof(ValueBuffer),
1952  &ResultLength);
1953  NtClose(KeyHandle2);
1954  if (NT_SUCCESS(Status) &&
1955  (PartialInfo->Type == REG_DWORD) &&
1956  (PartialInfo->DataLength >= sizeof(ULONG)))
1957  {
1958  /* Convert from the integer value to the correct specifier */
1959  RtlInitUnicodeString(&ValueName, L"SAFEBOOT_OPTION");
1960  switch (*(PULONG)PartialInfo->Data)
1961  {
1962  case 1:
1963  wcscpy(ValueBuffer, L"MINIMAL");
1964  break;
1965  case 2:
1966  wcscpy(ValueBuffer, L"NETWORK");
1967  break;
1968  case 3:
1969  wcscpy(ValueBuffer, L"DSREPAIR");
1970  break;
1971  }
1972 
1973  /* And write it in the environment! */
1974  DPRINT("Setting %wZ to %S\n", &ValueName, ValueBuffer);
1976  &ValueName,
1977  0,
1978  REG_SZ,
1979  ValueBuffer,
1980  (wcslen(ValueBuffer) + 1) * sizeof(WCHAR));
1981  if (!NT_SUCCESS(Status))
1982  {
1983  DPRINT1("SMSS: Failed writing %wZ environment variable - %x\n",
1984  &ValueName, Status);
1985  NtClose(KeyHandle);
1986  return Status;
1987  }
1988  }
1989  else
1990  {
1991  DPRINT1("SMSS: Failed to query SAFEBOOT option (Type %lu, Status 0x%x)\n",
1992  PartialInfo->Type, Status);
1993  }
1994  }
1995 
1996  /* We are all done now */
1997  NtClose(KeyHandle);
1998  return STATUS_SUCCESS;
1999 }
2000 
2001 NTSTATUS
2002 NTAPI
2004 {
2005  BOOLEAN OldState, HavePrivilege = FALSE;
2006  NTSTATUS Status;
2007  HANDLE FileHandle, OtherFileHandle;
2011  UNICODE_STRING FileString;
2012  FILE_BASIC_INFORMATION BasicInfo;
2013  FILE_DISPOSITION_INFORMATION DeleteInformation;
2015  PLIST_ENTRY Head, NextEntry;
2017  PWCHAR FileName;
2019 
2020  /* Give us access to restore any files we want */
2022  if (NT_SUCCESS(Status)) HavePrivilege = TRUE;
2023 
2024  // FIXME: Handle SFC-protected file renames!
2026  DPRINT1("SMSS: FIXME: Handle SFC-protected file renames!\n");
2027 
2028  /* Process pending files to rename */
2029  Head = &SmpFileRenameList;
2030  while (!IsListEmpty(Head))
2031  {
2032  /* Get this entry */
2033  NextEntry = RemoveHeadList(Head);
2035  DPRINT("Processing PFRO: '%wZ' / '%wZ'\n", &RegEntry->Value, &RegEntry->Name);
2036 
2037  /* Skip past the '@' marker */
2038  if (!(RegEntry->Value.Length) && (*RegEntry->Name.Buffer == L'@'))
2039  {
2040  RegEntry->Name.Length -= sizeof(UNICODE_NULL);
2041  RegEntry->Name.Buffer++;
2042  }
2043 
2044  /* Open the file for delete access */
2046  &RegEntry->Name,
2048  NULL,
2049  NULL);
2050  Status = NtOpenFile(&OtherFileHandle,
2051  DELETE | SYNCHRONIZE,
2053  &IoStatusBlock,
2056  if (!NT_SUCCESS(Status)) goto Quickie;
2057 
2058  /* Check if it's a rename or just a delete */
2059  ValueLength = RegEntry->Value.Length;
2060  if (!ValueLength)
2061  {
2062  /* Just a delete, set up the class, length and buffer */
2064  Length = sizeof(DeleteInformation);
2065  Buffer = (PFILE_RENAME_INFORMATION)&DeleteInformation;
2066 
2067  /* Set the delete disposition */
2068  DeleteInformation.DeleteFile = TRUE;
2069  }
2070  else
2071  {
2072  /* This is a rename, setup the class and length */
2075 
2076  /* Skip past the special markers */
2077  FileName = RegEntry->Value.Buffer;
2078  if ((*FileName == L'!') || (*FileName == L'@'))
2079  {
2080  FileName++;
2081  Length -= sizeof(UNICODE_NULL);
2082  }
2083 
2084  /* Now allocate the buffer for the rename information */
2085  Buffer = RtlAllocateHeap(RtlGetProcessHeap(), SmBaseTag, Length);
2086  if (Buffer)
2087  {
2088  /* Setup the buffer to point to the filename, and copy it */
2089  Buffer->RootDirectory = NULL;
2090  Buffer->FileNameLength = Length - sizeof(FILE_RENAME_INFORMATION);
2091  Buffer->ReplaceIfExists = FileName != RegEntry->Value.Buffer;
2092  RtlCopyMemory(Buffer->FileName, FileName, Buffer->FileNameLength);
2093  }
2094  else
2095  {
2096  /* Fail */
2098  }
2099  }
2100 
2101  /* Check if everything is okay till here */
2102  if (NT_SUCCESS(Status))
2103  {
2104  /* Now either rename or delete the file as requested */
2105  Status = NtSetInformationFile(OtherFileHandle,
2106  &IoStatusBlock,
2107  Buffer,
2108  Length,
2110 
2111  /* Check if we seem to have failed because the file was readonly */
2112  if (!NT_SUCCESS(Status) &&
2115  Buffer->ReplaceIfExists)
2116  {
2117  /* Open the file for write attribute access this time... */
2118  DPRINT("\nSMSS: '%wZ' => '%wZ' failed - Status == %x, Possible readonly target\n",
2119  &RegEntry->Name,
2120  &RegEntry->Value,
2122  FileString.Length = RegEntry->Value.Length - sizeof(WCHAR);
2123  FileString.MaximumLength = RegEntry->Value.MaximumLength - sizeof(WCHAR);
2124  FileString.Buffer = FileName;
2126  &FileString,
2128  NULL,
2129  NULL);
2133  &IoStatusBlock,
2136  if (!NT_SUCCESS(Status))
2137  {
2138  /* That didn't work, so bail out */
2139  DPRINT1(" SMSS: Open Existing file Failed - Status == %x\n",
2140  Status);
2141  }
2142  else
2143  {
2144  /* Now remove the read-only attribute from the file */
2145  DPRINT(" SMSS: Open Existing Success\n");
2146  RtlZeroMemory(&BasicInfo, sizeof(BasicInfo));
2149  &IoStatusBlock,
2150  &BasicInfo,
2151  sizeof(BasicInfo),
2154  if (!NT_SUCCESS(Status))
2155  {
2156  /* That didn't work, bail out */
2157  DPRINT1(" SMSS: Set To NORMAL Failed - Status == %x\n",
2158  Status);
2159  }
2160  else
2161  {
2162  /* Now that the file is no longer read-only, delete! */
2163  DPRINT(" SMSS: Set To NORMAL OK\n");
2164  Status = NtSetInformationFile(OtherFileHandle,
2165  &IoStatusBlock,
2166  Buffer,
2167  Length,
2169  if (!NT_SUCCESS(Status))
2170  {
2171  /* That failed too! */
2172  DPRINT1(" SMSS: Re-Rename Failed - Status == %x\n",
2173  Status);
2174  }
2175  else
2176  {
2177  /* Everything ok */
2178  DPRINT(" SMSS: Re-Rename Worked OK\n");
2179  }
2180  }
2181  }
2182  }
2183  }
2184 
2185  /* Close the file handle and check the operation result */
2186  NtClose(OtherFileHandle);
2187 Quickie:
2188  if (!NT_SUCCESS(Status))
2189  {
2190  /* We totally failed */
2191  DPRINT1("SMSS: '%wZ' => '%wZ' failed - Status == %x\n",
2192  &RegEntry->Name, &RegEntry->Value, Status);
2193  }
2194  else if (RegEntry->Value.Length)
2195  {
2196  /* We succeed with a rename */
2197  DPRINT("SMSS: '%wZ' (renamed to) '%wZ'\n", &RegEntry->Name, &RegEntry->Value);
2198  }
2199  else
2200  {
2201  /* We succeeded with a delete */
2202  DPRINT("SMSS: '%wZ' (deleted)\n", &RegEntry->Name);
2203  }
2204 
2205  /* Now free this entry and keep going */
2206  if (RegEntry->AnsiValue) RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry->AnsiValue);
2207  if (RegEntry->Value.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry->Value.Buffer);
2208  RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry);
2209  }
2210 
2211  /* Put back the restore privilege if we had requested it, and return */
2212  if (HavePrivilege) RtlAdjustPrivilege(SE_RESTORE_PRIVILEGE, FALSE, FALSE, &OldState);
2213  return Status;
2214 }
2215 
2216 NTSTATUS
2217 NTAPI
2219 {
2220  NTSTATUS Status;
2221  PLIST_ENTRY Head, NextEntry;
2223  PVOID OriginalEnvironment;
2224  ULONG MuSessionId = 0;
2226  HANDLE KeyHandle;
2228 
2229  /* Initialize the keywords we'll be looking for */
2233 
2234  /* Initialize all the registry-associated list heads */
2247 
2248  /* Initialize the SMSS environment */
2250  if (!NT_SUCCESS(Status))
2251  {
2252  /* Fail if there was a problem */
2253  DPRINT1("SMSS: Unable to allocate default environment - Status == %X\n",
2254  Status);
2256  return Status;
2257  }
2258 
2259  /* Check if we were booted in PE mode (LiveCD should have this) */
2261  L"\\Registry\\Machine\\System\\CurrentControlSet\\"
2262  L"Control\\MiniNT");
2266  NULL,
2267  NULL);
2269  if (NT_SUCCESS(Status))
2270  {
2271  /* If the key exists, we were */
2272  NtClose(KeyHandle);
2273  MiniNTBoot = TRUE;
2274  }
2275 
2276  /* Print out if this is the case */
2277  if (MiniNTBoot) DPRINT("SMSS: !!! MiniNT Boot !!!\n");
2278 
2279  /* Open the environment key to see if we are booted in safe mode */
2281  L"\\Registry\\Machine\\System\\CurrentControlSet\\"
2282  L"Control\\Session Manager\\Environment");
2286  NULL,
2287  NULL);
2289  if (NT_SUCCESS(Status))
2290  {
2291  /* Delete the value if we found it */
2292  RtlInitUnicodeString(&DestinationString, L"SAFEBOOT_OPTION");
2294  NtClose(KeyHandle);
2295  }
2296 
2297  /* Switch environments, then query the registry for all needed settings */
2298  OriginalEnvironment = NtCurrentPeb()->ProcessParameters->Environment;
2299  NtCurrentPeb()->ProcessParameters->Environment = SmpDefaultEnvironment;
2301  L"Session Manager",
2303  NULL,
2304  NULL);
2305  SmpDefaultEnvironment = NtCurrentPeb()->ProcessParameters->Environment;
2306  NtCurrentPeb()->ProcessParameters->Environment = OriginalEnvironment;
2307  if (!NT_SUCCESS(Status))
2308  {
2309  /* We failed somewhere in registry initialization, which is bad... */
2310  DPRINT1("SMSS: RtlQueryRegistryValues failed - Status == %lx\n", Status);
2312  return Status;
2313  }
2314 
2315  /* Now we can start acting on the registry settings. First to DOS devices */
2317  if (!NT_SUCCESS(Status))
2318  {
2319  /* Failed */
2320  DPRINT1("SMSS: Unable to initialize DosDevices configuration - Status == %lx\n",
2321  Status);
2323  return Status;
2324  }
2325 
2326  /* Next create the session directory... */
2327  RtlInitUnicodeString(&DestinationString, L"\\Sessions");
2331  NULL,
2335  &ObjectAttributes);
2336  if (!NT_SUCCESS(Status))
2337  {
2338  /* Fail */
2339  DPRINT1("SMSS: Unable to create %wZ object directory - Status == %lx\n",
2342  return Status;
2343  }
2344 
2345  /* Next loop all the boot execute binaries */
2346  Head = &SmpBootExecuteList;
2347  while (!IsListEmpty(Head))
2348  {
2349  /* Remove each one from the list */
2350  NextEntry = RemoveHeadList(Head);
2351 
2352  /* Execute it */
2354  SmpExecuteCommand(&RegEntry->Name, 0, NULL, 0);
2355 
2356  /* And free it */
2357  if (RegEntry->AnsiValue) RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry->AnsiValue);
2358  if (RegEntry->Value.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry->Value.Buffer);
2359  RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry);
2360  }
2361 
2362  /* Now do any pending file rename operations... */
2364 
2365  /* And initialize known DLLs... */
2367  if (!NT_SUCCESS(Status))
2368  {
2369  /* Fail if that didn't work */
2370  DPRINT1("SMSS: Unable to initialize KnownDll configuration - Status == %lx\n",
2371  Status);
2373  return Status;
2374  }
2375 
2376  /* Create the needed page files */
2377  if (!MiniNTBoot)
2378  {
2379  /* Loop every page file */
2380  Head = &SmpPagingFileList;
2381  while (!IsListEmpty(Head))
2382  {
2383  /* Remove each one from the list */
2384  NextEntry = RemoveHeadList(Head);
2385 
2386  /* Create the descriptor for it */
2389 
2390  /* And free it */
2391  if (RegEntry->AnsiValue) RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry->AnsiValue);
2392  if (RegEntry->Value.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry->Value.Buffer);
2393  RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry);
2394  }
2395 
2396  /* Now create all the paging files for the descriptors that we have */
2398  }
2399 
2400  /* Tell Cm it's now safe to fully enable write access to the registry */
2402 
2403  /* Create all the system-based environment variables for later inheriting */
2405  if (!NT_SUCCESS(Status))
2406  {
2407  /* Handle failure */
2409  return Status;
2410  }
2411 
2412  /* And finally load all the subsystems for our first session! */
2413  Status = SmpLoadSubSystemsForMuSession(&MuSessionId,
2415  InitialCommand);
2416  ASSERT(MuSessionId == 0);
2418  return Status;
2419 }
2420 
2421 NTSTATUS
2422 NTAPI
2423 SmpInit(IN PUNICODE_STRING InitialCommand,
2425 {
2426  NTSTATUS Status, Status2;
2428  UNICODE_STRING PortName, EventName;
2429  HANDLE EventHandle, PortHandle;
2430  ULONG HardErrorMode;
2431 
2432  /* Create the SMSS Heap */
2433  SmBaseTag = RtlCreateTagHeap(RtlGetProcessHeap(),
2434  0,
2435  L"SMSS!",
2436  L"INIT");
2437  SmpHeap = RtlGetProcessHeap();
2438 
2439  /* Enable hard errors */
2440  HardErrorMode = TRUE;
2443  &HardErrorMode,
2444  sizeof(HardErrorMode));
2445 
2446  /* Initialize the subsystem list and the session list, plus their locks */
2451 
2452  /* Initialize the process list */
2454 
2455  /* Initialize session parameters */
2456  SmpNextSessionId = 1;
2459 
2460  /* Create the initial security descriptors */
2462  if (!NT_SUCCESS(Status))
2463  {
2464  /* Fail */
2466  return Status;
2467  }
2468 
2469  /* Initialize subsystem names */
2470  RtlInitUnicodeString(&SmpSubsystemName, L"NT-Session Manager");
2471  RtlInitUnicodeString(&PosixName, L"POSIX");
2472  RtlInitUnicodeString(&Os2Name, L"OS2");
2473 
2474  /* Create the SM API Port */
2475  RtlInitUnicodeString(&PortName, L"\\SmApiPort");
2477  Status = NtCreatePort(&PortHandle,
2479  sizeof(SB_CONNECTION_INFO),
2480  sizeof(SM_API_MSG),
2481  sizeof(SB_API_MSG) * 32);
2483  SmpDebugPort = PortHandle;
2484 
2485  /* Create two SM API threads */
2487  NULL,
2488  FALSE,
2489  0,
2490  0,
2491  0,
2492  SmpApiLoop,
2493  PortHandle,
2494  NULL,
2495  NULL);
2498  NULL,
2499  FALSE,
2500  0,
2501  0,
2502  0,
2503  SmpApiLoop,
2504  PortHandle,
2505  NULL,
2506  NULL);
2508 
2509  /* Create the write event that autochk can set after running */
2510  RtlInitUnicodeString(&EventName, L"\\Device\\VolumesSafeForWriteAccess");
2512  &EventName,
2513  OBJ_PERMANENT,
2514  NULL,
2515  NULL);
2516  Status2 = NtCreateEvent(&EventHandle,
2519  0,
2520  0);
2521  if (!NT_SUCCESS(Status2))
2522  {
2523  /* Should never really fail */
2524  DPRINT1("SMSS: Unable to create %wZ event - Status == %lx\n",
2525  &EventName, Status2);
2526  ASSERT(NT_SUCCESS(Status2));
2527  }
2528 
2529  /* Now initialize everything else based on the registry parameters */
2530  Status = SmpLoadDataFromRegistry(InitialCommand);
2531  if (NT_SUCCESS(Status))
2532  {
2533  /* Autochk should've run now. Set the event and save the CSRSS handle */
2535  NtSetEvent(EventHandle, 0);
2537  }
2538 
2539  /* All done */
2540  return Status;
2541 }
HANDLE SmpDosDevicesObjectDirectory
Definition: sminit.c:26
#define CM_BOOT_FLAG_SMSS
Definition: cmtypes.h:158
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
signed char * PCHAR
Definition: retypes.h:7
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
LIST_ENTRY SmpBootExecuteList
Definition: sminit.c:19
_Must_inspect_result_ typedef _In_ PVOID Unused
Definition: iotypes.h:1149
PVOID SmpInitLastCall
Definition: sminit.c:33
#define IN
Definition: typedefs.h:39
#define GENERIC_ALL
Definition: nt_native.h:92
#define SECURITY_LOCAL_SYSTEM_RID
Definition: setypes.h:546
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
SECURITY_DESCRIPTOR SmpPrimarySDBody
Definition: sminit.c:35
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS NTAPI NtSetInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3373
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define SMSS_CHECKPOINT(x, y)
Definition: sminit.c:43
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
UNICODE_STRING PosixName
Definition: sminit.c:18
USHORT MaximumLength
Definition: env_spec_w32.h:370
NTSTATUS NTAPI SmpSaveRegistryValue(IN PLIST_ENTRY ListAddress, IN PWSTR Name, IN PWCHAR Value, IN BOOLEAN Flags)
Definition: sminit.c:54
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
PISECURITY_DESCRIPTOR SmpPrimarySecurityDescriptor
Definition: sminit.c:37
UNICODE_STRING SmpDefaultLibPath
Definition: sminit.c:28
NTSTATUS NTAPI SmpConfigureProtectionMode(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: sminit.c:219
static PSID AdminSid
Definition: msgina.c:39
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
PISECURITY_DESCRIPTOR SmpApiPortSecurityDescriptor
Definition: sminit.c:38
NTSTATUS NTAPI NtOpenDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: obdir.c:401
LIST_ENTRY SmpExcludeKnownDllsList
Definition: sminit.c:21
char CHAR
Definition: xmlstorage.h:175
#define RTL_QUERY_REGISTRY_TOPKEY
Definition: nt_native.h:129
SECURITY_DESCRIPTOR SmpKnownDllsSDBody
Definition: sminit.c:35
HANDLE SmpWindowsSubSysProcess
Definition: smsubsys.c:20
#define STATUS_OBJECT_NAME_EXISTS
Definition: ntstatus.h:114
LONG NTSTATUS
Definition: precomp.h:26
static SID_IDENTIFIER_AUTHORITY WorldAuthority
Definition: security.c:14
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define SE_RESTORE_PRIVILEGE
Definition: security.c:672
NTSTATUS NTAPI SmpConfigureKnownDlls(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: sminit.c:459
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
Definition: event.c:96
ULONG NTAPI SmpApiLoop(IN PVOID Parameter)
Definition: smloop.c:335
#define RTL_QUERY_REGISTRY_NOEXPAND
Definition: nt_native.h:139
unsigned short Length
Definition: sprintf.c:451
NTSTATUS NTAPI SmpConfigureEnvironment(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: sminit.c:482
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
LIST_ENTRY SmpDosDevicesList
Definition: sminit.c:20
LIST_ENTRY SmpPagingFileList
Definition: sminit.c:19
NTSTATUS NTAPI NtMakeTemporaryObject(IN HANDLE ObjectHandle)
Definition: oblife.c:1385
NTSYSAPI NTSTATUS NTAPI RtlGetAce(PACL Acl, ULONG AceIndex, PVOID *Ace)
NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor(_Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ ULONG Revision)
NTSTATUS NTAPI SmpInit(IN PUNICODE_STRING InitialCommand, OUT PHANDLE ProcessHandle)
Definition: sminit.c:2423
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PCUNICODE_STRING UnicodeString
Definition: wdfstring.h:64
_Must_inspect_result_ NTSTRSAFEAPI RtlStringCbLengthW(_In_reads_or_z_(cbMax/sizeof(wchar_t)) STRSAFE_LPCWSTR psz, _In_ _In_range_(1, NTSTRSAFE_MAX_CCH *sizeof(wchar_t)) size_t cbMax, _Out_opt_ _Deref_out_range_(<, cbMax - 1) size_t *pcbLength)
Definition: ntstrsafe.h:1641
uint16_t * PWCHAR
Definition: typedefs.h:56
LIST_ENTRY NativeProcessList
Definition: sminit.c:22
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define RTL_REGISTRY_CONTROL
Definition: nt_native.h:163
#define InsertTailList(ListHead, Entry)
NTSYSAPI NTSTATUS WINAPI RtlAddAccessAllowedAce(PACL, DWORD, DWORD, PSID)
NTSTATUS NTAPI NtQueryDirectoryObject(IN HANDLE DirectoryHandle, OUT PVOID Buffer, IN ULONG BufferLength, IN BOOLEAN ReturnSingleEntry, IN BOOLEAN RestartScan, IN OUT PULONG Context, OUT PULONG ReturnLength OPTIONAL)
Definition: obdir.c:498
NTSYSAPI NTSTATUS WINAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR, BOOLEAN, PACL, BOOLEAN)
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
Definition: wdfregistry.h:279
NTSYSAPI NTSTATUS NTAPI RtlAllocateAndInitializeSid(IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, IN UCHAR SubAuthorityCount, IN ULONG SubAuthority0, IN ULONG SubAuthority1, IN ULONG SubAuthority2, IN ULONG SubAuthority3, IN ULONG SubAuthority4, IN ULONG SubAuthority5, IN ULONG SubAuthority6, IN ULONG SubAuthority7, OUT PSID *Sid)
Definition: sid.c:290
#define _stricmp
Definition: cat.c:22
#define SYMBOLIC_LINK_ALL_ACCESS
Definition: nt_native.h:1267
NTSTATUS NTAPI LdrVerifyImageMatchesChecksum(IN HANDLE FileHandle, IN PLDR_CALLBACK Callback, IN PVOID CallbackContext, OUT PUSHORT ImageCharacteristics)
Definition: ldrapi.c:837
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define IMAGE_FILE_DLL
Definition: pedump.c:169
#define OBJ_OPENIF
Definition: winternl.h:229
#define FILE_WRITE_ATTRIBUTES
Definition: nt_native.h:649
#define FILE_SHARE_READ
Definition: compat.h:136
struct _FILE_RENAME_INFORMATION FILE_RENAME_INFORMATION
BOOLEAN RegPosixSingleInstance
Definition: smsubsys.c:22
NTSYSAPI NTSTATUS NTAPI RtlCreateAcl(PACL Acl, ULONG AclSize, ULONG AclRevision)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define PROCESSOR_ARCHITECTURE_IA64
Definition: ketypes.h:111
UNICODE_STRING SmpASyncKeyword
Definition: smutil.c:34
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
VOID NTAPI SmpPagingFileInitialize(VOID)
Definition: pagefile.c:75
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
_Inout_ PUNICODE_STRING LinkTarget
Definition: zwfuncs.h:292
HANDLE FileHandle
Definition: stats.c:38
HANDLE SmpWindowsSubSysProcessId
Definition: smsubsys.c:21
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define RTL_QUERY_REGISTRY_DELETE
Definition: nt_native.h:153
void * Buffer
Definition: sprintf.c:453
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
#define ANSI_NULL
PWCHAR SmpDefaultEnvironment
Definition: sminit.c:27
PVOID SmpHeap
Definition: sminit.c:24
NTSTATUS NTAPI NtInitializeRegistry(IN USHORT Flag)
Definition: ntapi.c:1318
PISECURITY_DESCRIPTOR SmpLiberalSecurityDescriptor
Definition: sminit.c:37
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
WORD SECURITY_DESCRIPTOR_CONTROL
Definition: lsa.idl:37
NTSTATUS NTAPI SmpConfigureAllowProtectedRenames(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: sminit.c:246
#define REG_MULTI_SZ
Definition: nt_native.h:1501
Entry(ENTRY_TYPE etype)
Definition: entries.cpp:35
#define GENERIC_WRITE
Definition: nt_native.h:90
NTSTATUS NTAPI SmpInitializeKnownDllPath(IN PUNICODE_STRING DllPath, IN PWCHAR Buffer, IN ULONG Length)
Definition: sminit.c:429
NTSTATUS NTAPI SmpConfigureExcludeKnownDlls(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: sminit.c:381
NTSTRSAFEAPI RtlStringCbCopyNW(_Out_writes_bytes_(cbDest) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCWSTR pszSrc, _In_ size_t cbToCopy)
Definition: ntstrsafe.h:416
LIST_ENTRY SmpSubSystemsToLoad
Definition: sminit.c:21
Definition: card.h:12
ULONG NTAPI RtlCreateTagHeap(IN HANDLE HeapHandle, IN ULONG Flags, IN PWSTR TagName, IN PWSTR TagSubName)
Definition: heap.c:3956
unsigned char BOOLEAN
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:4142
#define ACL_REVISION2
Definition: setypes.h:43
struct _ACL ACL
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1868
#define RTL_QUERY_REGISTRY_SUBKEY
Definition: nt_native.h:125
NTSYSAPI NTSTATUS NTAPI RtlSetEnvironmentVariable(_In_z_ PWSTR *Environment, _In_ PUNICODE_STRING Name, _In_ PUNICODE_STRING Value)
#define PAGE_EXECUTE
Definition: nt_native.h:1306
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
NTSYSAPI ULONG NTAPI RtlLengthSid(IN PSID Sid)
Definition: sid.c:150
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
void * PVOID
Definition: retypes.h:9
_CRTIMP wchar_t *__cdecl _wcsupr(_Inout_z_ wchar_t *_String)
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:526
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define SE_DACL_DEFAULTED
Definition: setypes.h:768
UNICODE_STRING SmpKnownDllPath
Definition: sminit.c:28
#define NtCurrentProcess()
Definition: nt_native.h:1657
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
NTSYSAPI NTSTATUS NTAPI NtDeleteValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName)
Definition: ntapi.c:1014
Status
Definition: gdiplustypes.h:24
LIST_ENTRY SmpSetupExecuteList
Definition: sminit.c:19
#define CONTAINER_INHERIT_ACE
Definition: setypes.h:715
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
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)
NTSTATUS NTAPI SmpCreateDynamicEnvironmentVariables(VOID)
Definition: sminit.c:1658
struct _FILE_RENAME_INFORMATION * PFILE_RENAME_INFORMATION
ULONG SmpCalledConfigEnv
Definition: sminit.c:29
#define FILE_LIST_DIRECTORY
Definition: nt_native.h:629
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
NTSTATUS NTAPI NtCreatePort(OUT PHANDLE PortHandle, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG MaxConnectInfoLength, IN ULONG MaxDataLength, IN ULONG MaxPoolUsage)
Definition: create.c:212
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:553
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:454
#define ASSERT(a)
Definition: mode.c:45
NTSTATUS NTAPI SmpProcessFileRenames(VOID)
Definition: sminit.c:2003
NTSTATUS SmpInitReturnStatus
Definition: sminit.c:32
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI SmpTranslateSystemPartitionInformation(VOID)
Definition: sminit.c:786
Registry entry.
Definition: regfs.h:30
#define SECURITY_WORLD_SID_AUTHORITY
Definition: setypes.h:499
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
ULONG SmBaseTag
Definition: sminit.c:25
#define MAX_PATH
Definition: compat.h:34
#define swprintf(buf, format,...)
Definition: sprintf.c:56
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
NTSTATUS NTAPI SmpConfigureFileRenames(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: sminit.c:350
LIST_ENTRY SmpFileRenameList
Definition: sminit.c:20
#define SECURITY_WORLD_RID
Definition: setypes.h:513
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define PROCESSOR_ARCHITECTURE_AMD64
Definition: ketypes.h:114
static PPARTENTRY SystemPartition
Definition: usetup.c:61
#define SECURITY_CREATOR_OWNER_RID
Definition: setypes.h:517
UNICODE_STRING SmpDebugKeyword
Definition: smutil.c:34
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
HANDLE SmpDebugPort
Definition: sminit.c:26
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
PISECURITY_DESCRIPTOR SmpKnownDllsSecurityDescriptor
Definition: sminit.c:38
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1868
static const WCHAR L[]
Definition: oid.c:1250
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:454
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define FILE_EXECUTE
Definition: nt_native.h:642
NTSTATUS NTAPI SmpCreatePagingFiles(VOID)
Definition: pagefile.c:998
PSID WorldSid
Definition: globals.c:15
#define OBJ_PERMANENT
Definition: winternl.h:226
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define GENERIC_READ
Definition: compat.h:135
Definition: typedefs.h:119
NTSYSAPI NTSTATUS NTAPI RtlCreateUserThread(_In_ PVOID ThreadContext, _Out_ HANDLE *OutThreadHandle, _Reserved_ PVOID Reserved1, _Reserved_ PVOID Reserved2, _Reserved_ PVOID Reserved3, _Reserved_ PVOID Reserved4, _Reserved_ PVOID Reserved5, _Reserved_ PVOID Reserved6, _Reserved_ PVOID Reserved7, _Reserved_ PVOID Reserved8)
#define SYNCHRONIZE
Definition: nt_native.h:61
LIST_ENTRY SmpSessionListHead
Definition: smsessn.c:27
NTSTATUS NTAPI SmpLoadSubSystemsForMuSession(IN PULONG MuSessionId, OUT PHANDLE ProcessId, IN PUNICODE_STRING InitialCommand)
Definition: smsubsys.c:513
NTSTATUS NTAPI SmpExecuteCommand(IN PUNICODE_STRING CommandLine, IN ULONG MuSessionId, OUT PHANDLE ProcessId, IN ULONG Flags)
Definition: smss.c:221
NTSTATUS NTAPI SmpInitializeKnownDllsInternal(IN PUNICODE_STRING Directory, IN PUNICODE_STRING Path)
Definition: sminit.c:1400
LIST_ENTRY SmpExecuteList
Definition: sminit.c:22
RTL_CRITICAL_SECTION SmpSessionListLock
Definition: smsessn.c:26
struct _OBJECT_DIRECTORY_INFORMATION OBJECT_DIRECTORY_INFORMATION
NTSYSAPI NTSTATUS NTAPI RtlCreateEnvironment(_In_ BOOLEAN Inherit, _Out_ PWSTR *Environment)
#define PROCESSOR_ARCHITECTURE_INTEL
Definition: ketypes.h:105
NTSTATUS NTAPI SmpConfigureMemoryMgmt(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: sminit.c:337
BOOLEAN SmpDbgSsLoaded
Definition: smsessn.c:30
struct _FileName FileName
Definition: fatprocs.h:893
UNICODE_STRING SmpSubsystemName
Definition: sminit.c:18
NTSTATUS NTAPI NtCreateDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: obdir.c:773
ULONG SmpInitProgressByLine
Definition: sminit.c:31
ULONG SmpAllowProtectedRenames
Definition: sminit.c:40
PRTL_UNICODE_STRING_BUFFER Path
RTL_QUERY_REGISTRY_TABLE SmpRegistryConfigurationTable[]
Definition: sminit.c:597
#define STATUS_INVALID_IMPORT_OF_NON_DLL
Definition: ntstatus.h:921
HANDLE SmpSessionsObjectDirectory
Definition: smsessn.c:31
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
NTSTATUS NTAPI NtSetInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, IN PVOID ProcessInformation, IN ULONG ProcessInformationLength)
Definition: query.c:1107
UNICODE_STRING Os2Name
Definition: sminit.c:18
#define NtCurrentPeb()
Definition: FLS.c:20
unsigned short USHORT
Definition: pedump.c:61
NTSTATUS NTAPI SmpInitializeKnownDlls(VOID)
Definition: sminit.c:1627
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
static const char const char * DllPath
Definition: image.c:34
ULONG SmpNextSessionIdScanMode
Definition: smsessn.c:29
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define DIRECTORY_ALL_ACCESS
Definition: nt_native.h:1259
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
NTSTATUS NTAPI SmpConfigureSubSystems(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: sminit.c:524
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
VOID NTAPI SmpProcessModuleImports(IN PVOID Unused, IN PCHAR ImportName)
Definition: sminit.c:1358
NTSTATUS NTAPI SmpConfigureObjectDirectories(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: sminit.c:271
unsigned int * PULONG
Definition: retypes.h:1
#define SECURITY_RESTRICTED_CODE_RID
Definition: setypes.h:541
#define NULL
Definition: types.h:112
LIST_ENTRY SmpSubSystemsToDefer
Definition: sminit.c:22
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: ntapi.c:859
NTSYSAPI BOOLEAN NTAPI RtlPrefixUnicodeString(IN PUNICODE_STRING String1, IN PUNICODE_STRING String2, IN BOOLEAN CaseInSensitive)
#define DPRINT1
Definition: precomp.h:8
BOOLEAN MiniNTBoot
Definition: sminit.c:41
NTSTATUS NTAPI SmpTerminate(IN PULONG_PTR Parameters, IN ULONG ParameterMask, IN ULONG ParameterCount)
Definition: smss.c:391
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
NTSTATUS NTAPI SmpConfigureDosDevices(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: sminit.c:416
SECURITY_DESCRIPTOR SmpLiberalSDBody
Definition: sminit.c:35
ULONG SmpProtectionMode
Definition: sminit.c:40
NTSTATUS NTAPI SmpCreateSecurityDescriptors(IN BOOLEAN InitialCall)
Definition: sminit.c:950
ULONG SmpNextSessionId
Definition: smsessn.c:28
struct tagContext Context
Definition: acpixf.h:1034
#define OUT
Definition: typedefs.h:40
PSMP_REGISTRY_VALUE NTAPI SmpFindRegistryValue(IN PLIST_ENTRY List, IN PWSTR ValueName)
Definition: sminit.c:188
SECURITY_DESCRIPTOR SmpApiPortSDBody
Definition: sminit.c:36
unsigned int ULONG
Definition: retypes.h:1
base for all directory entries
Definition: entries.h:138
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
#define SEC_IMAGE
Definition: mmtypes.h:96
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
LIST_ENTRY SmpSubSystemList
Definition: sminit.c:21
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
#define INHERIT_ONLY_ACE
Definition: setypes.h:717
NTSTATUS NTAPI SmpInitializeDosDevices(VOID)
Definition: sminit.c:1254
PWCHAR SmpDefaultLibPathBuffer
Definition: sminit.c:27
#define STATUS_SUCCESS
Definition: shellext.h:65
#define REG_NONE
Definition: nt_native.h:1492
_In_ FILTER_INFORMATION_CLASS InformationClass
Definition: fltkernel.h:1714
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
#define GENERIC_EXECUTE
Definition: nt_native.h:91
unsigned short MaximumLength
Definition: sprintf.c:452
UNICODE_STRING SmpAutoChkKeyword
Definition: smutil.c:34
#define REG_DWORD
Definition: sdbapi.c:596
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:624
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
NTSTATUS NTAPI SmpCreatePagingFileDescriptor(IN PUNICODE_STRING PageFileToken)
Definition: pagefile.c:84
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJECT_INHERIT_ACE
Definition: setypes.h:714
LIST_ENTRY SmpKnownDllsList
Definition: sminit.c:20
base of all file and directory entries
Definition: entries.h:82
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_In_ ULONG AclLength
Definition: rtlfuncs.h:1844
NTSTATUS NTAPI SmpLoadDataFromRegistry(OUT PUNICODE_STRING InitialCommand)
Definition: sminit.c:2218
RTL_CRITICAL_SECTION SmpKnownSubSysLock
Definition: smsubsys.c:18
#define SECURITY_CREATOR_SID_AUTHORITY
Definition: setypes.h:505
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
LIST_ENTRY SmpKnownSubSysHead
Definition: smsubsys.c:19
SID_IDENTIFIER_AUTHORITY NtAuthority
Definition: database.c:19
#define DELETE
Definition: nt_native.h:57
IN PUNICODE_STRING PortName
Definition: conport.c:35
#define REG_SZ
Definition: layer.c:22
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:855
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:271