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.

1101 lines
35 KiB

  1. #include "precomp.h"
  2. #include <wininet.h>
  3. #include "rashelp.h"
  4. RASENUMCONNECTIONSA g_pfnRasEnumConnectionsA;
  5. RASHANGUPA g_pfnRasHangupA;
  6. RASGETCONNECTSTATUSA g_pfnRasGetConnectStatusA;
  7. RASENUMENTRIESA g_pfnRasEnumEntriesA;
  8. RASENUMENTRIESW g_pfnRasEnumEntriesW;
  9. RASDELETEENTRYA g_pfnRasDeleteEntryA;
  10. RASDELETEENTRYW g_pfnRasDeleteEntryW;
  11. RASENUMDEVICESA g_pfnRasEnumDevicesA;
  12. RASENUMDEVICESW g_pfnRasEnumDevicesW;
  13. RASGETENTRYPROPERTIESA g_pfnRasGetEntryPropertiesA;
  14. RASGETENTRYPROPERTIESW g_pfnRasGetEntryPropertiesW;
  15. RASGETENTRYDIALPARAMSA g_pfnRasGetEntryDialParamsA;
  16. RASGETENTRYDIALPARAMSW g_pfnRasGetEntryDialParamsW;
  17. RASSETENTRYPROPERTIESA g_pfnRasSetEntryPropertiesA;
  18. RASSETENTRYPROPERTIESW g_pfnRasSetEntryPropertiesW;
  19. RASSETENTRYDIALPARAMSA g_pfnRasSetEntryDialParamsA;
  20. RASSETENTRYDIALPARAMSW g_pfnRasSetEntryDialParamsW;
  21. // Private forward decalarations
  22. void rasEntryNameA2W(const LPRASENTRYNAMEA prenSourceA, LPRASENTRYNAMEW prenTargetW);
  23. void rasEntryNameW2A(const LPRASENTRYNAMEW prenSourceW, LPRASENTRYNAMEA prenTargetA);
  24. void rasEntryA2W(const LPRASENTRYA preSourceA, LPRASENTRYW preTargetW);
  25. void rasEntryW2A(const LPRASENTRYW preSourceW, LPRASENTRYA preTargetA);
  26. void rasDevInfoA2W(const LPRASDEVINFOA prdiSourceA, LPRASDEVINFOW prdiTargetW);
  27. void rasDialParamsA2W(const LPRASDIALPARAMSA prdpSourceA, LPRASDIALPARAMSW prdpTargetW);
  28. void rasDialParamsW2A(const LPRASDIALPARAMSW prdpSourceW, LPRASDIALPARAMSA prdpTargetA);
  29. BOOL RasIsInstalled()
  30. {
  31. static int s_iRasInstalled = -1; // not initialized
  32. if (s_iRasInstalled == -1) {
  33. DWORD dwFlags;
  34. dwFlags = 0;
  35. InternetGetConnectedStateEx(&dwFlags, NULL, 0, 0);
  36. s_iRasInstalled = HasFlag(dwFlags, INTERNET_RAS_INSTALLED) ? 1 : 0;
  37. }
  38. ASSERT(s_iRasInstalled == (int)FALSE || s_iRasInstalled == (int)TRUE);
  39. return (BOOL)s_iRasInstalled;
  40. }
  41. BOOL RasPrepareApis(DWORD dwApiFlags, BOOL fLoad /*= TRUE*/)
  42. {
  43. static struct {
  44. DWORD dwApiFlag;
  45. PCSTR pszApiName;
  46. PVOID *ppfn;
  47. } s_rgApisMap[] = {
  48. { RPA_RASENUMCONNECTIONSA, "RasEnumConnectionsA", (PVOID *)&g_pfnRasEnumConnectionsA },
  49. { RPA_RASHANGUPA, "RasHangUpA", (PVOID *)&g_pfnRasHangupA },
  50. { RPA_RASGETCONNECTSTATUSA, "RasGetConnectStatusA", (PVOID *)&g_pfnRasGetConnectStatusA },
  51. { RPA_RASENUMENTRIESA, "RasEnumEntriesA", (PVOID *)&g_pfnRasEnumEntriesA },
  52. { RPA_RASENUMENTRIESW, "RasEnumEntriesW", (PVOID *)&g_pfnRasEnumEntriesW },
  53. { RPA_RASDELETEENTRYA, "RasDeleteEntryA", (PVOID *)&g_pfnRasDeleteEntryA },
  54. { RPA_RASDELETEENTRYW, "RasDeleteEntryW", (PVOID *)&g_pfnRasDeleteEntryW },
  55. { RPA_RASENUMDEVICESA, "RasEnumDevicesA", (PVOID *)&g_pfnRasEnumDevicesA },
  56. { RPA_RASENUMDEVICESW, "RasEnumDevicesW", (PVOID *)&g_pfnRasEnumDevicesW },
  57. { RPA_RASGETENTRYPROPERTIESA, "RasGetEntryPropertiesA", (PVOID *)&g_pfnRasGetEntryPropertiesA },
  58. { RPA_RASGETENTRYPROPERTIESW, "RasGetEntryPropertiesW", (PVOID *)&g_pfnRasGetEntryPropertiesW },
  59. { RPA_RASGETENTRYDIALPARAMSA, "RasGetEntryDialParamsA", (PVOID *)&g_pfnRasGetEntryDialParamsA },
  60. { RPA_RASGETENTRYDIALPARAMSW, "RasGetEntryDialParamsW", (PVOID *)&g_pfnRasGetEntryDialParamsW },
  61. { RPA_RASSETENTRYPROPERTIESA, "RasSetEntryPropertiesA", (PVOID *)&g_pfnRasSetEntryPropertiesA },
  62. { RPA_RASSETENTRYPROPERTIESW, "RasSetEntryPropertiesW", (PVOID *)&g_pfnRasSetEntryPropertiesW },
  63. { RPA_RASSETENTRYDIALPARAMSA, "RasSetEntryDialParamsA", (PVOID *)&g_pfnRasSetEntryDialParamsA },
  64. { RPA_RASSETENTRYDIALPARAMSW, "RasSetEntryDialParamsW", (PVOID *)&g_pfnRasSetEntryDialParamsW }
  65. };
  66. static HINSTANCE s_hRasDll, s_hRnaDll;
  67. static UINT s_nLoadRef;
  68. UINT i;
  69. if (fLoad) {
  70. if (!RasIsInstalled())
  71. return FALSE;
  72. if (s_hRasDll == NULL) {
  73. ASSERT(s_nLoadRef == 0);
  74. s_hRasDll = LoadLibrary(TEXT("rasapi32.dll"));
  75. if (s_hRasDll == NULL)
  76. return FALSE;
  77. }
  78. s_nLoadRef++;
  79. for (i = 0; i < countof(s_rgApisMap); i++) {
  80. if (!HasFlag(dwApiFlags, s_rgApisMap[i].dwApiFlag))
  81. continue;
  82. ASSERT(s_rgApisMap[i].ppfn != NULL);
  83. if (*s_rgApisMap[i].ppfn != NULL)
  84. continue;
  85. *s_rgApisMap[i].ppfn = GetProcAddress(s_hRasDll, s_rgApisMap[i].pszApiName);
  86. if (*s_rgApisMap[i].ppfn == NULL) {
  87. if (s_hRnaDll == NULL) {
  88. s_hRnaDll = LoadLibrary(TEXT("rnaph.dll"));
  89. if (s_hRnaDll == NULL)
  90. return FALSE;
  91. }
  92. *s_rgApisMap[i].ppfn = GetProcAddress(s_hRnaDll, s_rgApisMap[i].pszApiName);
  93. if (*s_rgApisMap[i].ppfn == NULL)
  94. return FALSE;
  95. }
  96. }
  97. }
  98. else { /* if (!fLoad) */
  99. if (s_nLoadRef == 1) {
  100. for (i = 0; i < countof(s_rgApisMap); i++)
  101. *s_rgApisMap[i].ppfn = NULL;
  102. if (s_hRnaDll != NULL) {
  103. FreeLibrary(s_hRnaDll);
  104. s_hRnaDll = NULL;
  105. }
  106. ASSERT(s_hRasDll != NULL)
  107. FreeLibrary(s_hRasDll);
  108. s_hRasDll = NULL;
  109. }
  110. if (s_nLoadRef > 0)
  111. s_nLoadRef--;
  112. }
  113. return TRUE;
  114. }
  115. BOOL RasEnumEntriesCallback(PCTSTR pszPhonebook, PVOID pfnEnumAorW, LPARAM lParam,
  116. DWORD dwMode /*= RWM_RUNTIME*/)
  117. {
  118. USES_CONVERSION;
  119. PBYTE pBlob;
  120. DWORD cEntries,
  121. dwResult;
  122. UINT i;
  123. BOOL fCallback,
  124. fResult;
  125. if (!RasIsInstalled()) {
  126. ((RASENUMPROCW)pfnEnumAorW)(NULL, lParam); // for LAN settings
  127. return TRUE;
  128. }
  129. pBlob = NULL;
  130. cEntries = 0;
  131. fResult = FALSE;
  132. if (dwMode != RWM_FORCE_A)
  133. dwResult = RasEnumEntriesExW(T2CW(pszPhonebook), (LPRASENTRYNAMEW *)&pBlob, NULL, &cEntries, dwMode);
  134. else
  135. dwResult = RasEnumEntriesExA(T2CA(pszPhonebook), (LPRASENTRYNAMEA *)&pBlob, NULL, &cEntries);
  136. if (dwResult != ERROR_SUCCESS)
  137. goto Exit;
  138. for (i = 0; i < cEntries; i++) {
  139. if (dwMode != RWM_FORCE_A)
  140. fCallback = ((RASENUMPROCW)pfnEnumAorW)(((LPRASENTRYNAMEW)pBlob + i)->szEntryName, lParam);
  141. else
  142. fCallback = ((RASENUMPROCA)pfnEnumAorW)(((LPRASENTRYNAMEA)pBlob + i)->szEntryName, lParam);
  143. if (!fCallback)
  144. break;
  145. }
  146. fResult = TRUE;
  147. Exit:
  148. if (pBlob != NULL)
  149. CoTaskMemFree(pBlob);
  150. ((RASENUMPROCW)pfnEnumAorW)(NULL, lParam); // for LAN settings
  151. return fResult;
  152. }
  153. DWORD RasEnumConnectionsExA(LPRASCONNA *pprcA, PDWORD pcbBuffer, PDWORD pcEntries)
  154. {
  155. LPRASCONNA prcA;
  156. DWORD cbBuffer, cEntries,
  157. dwResult;
  158. BOOL fRasApisLoaded;
  159. ASSERT(RasIsInstalled());
  160. if (pprcA == NULL || pcEntries == NULL)
  161. return ERROR_INVALID_PARAMETER;
  162. *pprcA = NULL;
  163. if (pcbBuffer != NULL)
  164. *pcbBuffer = 0;
  165. *pcEntries = 0;
  166. cbBuffer = sizeof(RASCONNA);
  167. cEntries = 0;
  168. fRasApisLoaded = FALSE;
  169. prcA = (LPRASCONNA)CoTaskMemAlloc(sizeof(RASCONNA));
  170. if (prcA == NULL) {
  171. dwResult = ERROR_NOT_ENOUGH_MEMORY;
  172. goto Exit;
  173. }
  174. ZeroMemory(prcA, sizeof(RASCONNA));
  175. prcA[0].dwSize = sizeof(RASCONNA);
  176. if (!RasPrepareApis(RPA_RASENUMCONNECTIONSA) || g_pfnRasEnumConnectionsA == NULL) {
  177. dwResult = ERROR_INVALID_FUNCTION;
  178. goto Exit;
  179. }
  180. fRasApisLoaded = TRUE;
  181. dwResult = g_pfnRasEnumConnectionsA(prcA, &cbBuffer, &cEntries);
  182. if (dwResult == ERROR_BUFFER_TOO_SMALL || dwResult == ERROR_NOT_ENOUGH_MEMORY) {
  183. prcA = (LPRASCONNA)CoTaskMemRealloc(prcA, cbBuffer);
  184. if (prcA == NULL) {
  185. dwResult = ERROR_NOT_ENOUGH_MEMORY;
  186. goto Exit;
  187. }
  188. ZeroMemory(prcA, cbBuffer);
  189. prcA[0].dwSize = sizeof(RASCONNA);
  190. cEntries = 0;
  191. dwResult = g_pfnRasEnumConnectionsA(prcA, &cbBuffer, &cEntries);
  192. }
  193. if (dwResult != ERROR_SUCCESS)
  194. goto Exit;
  195. if (cEntries > 0) {
  196. *pprcA = prcA;
  197. if (pcbBuffer != NULL)
  198. *pcbBuffer = cbBuffer;
  199. }
  200. *pcEntries = cEntries;
  201. Exit:
  202. if ((dwResult != ERROR_SUCCESS || cEntries == 0) && prcA != NULL)
  203. CoTaskMemFree(prcA);
  204. if (fRasApisLoaded)
  205. RasPrepareApis(RPA_UNLOAD, FALSE);
  206. return dwResult;
  207. }
  208. DWORD RasEnumEntriesExA(PCSTR pszPhonebookA, LPRASENTRYNAMEA *pprenA, PDWORD pcbBuffer, PDWORD pcEntries)
  209. {
  210. LPRASENTRYNAMEA prenA;
  211. DWORD cbBuffer, cEntries,
  212. dwResult;
  213. BOOL fRasApisLoaded;
  214. ASSERT(RasIsInstalled());
  215. if (pprenA == NULL || pcEntries == NULL)
  216. return ERROR_INVALID_PARAMETER;
  217. *pprenA = NULL;
  218. if (pcbBuffer != NULL)
  219. *pcbBuffer = 0;
  220. *pcEntries = 0;
  221. cbBuffer = sizeof(RASENTRYNAMEA);
  222. cEntries = 0;
  223. fRasApisLoaded = FALSE;
  224. prenA = (LPRASENTRYNAMEA)CoTaskMemAlloc(sizeof(RASENTRYNAMEA));
  225. if (prenA == NULL) {
  226. dwResult = ERROR_NOT_ENOUGH_MEMORY;
  227. goto Exit;
  228. }
  229. ZeroMemory(prenA, sizeof(RASENTRYNAMEA));
  230. prenA[0].dwSize = sizeof(RASENTRYNAMEA);
  231. if (!RasPrepareApis(RPA_RASENUMENTRIESA) || g_pfnRasEnumEntriesA == NULL) {
  232. dwResult = ERROR_INVALID_FUNCTION;
  233. goto Exit;
  234. }
  235. fRasApisLoaded = TRUE;
  236. dwResult = g_pfnRasEnumEntriesA(NULL, pszPhonebookA, prenA, &cbBuffer, &cEntries);
  237. if (dwResult == ERROR_BUFFER_TOO_SMALL || dwResult == ERROR_NOT_ENOUGH_MEMORY) {
  238. prenA = (LPRASENTRYNAMEA)CoTaskMemRealloc(prenA, cbBuffer);
  239. if (prenA == NULL) {
  240. dwResult = ERROR_NOT_ENOUGH_MEMORY;
  241. goto Exit;
  242. }
  243. ZeroMemory(prenA, cbBuffer);
  244. prenA[0].dwSize = sizeof(RASENTRYNAMEA);
  245. cEntries = 0;
  246. dwResult = g_pfnRasEnumEntriesA(NULL, pszPhonebookA, prenA, &cbBuffer, &cEntries);
  247. }
  248. if (dwResult != ERROR_SUCCESS)
  249. goto Exit;
  250. if (cEntries > 0) {
  251. *pprenA = prenA;
  252. if (pcbBuffer != NULL)
  253. *pcbBuffer = cbBuffer;
  254. }
  255. *pcEntries = cEntries;
  256. Exit:
  257. if ((dwResult != ERROR_SUCCESS || cEntries == 0) && prenA != NULL)
  258. CoTaskMemFree(prenA);
  259. if (fRasApisLoaded)
  260. RasPrepareApis(RPA_UNLOAD, FALSE);
  261. return dwResult;
  262. }
  263. DWORD RasEnumEntriesExW(PCWSTR pszPhonebookW, LPRASENTRYNAMEW *pprenW, PDWORD pcbBuffer, PDWORD pcEntries,
  264. DWORD dwMode /*= RWM_RUNTIME*/)
  265. {
  266. LPRASENTRYNAMEW prenW;
  267. DWORD cbBuffer, cEntries,
  268. dwResult;
  269. ASSERT(RasIsInstalled());
  270. if (pprenW == NULL || pcEntries == NULL)
  271. return ERROR_INVALID_PARAMETER;
  272. *pprenW = NULL;
  273. if (pcbBuffer != NULL)
  274. *pcbBuffer = 0;
  275. *pcEntries = 0;
  276. cbBuffer = sizeof(RASENTRYNAMEW);
  277. cEntries = 0;
  278. prenW = (LPRASENTRYNAMEW)CoTaskMemAlloc(sizeof(RASENTRYNAMEW));
  279. if (prenW == NULL) {
  280. dwResult = ERROR_NOT_ENOUGH_MEMORY;
  281. goto Exit;
  282. }
  283. ZeroMemory(prenW, sizeof(RASENTRYNAMEW));
  284. prenW[0].dwSize = sizeof(RASENTRYNAMEW);
  285. dwResult = RasEnumEntriesWrap(pszPhonebookW, prenW, &cbBuffer, &cEntries, dwMode);
  286. if (dwResult == ERROR_BUFFER_TOO_SMALL || dwResult == ERROR_NOT_ENOUGH_MEMORY) {
  287. prenW = (LPRASENTRYNAMEW)CoTaskMemRealloc(prenW, cbBuffer);
  288. if (prenW == NULL) {
  289. dwResult = ERROR_NOT_ENOUGH_MEMORY;
  290. goto Exit;
  291. }
  292. ZeroMemory(prenW, cbBuffer);
  293. prenW[0].dwSize = sizeof(RASENTRYNAMEW);
  294. cEntries = 0;
  295. dwResult = RasEnumEntriesWrap(pszPhonebookW, prenW, &cbBuffer, &cEntries, dwMode);
  296. }
  297. if (dwResult != ERROR_SUCCESS)
  298. goto Exit;
  299. if (cEntries > 0) {
  300. *pprenW = prenW;
  301. if (pcbBuffer != NULL)
  302. *pcbBuffer = cbBuffer;
  303. }
  304. *pcEntries = cEntries;
  305. Exit:
  306. if ((dwResult != ERROR_SUCCESS || cEntries == 0) && prenW != NULL)
  307. CoTaskMemFree(prenW);
  308. return dwResult;
  309. }
  310. DWORD RasEnumDevicesExA(LPRASDEVINFOA *pprdiA, PDWORD pcbBuffer, PDWORD pcEntries)
  311. {
  312. LPRASDEVINFOA prdiA;
  313. DWORD cbBuffer, cEntries,
  314. dwResult;
  315. BOOL fRasApisLoaded;
  316. ASSERT(RasIsInstalled());
  317. if (pprdiA == NULL || pcEntries == NULL)
  318. return ERROR_INVALID_PARAMETER;
  319. *pprdiA = NULL;
  320. if (pcbBuffer != NULL)
  321. *pcbBuffer = 0;
  322. *pcEntries = 0;
  323. prdiA = NULL;
  324. cbBuffer = 0;
  325. cEntries = 0;
  326. fRasApisLoaded = FALSE;
  327. if (!RasPrepareApis(RPA_RASENUMDEVICESA) || g_pfnRasEnumDevicesA == NULL) {
  328. dwResult = ERROR_INVALID_FUNCTION;
  329. goto Exit;
  330. }
  331. fRasApisLoaded = TRUE;
  332. dwResult = g_pfnRasEnumDevicesA(NULL, &cbBuffer, &cEntries);
  333. if (dwResult == ERROR_BUFFER_TOO_SMALL || dwResult == ERROR_NOT_ENOUGH_MEMORY) {
  334. prdiA = (LPRASDEVINFOA)CoTaskMemAlloc(cbBuffer);
  335. if (prdiA == NULL) {
  336. dwResult = ERROR_NOT_ENOUGH_MEMORY;
  337. goto Exit;
  338. }
  339. ZeroMemory(prdiA, cbBuffer);
  340. prdiA[0].dwSize = sizeof(RASDEVINFOA);
  341. cEntries = 0;
  342. dwResult = g_pfnRasEnumDevicesA(prdiA, &cbBuffer, &cEntries);
  343. }
  344. if (dwResult != ERROR_SUCCESS)
  345. goto Exit;
  346. if (cEntries > 0) {
  347. *pprdiA = prdiA;
  348. if (pcbBuffer != NULL)
  349. *pcbBuffer = cbBuffer;
  350. }
  351. *pcEntries = cEntries;
  352. Exit:
  353. if ((dwResult != ERROR_SUCCESS || cEntries == 0) && prdiA != NULL)
  354. CoTaskMemFree(prdiA);
  355. if (fRasApisLoaded)
  356. RasPrepareApis(RPA_UNLOAD, FALSE);
  357. return dwResult;
  358. }
  359. DWORD RasEnumDevicesExW(LPRASDEVINFOW *pprdiW, PDWORD pcbBuffer, PDWORD pcEntries, DWORD dwMode /*= RWM_RUNTIME*/)
  360. {
  361. LPRASDEVINFOW prdiW;
  362. DWORD cbBuffer, cEntries,
  363. dwResult;
  364. ASSERT(RasIsInstalled());
  365. if (pprdiW == NULL || pcEntries == NULL)
  366. return ERROR_INVALID_PARAMETER;
  367. *pprdiW = NULL;
  368. if (pcbBuffer != NULL)
  369. *pcbBuffer = 0;
  370. *pcEntries = 0;
  371. prdiW = NULL;
  372. cbBuffer = 0;
  373. cEntries = 0;
  374. dwResult = RasEnumDevicesWrap(NULL, &cbBuffer, &cEntries, dwMode);
  375. if (dwResult == ERROR_BUFFER_TOO_SMALL || dwResult == ERROR_NOT_ENOUGH_MEMORY) {
  376. prdiW = (LPRASDEVINFOW)CoTaskMemAlloc(cbBuffer);
  377. if (prdiW == NULL) {
  378. dwResult = ERROR_NOT_ENOUGH_MEMORY;
  379. goto Exit;
  380. }
  381. ZeroMemory(prdiW, cbBuffer);
  382. prdiW[0].dwSize = sizeof(RASDEVINFOW);
  383. cEntries = 0;
  384. dwResult = RasEnumDevicesWrap(prdiW, &cbBuffer, &cEntries, dwMode);
  385. }
  386. if (dwResult != ERROR_SUCCESS)
  387. goto Exit;
  388. if (cEntries > 0) {
  389. *pprdiW = prdiW;
  390. if (pcbBuffer != NULL)
  391. *pcbBuffer = cbBuffer;
  392. }
  393. *pcEntries = cEntries;
  394. Exit:
  395. if ((dwResult != ERROR_SUCCESS || cEntries == 0) && prdiW != NULL)
  396. CoTaskMemFree(prdiW);
  397. return dwResult;
  398. }
  399. DWORD RasGetEntryPropertiesExA(PCSTR pszNameA, LPRASENTRYA *ppreA, PDWORD pcbRasEntry)
  400. {
  401. LPRASENTRYA preA;
  402. DWORD cbRasEntry,
  403. dwResult;
  404. BOOL fRasApisLoaded;
  405. ASSERT(RasIsInstalled());
  406. if (pszNameA == NULL || ppreA == NULL || pcbRasEntry == NULL)
  407. return ERROR_INVALID_PARAMETER;
  408. *ppreA = NULL;
  409. *pcbRasEntry = 0;
  410. preA = NULL;
  411. fRasApisLoaded = FALSE;
  412. if (!RasPrepareApis(RPA_RASGETENTRYPROPERTIESA) || g_pfnRasGetEntryPropertiesA == NULL) {
  413. dwResult = ERROR_INVALID_FUNCTION;
  414. goto Exit;
  415. }
  416. fRasApisLoaded = TRUE;
  417. cbRasEntry = 0;
  418. dwResult = g_pfnRasGetEntryPropertiesA(NULL, pszNameA, NULL, &cbRasEntry, NULL, NULL);
  419. ASSERT(dwResult != ERROR_SUCCESS);
  420. if (dwResult == ERROR_BUFFER_TOO_SMALL || dwResult == ERROR_NOT_ENOUGH_MEMORY) {
  421. preA = (LPRASENTRYA)CoTaskMemAlloc(cbRasEntry);
  422. if (preA == NULL) {
  423. dwResult = ERROR_NOT_ENOUGH_MEMORY;
  424. goto Exit;
  425. }
  426. ZeroMemory(preA, cbRasEntry);
  427. preA[0].dwSize = sizeof(RASENTRYA);
  428. dwResult = g_pfnRasGetEntryPropertiesA(NULL, pszNameA, preA, &cbRasEntry, NULL, NULL);
  429. }
  430. if (dwResult != ERROR_SUCCESS)
  431. goto Exit;
  432. *ppreA = preA;
  433. *pcbRasEntry = cbRasEntry;
  434. Exit:
  435. if (dwResult != ERROR_SUCCESS && preA != NULL)
  436. CoTaskMemFree(preA);
  437. if (fRasApisLoaded)
  438. RasPrepareApis(RPA_UNLOAD, FALSE);
  439. return dwResult;
  440. }
  441. DWORD RasGetEntryPropertiesExW(PCWSTR pszNameW, LPRASENTRYW *ppreW, PDWORD pcbRasEntry,
  442. DWORD dwMode /*= RWM_RUNTIME*/)
  443. {
  444. LPRASENTRYW preW;
  445. DWORD cbRasEntry,
  446. dwResult;
  447. ASSERT(RasIsInstalled());
  448. if (pszNameW == NULL || ppreW == NULL || pcbRasEntry == NULL)
  449. return ERROR_INVALID_PARAMETER;
  450. *ppreW = NULL;
  451. *pcbRasEntry = 0;
  452. preW = NULL;
  453. cbRasEntry = 0;
  454. dwResult = RasGetEntryPropertiesWrap(pszNameW, NULL, &cbRasEntry, dwMode);
  455. ASSERT(dwResult != ERROR_SUCCESS);
  456. if (dwResult == ERROR_BUFFER_TOO_SMALL || dwResult == ERROR_NOT_ENOUGH_MEMORY) {
  457. preW = (LPRASENTRYW)CoTaskMemAlloc(cbRasEntry);
  458. if (preW == NULL) {
  459. dwResult = ERROR_NOT_ENOUGH_MEMORY;
  460. goto Exit;
  461. }
  462. ZeroMemory(preW, cbRasEntry);
  463. preW[0].dwSize = sizeof(RASENTRYW);
  464. dwResult = RasGetEntryPropertiesWrap(pszNameW, preW, &cbRasEntry, dwMode);
  465. }
  466. if (dwResult != ERROR_SUCCESS)
  467. goto Exit;
  468. *ppreW = preW;
  469. *pcbRasEntry = cbRasEntry;
  470. Exit:
  471. if (dwResult != ERROR_SUCCESS && preW != NULL)
  472. CoTaskMemFree(preW);
  473. return dwResult;
  474. }
  475. DWORD RasEnumEntriesWrap(PCWSTR pszPhonebookW, LPRASENTRYNAMEW prenW, PDWORD pcbBuffer, PDWORD pcEntries,
  476. DWORD dwMode /*= RWM_RUNTIME*/)
  477. {
  478. USES_CONVERSION;
  479. LPRASENTRYNAMEA prenA;
  480. DWORD cEntries, cbBuffer,
  481. dwResult;
  482. UINT i;
  483. BOOL fRasApisLoaded;
  484. ASSERT(RasIsInstalled());
  485. if (prenW == NULL || pcbBuffer == NULL || pcEntries == NULL)
  486. return ERROR_INVALID_PARAMETER;
  487. prenA = NULL;
  488. cEntries = 0;
  489. dwResult = ERROR_SUCCESS;
  490. fRasApisLoaded = FALSE;
  491. if (HasFlag(dwMode, RWM_FORCE_W) || (HasFlag(dwMode, RWM_RUNTIME) && IsOS(OS_NT))) {
  492. if (!RasPrepareApis(RPA_RASENUMENTRIESW) || g_pfnRasEnumEntriesW == NULL)
  493. return ERROR_INVALID_FUNCTION;
  494. fRasApisLoaded = TRUE;
  495. dwResult = g_pfnRasEnumEntriesW(NULL, pszPhonebookW, prenW, pcbBuffer, pcEntries);
  496. }
  497. else {
  498. ASSERT(dwMode == RWM_FORCE_A || (HasFlag(dwMode, RWM_RUNTIME) && !IsOS(OS_NT)));
  499. ASSERT(*pcbBuffer % sizeof(RASENTRYNAMEW) == 0);
  500. cEntries = *pcbBuffer / sizeof(RASENTRYNAMEW);
  501. cbBuffer = cEntries * sizeof(RASENTRYNAMEA);
  502. *pcbBuffer = 0;
  503. *pcEntries = 0;
  504. prenA = (LPRASENTRYNAMEA)CoTaskMemAlloc(cbBuffer);
  505. if (prenA == NULL) {
  506. dwResult = ERROR_NOT_ENOUGH_MEMORY;
  507. goto Exit;
  508. }
  509. ZeroMemory(prenA, cbBuffer);
  510. prenA[0].dwSize = sizeof(RASENTRYNAMEA);
  511. if (!RasPrepareApis(RPA_RASENUMENTRIESA) || g_pfnRasEnumEntriesA == NULL) {
  512. dwResult = ERROR_INVALID_FUNCTION;
  513. goto Exit;
  514. }
  515. fRasApisLoaded = TRUE;
  516. cEntries = 0;
  517. dwResult = g_pfnRasEnumEntriesA(NULL, W2CA(pszPhonebookW), prenA, &cbBuffer, &cEntries);
  518. if (dwResult == ERROR_SUCCESS) {
  519. ASSERT(cbBuffer == cEntries * sizeof(RASENTRYNAMEA));
  520. for (i = 0; i < cEntries; i++) {
  521. rasEntryNameA2W(prenA + i, prenW + i);
  522. ASSERT((prenW + i)->dwSize == sizeof(RASENTRYNAMEW));
  523. }
  524. }
  525. *pcbBuffer = cEntries * sizeof(RASENTRYNAMEW);
  526. *pcEntries = cEntries;
  527. }
  528. Exit:
  529. if (prenA != NULL)
  530. CoTaskMemFree(prenA);
  531. if (fRasApisLoaded)
  532. RasPrepareApis(RPA_UNLOAD, FALSE);
  533. return dwResult;
  534. }
  535. DWORD RasEnumDevicesWrap(LPRASDEVINFOW prdiW, PDWORD pcbBuffer, PDWORD pcEntries,
  536. DWORD dwMode /*= RWM_RUNTIME*/)
  537. {
  538. LPRASDEVINFOA prdiA;
  539. DWORD cbBuffer, cEntries,
  540. dwResult;
  541. UINT i;
  542. BOOL fRasApisLoaded;
  543. ASSERT(RasIsInstalled());
  544. if (pcbBuffer == NULL || pcEntries == NULL)
  545. return ERROR_INVALID_PARAMETER;
  546. prdiA = NULL;
  547. dwResult = ERROR_SUCCESS;
  548. fRasApisLoaded = FALSE;
  549. if (HasFlag(dwMode, RWM_FORCE_W) || (HasFlag(dwMode, RWM_RUNTIME) && IsOS(OS_NT))) {
  550. if (!RasPrepareApis(RPA_RASENUMDEVICESW) || g_pfnRasEnumDevicesW == NULL)
  551. return ERROR_INVALID_FUNCTION;
  552. fRasApisLoaded = TRUE;
  553. dwResult = g_pfnRasEnumDevicesW(prdiW, pcbBuffer, pcEntries);
  554. }
  555. else {
  556. ASSERT(dwMode == RWM_FORCE_A || (HasFlag(dwMode, RWM_RUNTIME) && !IsOS(OS_NT)));
  557. *pcEntries = 0;
  558. if (prdiW == NULL) {
  559. cEntries = 0;
  560. cbBuffer = 0;
  561. *pcbBuffer = 0;
  562. }
  563. else {
  564. ASSERT(*pcbBuffer % sizeof(RASDEVINFOW) == 0);
  565. cEntries = *pcbBuffer / sizeof(RASDEVINFOW);
  566. cbBuffer = cEntries * sizeof(RASDEVINFOA);
  567. *pcbBuffer = 0;
  568. prdiA = (LPRASDEVINFOA)CoTaskMemAlloc(cbBuffer);
  569. if (prdiA == NULL) {
  570. dwResult = ERROR_NOT_ENOUGH_MEMORY;
  571. goto Exit;
  572. }
  573. ZeroMemory(prdiA, cbBuffer);
  574. prdiA[0].dwSize = sizeof(RASDEVINFOA);
  575. }
  576. if (!RasPrepareApis(RPA_RASENUMDEVICESA) || g_pfnRasEnumDevicesA == NULL) {
  577. dwResult = ERROR_INVALID_FUNCTION;
  578. goto Exit;
  579. }
  580. fRasApisLoaded = TRUE;
  581. cEntries = 0;
  582. dwResult = g_pfnRasEnumDevicesA(prdiA, &cbBuffer, &cEntries);
  583. if (dwResult == ERROR_SUCCESS && prdiA != NULL) {
  584. ASSERT(prdiW != NULL);
  585. for (i = 0; i < cEntries; i++) {
  586. rasDevInfoA2W(prdiA + i, prdiW + i);
  587. ASSERT((prdiW + i)->dwSize == sizeof(RASDEVINFOW));
  588. }
  589. }
  590. *pcbBuffer = cEntries * sizeof(RASDEVINFOW);
  591. *pcEntries = cEntries;
  592. }
  593. Exit:
  594. if (prdiA != NULL)
  595. CoTaskMemFree(prdiA);
  596. if (fRasApisLoaded)
  597. RasPrepareApis(RPA_UNLOAD, FALSE);
  598. return dwResult;
  599. }
  600. DWORD RasGetEntryPropertiesWrap(PCWSTR pszNameW, LPRASENTRYW preW, PDWORD pcbRasEntry,
  601. DWORD dwMode /*= RWM_RUNTIME*/)
  602. {
  603. USES_CONVERSION;
  604. DWORD dwResult;
  605. ASSERT(RasIsInstalled());
  606. if (pszNameW == NULL || pcbRasEntry == NULL)
  607. return ERROR_INVALID_PARAMETER;
  608. if (HasFlag(dwMode, RWM_FORCE_W) || (HasFlag(dwMode, RWM_RUNTIME) && IsOS(OS_NT))) {
  609. if (!RasPrepareApis(RPA_RASGETENTRYPROPERTIESW) || g_pfnRasGetEntryPropertiesW == NULL)
  610. return ERROR_INVALID_FUNCTION;
  611. dwResult = g_pfnRasGetEntryPropertiesW(NULL, pszNameW, preW, pcbRasEntry, NULL, NULL);
  612. }
  613. else {
  614. RASENTRYA reA;
  615. LPRASENTRYA preA;
  616. DWORD cbRasEntry;
  617. ASSERT(dwMode == RWM_FORCE_A || (HasFlag(dwMode, RWM_RUNTIME) && !IsOS(OS_NT)));
  618. *pcbRasEntry = 0;
  619. if (!RasPrepareApis(RPA_RASGETENTRYPROPERTIESA) || g_pfnRasGetEntryPropertiesA == NULL)
  620. return ERROR_INVALID_FUNCTION;
  621. preA = NULL;
  622. cbRasEntry = 0;
  623. if (preW != NULL) {
  624. preA = &reA;
  625. rasEntryW2A(preW, preA);
  626. ASSERT(preA->dwSize == sizeof(RASENTRYA));
  627. cbRasEntry = sizeof(RASENTRYA);
  628. }
  629. dwResult = g_pfnRasGetEntryPropertiesA(NULL, W2CA(pszNameW), preA, &cbRasEntry, NULL, NULL);
  630. if (dwResult == ERROR_SUCCESS && preW != NULL) {
  631. ASSERT(preA != NULL);
  632. rasEntryA2W(preA, preW);
  633. ASSERT(preW->dwSize == sizeof(RASENTRYW));
  634. }
  635. *pcbRasEntry = sizeof(RASENTRYW);
  636. }
  637. RasPrepareApis(RPA_UNLOAD, FALSE);
  638. return dwResult;
  639. }
  640. DWORD RasGetEntryDialParamsWrap(LPRASDIALPARAMSW prdpW, PBOOL pfPassword,
  641. DWORD dwMode /*= RWM_RUNTIME*/)
  642. {
  643. DWORD dwResult;
  644. ASSERT(RasIsInstalled());
  645. if (prdpW == NULL)
  646. return ERROR_INVALID_PARAMETER;
  647. if (HasFlag(dwMode, RWM_FORCE_W) || (HasFlag(dwMode, RWM_RUNTIME) && IsOS(OS_NT))) {
  648. if (!RasPrepareApis(RPA_RASGETENTRYDIALPARAMSW) || g_pfnRasGetEntryDialParamsW == NULL)
  649. return ERROR_INVALID_FUNCTION;
  650. dwResult = g_pfnRasGetEntryDialParamsW(NULL, prdpW, pfPassword);
  651. }
  652. else {
  653. RASDIALPARAMSA rdpA;
  654. BOOL fPassword;
  655. ASSERT(dwMode == RWM_FORCE_A || (HasFlag(dwMode, RWM_RUNTIME) && !IsOS(OS_NT)));
  656. if (!RasPrepareApis(RPA_RASGETENTRYDIALPARAMSA) || g_pfnRasGetEntryDialParamsA == NULL)
  657. return ERROR_INVALID_FUNCTION;
  658. rasDialParamsW2A(prdpW, &rdpA);
  659. ASSERT(rdpA.dwSize == sizeof(RASDIALPARAMSA));
  660. fPassword = FALSE;
  661. dwResult = g_pfnRasGetEntryDialParamsA(NULL, &rdpA, &fPassword);
  662. if (dwResult == ERROR_SUCCESS) {
  663. rasDialParamsA2W(&rdpA, prdpW);
  664. ASSERT(prdpW->dwSize == sizeof(RASDIALPARAMSW));
  665. if (pfPassword != NULL)
  666. *pfPassword = fPassword;
  667. }
  668. }
  669. RasPrepareApis(RPA_UNLOAD, FALSE);
  670. return dwResult;
  671. }
  672. DWORD RasSetEntryPropertiesWrap(PCWSTR pszPhonebookW, PCWSTR pszNameW, LPRASENTRYW preW, DWORD cbRasEntry,
  673. DWORD dwMode /*= RWM_RUNTIME*/)
  674. {
  675. USES_CONVERSION;
  676. DWORD dwResult;
  677. ASSERT(RasIsInstalled());
  678. if (pszNameW == NULL || preW == NULL)
  679. return ERROR_INVALID_PARAMETER;
  680. if (HasFlag(dwMode, RWM_FORCE_W) || (HasFlag(dwMode, RWM_RUNTIME) && IsOS(OS_NT))) {
  681. if (!RasPrepareApis(RPA_RASSETENTRYPROPERTIESW) || g_pfnRasSetEntryPropertiesW == NULL)
  682. return ERROR_INVALID_FUNCTION;
  683. dwResult = g_pfnRasSetEntryPropertiesW(pszPhonebookW, pszNameW, preW, cbRasEntry, NULL, 0);
  684. }
  685. else {
  686. RASENTRYA reA;
  687. ASSERT(dwMode == RWM_FORCE_A || (HasFlag(dwMode, RWM_RUNTIME) && !IsOS(OS_NT)));
  688. if (!RasPrepareApis(RPA_RASSETENTRYPROPERTIESA) || g_pfnRasSetEntryPropertiesA == NULL)
  689. return ERROR_INVALID_FUNCTION;
  690. rasEntryW2A(preW, &reA);
  691. ASSERT(reA.dwSize == sizeof(RASENTRYA));
  692. dwResult = g_pfnRasSetEntryPropertiesA(W2CA(pszPhonebookW), W2CA(pszNameW), &reA, reA.dwSize, NULL, 0);
  693. }
  694. RasPrepareApis(RPA_UNLOAD, FALSE);
  695. return dwResult;
  696. }
  697. DWORD RasSetEntryDialParamsWrap(PCWSTR pszPhonebookW, LPRASDIALPARAMSW prdpW, BOOL fRemovePassword,
  698. DWORD dwMode /*= RWM_RUNTIME*/)
  699. {
  700. USES_CONVERSION;
  701. DWORD dwResult;
  702. ASSERT(RasIsInstalled());
  703. if (prdpW == NULL)
  704. return ERROR_INVALID_PARAMETER;
  705. if (HasFlag(dwMode, RWM_FORCE_W) || (HasFlag(dwMode, RWM_RUNTIME) && IsOS(OS_NT))) {
  706. if (!RasPrepareApis(RPA_RASSETENTRYDIALPARAMSW) || g_pfnRasSetEntryDialParamsW == NULL)
  707. return ERROR_INVALID_FUNCTION;
  708. dwResult = g_pfnRasSetEntryDialParamsW(pszPhonebookW, prdpW, fRemovePassword);
  709. }
  710. else {
  711. RASDIALPARAMSA rdpA;
  712. ASSERT(dwMode == RWM_FORCE_A || (HasFlag(dwMode, RWM_RUNTIME) && !IsOS(OS_NT)));
  713. if (!RasPrepareApis(RPA_RASSETENTRYDIALPARAMSA) || g_pfnRasSetEntryDialParamsA == NULL)
  714. return ERROR_INVALID_FUNCTION;
  715. rasDialParamsW2A(prdpW, &rdpA);
  716. ASSERT(rdpA.dwSize == sizeof(RASDIALPARAMSA));
  717. dwResult = g_pfnRasSetEntryDialParamsA(W2CA(pszPhonebookW), &rdpA, fRemovePassword);
  718. }
  719. RasPrepareApis(RPA_UNLOAD, FALSE);
  720. return dwResult;
  721. }
  722. /////////////////////////////////////////////////////////////////////////////
  723. // Implementation helper routines
  724. void rasEntryNameA2W(const LPRASENTRYNAMEA prenSourceA, LPRASENTRYNAMEW prenTargetW)
  725. {
  726. ASSERT(prenSourceA != NULL && prenTargetW != NULL);
  727. ASSERT(RasIsInstalled());
  728. ZeroMemory(prenTargetW, sizeof(RASENTRYNAMEW));
  729. prenTargetW->dwSize = sizeof(RASENTRYNAMEW);
  730. A2Wbux(prenSourceA->szEntryName, prenTargetW->szEntryName);
  731. }
  732. void rasEntryNameW2A(const LPRASENTRYNAMEW prenSourceW, LPRASENTRYNAMEA prenTargetA)
  733. {
  734. ASSERT(prenSourceW != NULL && prenTargetA != NULL);
  735. ASSERT(RasIsInstalled());
  736. ZeroMemory(prenTargetA, sizeof(RASENTRYNAMEA));
  737. prenTargetA->dwSize = sizeof(RASENTRYNAMEA);
  738. W2Abux(prenSourceW->szEntryName, prenTargetA->szEntryName);
  739. }
  740. void rasEntryA2W(const LPRASENTRYA preSourceA, LPRASENTRYW preTargetW)
  741. {
  742. ASSERT(preSourceA != NULL && preTargetW != NULL);
  743. ASSERT(RasIsInstalled());
  744. ZeroMemory(preTargetW, sizeof(RASENTRYW));
  745. // first quirk
  746. preTargetW->dwSize = sizeof(RASENTRYW);
  747. preTargetW->dwfOptions = preSourceA->dwfOptions;
  748. preTargetW->dwCountryID = preSourceA->dwCountryID;
  749. preTargetW->dwCountryCode = preSourceA->dwCountryCode;
  750. A2Wbux(preSourceA->szAreaCode, preTargetW->szAreaCode);
  751. A2Wbux(preSourceA->szLocalPhoneNumber, preTargetW->szLocalPhoneNumber);
  752. // second quirk
  753. preTargetW->dwAlternateOffset = 0;
  754. CopyMemory(&preTargetW->ipaddr, &preSourceA->ipaddr, sizeof(preSourceA->ipaddr));
  755. CopyMemory(&preTargetW->ipaddrDns, &preSourceA->ipaddrDns, sizeof(preSourceA->ipaddrDns));
  756. CopyMemory(&preTargetW->ipaddrDnsAlt, &preSourceA->ipaddrDnsAlt, sizeof(preSourceA->ipaddrDnsAlt));
  757. CopyMemory(&preTargetW->ipaddrWins, &preSourceA->ipaddrWins, sizeof(preSourceA->ipaddrWins));
  758. CopyMemory(&preTargetW->ipaddrWinsAlt, &preSourceA->ipaddrWinsAlt, sizeof(preSourceA->ipaddrWinsAlt));
  759. preTargetW->dwFrameSize = preSourceA->dwFrameSize;
  760. preTargetW->dwfNetProtocols = preSourceA->dwfNetProtocols;
  761. preTargetW->dwFramingProtocol = preSourceA->dwFramingProtocol;
  762. A2Wbux(preSourceA->szScript, preTargetW->szScript);
  763. A2Wbux(preSourceA->szAutodialDll, preTargetW->szAutodialDll);
  764. A2Wbux(preSourceA->szAutodialFunc, preTargetW->szAutodialFunc);
  765. A2Wbux(preSourceA->szDeviceType, preTargetW->szDeviceType);
  766. A2Wbux(preSourceA->szDeviceName, preTargetW->szDeviceName);
  767. A2Wbux(preSourceA->szX25PadType, preTargetW->szX25PadType);
  768. A2Wbux(preSourceA->szX25Address, preTargetW->szX25Address);
  769. A2Wbux(preSourceA->szX25Facilities, preTargetW->szX25Facilities);
  770. A2Wbux(preSourceA->szX25UserData, preTargetW->szX25UserData);
  771. preTargetW->dwChannels = preSourceA->dwChannels;
  772. preTargetW->dwReserved1 = preSourceA->dwReserved1;
  773. preTargetW->dwReserved2 = preSourceA->dwReserved2;
  774. // third quirk
  775. #if (WINVER >= 0x401)
  776. #error RASENTRY has more members than currently copied. These new members need to be added!
  777. #endif
  778. }
  779. void rasEntryW2A(const LPRASENTRYW preSourceW, LPRASENTRYA preTargetA)
  780. {
  781. ASSERT(preSourceW != NULL && preTargetA != NULL);
  782. ASSERT(RasIsInstalled());
  783. ZeroMemory(preTargetA, sizeof(RASENTRYA));
  784. // first quirk
  785. preTargetA->dwSize = sizeof(RASENTRYA);
  786. preTargetA->dwfOptions = preSourceW->dwfOptions;
  787. preTargetA->dwCountryID = preSourceW->dwCountryID;
  788. preTargetA->dwCountryCode = preSourceW->dwCountryCode;
  789. W2Abux(preSourceW->szAreaCode, preTargetA->szAreaCode);
  790. W2Abux(preSourceW->szLocalPhoneNumber, preTargetA->szLocalPhoneNumber);
  791. // second quirk
  792. preTargetA->dwAlternateOffset = 0;
  793. CopyMemory(&preTargetA->ipaddr, &preSourceW->ipaddr, sizeof(preSourceW->ipaddr));
  794. CopyMemory(&preTargetA->ipaddrDns, &preSourceW->ipaddrDns, sizeof(preSourceW->ipaddrDns));
  795. CopyMemory(&preTargetA->ipaddrDnsAlt, &preSourceW->ipaddrDnsAlt, sizeof(preSourceW->ipaddrDnsAlt));
  796. CopyMemory(&preTargetA->ipaddrWins, &preSourceW->ipaddrWins, sizeof(preSourceW->ipaddrWins));
  797. CopyMemory(&preTargetA->ipaddrWinsAlt, &preSourceW->ipaddrWinsAlt, sizeof(preSourceW->ipaddrWinsAlt));
  798. preTargetA->dwFrameSize = preSourceW->dwFrameSize;
  799. preTargetA->dwfNetProtocols = preSourceW->dwfNetProtocols;
  800. preTargetA->dwFramingProtocol = preSourceW->dwFramingProtocol;
  801. W2Abux(preSourceW->szScript, preTargetA->szScript);
  802. W2Abux(preSourceW->szAutodialDll, preTargetA->szAutodialDll);
  803. W2Abux(preSourceW->szAutodialFunc, preTargetA->szAutodialFunc);
  804. W2Abux(preSourceW->szDeviceType, preTargetA->szDeviceType);
  805. W2Abux(preSourceW->szDeviceName, preTargetA->szDeviceName);
  806. W2Abux(preSourceW->szX25PadType, preTargetA->szX25PadType);
  807. W2Abux(preSourceW->szX25Address, preTargetA->szX25Address);
  808. W2Abux(preSourceW->szX25Facilities, preTargetA->szX25Facilities);
  809. W2Abux(preSourceW->szX25UserData, preTargetA->szX25UserData);
  810. preTargetA->dwChannels = preSourceW->dwChannels;
  811. preTargetA->dwReserved1 = preSourceW->dwReserved1;
  812. preTargetA->dwReserved2 = preSourceW->dwReserved2;
  813. }
  814. void rasDevInfoA2W(const LPRASDEVINFOA prdiSourceA, LPRASDEVINFOW prdiTargetW)
  815. {
  816. ASSERT(prdiSourceA != NULL && prdiTargetW != NULL);
  817. ASSERT(RasIsInstalled());
  818. ZeroMemory(prdiTargetW, sizeof(RASDEVINFOW));
  819. // first quirk
  820. prdiTargetW->dwSize = sizeof(RASDEVINFOW);
  821. A2Wbux(prdiSourceA->szDeviceType, prdiTargetW->szDeviceType);
  822. A2Wbux(prdiSourceA->szDeviceName, prdiTargetW->szDeviceName);
  823. }
  824. void rasDialParamsA2W(const LPRASDIALPARAMSA prdpSourceA, LPRASDIALPARAMSW prdpTargetW)
  825. {
  826. ASSERT(prdpSourceA != NULL && prdpTargetW != NULL);
  827. ASSERT(RasIsInstalled());
  828. ZeroMemory(prdpTargetW, sizeof(RASDIALPARAMSW));
  829. // first quirk
  830. prdpTargetW->dwSize = sizeof(RASDIALPARAMSW);
  831. A2Wbux(prdpSourceA->szEntryName, prdpTargetW->szEntryName);
  832. A2Wbux(prdpSourceA->szPhoneNumber, prdpTargetW->szPhoneNumber);
  833. A2Wbux(prdpSourceA->szCallbackNumber, prdpTargetW->szCallbackNumber);
  834. A2Wbux(prdpSourceA->szUserName, prdpTargetW->szUserName);
  835. A2Wbux(prdpSourceA->szPassword, prdpTargetW->szPassword);
  836. A2Wbux(prdpSourceA->szDomain, prdpTargetW->szDomain);
  837. }
  838. void rasDialParamsW2A(const LPRASDIALPARAMSW prdpSourceW, LPRASDIALPARAMSA prdpTargetA)
  839. {
  840. ASSERT(prdpSourceW != NULL && prdpTargetA != NULL);
  841. ASSERT(RasIsInstalled());
  842. ZeroMemory(prdpTargetA, sizeof(RASDIALPARAMSA));
  843. // first quirk
  844. prdpTargetA->dwSize = sizeof(RASDIALPARAMSA);
  845. W2Abux(prdpSourceW->szEntryName, prdpTargetA->szEntryName);
  846. W2Abux(prdpSourceW->szPhoneNumber, prdpTargetA->szPhoneNumber);
  847. W2Abux(prdpSourceW->szCallbackNumber, prdpTargetA->szCallbackNumber);
  848. W2Abux(prdpSourceW->szUserName, prdpTargetA->szUserName);
  849. W2Abux(prdpSourceW->szPassword, prdpTargetA->szPassword);
  850. W2Abux(prdpSourceW->szDomain, prdpTargetA->szDomain);
  851. }