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.

139 lines
3.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: I S D N H O O K . C P P
  7. //
  8. // Contents: Hook for the ISDN wizard, from the netdi.cpp class installer
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 14 Jun 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "isdncfg.h"
  18. #include "isdnwiz.h"
  19. #include "ncmisc.h"
  20. #include "ncreg.h"
  21. #include "ncstring.h"
  22. //---[ Constants ]------------------------------------------------------------
  23. extern const WCHAR c_szRegKeyInterfacesFromInstance[];
  24. extern const WCHAR c_szRegValueLowerRange[];
  25. //+--------------------------------------------------------------------------
  26. //
  27. // Function: FAdapterIsIsdn
  28. //
  29. // Purpose: Checks information under the adapters driver's key to
  30. // determine if the adapter is ISDN
  31. //
  32. // Arguments:
  33. // hkeyDriver [in] The driver key for the adapter
  34. //
  35. // Returns: BOOL. TRUE if the adapter is ISDN, FALSE otherwise
  36. //
  37. // Author: billbe 09 Sep 1997
  38. //
  39. // Notes:
  40. //
  41. BOOL
  42. FAdapterIsIsdn(HKEY hkeyDriver)
  43. {
  44. Assert(hkeyDriver);
  45. const WCHAR c_szIsdn[] = L"isdn";
  46. HKEY hkey;
  47. BOOL fIsIsdn = FALSE;
  48. // Open the Interfaces key under the driver key
  49. HRESULT hr = HrRegOpenKeyEx(hkeyDriver,
  50. c_szRegKeyInterfacesFromInstance, KEY_READ, &hkey);
  51. if (SUCCEEDED(hr))
  52. {
  53. PWSTR szRange;
  54. // Get the lower range of interfaces
  55. hr = HrRegQuerySzWithAlloc(hkey, c_szRegValueLowerRange, &szRange);
  56. if (SUCCEEDED(hr))
  57. {
  58. // Look for ISDN in the lower range
  59. fIsIsdn = FFindStringInCommaSeparatedList(c_szIsdn, szRange,
  60. NC_IGNORE, NULL);
  61. MemFree(szRange);
  62. }
  63. RegCloseKey(hkey);
  64. }
  65. return fIsIsdn;
  66. }
  67. //+---------------------------------------------------------------------------
  68. //
  69. // Function: HrAddIsdnWizardPagesIfAppropriate
  70. //
  71. // Purpose: Adds the ISDN wizard pages to the hardware wizard if the
  72. // bindings dictate such. We look to see if they have a lower
  73. // binding of "isdn", and if so, then add the pages.
  74. //
  75. // Arguments:
  76. // hdi [in] See Device Installer Api for more info
  77. // pdeid [in]
  78. //
  79. // Returns: S_OK if successful or valid Win32 error
  80. //
  81. // Author: jeffspr 17 Jun 1997
  82. //
  83. // Notes:
  84. //
  85. HRESULT HrAddIsdnWizardPagesIfAppropriate(HDEVINFO hdi,
  86. PSP_DEVINFO_DATA pdeid)
  87. {
  88. Assert(IsValidHandle(hdi));
  89. Assert(pdeid);
  90. // Open the adapter's driver key
  91. //
  92. HKEY hkeyInstance = NULL;
  93. HRESULT hr = HrSetupDiOpenDevRegKey(hdi, pdeid, DICS_FLAG_GLOBAL, 0,
  94. DIREG_DRV, KEY_READ, &hkeyInstance);
  95. // Don't do anything if its not an ISDN adapter.
  96. if (SUCCEEDED(hr) && FShowIsdnPages(hkeyInstance))
  97. {
  98. // Read the ISDN registry structure into the config info
  99. //
  100. PISDN_CONFIG_INFO pisdnci;
  101. hr = HrReadIsdnPropertiesInfo(hkeyInstance, hdi, pdeid, &pisdnci);
  102. if (SUCCEEDED(hr))
  103. {
  104. Assert(pisdnci);
  105. if (pisdnci->dwCurSwitchType == ISDN_SWITCH_NONE)
  106. {
  107. // Add the wizard pages to the device's class install params.
  108. //
  109. hr = HrAddIsdnWizardPagesToDevice(hdi, pdeid, pisdnci);
  110. }
  111. else
  112. {
  113. TraceTag(ttidISDNCfg, "Not adding wizard pages because we "
  114. "found a previous switch type for this device.");
  115. }
  116. }
  117. }
  118. RegSafeCloseKey(hkeyInstance);
  119. TraceError("HrAddIsdnWizardPagesIfAppropriate", hr);
  120. return hr;
  121. }