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.

412 lines
11 KiB

  1. //****************************************************************************
  2. //
  3. // Module: ISIGNUP.EXE
  4. // File: extfunc.c
  5. // Content: This file contains all the functions that handle
  6. // History:
  7. // Sat 10-Mar-1996 23:50:40 -by- Mark MacLin [mmaclin]
  8. //
  9. // Copyright (c) Microsoft Corporation 1991-1996
  10. //
  11. //****************************************************************************
  12. #include "isignup.h"
  13. static const TCHAR cszRnaPhDLL[] = TEXT("RNAPH.DLL");
  14. #ifdef WIN32
  15. static const TCHAR cszRasDLL[] = TEXT("RASAPI32.DLL");
  16. static const TCHAR cszBrandingDLL[] = TEXT("IEDKCS32.DLL");
  17. #else
  18. static const CHAR cszRasDLL[] = "RASC16IE.DLL";
  19. static const CHAR cszBrandingDLL[] = "IEDKCS16.DLL";
  20. #endif
  21. RASENUMCONNECTIONS lpfnRasEnumConnections = NULL;
  22. RASHANGUP lpfnRasHangUp = NULL;
  23. RASDELETEENTRY lpfnRasDeleteEntry = NULL;
  24. RASGETENTRYDIALPARAMS lpfnRasGetEntryDialParams = NULL;
  25. RASDIAL lpfnRasDial = NULL;
  26. RASGETCONECTSTATUS lpfnRasGetConnectStatus = NULL;
  27. RASGETERRORSTRING lpfnRasGetErrorString = NULL;
  28. RASGETENTRYPROPERTIES lpfnRasGetEntryProperties = NULL;
  29. RASENUMDEVICES lpfnRasEnumDevices = NULL;
  30. RASSETENTRYPROPERTIES lpfnRasSetEntryProperties = NULL;
  31. RASSETENTRYDIALPARAMS lpfnRasSetEntryDialParams = NULL;
  32. #ifdef WIN32
  33. // these two should only be used on NT, and _not_ on Win95
  34. RASSETAUTODIALENABLE lpfnRasSetAutodialEnable = NULL;
  35. RASSETAUTODIALADDRESS lpfnRasSetAutodialAddress = NULL;
  36. #endif
  37. #ifdef UNUSED
  38. RASVALIDATEENTRYNAME lpfnRasValidateEntryName = NULL;
  39. RASRENAMEENTRY lpfnRasRenameEntry = NULL;
  40. RASGETCOUNTRYINFO lpfnRasGetCountryInfo = NULL;
  41. #endif
  42. #ifdef WIN32
  43. INETCONFIGSYSTEM lpfnInetConfigSystem = NULL;
  44. INETGETPROXY lpfnInetGetProxy = NULL;
  45. #endif
  46. INETCONFIGCLIENT lpfnInetConfigClient = NULL;
  47. INETGETAUTODIAL lpfnInetGetAutodial = NULL;
  48. INETSETAUTODIAL lpfnInetSetAutodial = NULL;
  49. INETSETCLIENTINFO lpfnInetSetClientInfo = NULL;
  50. INETSETPROXY lpfnInetSetProxy = NULL;
  51. #ifdef UNUSED
  52. INETGETCLIENTINFO lpfnInetGetClientInfo = NULL;
  53. #endif
  54. #ifdef WIN32
  55. BRANDICW lpfnBrandICW = NULL;
  56. #else
  57. BRANDME lpfnBrandMe = NULL;
  58. #endif
  59. typedef struct tagApiFcn {
  60. LPVOID FAR* lplpfn;
  61. LPCSTR szApiName;
  62. } APIFCN;
  63. #ifdef UNICODE
  64. APIFCN RasProcList[] = {
  65. { (LPVOID *) &lpfnRasEnumConnections, "RasEnumConnectionsW"},
  66. { (LPVOID *) &lpfnRasHangUp, "RasHangUpW"},
  67. { (LPVOID *) &lpfnRasGetEntryDialParams,"RasGetEntryDialParamsW"},
  68. { (LPVOID *) &lpfnRasDial, "RasDialW"},
  69. { (LPVOID *) &lpfnRasGetConnectStatus, "RasGetConnectStatusW"},
  70. { (LPVOID *) &lpfnRasGetErrorString, "RasGetErrorStringW"},
  71. { (LPVOID *) &lpfnRasSetEntryDialParams,"RasSetEntryDialParamsW"},
  72. };
  73. #else // UNICODE
  74. APIFCN RasProcList[] = {
  75. { (LPVOID *) &lpfnRasEnumConnections, "RasEnumConnectionsA"},
  76. { (LPVOID *) &lpfnRasHangUp, "RasHangUpA"},
  77. { (LPVOID *) &lpfnRasGetEntryDialParams,"RasGetEntryDialParamsA"},
  78. { (LPVOID *) &lpfnRasDial, "RasDialA"},
  79. { (LPVOID *) &lpfnRasGetConnectStatus, "RasGetConnectStatusA"},
  80. { (LPVOID *) &lpfnRasGetErrorString, "RasGetErrorStringA"},
  81. { (LPVOID *) &lpfnRasSetEntryDialParams,"RasSetEntryDialParamsA"},
  82. };
  83. #endif // UNICODE
  84. #define cRasProc (sizeof(RasProcList) / sizeof(RasProcList[0]))
  85. #ifdef WIN32
  86. #ifdef UNICODE
  87. APIFCN RasProcListNT[] = {
  88. { (LPVOID *) &lpfnRasEnumConnections, "RasEnumConnectionsW"},
  89. { (LPVOID *) &lpfnRasHangUp, "RasHangUpW"},
  90. { (LPVOID *) &lpfnRasGetEntryDialParams,"RasGetEntryDialParamsW"},
  91. { (LPVOID *) &lpfnRasDial, "RasDialW"},
  92. { (LPVOID *) &lpfnRasGetConnectStatus, "RasGetConnectStatusW"},
  93. { (LPVOID *) &lpfnRasGetErrorString, "RasGetErrorStringW"},
  94. { (LPVOID *) &lpfnRasSetAutodialEnable, "RasSetAutodialEnableW"},
  95. { (LPVOID *) &lpfnRasSetAutodialAddress,"RasSetAutodialAddressW"},
  96. { (LPVOID *) &lpfnRasSetEntryDialParams,"RasSetEntryDialParamsW"},
  97. };
  98. #else // UNICODE
  99. APIFCN RasProcListNT[] = {
  100. { (LPVOID *) &lpfnRasEnumConnections, "RasEnumConnectionsA"},
  101. { (LPVOID *) &lpfnRasHangUp, "RasHangUpA"},
  102. { (LPVOID *) &lpfnRasGetEntryDialParams,"RasGetEntryDialParamsA"},
  103. { (LPVOID *) &lpfnRasDial, "RasDialA"},
  104. { (LPVOID *) &lpfnRasGetConnectStatus, "RasGetConnectStatusA"},
  105. { (LPVOID *) &lpfnRasGetErrorString, "RasGetErrorStringA"},
  106. { (LPVOID *) &lpfnRasSetAutodialEnable, "RasSetAutodialEnableA"},
  107. { (LPVOID *) &lpfnRasSetAutodialAddress,"RasSetAutodialAddressA"},
  108. { (LPVOID *) &lpfnRasSetEntryDialParams,"RasSetEntryDialParamsA"},
  109. };
  110. #endif // UNICODE
  111. #define cRasProcNT (sizeof(RasProcListNT) / sizeof(RasProcListNT[0]))
  112. #endif
  113. APIFCN RnaPhProcList[] = {
  114. #ifdef UNICODE
  115. { (LPVOID *) &lpfnRasDeleteEntry, "RasDeleteEntryW"},
  116. { (LPVOID *) &lpfnRasGetEntryProperties,"RasGetEntryPropertiesW"},
  117. { (LPVOID *) &lpfnRasEnumDevices, "RasEnumDevicesW"},
  118. { (LPVOID *) &lpfnRasSetEntryProperties,"RasSetEntryPropertiesW"},
  119. #else
  120. { (LPVOID *) &lpfnRasDeleteEntry, "RasDeleteEntryA"},
  121. { (LPVOID *) &lpfnRasGetEntryProperties,"RasGetEntryPropertiesA"},
  122. { (LPVOID *) &lpfnRasEnumDevices, "RasEnumDevicesA"},
  123. { (LPVOID *) &lpfnRasSetEntryProperties,"RasSetEntryPropertiesA"},
  124. #endif
  125. #ifdef UNUSED
  126. { (LPVOID *) &lpfnRasValidateEntryName, "RasValidateEntryName"},
  127. { (LPVOID *) &lpfnRasRenameEntry, "RasRenameEntry"},
  128. { (LPVOID *) &lpfnRasGetCountryInfo, "RasGetCountryInfo"},
  129. #endif
  130. };
  131. #define cRnaPhProc (sizeof(RnaPhProcList) / sizeof(RnaPhProcList[0]))
  132. APIFCN InetProcList[] = {
  133. #ifdef WIN32
  134. { (LPVOID *) &lpfnInetConfigSystem, "InetConfigSystem"},
  135. #ifdef UNICODE
  136. { (LPVOID *) &lpfnInetGetProxy, "InetGetProxyW"},
  137. #else
  138. { (LPVOID *) &lpfnInetGetProxy, "InetGetProxy"},
  139. #endif // UNICODE
  140. #endif // WIN32
  141. #ifdef UNICODE
  142. { (LPVOID *) &lpfnInetConfigClient, "InetConfigClientW"},
  143. { (LPVOID *) &lpfnInetGetAutodial, "InetGetAutodialW"},
  144. { (LPVOID *) &lpfnInetSetAutodial, "InetSetAutodialW"},
  145. { (LPVOID *) &lpfnInetSetClientInfo, "InetSetClientInfoW"},
  146. { (LPVOID *) &lpfnInetSetProxy, "InetSetProxyW"},
  147. #else
  148. { (LPVOID *) &lpfnInetConfigClient, "InetConfigClient"},
  149. { (LPVOID *) &lpfnInetGetAutodial, "InetGetAutodial"},
  150. { (LPVOID *) &lpfnInetSetAutodial, "InetSetAutodial"},
  151. { (LPVOID *) &lpfnInetSetClientInfo, "InetSetClientInfo"},
  152. { (LPVOID *) &lpfnInetSetProxy, "InetSetProxy"},
  153. #endif // UNICODE
  154. #ifdef UNUSED
  155. #ifdef UNICODE
  156. { (LPVOID *) &lpfnInetGetClientInfo, "InetGetClientInfoW"},
  157. #else
  158. { (LPVOID *) &lpfnInetGetClientInfo, "InetGetClientInfo"},
  159. #endif
  160. #endif
  161. };
  162. #define cInetProc (sizeof(InetProcList) / sizeof(InetProcList[0]))
  163. APIFCN BrandingProcList[] = {
  164. #ifdef WIN32
  165. { (LPVOID *) &lpfnBrandICW, "BrandICW2"},
  166. #else
  167. { (LPVOID *) &lpfnBrandMe, "BrandMe"},
  168. #endif
  169. };
  170. #define cBrandingProc (sizeof(BrandingProcList) / sizeof(BrandingProcList[0]))
  171. static HINSTANCE ghRas = NULL;
  172. static HINSTANCE ghRnaPh = NULL;
  173. static HINSTANCE ghInet = NULL;
  174. static HINSTANCE ghBranding = NULL;
  175. #ifndef WIN32
  176. static int iRasRefs = 0;
  177. static int iInetRefs = 0;
  178. static int iBrandingRefs = 0;
  179. #endif
  180. HINSTANCE InitLpfn(LPCTSTR szDllName, APIFCN *pProcList, int cProcs);
  181. BOOL LoadRnaFunctions(HWND hwndParent)
  182. {
  183. #if !defined(WIN16)
  184. if (!IsRASReady())
  185. {
  186. DebugOut("ISIGN32: Attempted to load RAS API's however, the system isn't ready for it.\r\n");
  187. return FALSE;
  188. }
  189. #endif
  190. if (ghRas == NULL)
  191. {
  192. if (RAS_MaxEntryName != 256)
  193. {
  194. // MessageBox(NULL, "Invalid header used for compile", szAppName, MB_OK);
  195. return FALSE;
  196. }
  197. #ifdef WIN32
  198. // 1/7/96 jmazner Normandy #12930
  199. // init different proc lists based on whether we're in NT or not.
  200. if( IsNT() )
  201. {
  202. if ((ghRas = InitLpfn(cszRasDLL, RasProcListNT, cRasProcNT)) == NULL)
  203. {
  204. ErrorMsg(hwndParent, IDS_MISSINGRNADLL);
  205. return FALSE;
  206. }
  207. }
  208. else
  209. {
  210. #endif
  211. if ((ghRas = InitLpfn(cszRasDLL, RasProcList, cRasProc)) == NULL)
  212. {
  213. ErrorMsg(hwndParent, IDS_MISSINGRNADLL);
  214. return FALSE;
  215. }
  216. #ifdef WIN32
  217. }
  218. #endif
  219. if ((ghRnaPh = InitLpfn(cszRasDLL, RnaPhProcList, cRnaPhProc)) == NULL)
  220. {
  221. #ifdef WIN32
  222. //
  223. // we only load RNAPH.DLL if it is not NT
  224. // MKarki (5/4/97) - Fix for Bug #3378
  225. //
  226. if (FALSE == IsNT ())
  227. {
  228. #endif
  229. if ((ghRnaPh = InitLpfn(cszRnaPhDLL, RnaPhProcList, cRnaPhProc)) == NULL)
  230. {
  231. FreeLibrary(ghRas);
  232. ghRas = NULL;
  233. ErrorMsg(hwndParent, IDS_WRONGRNADLLVER);
  234. return FALSE;
  235. }
  236. #ifdef WIN32
  237. }
  238. else
  239. {
  240. FreeLibrary(ghRas);
  241. ghRas = NULL;
  242. ErrorMsg(hwndParent, IDS_WRONGRNADLLVER);
  243. return FALSE;
  244. }
  245. #endif
  246. }
  247. }
  248. #ifndef WIN32
  249. ++iRasRefs;
  250. #endif
  251. return TRUE;
  252. }
  253. BOOL LoadInetFunctions(HWND hwndParent)
  254. {
  255. if (ghInet == NULL)
  256. {
  257. if ((ghInet = InitLpfn(TEXT("INETCFG.DLL"), InetProcList, cInetProc)) == NULL)
  258. {
  259. ErrorMsg(hwndParent, IDS_MISSINGCFGDLL);
  260. return FALSE;
  261. }
  262. }
  263. #ifndef WIN32
  264. ++iInetRefs;
  265. #endif
  266. return TRUE;
  267. }
  268. BOOL LoadBrandingFunctions(void)
  269. {
  270. if (ghBranding == NULL)
  271. {
  272. if ((ghBranding = InitLpfn(cszBrandingDLL, BrandingProcList, cBrandingProc)) == NULL)
  273. {
  274. return FALSE;
  275. }
  276. }
  277. #ifndef WIN32
  278. ++iBrandingRefs;
  279. #endif
  280. return TRUE;
  281. }
  282. HINSTANCE InitLpfn(LPCTSTR szDllName, APIFCN *pProcList, int cProcs)
  283. {
  284. int i;
  285. HINSTANCE hLib;
  286. hLib = LoadLibrary(szDllName);
  287. if (hLib != NULL)
  288. {
  289. for (i = 0; i < cProcs; i++)
  290. {
  291. *pProcList[i].lplpfn = (LPVOID) GetProcAddress(hLib, pProcList[i].szApiName);
  292. if (*pProcList[i].lplpfn == NULL)
  293. {
  294. #if 0
  295. CHAR szMsg[256];
  296. wsprintf(szMsg,
  297. "Could not find %s in %s",
  298. pProcList[i].szApiName,
  299. szDllName);
  300. MessageBox(NULL, szMsg, "Internet Signup", MB_OK);
  301. #endif
  302. FreeLibrary(hLib);
  303. return NULL;
  304. }
  305. }
  306. }
  307. #if 0
  308. else
  309. {
  310. wsprintf(szMsg,
  311. "Could not load %s",
  312. szDllName);
  313. MessageBox(NULL, szMsg, "Internet Signup", MB_OK);
  314. }
  315. #endif
  316. return hLib;
  317. }
  318. void UnloadRnaFunctions(void)
  319. {
  320. #ifndef WIN32
  321. if (0 != --iRasRefs)
  322. {
  323. return;
  324. }
  325. #endif
  326. // need to unload libraries
  327. if (NULL != ghRas)
  328. {
  329. FreeLibrary(ghRas);
  330. ghRas = NULL;
  331. }
  332. if (NULL != ghRnaPh)
  333. {
  334. FreeLibrary(ghRnaPh);
  335. ghRas = NULL;
  336. }
  337. }
  338. void UnloadInetFunctions(void)
  339. {
  340. #ifndef WIN32
  341. if (0 != --iInetRefs)
  342. {
  343. return;
  344. }
  345. #endif
  346. if (NULL != ghInet)
  347. {
  348. FreeLibrary(ghInet);
  349. ghInet = NULL;
  350. }
  351. }
  352. void UnloadBrandingFunctions(void)
  353. {
  354. #ifndef WIN32
  355. if (0 != --iBrandingRefs)
  356. {
  357. return;
  358. }
  359. #endif
  360. if (NULL != ghBranding)
  361. {
  362. FreeLibrary(ghBranding);
  363. ghBranding = NULL;
  364. }
  365. }