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.

288 lines
6.2 KiB

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