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.

847 lines
23 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997 - 2001.
  5. //
  6. // File: I N B O U N D . C P P
  7. //
  8. // Contents: Implements the inbound connection object.
  9. //
  10. // Notes:
  11. //
  12. // Author: shaunco 12 Nov 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "inbound.h"
  18. #include "nccom.h"
  19. #include "ncnetcon.h"
  20. #include "..\conman\conman.h"
  21. LONG g_CountIncomingConnectionObjects;
  22. static const CLSID CLSID_InboundConnectionUi =
  23. {0x7007ACC3,0x3202,0x11D1,{0xAA,0xD2,0x00,0x80,0x5F,0xC1,0x27,0x0E}};
  24. extern const GUID GUID_InboundConfigConnectionId =
  25. { /* 89150b9f-9b5c-11d1-a91f-00805fc1270e */
  26. 0x89150b9f,
  27. 0x9b5c,
  28. 0x11d1,
  29. {0xa9, 0x1f, 0x00, 0x80, 0x5f, 0xc1, 0x27, 0x0e}
  30. };
  31. //+---------------------------------------------------------------------------
  32. //
  33. // Member: CInboundConnection::CreateInstance
  34. //
  35. // Purpose: Creates an inbound connection object.
  36. //
  37. // Arguments:
  38. // fIsConfigConnection [in]
  39. // hRasSrvConn [in]
  40. // pszwName [in]
  41. // pguidId [in]
  42. // riid [in]
  43. // ppv [in]
  44. //
  45. // Returns: S_OK or an error code.
  46. //
  47. // Author: shaunco 12 Nov 1997
  48. //
  49. // Notes:
  50. //
  51. HRESULT
  52. CInboundConnection::CreateInstance (
  53. IN BOOL fIsConfigConnection,
  54. IN HRASSRVCONN hRasSrvConn,
  55. IN PCWSTR pszwName,
  56. IN PCWSTR pszwDeviceName,
  57. IN DWORD dwType,
  58. IN const GUID* pguidId,
  59. IN REFIID riid,
  60. OUT void** ppv)
  61. {
  62. Assert (FIff(fIsConfigConnection, !hRasSrvConn));
  63. Assert (pguidId);
  64. HRESULT hr = E_OUTOFMEMORY;
  65. CInboundConnection* pObj;
  66. pObj = new CComObject <CInboundConnection>;
  67. if (pObj)
  68. {
  69. if (fIsConfigConnection)
  70. {
  71. // No need to start the service (FALSE) since we're being
  72. // created as a result of the service running.
  73. //
  74. pObj->InitializeAsConfigConnection (FALSE);
  75. }
  76. else
  77. {
  78. // Initialize our members.
  79. //
  80. pObj->m_fIsConfigConnection = FALSE;
  81. pObj->m_hRasSrvConn = hRasSrvConn;
  82. pObj->SetName (pszwName);
  83. pObj->SetDeviceName (pszwDeviceName);
  84. switch (dwType)
  85. {
  86. case RASSRVUI_MODEM:
  87. pObj->m_MediaType = NCM_PHONE;
  88. break;
  89. case RASSRVUI_VPN:
  90. pObj->m_MediaType = NCM_TUNNEL;
  91. break;
  92. case RASSRVUI_DCC:
  93. pObj->m_MediaType = NCM_DIRECT;
  94. break;
  95. default:
  96. pObj->m_MediaType = NCM_PHONE;
  97. break;
  98. }
  99. pObj->m_guidId = *pguidId;
  100. // We are now a full-fledged object.
  101. //
  102. pObj->m_fInitialized = TRUE;
  103. }
  104. // Do the standard CComCreator::CreateInstance stuff.
  105. //
  106. pObj->SetVoid (NULL);
  107. pObj->InternalFinalConstructAddRef ();
  108. hr = pObj->FinalConstruct ();
  109. pObj->InternalFinalConstructRelease ();
  110. if (SUCCEEDED(hr))
  111. {
  112. INetConnection* pCon = static_cast<INetConnection*>(pObj);
  113. hr = pCon->QueryInterface (riid, ppv);
  114. }
  115. if (FAILED(hr))
  116. {
  117. delete pObj;
  118. }
  119. }
  120. TraceError ("CInboundConnection::CreateInstance", hr);
  121. return hr;
  122. }
  123. CInboundConnection::CInboundConnection() throw()
  124. {
  125. InterlockedIncrement (&g_CountIncomingConnectionObjects);
  126. m_fIsConfigConnection = FALSE;
  127. m_hRasSrvConn = NULL;
  128. m_MediaType = NCM_NONE;
  129. m_fInitialized = FALSE;
  130. }
  131. CInboundConnection::~CInboundConnection() throw()
  132. {
  133. InterlockedDecrement (&g_CountIncomingConnectionObjects);
  134. }
  135. HRESULT
  136. CInboundConnection::GetCharacteristics (
  137. OUT DWORD* pdwFlags)
  138. {
  139. HRESULT hr = S_OK;
  140. // Validate parameters.
  141. //
  142. if (!pdwFlags)
  143. {
  144. hr = E_POINTER;
  145. }
  146. else if (!m_fInitialized)
  147. {
  148. hr = E_UNEXPECTED;
  149. }
  150. else
  151. {
  152. *pdwFlags = NCCF_INCOMING_ONLY | NCCF_ALL_USERS;
  153. // For the configuration connection, we only allow removal.
  154. // Don't query for NCCF_SHOW_ICON (below) because this connection
  155. // never get's connected.
  156. //
  157. if (m_fIsConfigConnection)
  158. {
  159. *pdwFlags |= NCCF_ALLOW_REMOVAL;
  160. }
  161. else
  162. {
  163. BOOL fShowIcon;
  164. DWORD dwErr = RasSrvQueryShowIcon (&fShowIcon);
  165. TraceError ("RasSrvQueryShowIcon", HRESULT_FROM_WIN32(dwErr));
  166. if ((ERROR_SUCCESS == dwErr) && fShowIcon)
  167. {
  168. *pdwFlags |= NCCF_SHOW_ICON;
  169. }
  170. }
  171. }
  172. TraceError ("CInboundConnection::GetCharacteristics", hr);
  173. return hr;
  174. }
  175. HRESULT
  176. CInboundConnection::GetStatus (
  177. OUT NETCON_STATUS* pStatus)
  178. {
  179. Assert (pStatus);
  180. HRESULT hr = S_OK;
  181. // Initialize the output parameter.
  182. //
  183. *pStatus = NCS_DISCONNECTED;
  184. if (!m_fIsConfigConnection)
  185. {
  186. BOOL fConnected;
  187. DWORD dwErr = RasSrvIsConnectionConnected (m_hRasSrvConn,
  188. &fConnected);
  189. TraceError ("RasSrvIsConnectionConnected",
  190. HRESULT_FROM_WIN32(dwErr));
  191. if ((ERROR_SUCCESS == dwErr) && fConnected)
  192. {
  193. *pStatus = NCS_CONNECTED;
  194. }
  195. }
  196. TraceError ("CInboundConnection::GetStatus", hr);
  197. return hr;
  198. }
  199. //+---------------------------------------------------------------------------
  200. // INetConnection
  201. //
  202. STDMETHODIMP
  203. CInboundConnection::Connect ()
  204. {
  205. return E_NOTIMPL;
  206. }
  207. STDMETHODIMP
  208. CInboundConnection::Disconnect ()
  209. {
  210. HRESULT hr;
  211. // We don't expect to be called on Disconnect if we are the
  212. // configuration connection object. Why? Because this object never
  213. // reports itself as connected through GetStatus.
  214. //
  215. if (!m_fInitialized || m_fIsConfigConnection)
  216. {
  217. hr = E_UNEXPECTED;
  218. }
  219. else
  220. {
  221. DWORD dwErr = RasSrvHangupConnection (m_hRasSrvConn);
  222. hr = HRESULT_FROM_WIN32 (dwErr);
  223. TraceError ("RasSrvHangupConnection", hr);
  224. // Disconnect means this object is no longer valid.
  225. // Indicate so by uniniatializing ourselves (so subsequent
  226. // method calls will fail) and returning S_OBJECT_NO_LONGER_VALID.
  227. //
  228. m_fInitialized = FALSE;
  229. hr = S_OBJECT_NO_LONGER_VALID;
  230. }
  231. TraceError ("CInboundConnection::Disconnect",
  232. (S_OBJECT_NO_LONGER_VALID == hr) ? S_OK : hr);
  233. return hr;
  234. }
  235. STDMETHODIMP
  236. CInboundConnection::Delete ()
  237. {
  238. HRESULT hr;
  239. // We don't expect to be called on Remove if we are not the
  240. // configuration connection object. Why? Because connected objects never
  241. // report themselves as removeable through GetCharacteristics.
  242. //
  243. if (!m_fInitialized || !m_fIsConfigConnection)
  244. {
  245. hr = E_UNEXPECTED;
  246. }
  247. else
  248. {
  249. DWORD dwErr = RasSrvCleanupService ();
  250. hr = HRESULT_FROM_WIN32 (dwErr);
  251. TraceError ("RasSrvCleanupService", hr);
  252. }
  253. TraceError ("CInboundConnection::Delete", hr);
  254. return hr;
  255. }
  256. STDMETHODIMP
  257. CInboundConnection::Duplicate (
  258. IN PCWSTR pszwDuplicateName,
  259. OUT INetConnection** ppCon)
  260. {
  261. return E_NOTIMPL;
  262. }
  263. STDMETHODIMP
  264. CInboundConnection::GetProperties (
  265. OUT NETCON_PROPERTIES** ppProps)
  266. {
  267. HRESULT hr = S_OK;
  268. // Validate parameters.
  269. //
  270. if (!ppProps)
  271. {
  272. hr = E_POINTER;
  273. }
  274. else if (!m_fInitialized)
  275. {
  276. hr = E_UNEXPECTED;
  277. }
  278. else
  279. {
  280. // Initialize the output parameter.
  281. //
  282. *ppProps = NULL;
  283. NETCON_PROPERTIES* pProps;
  284. hr = HrCoTaskMemAlloc (sizeof (NETCON_PROPERTIES),
  285. reinterpret_cast<void**>(&pProps));
  286. if (SUCCEEDED(hr))
  287. {
  288. HRESULT hrT;
  289. ZeroMemory (pProps, sizeof (NETCON_PROPERTIES));
  290. // guidId
  291. //
  292. pProps->guidId = m_guidId;
  293. // pszwName
  294. //
  295. hrT = HrCoTaskMemAllocAndDupSz (PszwName(),
  296. &pProps->pszwName,
  297. NETCON_MAX_NAME_LEN);
  298. if (FAILED(hrT))
  299. {
  300. hr = hrT;
  301. }
  302. // pszwDeviceName
  303. //
  304. if (!m_fIsConfigConnection)
  305. {
  306. hrT = HrCoTaskMemAllocAndDupSz (PszwDeviceName(),
  307. &pProps->pszwDeviceName,
  308. NETCON_MAX_NAME_LEN);
  309. if (FAILED(hrT))
  310. {
  311. hr = hrT;
  312. }
  313. }
  314. // Status
  315. //
  316. hrT = GetStatus (&pProps->Status);
  317. if (FAILED(hrT))
  318. {
  319. hr = hrT;
  320. }
  321. // MediaType
  322. //
  323. pProps->MediaType = m_MediaType;
  324. // dwCharacter
  325. //
  326. hrT = GetCharacteristics (&pProps->dwCharacter);
  327. if (FAILED(hrT))
  328. {
  329. hr = hrT;
  330. }
  331. // clsidThisObject
  332. //
  333. pProps->clsidThisObject = CLSID_InboundConnection;
  334. // clsidUiObject
  335. //
  336. pProps->clsidUiObject = CLSID_InboundConnectionUi;
  337. // Assign the output parameter or cleanup if we had any failures.
  338. //
  339. if (SUCCEEDED(hr))
  340. {
  341. *ppProps = pProps;
  342. }
  343. else
  344. {
  345. Assert (NULL == *ppProps);
  346. FreeNetconProperties (pProps);
  347. }
  348. }
  349. }
  350. TraceError ("CInboundConnection::GetProperties", hr);
  351. return hr;
  352. }
  353. STDMETHODIMP
  354. CInboundConnection::GetUiObjectClassId (
  355. OUT CLSID* pclsid)
  356. {
  357. HRESULT hr = S_OK;
  358. // Validate parameters.
  359. //
  360. if (!pclsid)
  361. {
  362. hr = E_POINTER;
  363. }
  364. else if (!m_fInitialized)
  365. {
  366. hr = E_UNEXPECTED;
  367. }
  368. else
  369. {
  370. *pclsid = CLSID_InboundConnectionUi;
  371. }
  372. TraceError ("CInboundConnection::GetUiObjectClassId", hr);
  373. return hr;
  374. }
  375. STDMETHODIMP
  376. CInboundConnection::Rename (
  377. IN PCWSTR pszwNewName)
  378. {
  379. return E_NOTIMPL;
  380. }
  381. //+---------------------------------------------------------------------------
  382. // INetInboundConnection
  383. //
  384. STDMETHODIMP
  385. CInboundConnection::GetServerConnectionHandle (
  386. OUT ULONG_PTR* phRasSrvConn)
  387. {
  388. HRESULT hr = S_OK;
  389. // If this is the configuration connection, the server connection
  390. // handle better be zero. This is used by the UI object so that it
  391. // knows it is the configuration connection.
  392. //
  393. Assert (FIff (m_fIsConfigConnection, !m_hRasSrvConn));
  394. // Because MIDL doesn't know about HRASSRVCONN's, just make sure
  395. // it is the same size as the ULONG_PTR we pass it as.
  396. //
  397. Assert (sizeof (m_hRasSrvConn) == sizeof (*phRasSrvConn));
  398. *phRasSrvConn = reinterpret_cast<ULONG_PTR>(m_hRasSrvConn);
  399. TraceError ("CInboundConnection::GetServerConnectionHandle", hr);
  400. return hr;
  401. }
  402. STDMETHODIMP
  403. CInboundConnection::InitializeAsConfigConnection (
  404. IN BOOL fStartRemoteAccess)
  405. {
  406. Assert (!m_fInitialized);
  407. // Initialize our members.
  408. //
  409. m_fIsConfigConnection = TRUE;
  410. m_hRasSrvConn = 0;
  411. SetName (SzLoadIds (IDS_INBOUND_CONFIG_CONNECTION_NAME));
  412. SetDeviceName (NULL);
  413. m_MediaType = NCM_NONE;
  414. m_guidId = GUID_InboundConfigConnectionId;
  415. // We are now a full-fledged object.
  416. //
  417. m_fInitialized = TRUE;
  418. // Start the service if we were told.
  419. //
  420. HRESULT hr = S_OK;
  421. if (fStartRemoteAccess)
  422. {
  423. DWORD dwErr = RasSrvInitializeService ();
  424. hr = HRESULT_FROM_WIN32 (dwErr);
  425. TraceError ("RasSrvInitializeService", hr);
  426. }
  427. TraceError ("CInboundConnection::InitializeAsConfigConnection", hr);
  428. return hr;
  429. }
  430. //+---------------------------------------------------------------------------
  431. // IPersistNetConnection
  432. //
  433. STDMETHODIMP
  434. CInboundConnection::GetClassID (
  435. OUT CLSID* pclsid)
  436. {
  437. HRESULT hr = S_OK;
  438. // Validate parameters.
  439. //
  440. if (!pclsid)
  441. {
  442. hr = E_POINTER;
  443. }
  444. else
  445. {
  446. *pclsid = CLSID_InboundConnection;
  447. }
  448. TraceError ("CInboundConnection::GetClassID", hr);
  449. return hr;
  450. }
  451. static const WCHAR c_chwLead = 0x19;
  452. static const WCHAR c_chwTrail = 0x07;
  453. STDMETHODIMP
  454. CInboundConnection::GetSizeMax (
  455. OUT ULONG* pcbSize)
  456. {
  457. HRESULT hr = S_OK;
  458. // Validate parameters.
  459. //
  460. if (!pcbSize)
  461. {
  462. hr = E_POINTER;
  463. }
  464. else if (!m_fInitialized)
  465. {
  466. hr = E_UNEXPECTED;
  467. }
  468. else
  469. {
  470. // Size the buffer for the following form:
  471. // +--------------------------------------------------------------+
  472. // |0x19<m_fIsConfigConnection><m_hRasSrvConn><m_strName>...\00x07|
  473. // +--------------------------------------------------------------+
  474. //
  475. // m_strDeviceName may be empty, in which case we want to still
  476. // store the null-terminator. Don't use PszwDeviceName() as it
  477. // returns NULL when m_strDeviceName is empty.
  478. //
  479. *pcbSize = sizeof (c_chwLead) +
  480. sizeof (m_fIsConfigConnection) +
  481. sizeof (m_hRasSrvConn) +
  482. CbOfSzAndTerm (PszwName()) +
  483. CbOfSzAndTerm (m_strDeviceName.c_str()) +
  484. sizeof (m_MediaType) +
  485. sizeof (m_guidId) +
  486. sizeof (c_chwTrail);
  487. }
  488. TraceError ("CInboundConnection::GetSizeMax", hr);
  489. return hr;
  490. }
  491. STDMETHODIMP
  492. CInboundConnection::Load (
  493. IN const BYTE* pbBuf,
  494. IN ULONG cbSize)
  495. {
  496. // The theoretical minimum size for the buffer. Computed
  497. // as the number of bytes in the following minimum string:
  498. //
  499. const ULONG c_cbSizeMin = sizeof (c_chwLead) +
  500. sizeof (m_fIsConfigConnection) +
  501. sizeof (m_hRasSrvConn) +
  502. 4 + // 4 bytes for 1 UNICODE char and NULL
  503. 2 + // 1 UNICODE NULL for empty device name
  504. sizeof (m_MediaType) +
  505. sizeof (m_guidId) +
  506. sizeof (c_chwTrail);
  507. HRESULT hr = E_INVALIDARG;
  508. // Validate parameters.
  509. //
  510. if (!pbBuf)
  511. {
  512. hr = E_POINTER;
  513. }
  514. else if (cbSize < c_cbSizeMin)
  515. {
  516. hr = E_INVALIDARG;
  517. }
  518. // We can only accept one call on this method and only if we're not
  519. // already initialized.
  520. //
  521. else if (m_fInitialized)
  522. {
  523. hr = E_UNEXPECTED;
  524. }
  525. else
  526. {
  527. // The buffer *should* look like this:
  528. // +--------------------------------------------------------------+
  529. // |0x19<m_fIsConfigConnection><m_hRasSrvConn><m_strName>...\00x07|
  530. // +--------------------------------------------------------------+
  531. //
  532. const WCHAR * pchw;
  533. const WCHAR * pchwMax;
  534. const BOOL UNALIGNED * pfIsConfigConnection;
  535. BOOL fIsConfigConnection;
  536. const HRASSRVCONN UNALIGNED * phRasSrvCon;
  537. HRASSRVCONN hRasSrvConn;
  538. PCWSTR pszwName;
  539. PCWSTR pszwDeviceName;
  540. const NETCON_MEDIATYPE UNALIGNED * pMediaType;
  541. const GUID UNALIGNED * pguidTemp;
  542. const GUID UNALIGNED * pguidId;
  543. NETCON_MEDIATYPE MediaType;
  544. pchw = reinterpret_cast<const WCHAR*>(pbBuf);
  545. // The last valid pointer for the embedded strings.
  546. //
  547. pchwMax = reinterpret_cast<const WCHAR*>(pbBuf + cbSize
  548. - (sizeof (m_MediaType) +
  549. sizeof (m_guidId) +
  550. sizeof (c_chwTrail)));
  551. // Check our lead byte.
  552. //
  553. if (c_chwLead != *pchw)
  554. {
  555. goto finished;
  556. }
  557. pchw++;
  558. // Get m_fIsConfigConnection.
  559. //
  560. pfIsConfigConnection = reinterpret_cast<const BOOL*>(pchw);
  561. CopyMemory(&fIsConfigConnection, pfIsConfigConnection, sizeof(fIsConfigConnection));
  562. pfIsConfigConnection++;
  563. // Get m_hRasSrvConn.
  564. //
  565. phRasSrvCon = reinterpret_cast<const HRASSRVCONN*>(pfIsConfigConnection);
  566. CopyMemory(&hRasSrvConn, phRasSrvCon, sizeof(hRasSrvConn));
  567. phRasSrvCon++;
  568. // Get m_strName. Search for the terminating null and make sure
  569. // we find it before the end of the buffer. Using lstrlen to skip
  570. // the string can result in an AV in the event the string is not
  571. // actually null-terminated.
  572. //
  573. pchw = reinterpret_cast<const WCHAR*>(phRasSrvCon);
  574. for (pszwName = pchw; ; pchw++)
  575. {
  576. if (pchw >= pchwMax)
  577. {
  578. goto finished;
  579. }
  580. if (0 == *pchw)
  581. {
  582. pchw++;
  583. break;
  584. }
  585. }
  586. // Get m_strDeviceName. Search for the terminating null and make
  587. // sure we find it before the end of the buffer.
  588. //
  589. for (pszwDeviceName = pchw; ; pchw++)
  590. {
  591. if (pchw >= pchwMax)
  592. {
  593. goto finished;
  594. }
  595. if (0 == *pchw)
  596. {
  597. pchw++;
  598. break;
  599. }
  600. }
  601. // Get m_MediaType.
  602. //
  603. pMediaType = reinterpret_cast<const NETCON_MEDIATYPE*>(pchw);
  604. CopyMemory(&MediaType, pMediaType, sizeof(MediaType));
  605. pMediaType++;
  606. // Get m_guidId.
  607. //
  608. pguidTemp = reinterpret_cast<const GUID*>(pMediaType);
  609. pguidId = pguidTemp;
  610. pguidTemp++;
  611. // Check our trail byte.
  612. //
  613. pchw = reinterpret_cast<const WCHAR*>(pguidTemp);
  614. if (c_chwTrail != *pchw)
  615. {
  616. goto finished;
  617. }
  618. // If we're the configuration object, we can't have a connection
  619. // HANDLE and vice-versa.
  620. //
  621. if ((fIsConfigConnection && hRasSrvConn) ||
  622. (!fIsConfigConnection && !hRasSrvConn))
  623. {
  624. goto finished;
  625. }
  626. // We are now a full-fledged object.
  627. //
  628. m_fIsConfigConnection = fIsConfigConnection;
  629. m_hRasSrvConn = hRasSrvConn;
  630. SetName (pszwName);
  631. SetDeviceName (pszwDeviceName);
  632. m_MediaType = MediaType;
  633. CopyMemory(&m_guidId, pguidId, sizeof(m_guidId));
  634. m_fInitialized = TRUE;
  635. hr = S_OK;
  636. finished:
  637. ;
  638. }
  639. TraceError ("CInboundConnection::Load", hr);
  640. return hr;
  641. }
  642. STDMETHODIMP
  643. CInboundConnection::Save (
  644. OUT BYTE* pbBuf,
  645. IN ULONG cbSize)
  646. {
  647. HRESULT hr = S_OK;
  648. // Validate parameters.
  649. //
  650. if (!pbBuf)
  651. {
  652. hr = E_POINTER;
  653. }
  654. else if (!m_fInitialized)
  655. {
  656. hr = E_UNEXPECTED;
  657. }
  658. else
  659. {
  660. // Make sure the user's buffer is big enough.
  661. //
  662. ULONG cbSizeRequired;
  663. SideAssert (SUCCEEDED(GetSizeMax(&cbSizeRequired)));
  664. if (cbSize < cbSizeRequired)
  665. {
  666. hr = E_INVALIDARG;
  667. }
  668. else
  669. {
  670. // Make the buffer look like this when we're done:
  671. // +--------------------------------------------------------------+
  672. // |0x19<m_fIsConfigConnection><m_hRasSrvConn><m_strName>...\00x07|
  673. // +--------------------------------------------------------------+
  674. //
  675. WCHAR* pchw = reinterpret_cast<WCHAR*>(pbBuf);
  676. // Put our lead byte.
  677. //
  678. *pchw = c_chwLead;
  679. pchw++;
  680. // Put m_fIsConfigConnection.
  681. //
  682. BOOL UNALIGNED *pfIsConfigConnection =
  683. reinterpret_cast<BOOL*>(pchw);
  684. CopyMemory(pfIsConfigConnection, &m_fIsConfigConnection, sizeof(m_fIsConfigConnection));
  685. pfIsConfigConnection++;
  686. // Put m_hRasSrvConn.
  687. //
  688. HRASSRVCONN UNALIGNED *phRasSrvCon =
  689. reinterpret_cast<HRASSRVCONN*>(pfIsConfigConnection);
  690. CopyMemory(phRasSrvCon, &m_hRasSrvConn, sizeof(m_hRasSrvConn));
  691. phRasSrvCon++;
  692. // Put m_strName.
  693. //
  694. pchw = reinterpret_cast<WCHAR*>(phRasSrvCon);
  695. lstrcpyW (pchw, PszwName());
  696. pchw += lstrlenW (PszwName()) + 1;
  697. // Put m_strDeviceName.
  698. //
  699. lstrcpyW (pchw, m_strDeviceName.c_str());
  700. pchw += m_strDeviceName.length() + 1;
  701. // Put m_MediaType.
  702. //
  703. NETCON_MEDIATYPE UNALIGNED *pMediaType = reinterpret_cast<NETCON_MEDIATYPE*>(pchw);
  704. CopyMemory(pMediaType, &m_MediaType, sizeof(m_MediaType));
  705. pMediaType++;
  706. // Put m_guidId.
  707. //
  708. GUID UNALIGNED *pguidId = reinterpret_cast<GUID*>(pMediaType);
  709. CopyMemory(pguidId, &m_guidId, sizeof(m_guidId));
  710. pguidId++;
  711. // Put our trail byte.
  712. //
  713. pchw = reinterpret_cast<WCHAR*>(pguidId);
  714. *pchw = c_chwTrail;
  715. pchw++;
  716. AssertSz (pbBuf + cbSizeRequired == (BYTE*)pchw,
  717. "pch isn't pointing where it should be.");
  718. }
  719. }
  720. TraceError ("CInboundConnection::Save", hr);
  721. return hr;
  722. }
  723. #define ID_DEVICE_DATABASE 1
  724. #define ID_MISC_DATABASE 8
  725. //+---------------------------------------------------------------------------
  726. //
  727. // Function: IconStateChanged
  728. //
  729. // Purpose: Fires an event to notify NetShell of a Change occuring in an
  730. // incoming connection.
  731. //
  732. // Arguments:
  733. //
  734. // Returns: S_OK on success; error otherwise
  735. //
  736. // Author: ckotze 25 September 2000
  737. //
  738. // Notes:
  739. //
  740. HRESULT CInboundConnection::IconStateChanged()
  741. {
  742. HRESULT hr = S_OK;
  743. IncomingEventNotify(REFRESH_ALL, NULL, NULL, NULL);
  744. return hr;
  745. }