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.

166 lines
3.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996.
  5. //
  6. // File: A D A P T E R . H
  7. //
  8. // Contents: Net class installer functions for eumerated devices.
  9. //
  10. // Notes:
  11. //
  12. // Author: billbe 11 Nov 1996
  13. //
  14. //---------------------------------------------------------------------------
  15. #pragma once
  16. #include "compdefs.h"
  17. #include "ncsetup.h"
  18. struct COMPONENT_INSTALL_INFO;
  19. HRESULT
  20. HrCiGetBusInfoFromInf (
  21. IN HINF hinfFile,
  22. OUT COMPONENT_INSTALL_INFO* pcii);
  23. struct ADAPTER_OUT_PARAMS
  24. {
  25. OUT GUID InstanceGuid;
  26. OUT DWORD dwCharacter;
  27. };
  28. struct ADAPTER_REMOVE_PARAMS
  29. {
  30. IN BOOL fBadDevInst;
  31. IN BOOL fNotifyINetCfg;
  32. };
  33. //+--------------------------------------------------------------------------
  34. //
  35. // Function: EInterfaceTypeFromDword
  36. //
  37. // Purpose: Safely converts a dword to the enumerated type INTERFACE_TYPE
  38. //
  39. // Arguments:
  40. // dwBusType [in] The bus type of the adapter
  41. //
  42. // Returns: INTERFACE_TYPE. See ntioapi.h for more info.
  43. //
  44. // Author: billbe 28 Jun 1997
  45. //
  46. // Notes:
  47. //
  48. inline INTERFACE_TYPE
  49. EInterfaceTypeFromDword(DWORD dwBusType)
  50. {
  51. INTERFACE_TYPE eBusType;
  52. if (dwBusType < MaximumInterfaceType)
  53. {
  54. // Since dwBusType is less than MaximumInterfaceType, we can safely
  55. // cast dwBusType to the enumerated value.
  56. //
  57. eBusType = static_cast<INTERFACE_TYPE>(dwBusType);
  58. }
  59. else
  60. {
  61. eBusType = InterfaceTypeUndefined;
  62. }
  63. return eBusType;
  64. }
  65. HRESULT
  66. HrCiInstallEnumeratedComponent(HINF hinf, HKEY hkeyInstance,
  67. IN const COMPONENT_INSTALL_INFO& cii);
  68. inline void
  69. CiSetReservedField(HDEVINFO hdi, PSP_DEVINFO_DATA pdeid,
  70. const VOID* pvInfo)
  71. {
  72. AssertH(IsValidHandle(hdi));
  73. SP_DEVINSTALL_PARAMS deip;
  74. (void) HrSetupDiGetDeviceInstallParams(hdi, pdeid, &deip);
  75. deip.ClassInstallReserved = reinterpret_cast<ULONG_PTR>(pvInfo);
  76. (void) HrSetupDiSetDeviceInstallParams(hdi, pdeid, &deip);
  77. }
  78. inline void
  79. CiClearReservedField(HDEVINFO hdi, PSP_DEVINFO_DATA pdeid)
  80. {
  81. AssertH(IsValidHandle(hdi));
  82. SP_DEVINSTALL_PARAMS deip;
  83. (void) HrSetupDiGetDeviceInstallParams(hdi, pdeid, &deip);
  84. deip.ClassInstallReserved = NULL;
  85. (void) HrSetupDiSetDeviceInstallParams(hdi, pdeid, &deip);
  86. }
  87. HRESULT
  88. HrCiRemoveEnumeratedComponent(IN const COMPONENT_INSTALL_INFO cii);
  89. HRESULT
  90. HrCiRegOpenKeyFromEnumDevs(HDEVINFO hdi, DWORD* pIndex, REGSAM samDesired,
  91. HKEY* phkey);
  92. inline HRESULT
  93. HrCiFilterOutPhantomDevs(HDEVINFO hdi)
  94. {
  95. DWORD dwIndex = 0;
  96. HRESULT hr;
  97. HKEY hkey;
  98. // This call eliminates phantom devices
  99. while (SUCCEEDED(hr = HrCiRegOpenKeyFromEnumDevs(hdi, &dwIndex, KEY_READ,
  100. &hkey)))
  101. {
  102. // We don't need the hkey; we just wanted the phantoms removed
  103. RegCloseKey (hkey);
  104. // on to the next
  105. dwIndex++;
  106. }
  107. // No more items is not really an error
  108. if (HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS) == hr)
  109. {
  110. hr = S_OK;
  111. }
  112. return hr;
  113. }
  114. // Device friendly name functions and types.
  115. //
  116. enum DM_OP
  117. {
  118. DM_ADD,
  119. DM_DELETE,
  120. };
  121. HRESULT
  122. HrCiUpdateDescriptionIndexList(NETCLASS Class, PCWSTR pszDescription,
  123. DM_OP eOp, ULONG* pulIndex);
  124. //////////////Legacy NT4 App support//////////////////////////
  125. enum LEGACY_NT4_KEY_OP
  126. {
  127. LEGACY_NT4_KEY_ADD,
  128. LEGACY_NT4_KEY_REMOVE,
  129. };
  130. VOID
  131. AddOrRemoveLegacyNt4AdapterKey (
  132. IN HDEVINFO hdi,
  133. IN PSP_DEVINFO_DATA pdeid,
  134. IN const GUID* pInstanceGuid,
  135. IN PCWSTR pszDescription,
  136. IN LEGACY_NT4_KEY_OP Op);