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.

132 lines
3.9 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. RpcpInitRpcServer();
  55. s_dwProgress |= SVCHOST_RPCP_INIT;
  56. }
  57. //
  58. // Initialize the NetBios critical section for services
  59. // that use NetBios.
  60. //
  61. if (!(s_dwProgress & SVCHOST_NETBIOS_INIT))
  62. {
  63. SvcNetBiosInit();
  64. s_dwProgress |= SVCHOST_NETBIOS_INIT;
  65. }
  66. //
  67. // Build up the shared global SIDs -- use the Service Controller's
  68. // routine for this.
  69. //
  70. if (!(s_dwProgress & SVCHOST_SIDS_BUILT))
  71. {
  72. ntStatus = ScCreateWellKnownSids();
  73. if (!NT_SUCCESS(ntStatus))
  74. {
  75. return;
  76. }
  77. s_dwProgress |= SVCHOST_SIDS_BUILT;
  78. }
  79. //
  80. // Create and populate the global data structure.
  81. //
  82. g_pSvchostSharedGlobals = MemAlloc(HEAP_ZERO_MEMORY,
  83. sizeof(SVCHOST_GLOBAL_DATA));
  84. if (g_pSvchostSharedGlobals != NULL)
  85. {
  86. g_pSvchostSharedGlobals->NullSid = NullSid;
  87. g_pSvchostSharedGlobals->WorldSid = WorldSid;
  88. g_pSvchostSharedGlobals->LocalSid = LocalSid;
  89. g_pSvchostSharedGlobals->NetworkSid = NetworkSid;
  90. g_pSvchostSharedGlobals->LocalSystemSid = LocalSystemSid;
  91. g_pSvchostSharedGlobals->LocalServiceSid = LocalServiceSid;
  92. g_pSvchostSharedGlobals->NetworkServiceSid = NetworkServiceSid;
  93. g_pSvchostSharedGlobals->BuiltinDomainSid = BuiltinDomainSid;
  94. g_pSvchostSharedGlobals->AuthenticatedUserSid = AuthenticatedUserSid;
  95. g_pSvchostSharedGlobals->AnonymousLogonSid = AnonymousLogonSid;
  96. g_pSvchostSharedGlobals->AliasAdminsSid = AliasAdminsSid;
  97. g_pSvchostSharedGlobals->AliasUsersSid = AliasUsersSid;
  98. g_pSvchostSharedGlobals->AliasGuestsSid = AliasGuestsSid;
  99. g_pSvchostSharedGlobals->AliasPowerUsersSid = AliasPowerUsersSid;
  100. g_pSvchostSharedGlobals->AliasAccountOpsSid = AliasAccountOpsSid;
  101. g_pSvchostSharedGlobals->AliasSystemOpsSid = AliasSystemOpsSid;
  102. g_pSvchostSharedGlobals->AliasPrintOpsSid = AliasPrintOpsSid;
  103. g_pSvchostSharedGlobals->AliasBackupOpsSid = AliasBackupOpsSid;
  104. g_pSvchostSharedGlobals->StartRpcServer = RpcpStartRpcServer;
  105. g_pSvchostSharedGlobals->StopRpcServer = RpcpStopRpcServer;
  106. g_pSvchostSharedGlobals->StopRpcServerEx = RpcpStopRpcServerEx;
  107. g_pSvchostSharedGlobals->NetBiosOpen = SvcNetBiosOpen;
  108. g_pSvchostSharedGlobals->NetBiosClose = SvcNetBiosClose;
  109. g_pSvchostSharedGlobals->NetBiosReset = SvcNetBiosReset;
  110. }
  111. return;
  112. }