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.

167 lines
4.0 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation
  4. //
  5. // File: provider.c
  6. //
  7. // Contents: Module to initialize DFS driver providers.
  8. //
  9. // Classes:
  10. //
  11. // Functions: ProviderInit()
  12. //
  13. // History: 12 Sep 1992 Milans created.
  14. // 05 Apr 1993 Milans moved into driver.
  15. //
  16. //-----------------------------------------------------------------------------
  17. #include "dfsprocs.h"
  18. #include "registry.h"
  19. #include "regkeys.h"
  20. #include "provider.h"
  21. #define MAX_ENTRY_PATH 80 // Max. length of entry path
  22. #define Dbg DEBUG_TRACE_INIT
  23. #define prov_debug_out(x, y) DebugTrace(0, Dbg, x, y)
  24. #ifdef ALLOC_PRAGMA
  25. #pragma alloc_text( INIT, ProviderInit )
  26. #endif // ALLOC_PRAGMA
  27. //+----------------------------------------------------------------------------
  28. //
  29. // Function: ProviderInit
  30. //
  31. // Synopsis: Initializes the provider list with
  32. // - Local File service provider
  33. // - Standard remote Cairo provider
  34. // - Downlevel LanMan provider.
  35. //
  36. // Arguments: None
  37. //
  38. // Returns: STATUS_SUCCESS
  39. //
  40. //-----------------------------------------------------------------------------
  41. NTSTATUS
  42. ProviderInit(void)
  43. {
  44. NTSTATUS Status;
  45. ULONG i, cProviders;
  46. APWSTR awszProviders; // array of provider names
  47. PBYTE pData;
  48. ULONG ProviderId, Capabilities;
  49. UNICODE_STRING ustrProviderName;
  50. Status = KRegSetRoot(wszRegRootDFS);
  51. if (!NT_SUCCESS(Status)) {
  52. prov_debug_out("ProviderInit: Error %08lx opening Registry!\n", Status);
  53. return(Status);
  54. }
  55. //
  56. // Get all the Provider subkeys.
  57. //
  58. Status = KRegEnumSubKeySet(wszProviderKey, &cProviders, &awszProviders);
  59. if (!NT_SUCCESS(Status)) {
  60. prov_debug_out("ProviderInit: Error %08lx reading Providers!\n", Status);
  61. KRegCloseRoot();
  62. return(Status);
  63. }
  64. //
  65. // Get the parameters for each provider and define the provider
  66. //
  67. for (i = 0; i < cProviders; i++) {
  68. //
  69. // Get the Provider ID
  70. //
  71. Status = KRegGetValue(awszProviders[i], wszProviderId, &pData);
  72. if (NT_SUCCESS(Status)) {
  73. ProviderId = *((ULONG *)pData);
  74. DfsFree(pData);
  75. } else {
  76. prov_debug_out( "Error reading Provider Id for %ws\n", awszProviders[i]);
  77. continue;
  78. }
  79. //
  80. // Get the Provider Caps
  81. //
  82. Status = KRegGetValue(awszProviders[i], wszCapabilities, &pData);
  83. if (NT_SUCCESS(Status)) {
  84. Capabilities = *((ULONG *)pData);
  85. DfsFree(pData);
  86. } else {
  87. prov_debug_out("Error reading Capabilities for %ws\n", awszProviders[i]);
  88. continue;
  89. }
  90. //
  91. // Get the DeviceName
  92. //
  93. Status = KRegGetValue(awszProviders[i], wszDeviceName, &pData);
  94. if (NT_SUCCESS(Status)) {
  95. RtlInitUnicodeString(&ustrProviderName, (PWSTR) pData);
  96. prov_debug_out("Defining %ws provider.\n", awszProviders[i]);
  97. prov_debug_out("\tTarget = %wZ\n", &ustrProviderName);
  98. Status = DfsInsertProvider(
  99. &ustrProviderName,
  100. Capabilities,
  101. ProviderId);
  102. if (!NT_SUCCESS(Status)) {
  103. DfsFree(pData);
  104. }
  105. } else {
  106. //
  107. // Device name is "optional"
  108. //
  109. prov_debug_out("Defining %ws provider.\n", awszProviders[i]);
  110. prov_debug_out("\tNo Target\n", 0);
  111. RtlInitUnicodeString(&ustrProviderName, NULL);
  112. Status = DfsInsertProvider(
  113. &ustrProviderName,
  114. Capabilities,
  115. ProviderId);
  116. }
  117. //
  118. // See if provider definition went ok
  119. //
  120. if (!NT_SUCCESS(Status)) {
  121. prov_debug_out("Definition of %ws provider failed!\n", awszProviders[i]);
  122. prov_debug_out("Error = %08lx\n", Status);
  123. }
  124. }
  125. KRegCloseRoot();
  126. KRegFreeArray(cProviders, (APBYTE) awszProviders);
  127. return(STATUS_SUCCESS);
  128. }