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.

178 lines
4.5 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation
  4. //
  5. // Module: homenet.cpp
  6. //
  7. // Author: Dan Elliott
  8. //
  9. // Abstract:
  10. //
  11. // Environment:
  12. // Neptune
  13. //
  14. // Revision History:
  15. // 000828 dane Created.
  16. //
  17. //////////////////////////////////////////////////////////////////////////////
  18. #pragma comment(user, "Compiled on " __DATE__ " at " __TIME__)
  19. #pragma comment(compiler)
  20. //////////////////////////////////////////////////////////////////////////////
  21. //
  22. // Include files
  23. //
  24. #include <nt.h>
  25. #include <ntrtl.h>
  26. #include <nturtl.h>
  27. #include <windows.h>
  28. #include <util.h>
  29. #include <homenet.h>
  30. //////////////////////////////////////////////////////////////////////////////
  31. //
  32. // Static initialization
  33. //
  34. //////////////////////////////////////////////////////////////////////////////
  35. //
  36. // CHomeNet
  37. //
  38. // Default constructor for CHomeNet. All initialization that cannot fail
  39. // should be done here.
  40. //
  41. // parameters:
  42. // None
  43. //
  44. // returns:
  45. // Nothing.
  46. //
  47. //////////////////////////////////////////////////////////////////////////////
  48. CHomeNet::CHomeNet()
  49. : m_pHNWiz(NULL)
  50. {
  51. } // CHomeNet::CHomeNet
  52. //////////////////////////////////////////////////////////////////////////////
  53. //
  54. // ~CHomeNet
  55. //
  56. // Destructor for CHomeNet.
  57. //
  58. // parameters:
  59. // None.
  60. //
  61. // returns:
  62. // Nothing.
  63. //
  64. //////////////////////////////////////////////////////////////////////////////
  65. CHomeNet::~CHomeNet()
  66. {
  67. if (NULL != m_pHNWiz)
  68. {
  69. m_pHNWiz->Release();
  70. m_pHNWiz = NULL;
  71. }
  72. } // CHomeNet::~CHomeNet
  73. //////////////////////////////////////////////////////////////////////////////
  74. //
  75. // Create
  76. //
  77. // Initialization for CHomeNet that can fail.
  78. //
  79. // parameters:
  80. // None.
  81. //
  82. // returns:
  83. // HRESULT returned from CoCreateInstance.
  84. //
  85. //////////////////////////////////////////////////////////////////////////////
  86. HRESULT
  87. CHomeNet::Create()
  88. {
  89. HRESULT hr = CoCreateInstance(
  90. CLSID_HomeNetworkWizard,
  91. NULL,
  92. CLSCTX_INPROC_SERVER,
  93. IID_PPV_ARG(IHomeNetworkWizard, &m_pHNWiz)
  94. );
  95. if (FAILED(hr))
  96. {
  97. TRACE1(L"Failed to CoCreate CSLID_HomeNetworkWizard (0x%08X)", hr);
  98. ASSERT(SUCCEEDED(hr));
  99. }
  100. return hr;
  101. } // CHomeNet::Create
  102. //////////////////////////////////////////////////////////////////////////////
  103. //
  104. // ConfigureSilently
  105. //
  106. // Run the Home Networking Wizard sans UI.
  107. //
  108. // parameters:
  109. // szConnectoidName Name of the RAS connectoid to be firewalled.
  110. // NULL is valid if no connectoid is to be firewalled.
  111. // pfRebootRequired Return value indicating whether the changes made by
  112. // the HNW required a reboot before taking affect.
  113. //
  114. // returns:
  115. // E_UNEXPECTED if object has not be initialized
  116. // E_INVALIDARG if pfRebootRequired is NULL
  117. // HRESULT returned by IHomeNetWizard::ConfigureSilently
  118. //
  119. //////////////////////////////////////////////////////////////////////////////
  120. HRESULT
  121. CHomeNet::ConfigureSilently(
  122. LPCWSTR szConnectoidName,
  123. BOOL* pfRebootRequired
  124. )
  125. {
  126. MYASSERT(IsValid());
  127. MYASSERT(NULL != pfRebootRequired);
  128. if (!IsValid())
  129. {
  130. return E_UNEXPECTED;
  131. }
  132. if (NULL == pfRebootRequired)
  133. {
  134. return E_INVALIDARG;
  135. }
  136. TRACE(L"Starting IHomeNetWizard::ConfigureSilently()...");
  137. HRESULT hr = m_pHNWiz->ConfigureSilently(szConnectoidName,
  138. HNET_FIREWALLCONNECTION,
  139. pfRebootRequired
  140. );
  141. TRACE(L" IHomeNetWizard::ConfigureSilently() completed");
  142. if (FAILED(hr))
  143. {
  144. TRACE2(L"IHomeNetWizard::ConfigureSilently(%s) failed (0x%08X)",
  145. (NULL != szConnectoidName) ? szConnectoidName
  146. : L"No connectoid specified",
  147. hr
  148. );
  149. }
  150. return hr;
  151. } // CHomeNet::ConfigureSilently
  152. //
  153. ///// End of file: homenet.cpp /////////////////////////////////////////////