Source code of Windows XP (NT5)
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.

282 lines
5.6 KiB

  1. /*
  2. Copyright (c) 1997, Microsoft Corporation, all rights reserved
  3. Description:
  4. History:
  5. */
  6. #include <eaptypeid.h>
  7. #include "ceapcfg.h"
  8. extern "C"
  9. DWORD
  10. InvokeServerConfigUI(
  11. IN HWND hWnd,
  12. IN CHAR* pszMachineName
  13. );
  14. extern "C"
  15. DWORD
  16. RasEapGetIdentity(
  17. IN DWORD dwEapTypeId,
  18. IN HWND hwndParent,
  19. IN DWORD dwFlags,
  20. IN const WCHAR* pwszPhonebook,
  21. IN const WCHAR* pwszEntry,
  22. IN BYTE* pConnectionDataIn,
  23. IN DWORD dwSizeOfConnectionDataIn,
  24. IN BYTE* pUserDataIn,
  25. IN DWORD dwSizeOfUserDataIn,
  26. OUT BYTE** ppUserDataOut,
  27. OUT DWORD* pdwSizeOfUserDataOut,
  28. OUT WCHAR** ppwszIdentityOut
  29. );
  30. extern "C"
  31. DWORD
  32. RasEapInvokeConfigUI(
  33. IN DWORD dwEapTypeId,
  34. IN HWND hwndParent,
  35. IN DWORD dwFlags,
  36. IN BYTE* pConnectionDataIn,
  37. IN DWORD dwSizeOfConnectionDataIn,
  38. OUT BYTE** ppConnectionDataOut,
  39. OUT DWORD* pdwSizeOfConnectionDataOut
  40. );
  41. extern "C"
  42. DWORD
  43. RasEapFreeMemory(
  44. IN BYTE* pMemory
  45. );
  46. /*
  47. Returns:
  48. Notes:
  49. Implementation of IEAPProviderConfig::Initialize
  50. */
  51. STDMETHODIMP
  52. CEapCfg::Initialize(
  53. LPCOLESTR pwszMachineName,
  54. DWORD dwEapTypeId,
  55. ULONG_PTR* puConnectionParam
  56. )
  57. {
  58. size_t size;
  59. CHAR* psz = NULL;
  60. DWORD dwErr = NO_ERROR;
  61. *puConnectionParam = NULL;
  62. size = wcslen(pwszMachineName);
  63. psz = (CHAR*) LocalAlloc(LPTR, (size + 1)*sizeof(CHAR));
  64. if (NULL == psz)
  65. {
  66. dwErr = GetLastError();
  67. goto LDone;
  68. }
  69. if ( 0 == WideCharToMultiByte(
  70. CP_ACP,
  71. 0,
  72. pwszMachineName,
  73. -1,
  74. psz,
  75. size+1,
  76. NULL,
  77. NULL ) )
  78. {
  79. dwErr = GetLastError();
  80. goto LDone;
  81. }
  82. *puConnectionParam = (ULONG_PTR)psz;
  83. psz = NULL;
  84. LDone:
  85. LocalFree(psz);
  86. return(HRESULT_FROM_WIN32(dwErr));
  87. }
  88. /*
  89. Returns:
  90. Notes:
  91. Implementation of IEAPProviderConfig::Uninitialize
  92. */
  93. STDMETHODIMP
  94. CEapCfg::Uninitialize(
  95. DWORD dwEapTypeId,
  96. ULONG_PTR uConnectionParam
  97. )
  98. {
  99. LocalFree((VOID*)uConnectionParam);
  100. return(HRESULT_FROM_WIN32(NO_ERROR));
  101. }
  102. /*
  103. Returns:
  104. Notes:
  105. Implementation of IEAPProviderConfig::ServerInvokeConfigUI
  106. hWnd - handle to the parent window
  107. dwRes1 - reserved parameter (ignore)
  108. dwRes2 - reserved parameter (ignore)
  109. */
  110. STDMETHODIMP
  111. CEapCfg::ServerInvokeConfigUI(
  112. DWORD dwEapTypeId,
  113. ULONG_PTR uConnectionParam,
  114. HWND hWnd,
  115. DWORD_PTR dwRes1,
  116. DWORD_PTR dwRes2
  117. )
  118. {
  119. CHAR* pszMachineName;
  120. HRESULT hr;
  121. DWORD dwErr;
  122. pszMachineName = (CHAR*)uConnectionParam;
  123. if (NULL == pszMachineName)
  124. {
  125. dwErr = E_FAIL;
  126. }
  127. else
  128. {
  129. //Invoke configuration UI here.
  130. dwErr = InvokeServerConfigUI(hWnd, pszMachineName);
  131. }
  132. hr = HRESULT_FROM_WIN32(dwErr);
  133. return(hr);
  134. }
  135. /*
  136. Returns:
  137. Notes:
  138. Implementation of IEAPProviderConfig::RouterInvokeConfigUI
  139. */
  140. STDMETHODIMP
  141. CEapCfg::RouterInvokeConfigUI(
  142. DWORD dwEapTypeId,
  143. ULONG_PTR uConnectionParam,
  144. HWND hwndParent,
  145. DWORD dwFlags,
  146. BYTE* pConnectionDataIn,
  147. DWORD dwSizeOfConnectionDataIn,
  148. BYTE** ppConnectionDataOut,
  149. DWORD* pdwSizeOfConnectionDataOut
  150. )
  151. {
  152. DWORD dwErr = NO_ERROR;
  153. BYTE* pConnectionDataOut = NULL;
  154. DWORD dwSizeOfConnectionDataOut = 0;
  155. *ppConnectionDataOut = NULL;
  156. *pdwSizeOfConnectionDataOut = 0;
  157. dwErr = RasEapInvokeConfigUI(
  158. dwEapTypeId,
  159. hwndParent,
  160. dwFlags,
  161. pConnectionDataIn,
  162. dwSizeOfConnectionDataIn,
  163. &pConnectionDataOut,
  164. &dwSizeOfConnectionDataOut);
  165. if ( (NO_ERROR == dwErr)
  166. && (0 != dwSizeOfConnectionDataOut))
  167. {
  168. *ppConnectionDataOut = (BYTE*)CoTaskMemAlloc(dwSizeOfConnectionDataOut);
  169. if (NULL == *ppConnectionDataOut)
  170. {
  171. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  172. goto LDone;
  173. }
  174. CopyMemory(*ppConnectionDataOut, pConnectionDataOut,
  175. dwSizeOfConnectionDataOut);
  176. *pdwSizeOfConnectionDataOut = dwSizeOfConnectionDataOut;
  177. }
  178. LDone:
  179. RasEapFreeMemory(pConnectionDataOut);
  180. return(HRESULT_FROM_WIN32(dwErr));
  181. }
  182. /*
  183. Returns:
  184. Notes:
  185. Implementation of IEAPProviderConfig::RouterInvokeCredentialsUI
  186. */
  187. STDMETHODIMP
  188. CEapCfg::RouterInvokeCredentialsUI(
  189. DWORD dwEapTypeId,
  190. ULONG_PTR uConnectionParam,
  191. HWND hwndParent,
  192. DWORD dwFlags,
  193. BYTE* pConnectionDataIn,
  194. DWORD dwSizeOfConnectionDataIn,
  195. BYTE* pUserDataIn,
  196. DWORD dwSizeOfUserDataIn,
  197. BYTE** ppUserDataOut,
  198. DWORD* pdwSizeOfUserDataOut
  199. )
  200. {
  201. return RasEapGetIdentity(
  202. dwEapTypeId,
  203. hwndParent,
  204. dwFlags,
  205. NULL,
  206. NULL,
  207. pConnectionDataIn,
  208. dwSizeOfConnectionDataIn,
  209. pUserDataIn,
  210. dwSizeOfUserDataIn,
  211. ppUserDataOut,
  212. pdwSizeOfUserDataOut,
  213. NULL
  214. );
  215. }