Leaked source code of windows server 2003
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.

138 lines
4.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2000.
  5. //
  6. // File: G L O B A L S . C
  7. //
  8. // Contents: Support for shared global data for services in svchost.exe
  9. // that choose to use it.
  10. //
  11. // Notes:
  12. //
  13. // Author: jschwart 26 Jan 2000
  14. //
  15. //----------------------------------------------------------------------------
  16. #include "pch.h"
  17. #pragma hdrstop
  18. #include <svcslib.h>
  19. #include <scseclib.h>
  20. #include <ntrpcp.h>
  21. #include "globals.h"
  22. #include "svcsnb.h"
  23. //
  24. // Defines to gauge progress from past calls
  25. // to SvchostBuildSharedGlobals
  26. //
  27. #define SVCHOST_RPCP_INIT 0x00000001
  28. #define SVCHOST_NETBIOS_INIT 0x00000002
  29. #define SVCHOST_SIDS_BUILT 0x00000004
  30. //
  31. // Global data
  32. //
  33. PSVCHOST_GLOBAL_DATA g_pSvchostSharedGlobals;
  34. #if DBG
  35. DWORD SvcctrlDebugLevel; // Needed to resolve external in sclib.lib
  36. #endif
  37. VOID
  38. SvchostBuildSharedGlobals(
  39. VOID
  40. )
  41. {
  42. static DWORD s_dwProgress;
  43. NTSTATUS ntStatus;
  44. //
  45. // Note that this routine assumes it is being called
  46. // while the ListLock critsec (in svchost.c) is held
  47. //
  48. ASSERT(g_pSvchostSharedGlobals == NULL);
  49. //
  50. // Initialize the RPC helper routine global data
  51. //
  52. if (!(s_dwProgress & SVCHOST_RPCP_INIT))
  53. {
  54. ntStatus = RpcpInitRpcServer();
  55. if (!NT_SUCCESS(ntStatus))
  56. {
  57. return;
  58. }
  59. s_dwProgress |= SVCHOST_RPCP_INIT;
  60. }
  61. //
  62. // Initialize the NetBios critical section for services
  63. // that use NetBios.
  64. //
  65. if (!(s_dwProgress & SVCHOST_NETBIOS_INIT))
  66. {
  67. SvcNetBiosInit();
  68. s_dwProgress |= SVCHOST_NETBIOS_INIT;
  69. }
  70. //
  71. // Build up the shared global SIDs -- use the Service Controller's
  72. // routine for this.
  73. //
  74. if (!(s_dwProgress & SVCHOST_SIDS_BUILT))
  75. {
  76. ntStatus = ScCreateWellKnownSids();
  77. if (!NT_SUCCESS(ntStatus))
  78. {
  79. return;
  80. }
  81. s_dwProgress |= SVCHOST_SIDS_BUILT;
  82. }
  83. //
  84. // Create and populate the global data structure.
  85. //
  86. g_pSvchostSharedGlobals = MemAlloc(HEAP_ZERO_MEMORY,
  87. sizeof(SVCHOST_GLOBAL_DATA));
  88. if (g_pSvchostSharedGlobals != NULL)
  89. {
  90. g_pSvchostSharedGlobals->NullSid = NullSid;
  91. g_pSvchostSharedGlobals->WorldSid = WorldSid;
  92. g_pSvchostSharedGlobals->LocalSid = LocalSid;
  93. g_pSvchostSharedGlobals->NetworkSid = NetworkSid;
  94. g_pSvchostSharedGlobals->LocalSystemSid = LocalSystemSid;
  95. g_pSvchostSharedGlobals->LocalServiceSid = LocalServiceSid;
  96. g_pSvchostSharedGlobals->NetworkServiceSid = NetworkServiceSid;
  97. g_pSvchostSharedGlobals->BuiltinDomainSid = BuiltinDomainSid;
  98. g_pSvchostSharedGlobals->AuthenticatedUserSid = AuthenticatedUserSid;
  99. g_pSvchostSharedGlobals->AnonymousLogonSid = AnonymousLogonSid;
  100. g_pSvchostSharedGlobals->AliasAdminsSid = AliasAdminsSid;
  101. g_pSvchostSharedGlobals->AliasUsersSid = AliasUsersSid;
  102. g_pSvchostSharedGlobals->AliasGuestsSid = AliasGuestsSid;
  103. g_pSvchostSharedGlobals->AliasPowerUsersSid = AliasPowerUsersSid;
  104. g_pSvchostSharedGlobals->AliasAccountOpsSid = AliasAccountOpsSid;
  105. g_pSvchostSharedGlobals->AliasSystemOpsSid = AliasSystemOpsSid;
  106. g_pSvchostSharedGlobals->AliasPrintOpsSid = AliasPrintOpsSid;
  107. g_pSvchostSharedGlobals->AliasBackupOpsSid = AliasBackupOpsSid;
  108. g_pSvchostSharedGlobals->StartRpcServer = RpcpStartRpcServer;
  109. g_pSvchostSharedGlobals->StopRpcServer = RpcpStopRpcServer;
  110. g_pSvchostSharedGlobals->StopRpcServerEx = RpcpStopRpcServerEx;
  111. g_pSvchostSharedGlobals->NetBiosOpen = SvcNetBiosOpen;
  112. g_pSvchostSharedGlobals->NetBiosClose = SvcNetBiosClose;
  113. g_pSvchostSharedGlobals->NetBiosReset = SvcNetBiosReset;
  114. }
  115. return;
  116. }