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
4.7 KiB

  1. #pragma once
  2. #include "nmbase.h"
  3. #include "nmres.h"
  4. #include "nmhnet.h"
  5. extern LONG g_CountLanConnectionObjects;
  6. class ATL_NO_VTABLE CLanConnection :
  7. public CComObjectRootEx <CComMultiThreadModel>,
  8. public CComCoClass <CLanConnection, &CLSID_LanConnection>,
  9. public INetConnection,
  10. public IPersistNetConnection,
  11. public INetLanConnection,
  12. public INetConnectionSysTray,
  13. public INetConnection2
  14. {
  15. private:
  16. HKEY m_hkeyConn; // hkey for connection root
  17. BOOL m_fInitialized;
  18. HDEVINFO m_hdi;
  19. SP_DEVINFO_DATA m_deid;
  20. // This is required for checking permission on Firewall etc.
  21. CComPtr<INetMachinePolicies> m_pNetMachinePolicies;
  22. // Home networking support. m_fHNetPropertiesCached is set to TRUE
  23. // after the first successful call to HrEnsureHNetPropertiesCached.
  24. //
  25. BOOL m_fHNetPropertiesCached;
  26. LONG m_lHNetModifiedEra;
  27. LONG m_lUpdatingHNetProperties;
  28. HNET_CONN_PROPERTIES *m_pHNetProperties;
  29. public:
  30. CLanConnection() throw()
  31. {
  32. m_hkeyConn = NULL;
  33. m_fInitialized = FALSE;
  34. m_hdi = NULL;
  35. m_fHNetPropertiesCached = FALSE;
  36. m_lHNetModifiedEra = 0;
  37. m_pHNetProperties = NULL;
  38. m_lUpdatingHNetProperties = 0;
  39. m_pNetMachinePolicies = NULL;
  40. InterlockedIncrement(&g_CountLanConnectionObjects);
  41. }
  42. ~CLanConnection() throw();
  43. DECLARE_REGISTRY_RESOURCEID(IDR_LAN_CONNECTION)
  44. BEGIN_COM_MAP(CLanConnection)
  45. COM_INTERFACE_ENTRY(INetConnection)
  46. COM_INTERFACE_ENTRY(IPersistNetConnection)
  47. COM_INTERFACE_ENTRY(INetLanConnection)
  48. COM_INTERFACE_ENTRY(INetConnectionSysTray)
  49. COM_INTERFACE_ENTRY(INetConnection2)
  50. END_COM_MAP()
  51. // INetConnection
  52. HRESULT GetDeviceName(OUT PWSTR* ppszwDeviceName);
  53. HRESULT GetStatus(OUT NETCON_STATUS* pStatus);
  54. HRESULT GetCharacteristics(IN NETCON_MEDIATYPE ncm, OUT DWORD* pdwFlags);
  55. STDMETHOD(Connect)();
  56. STDMETHOD(Disconnect)();
  57. STDMETHOD(Delete)();
  58. STDMETHOD(Duplicate) (IN PCWSTR pszwDuplicateName, OUT INetConnection** ppCon);
  59. STDMETHOD(GetProperties) (OUT NETCON_PROPERTIES** ppProps);
  60. STDMETHOD(GetUiObjectClassId)(OUT CLSID *pclsid);
  61. STDMETHOD(Rename)(PCWSTR pszwNewName);
  62. //
  63. // INetLanConnection
  64. //
  65. STDMETHOD(GetInfo)(IN DWORD dwMask, OUT LANCON_INFO* pLanConInfo);
  66. STDMETHOD(SetInfo)(IN DWORD dwMask, IN const LANCON_INFO* pLanConInfo);
  67. STDMETHOD(GetDeviceGuid)(OUT GUID *pguid);
  68. //
  69. // IPersistNetConnection
  70. //
  71. STDMETHOD(GetClassID)(OUT CLSID *pclsid);
  72. STDMETHOD(GetSizeMax)(OUT ULONG *pcbSize);
  73. STDMETHOD(Load)(IN const BYTE *pbBuf, IN ULONG cbSize);
  74. STDMETHOD(Save)(OUT BYTE *pbBuf, IN ULONG cbSize);
  75. // INetConnectionSysTray
  76. STDMETHOD (ShowIcon) (IN const BOOL bShowIcon);
  77. // INetConnectionSysTray
  78. STDMETHOD (IconStateChanged) ();
  79. // INetConnection2
  80. STDMETHOD (GetPropertiesEx)(OUT NETCON_PROPERTIES_EX** ppConnectionPropertiesEx);
  81. //
  82. // Overrides
  83. //
  84. static HRESULT CreateInstance(IN HDEVINFO hdi,
  85. IN const SP_DEVINFO_DATA &deid,
  86. IN PCWSTR pszPnpId,
  87. IN REFIID riid,
  88. OUT LPVOID *ppv);
  89. private:
  90. HRESULT HrIsConnectionActive(VOID);
  91. HRESULT HrPutName(IN PCWSTR szwName);
  92. HRESULT HrInitialize(IN PCWSTR pszPnpId);
  93. HRESULT HrLoad(IN const GUID &guid);
  94. HRESULT HrOpenRegistryKeys(IN const GUID &guid);
  95. HRESULT HrConnectOrDisconnect(IN BOOL fConnect);
  96. HRESULT HrCallSens(IN BOOL fConnect);
  97. HRESULT HrLoadDevInfoFromGuid(IN const GUID &guid);
  98. HRESULT HrIsAtmAdapterFromHkey(IN HKEY hkey);
  99. HRESULT HrIsAtmElanFromHkey(IN HKEY hkey);
  100. BOOL FIsMediaPresent(VOID) throw();
  101. HRESULT HrIsConnectionBridged(OUT BOOL* pfBridged);
  102. HRESULT HrIsConnectionFirewalled(OUT BOOL* pfFirewalled);
  103. HRESULT HrIsConnectionNetworkBridge(OUT BOOL* pfBridged);
  104. HRESULT HrIsConnectionIcsPublic(OUT BOOL* pfIcsPublic);
  105. HRESULT HrEnsureHNetPropertiesCached(VOID);
  106. HRESULT HrGetIHNetConnection(OUT IHNetConnection **ppHNetConnection);
  107. HRESULT HrEnsureValidNlaPolicyEngine();
  108. };
  109. //
  110. // Globals
  111. //
  112. HRESULT HrGetInstanceGuid(IN HDEVINFO hdi,
  113. IN const SP_DEVINFO_DATA &deid,
  114. OUT LPGUID pguid);
  115. VOID EnsureUniqueConnectionName(IN PCWSTR pszPotentialName, OUT PWSTR pszNewName);