Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. csrss.c
  5. Abstract:
  6. This is the main startup module for the Server side of the Client
  7. Server Runtime Subsystem (CSRSS)
  8. Author:
  9. Steve Wood (stevewo) 8-Oct-1990
  10. Environment:
  11. User Mode Only
  12. Revision History:
  13. --*/
  14. #include "csrsrv.h"
  15. VOID
  16. DisableErrorPopups(
  17. VOID
  18. )
  19. {
  20. ULONG NewMode;
  21. NewMode = 0;
  22. NtSetInformationProcess(
  23. NtCurrentProcess(),
  24. ProcessDefaultHardErrorMode,
  25. (PVOID) &NewMode,
  26. sizeof(NewMode)
  27. );
  28. }
  29. int
  30. _cdecl
  31. main(
  32. IN ULONG argc,
  33. IN PCH argv[],
  34. IN PCH envp[],
  35. IN ULONG DebugFlag OPTIONAL
  36. )
  37. {
  38. NTSTATUS status;
  39. ULONG ErrorResponse;
  40. KPRIORITY SetBasePriority;
  41. //
  42. // Force early creation of critical section events
  43. //
  44. // RtlEnableEarlyCriticalSectionEventCreation (); // Looping inside resource package now
  45. SetBasePriority = FOREGROUND_BASE_PRIORITY + 4;
  46. NtSetInformationProcess(
  47. NtCurrentProcess(),
  48. ProcessBasePriority,
  49. (PVOID) &SetBasePriority,
  50. sizeof(SetBasePriority)
  51. );
  52. //
  53. // Give IOPL to the server so GDI and the display drivers can access the
  54. // video registers.
  55. //
  56. status = NtSetInformationProcess( NtCurrentProcess(),
  57. ProcessUserModeIOPL,
  58. NULL,
  59. 0 );
  60. if (!NT_SUCCESS( status )) {
  61. IF_DEBUG {
  62. DbgPrint( "CSRSS: Unable to give IOPL to the server. status == %X\n",
  63. status);
  64. }
  65. status = NtRaiseHardError( (NTSTATUS)STATUS_IO_PRIVILEGE_FAILED,
  66. 0,
  67. 0,
  68. NULL,
  69. OptionOk,
  70. &ErrorResponse
  71. );
  72. }
  73. status = CsrServerInitialization( argc, argv );
  74. if (!NT_SUCCESS( status )) {
  75. IF_DEBUG {
  76. DbgPrint( "CSRSS: Unable to initialize server. status == %X\n",
  77. status
  78. );
  79. }
  80. NtTerminateProcess( NtCurrentProcess(), status );
  81. }
  82. DisableErrorPopups();
  83. if (NtCurrentPeb()->SessionId == 0) {
  84. //
  85. // Make terminating the root csrss fatal
  86. //
  87. RtlSetProcessIsCritical(TRUE, NULL, FALSE);
  88. }
  89. NtTerminateThread( NtCurrentThread(), status );
  90. return( 0 );
  91. }