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.

2756 lines
83 KiB

  1. /* Copyright (c) 1996, Microsoft Corporation, all rights reserved
  2. **
  3. ** loaddlls.c
  4. ** RAS DLL load routines
  5. ** Listed alphabetically
  6. **
  7. ** 02/17/96 Steve Cobb
  8. */
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include <stdlib.h>
  12. #include <nt.h>
  13. #include <ntrtl.h>
  14. #include <nturtl.h>
  15. #include <windows.h>
  16. #include <rpc.h>
  17. #include "rasrpc.h"
  18. #include <debug.h> // Trace and assert
  19. #include <nouiutil.h>
  20. #include <loaddlls.h> // Our public header
  21. #include <rasrpclb.h>
  22. #include <rasman.h>
  23. /*----------------------------------------------------------------------------
  24. ** Constants
  25. **----------------------------------------------------------------------------
  26. */
  27. #define RasRpcCatchException(_pStatus) \
  28. RpcExcept(I_RpcExceptionFilter(*(_pStatus) = RpcExceptionCode()))
  29. #ifdef UNICODE
  30. #define SZ_RasConnectionNotification "RasConnectionNotificationW"
  31. #define SZ_RasDeleteEntry "RasDeleteEntryW"
  32. #define SZ_RasDial "RasDialW"
  33. #define SZ_RasDialDlg "RasDialDlgW"
  34. #define SZ_RasEntryDlg "RasEntryDlgW"
  35. #define SZ_RasEnumConnections "RasEnumConnectionsW"
  36. #define SZ_RasEnumEntries "RasEnumEntriesW"
  37. #define SZ_RasGetAutodialEnable "RasGetAutodialEnableW"
  38. #define SZ_RasGetAutodialParam "RasGetAutodialParamW"
  39. #define SZ_RasGetConnectResponse "RasGetConnectResponse"
  40. #define SZ_RasGetConnectStatus "RasGetConnectStatusW"
  41. #define SZ_RasGetCountryInfo "RasGetCountryInfoW"
  42. #define SZ_RasGetCredentials "RasGetCredentialsW"
  43. #define SZ_RasGetEntryDialParams "RasGetEntryDialParamsW"
  44. #define SZ_RasGetEntryProperties "RasGetEntryPropertiesW"
  45. #define SZ_RasGetErrorString "RasGetErrorStringW"
  46. #define SZ_RasGetProjectionInfo "RasGetProjectionInfoW"
  47. #define SZ_RasGetSubEntryHandle "RasGetSubEntryHandleW"
  48. #define SZ_RasHangUp "RasHangUpW"
  49. #define SZ_RasPhonebookDlg "RasPhonebookDlgW"
  50. #define SZ_RasSetAutodialEnable "RasSetAutodialEnableW"
  51. #define SZ_RasSetAutodialParam "RasSetAutodialParamW"
  52. #define SZ_RasSetCredentials "RasSetCredentialsW"
  53. #define SZ_RasValidateEntryName "RasValidateEntryNameW"
  54. #define SZ_RouterEntryDlg "RouterEntryDlgW"
  55. #define SZ_RasSetEapUserData "RasSetEapUserDataW"
  56. #else
  57. #define SZ_RasConnectionNotification "RasConnectionNotificationA"
  58. #define SZ_RasDeleteEntry "RasDeleteEntryA"
  59. #define SZ_RasDial "RasDialA"
  60. #define SZ_RasDialDlg "RasDialDlgA"
  61. #define SZ_RasEnumConnections "RasEnumConnectionsA"
  62. #define SZ_RasEnumEntries "RasEnumEntriesA"
  63. #define SZ_RasGetAutodialEnable "RasGetAutodialEnableA"
  64. #define SZ_RasGetAutodialParam "RasGetAutodialParamA"
  65. #define SZ_RasGetConnectResponse "RasGetConnectResponse"
  66. #define SZ_RasGetConnectStatus "RasGetConnectStatusA"
  67. #define SZ_RasGetCountryInfo "RasGetCountryInfoA"
  68. #define SZ_RasGetCredentials "RasGetCredentialsA"
  69. #define SZ_RasGetEntryDialParams "RasGetEntryDialParamsA"
  70. #define SZ_RasGetEntryProperties "RasGetEntryPropertiesA"
  71. #define SZ_RasGetErrorString "RasGetErrorStringA"
  72. #define SZ_RasGetProjectionInfo "RasGetProjectionInfoA"
  73. #define SZ_RasGetSubEntryHandle "RasGetSubEntryHandleA"
  74. #define SZ_RasHangUp "RasHangUpA"
  75. #define SZ_RasPhonebookDlg "RasPhonebookDlgA"
  76. #define SZ_RasSetAutodialEnable "RasSetAutodialEnableA"
  77. #define SZ_RasSetAutodialParam "RasSetAutodialParamA"
  78. #define SZ_RasSetCredentials "RasSetCredentialsA"
  79. #define SZ_RasValidateEntryName "RasValidateEntryNameA"
  80. #define SZ_RouterEntryDlg "RouterEntryDlgA"
  81. #define SZ_RasSetEapUserData "RasSetEapUserDataA"
  82. #endif
  83. #define SZ_MprAdminInterfaceCreate "MprAdminInterfaceCreate"
  84. #define SZ_MprAdminInterfaceDelete "MprAdminInterfaceDelete"
  85. #define SZ_MprAdminInterfaceGetHandle "MprAdminInterfaceGetHandle"
  86. #define SZ_MprAdminInterfaceGetCredentials "MprAdminInterfaceGetCredentials"
  87. #define SZ_MprAdminInterfaceGetCredentialsEx "MprAdminInterfaceGetCredentialsEx"
  88. #define SZ_MprAdminInterfaceSetCredentials "MprAdminInterfaceSetCredentials"
  89. #define SZ_MprAdminInterfaceSetCredentialsEx "MprAdminInterfaceSetCredentialsEx"
  90. #define SZ_MprAdminBufferFree "MprAdminBufferFree"
  91. #define SZ_MprAdminInterfaceTransportAdd "MprAdminInterfaceTransportAdd"
  92. #define SZ_MprAdminInterfaceTransportSetInfo "MprAdminInterfaceTransportSetInfo"
  93. #define SZ_MprAdminServerConnect "MprAdminServerConnect"
  94. #define SZ_MprAdminServerDisconnect "MprAdminServerDisconnect"
  95. #define SZ_MprAdminTransportSetInfo "MprAdminTransportSetInfo"
  96. #define SZ_RasAdminBufferFree "MprAdminBufferFree"
  97. #define SZ_RasAdminConnectionEnum "MprAdminConnectionEnum"
  98. #define SZ_RasAdminConnectionGetInfo "MprAdminConnectionGetInfo"
  99. #define SZ_RasAdminPortDisconnect "MprAdminPortDisconnect"
  100. #define SZ_RasAdminPortEnum "MprAdminPortEnum"
  101. #define SZ_RasAdminPortGetInfo "MprAdminPortGetInfo"
  102. #define SZ_RasAdminServerConnect "MprAdminServerConnect"
  103. #define SZ_RasAdminServerDisconnect "MprAdminServerDisconnect"
  104. #define SZ_RasAdminUserSetInfo "MprAdminUserSetInfo"
  105. #define SZ_MprAdminUserServerConnect "MprAdminUserServerConnect"
  106. #define SZ_MprAdminUserServerDisconnect "MprAdminUserServerDisconnect"
  107. #define SZ_MprAdminUserOpen "MprAdminUserOpen"
  108. #define SZ_MprAdminUserClose "MprAdminUserClose"
  109. #define SZ_MprAdminUserWrite "MprAdminUserWrite"
  110. #define SZ_MprConfigBufferFree "MprConfigBufferFree"
  111. #define SZ_MprConfigServerConnect "MprConfigServerConnect"
  112. #define SZ_MprConfigServerDisconnect "MprConfigServerDisconnect"
  113. #define SZ_MprConfigTransportGetInfo "MprConfigTransportGetInfo"
  114. #define SZ_MprConfigTransportSetInfo "MprConfigTransportSetInfo"
  115. #define SZ_MprConfigTransportGetHandle "MprConfigTransportGetHandle"
  116. #define SZ_MprConfigInterfaceCreate "MprConfigInterfaceCreate"
  117. #define SZ_MprConfigInterfaceDelete "MprConfigInterfaceDelete"
  118. #define SZ_MprConfigInterfaceGetHandle "MprConfigInterfaceGetHandle"
  119. #define SZ_MprConfigInterfaceEnum "MprConfigInterfaceEnum"
  120. #define SZ_MprConfigInterfaceTransportAdd "MprConfigInterfaceTransportAdd"
  121. #define SZ_MprConfigInterfaceTransportGetInfo "MprConfigInterfaceTransportGetInfo"
  122. #define SZ_MprConfigInterfaceTransportSetInfo "MprConfigInterfaceTransportSetInfo"
  123. #define SZ_MprConfigInterfaceTransportGetHandle "MprConfigInterfaceTransportGetHandle"
  124. #define SZ_MprInfoCreate "MprInfoCreate"
  125. #define SZ_MprInfoDelete "MprInfoDelete"
  126. #define SZ_MprInfoDuplicate "MprInfoDuplicate"
  127. #define SZ_MprInfoBlockAdd "MprInfoBlockAdd"
  128. #define SZ_MprInfoBlockRemove "MprInfoBlockRemove"
  129. #define SZ_MprInfoBlockSet "MprInfoBlockSet"
  130. #define SZ_MprInfoBlockFind "MprInfoBlockFind"
  131. //
  132. // RASAPI32.DLL entry points.
  133. //
  134. HINSTANCE g_hRasapi32Dll = NULL;
  135. PRASCONNECTIONNOTIFICATION g_pRasConnectionNotification = NULL;
  136. PRASDELETEENTRY g_pRasDeleteEntry = NULL;
  137. PRASDIAL g_pRasDial = NULL;
  138. PRASENUMCONNECTIONS g_pRasEnumConnections = NULL;
  139. PRASENUMENTRIES g_pRasEnumEntries = NULL;
  140. PRASGETAUTODIALENABLE g_pRasGetAutodialEnable = NULL;
  141. PRASGETAUTODIALPARAM g_pRasGetAutodialParam = NULL;
  142. PRASGETCONNECTRESPONSE g_pRasGetConnectResponse = NULL;
  143. PRASGETCONNECTSTATUS g_pRasGetConnectStatus = NULL;
  144. PRASGETCOUNTRYINFO g_pRasGetCountryInfo = NULL;
  145. PRASGETCREDENTIALS g_pRasGetCredentials = NULL;
  146. PRASGETENTRYDIALPARAMS g_pRasGetEntryDialParams = NULL;
  147. PRASGETENTRYPROPERTIES g_pRasGetEntryProperties = NULL;
  148. PRASGETERRORSTRING g_pRasGetErrorString = NULL;
  149. PRASGETHPORT g_pRasGetHport = NULL;
  150. PRASGETPROJECTIONINFO g_pRasGetProjectionInfo = NULL;
  151. PRASGETSUBENTRYHANDLE g_pRasGetSubEntryHandle = NULL;
  152. PRASHANGUP g_pRasHangUp = NULL;
  153. PRASINVOKEEAPUI g_pRasInvokeEapUI = NULL;
  154. PRASSETEAPUSERDATA g_pRasSetEapUserData = NULL;
  155. PRASSETAUTODIALENABLE g_pRasSetAutodialEnable = NULL;
  156. PRASSETAUTODIALPARAM g_pRasSetAutodialParam = NULL;
  157. PRASSETCREDENTIALS g_pRasSetCredentials = NULL;
  158. PRASSETOLDPASSWORD g_pRasSetOldPassword = NULL;
  159. PRASVALIDATEENTRYNAME g_pRasValidateEntryName = NULL;
  160. //
  161. // RASDLG.DLL entry points
  162. //
  163. HINSTANCE g_hRasdlgDll = NULL;
  164. PRASDIALDLG g_pRasDialDlg = NULL;
  165. PRASENTRYDLG g_pRasEntryDlg = NULL;
  166. PRASPHONEBOOKDLG g_pRasPhonebookDlg = NULL;
  167. PROUTERENTRYDLG g_pRouterEntryDlg = NULL;
  168. //
  169. // RASMAN.DLL entry points
  170. //
  171. HINSTANCE g_hRasmanDll = NULL;
  172. PRASACTIVATEROUTE g_pRasActivateRoute = NULL;
  173. PRASACTIVATEROUTEEX g_pRasActivateRouteEx = NULL;
  174. PRASADDCONNECTIONPORT g_pRasAddConnectionPort = NULL;
  175. PRASADDNOTIFICATION g_pRasAddNotification = NULL;
  176. PRASALLOCATEROUTE g_pRasAllocateRoute = NULL;
  177. PRASBUNDLECLEARSTATISTICS g_pRasBundleClearStatistics = NULL;
  178. PRASBUNDLECLEARSTATISTICSEX g_pRasBundleClearStatisticsEx = NULL;
  179. PRASBUNDLEGETSTATISTICS g_pRasBundleGetStatistics = NULL;
  180. PRASBUNDLEGETSTATISTICSEX g_pRasBundleGetStatisticsEx = NULL;
  181. PRASCONNECTIONENUM g_pRasConnectionEnum = NULL;
  182. PRASCONNECTIONGETSTATISTICS g_pRasConnectionGetStatistics = NULL;
  183. PRASCREATECONNECTION g_pRasCreateConnection = NULL;
  184. PRASDESTROYCONNECTION g_pRasDestroyConnection = NULL;
  185. PRASDEVICECONNECT g_pRasDeviceConnect = NULL;
  186. PRASDEVICEENUM g_pRasDeviceEnum = NULL;
  187. PRASDEVICEGETINFO g_pRasDeviceGetInfo = NULL;
  188. PRASDEVICESETINFO g_pRasDeviceSetInfo = NULL;
  189. PRASENUMCONNECTIONPORTS g_pRasEnumConnectionPorts = NULL;
  190. PRASFINDPREREQUISITEENTRY g_pRasFindPrerequisiteEntry = NULL;
  191. PRASFREEBUFFER g_pRasFreeBuffer = NULL;
  192. PRASGETBUFFER g_pRasGetBuffer = NULL;
  193. PRASGETCONNECTIONPARAMS g_pRasGetConnectionParams = NULL;
  194. PRASGETCONNECTIONUSERDATA g_pRasGetConnectionUserData = NULL;
  195. PRASGETDEVCONFIG g_pRasGetDevConfig = NULL;
  196. PRASGETDEVCONFIG g_pRasGetDevConfigEx = NULL;
  197. PRASGETDIALPARAMS g_pRasGetDialParams = NULL;
  198. PRASGETHCONNFROMENTRY g_pRasGetHConnFromEntry = NULL;
  199. PRASGETHPORTFROMCONNECTION g_pRasGetHportFromConnection = NULL;
  200. PRASGETINFO g_pRasGetInfo = NULL;
  201. PRASGETNDISWANDRIVERCAPS g_pRasGetNdiswanDriverCaps = NULL;
  202. PRASGETPORTUSERDATA g_pRasGetPortUserData = NULL;
  203. PRASINITIALIZE g_pRasInitialize = NULL;
  204. PRASINITIALIZENOWAIT g_pRasInitializeNoWait = NULL;
  205. PRASLINKGETSTATISTICS g_pRasLinkGetStatistics = NULL;
  206. PRASNUMPORTOPEN g_pRasNumPortOpen = NULL;
  207. PRASPORTCANCELRECEIVE g_pRasPortCancelReceive = NULL;
  208. PRASPORTCLEARSTATISTICS g_pRasPortClearStatistics = NULL;
  209. PRASPORTCLOSE g_pRasPortClose = NULL;
  210. PRASPORTCONNECTCOMPLETE g_pRasPortConnectComplete = NULL;
  211. PRASPORTDISCONNECT g_pRasPortDisconnect = NULL;
  212. PRASPORTENUM g_pRasPortEnum = NULL;
  213. PRASPORTENUMPROTOCOLS g_pRasPortEnumProtocols = NULL;
  214. PRASPORTGETBUNDLE g_pRasPortGetBundle = NULL;
  215. PRASPORTGETFRAMINGEX g_pRasPortGetFramingEx = NULL;
  216. PRASPORTGETINFO g_pRasPortGetInfo = NULL;
  217. PRASPORTGETSTATISTICS g_pRasPortGetStatistics = NULL;
  218. PRASPORTGETSTATISTICSEX g_pRasPortGetStatisticsEx = NULL;
  219. PRASPORTLISTEN g_pRasPortListen = NULL;
  220. PRASPORTOPEN g_pRasPortOpen = NULL;
  221. PRASPORTOPENEX g_pRasPortOpenEx = NULL;
  222. PRASPORTRECEIVE g_pRasPortReceive = NULL;
  223. PRASPORTRECEIVEEX g_pRasPortReceiveEx = NULL;
  224. PRASPORTREGISTERSLIP g_pRasPortRegisterSlip = NULL;
  225. PRASPORTSEND g_pRasPortSend = NULL;
  226. PRASPORTSETFRAMING g_pRasPortSetFraming = NULL;
  227. PRASPORTSETFRAMINGEX g_pRasPortSetFramingEx = NULL;
  228. PRASPORTSETINFO g_pRasPortSetInfo = NULL;
  229. PRASPPPCALLBACK g_pRasPppCallback = NULL;
  230. PRASPPPCHANGEPASSWORD g_pRasPppChangePassword = NULL;
  231. PRASPPPGETEAPINFO g_pRasPppGetEapInfo = NULL;
  232. PRASPPPGETINFO g_pRasPppGetInfo = NULL;
  233. PRASPPPRETRY g_pRasPppRetry = NULL;
  234. PRASPPPSETEAPINFO g_pRasPppSetEapInfo = NULL;
  235. PRASPPPSTART g_pRasPppStart = NULL;
  236. PRASPPPSTOP g_pRasPppStop = NULL;
  237. PRASREFCONNECTION g_pRasRefConnection = NULL;
  238. PRASREFERENCECUSTOMCOUNT g_pRasReferenceCustomCount = NULL;
  239. PRASREQUESTNOTIFICATION g_pRasRequestNotification = NULL;
  240. PRASRPCBIND g_pRasRpcBind = NULL;
  241. PRASRPCCONNECT g_pRasRpcConnect = NULL;
  242. PRASRPCDISCONNECT g_pRasRpcDisconnect = NULL;
  243. PRASSENDPPPMESSAGETORASMAN g_pRasSendPppMessageToRasman = NULL;
  244. PRASSETCACHEDCREDENTIALS g_pRasSetCachedCredentials = NULL;
  245. PRASSETCONNECTIONPARAMS g_pRasSetConnectionParams = NULL;
  246. PRASSETCONNECTIONUSERDATA g_pRasSetConnectionUserData = NULL;
  247. PRASSETDEVCONFIG g_pRasSetDevConfig = NULL;
  248. PRASSETDIALPARAMS g_pRasSetDialParams = NULL;
  249. PRASSETIOCOMPLETIONPORT g_pRasSetIoCompletionPort = NULL;
  250. PRASSETPORTUSERDATA g_pRasSetPortUserData = NULL;
  251. PRASSETRASDIALINFO g_pRasSetRasdialInfo = NULL;
  252. PRASSIGNALNEWCONNECTION g_pRasSignalNewConnection = NULL;
  253. PRASGETDEVICENAME g_pRasGetDeviceName = NULL;
  254. PRASENABLEIPSEC g_pRasEnableIpSec = NULL;
  255. PRASISIPSECENABLED g_pRasIsIpSecEnabled = NULL;
  256. PRASGETEAPUSERINFO g_pRasGetEapUserInfo = NULL;
  257. PRASSETEAPUSERINFO g_pRasSetEapUserInfo = NULL;
  258. PRASSETEAPLOGONINFO g_pRasSetEapLogonInfo = NULL;
  259. PRASSTARTRASAUTOIFREQUIRED g_pRasStartRasAutoIfRequired = NULL;
  260. //
  261. // MPRAPI.DLL entry points.
  262. //
  263. HINSTANCE g_hMpradminDll = NULL;
  264. PMPRADMININTERFACECREATE g_pMprAdminInterfaceCreate = NULL;
  265. PMPRADMININTERFACEDELETE g_pMprAdminInterfaceDelete = NULL;
  266. PMPRADMININTERFACEGETHANDLE g_pMprAdminInterfaceGetHandle = NULL;
  267. PMPRADMININTERFACEGETCREDENTIALS g_pMprAdminInterfaceGetCredentials = NULL;
  268. PMPRADMININTERFACEGETCREDENTIALSEX g_pMprAdminInterfaceGetCredentialsEx = NULL;
  269. PMPRADMININTERFACESETCREDENTIALS g_pMprAdminInterfaceSetCredentials = NULL;
  270. PMPRADMININTERFACESETCREDENTIALSEX g_pMprAdminInterfaceSetCredentialsEx = NULL;
  271. PMPRADMINBUFFERFREE g_pMprAdminBufferFree = NULL;
  272. PMPRADMININTERFACETRANSPORTADD g_pMprAdminInterfaceTransportAdd = NULL;
  273. PMPRADMININTERFACETRANSPORTSETINFO g_pMprAdminInterfaceTransportSetInfo = NULL;
  274. PMPRADMINSERVERCONNECT g_pMprAdminServerConnect = NULL;
  275. PMPRADMINSERVERDISCONNECT g_pMprAdminServerDisconnect = NULL;
  276. PMPRADMINTRANSPORTSETINFO g_pMprAdminTransportSetInfo = NULL;
  277. PRASADMINBUFFERFREE g_pRasAdminBufferFree = NULL;
  278. PRASADMINCONNECTIONENUM g_pRasAdminConnectionEnum = NULL;
  279. PRASADMINCONNECTIONGETINFO g_pRasAdminConnectionGetInfo = NULL;
  280. PRASADMINPORTDISCONNECT g_pRasAdminPortDisconnect = NULL;
  281. PRASADMINPORTENUM g_pRasAdminPortEnum = NULL;
  282. PRASADMINPORTGETINFO g_pRasAdminPortGetInfo = NULL;
  283. PRASADMINSERVERCONNECT g_pRasAdminServerConnect = NULL;
  284. PRASADMINSERVERDISCONNECT g_pRasAdminServerDisconnect = NULL;
  285. PRASADMINUSERSETINFO g_pRasAdminUserSetInfo = NULL;
  286. PMPRADMINUSERSERVERCONNECT g_pMprAdminUserServerConnect = NULL;
  287. PMPRADMINUSERSERVERDISCONNECT g_pMprAdminUserServerDisconnect = NULL;
  288. PMPRADMINUSEROPEN g_pMprAdminUserOpen = NULL;
  289. PMPRADMINUSERCLOSE g_pMprAdminUserClose = NULL;
  290. PMPRADMINUSERWRITE g_pMprAdminUserWrite = NULL;
  291. PMPRCONFIGBUFFERFREE g_pMprConfigBufferFree;
  292. PMPRCONFIGSERVERCONNECT g_pMprConfigServerConnect;
  293. PMPRCONFIGSERVERDISCONNECT g_pMprConfigServerDisconnect;
  294. PMPRCONFIGTRANSPORTGETINFO g_pMprConfigTransportGetInfo;
  295. PMPRCONFIGTRANSPORTSETINFO g_pMprConfigTransportSetInfo;
  296. PMPRCONFIGTRANSPORTGETHANDLE g_pMprConfigTransportGetHandle;
  297. PMPRCONFIGINTERFACECREATE g_pMprConfigInterfaceCreate;
  298. PMPRCONFIGINTERFACEDELETE g_pMprConfigInterfaceDelete;
  299. PMPRCONFIGINTERFACEGETHANDLE g_pMprConfigInterfaceGetHandle;
  300. PMPRCONFIGINTERFACEENUM g_pMprConfigInterfaceEnum;
  301. PMPRCONFIGINTERFACETRANSPORTADD g_pMprConfigInterfaceTransportAdd;
  302. PMPRCONFIGINTERFACETRANSPORTGETINFO g_pMprConfigInterfaceTransportGetInfo;
  303. PMPRCONFIGINTERFACETRANSPORTSETINFO g_pMprConfigInterfaceTransportSetInfo;
  304. PMPRCONFIGINTERFACETRANSPORTGETHANDLE g_pMprConfigInterfaceTransportGetHandle;
  305. PMPRINFOCREATE g_pMprInfoCreate;
  306. PMPRINFODELETE g_pMprInfoDelete;
  307. PMPRINFODUPLICATE g_pMprInfoDuplicate;
  308. PMPRINFOBLOCKADD g_pMprInfoBlockAdd;
  309. PMPRINFOBLOCKREMOVE g_pMprInfoBlockRemove;
  310. PMPRINFOBLOCKSET g_pMprInfoBlockSet;
  311. PMPRINFOBLOCKFIND g_pMprInfoBlockFind;
  312. //
  313. // Miscellaneous DLLs
  314. //
  315. PGETINSTALLEDPROTOCOLS g_pGetInstalledProtocols = GetInstalledProtocols;
  316. PGETINSTALLEDPROTOCOLSEX g_pGetInstalledProtocolsEx = GetInstalledProtocolsEx;
  317. PGETUSERPREFERENCES g_pGetUserPreferences = GetUserPreferences;
  318. PSETUSERPREFERENCES g_pSetUserPreferences = SetUserPreferences;
  319. PGETSYSTEMDIRECTORY g_pGetSystemDirectory = RasGetSystemDirectory;
  320. //
  321. // RASRPC.DLL
  322. //
  323. RPC_BINDING_HANDLE g_hBinding;
  324. BOOL g_fRasapi32PreviouslyLoaded = FALSE;
  325. BOOL g_fRasmanPreviouslyLoaded = FALSE;
  326. BOOL g_Version = VERSION_501;
  327. BOOL g_dwConnectCount = 0;
  328. DWORD APIENTRY
  329. RemoteGetVersion(
  330. RPC_BINDING_HANDLE hServer,
  331. PDWORD pdwVersion
  332. );
  333. //
  334. // Routines
  335. //
  336. BOOL
  337. IsRasmanServiceRunning(
  338. void )
  339. /*++
  340. Routine Description
  341. Arguments
  342. Return Value
  343. Returns true if the PRASMAN service is running,
  344. false otherwise.
  345. --*/
  346. {
  347. BOOL fStatus;
  348. SC_HANDLE schScm;
  349. SC_HANDLE schRasman;
  350. SERVICE_STATUS status;
  351. fStatus = FALSE;
  352. schScm = NULL;
  353. schRasman = NULL;
  354. do
  355. {
  356. schScm = OpenSCManager( NULL, NULL, GENERIC_READ );
  357. if (!schScm)
  358. break;
  359. schRasman = OpenService(
  360. schScm, TEXT( RASMAN_SERVICE_NAME ), SERVICE_QUERY_STATUS );
  361. if (!schRasman)
  362. break;
  363. if (!QueryServiceStatus( schRasman, &status ))
  364. break;
  365. fStatus = (status.dwCurrentState == SERVICE_RUNNING);
  366. }
  367. while (FALSE);
  368. if (schRasman)
  369. CloseServiceHandle( schRasman );
  370. if (schScm)
  371. CloseServiceHandle( schScm );
  372. TRACE1("IsRasmanServiceRunning=%d",fStatus);
  373. return fStatus;
  374. }
  375. DWORD
  376. LoadMpradminDll(
  377. void )
  378. /*++
  379. Routine Description
  380. Loads MPRAPI DLL and it's entry points.
  381. Arguments
  382. Return Value
  383. Returns 0 if successful, otherwise a non-zero error code.
  384. --*/
  385. {
  386. HINSTANCE h;
  387. if (g_hMpradminDll)
  388. return 0;
  389. if (!(h = LoadLibrary(TEXT("MPRAPI.DLL")))
  390. || !(g_pMprAdminInterfaceCreate =
  391. (PMPRADMININTERFACECREATE)GetProcAddress(
  392. h, SZ_MprAdminInterfaceCreate))
  393. || !(g_pMprAdminInterfaceDelete =
  394. (PMPRADMININTERFACEDELETE)GetProcAddress(
  395. h, SZ_MprAdminInterfaceDelete))
  396. || !(g_pMprAdminInterfaceGetHandle =
  397. (PMPRADMININTERFACEGETHANDLE)GetProcAddress(
  398. h, SZ_MprAdminInterfaceGetHandle))
  399. || !(g_pMprAdminInterfaceGetCredentials =
  400. (PMPRADMININTERFACEGETCREDENTIALS)GetProcAddress(
  401. h, SZ_MprAdminInterfaceGetCredentials))
  402. || !(g_pMprAdminInterfaceGetCredentialsEx =
  403. (PMPRADMININTERFACEGETCREDENTIALSEX)GetProcAddress(
  404. h, SZ_MprAdminInterfaceGetCredentialsEx))
  405. || !(g_pMprAdminInterfaceSetCredentials =
  406. (PMPRADMININTERFACESETCREDENTIALS)GetProcAddress(
  407. h, SZ_MprAdminInterfaceSetCredentials))
  408. || !(g_pMprAdminInterfaceSetCredentialsEx =
  409. (PMPRADMININTERFACESETCREDENTIALSEX)GetProcAddress(
  410. h, SZ_MprAdminInterfaceSetCredentialsEx))
  411. || !(g_pMprAdminBufferFree =
  412. (PMPRADMINBUFFERFREE)GetProcAddress(
  413. h, SZ_MprAdminBufferFree))
  414. || !(g_pMprAdminInterfaceTransportAdd =
  415. (PMPRADMININTERFACETRANSPORTADD)GetProcAddress(
  416. h, SZ_MprAdminInterfaceTransportAdd))
  417. || !(g_pMprAdminInterfaceTransportSetInfo =
  418. (PMPRADMININTERFACETRANSPORTSETINFO)GetProcAddress(
  419. h, SZ_MprAdminInterfaceTransportSetInfo))
  420. || !(g_pMprAdminServerConnect =
  421. (PMPRADMINSERVERCONNECT)GetProcAddress(
  422. h, SZ_MprAdminServerConnect))
  423. || !(g_pMprAdminServerDisconnect =
  424. (PMPRADMINSERVERDISCONNECT)GetProcAddress(
  425. h, SZ_MprAdminServerDisconnect))
  426. || !(g_pMprAdminTransportSetInfo =
  427. (PMPRADMINTRANSPORTSETINFO)GetProcAddress(
  428. h, SZ_MprAdminTransportSetInfo))
  429. || !(g_pRasAdminServerConnect =
  430. (PRASADMINSERVERCONNECT)GetProcAddress(
  431. h, SZ_RasAdminServerConnect))
  432. || !(g_pRasAdminServerDisconnect =
  433. (PRASADMINSERVERDISCONNECT)GetProcAddress(
  434. h, SZ_RasAdminServerDisconnect))
  435. || !(g_pRasAdminBufferFree =
  436. (PRASADMINBUFFERFREE)GetProcAddress(
  437. h, SZ_RasAdminBufferFree))
  438. || !(g_pRasAdminConnectionEnum =
  439. (PRASADMINCONNECTIONENUM)GetProcAddress(
  440. h, SZ_RasAdminConnectionEnum))
  441. || !(g_pRasAdminConnectionGetInfo =
  442. (PRASADMINCONNECTIONGETINFO)GetProcAddress(
  443. h, SZ_RasAdminConnectionGetInfo))
  444. || !(g_pRasAdminPortEnum =
  445. (PRASADMINPORTENUM)GetProcAddress(
  446. h, SZ_RasAdminPortEnum))
  447. || !(g_pRasAdminPortGetInfo =
  448. (PRASADMINPORTGETINFO)GetProcAddress(
  449. h, SZ_RasAdminPortGetInfo))
  450. || !(g_pRasAdminPortDisconnect =
  451. (PRASADMINPORTDISCONNECT)GetProcAddress(
  452. h, SZ_RasAdminPortDisconnect))
  453. || !(g_pRasAdminUserSetInfo =
  454. (PRASADMINUSERSETINFO)GetProcAddress(
  455. h, SZ_RasAdminUserSetInfo))
  456. || !(g_pMprAdminUserServerConnect =
  457. (PMPRADMINUSERSERVERCONNECT)GetProcAddress(
  458. h, SZ_MprAdminUserServerConnect))
  459. || !(g_pMprAdminUserServerDisconnect =
  460. (PMPRADMINUSERSERVERDISCONNECT)GetProcAddress(
  461. h, SZ_MprAdminUserServerDisconnect))
  462. || !(g_pMprAdminUserOpen =
  463. (PMPRADMINUSEROPEN)GetProcAddress(
  464. h, SZ_MprAdminUserOpen))
  465. || !(g_pMprAdminUserClose =
  466. (PMPRADMINUSERCLOSE)GetProcAddress(
  467. h, SZ_MprAdminUserClose))
  468. || !(g_pMprAdminUserWrite =
  469. (PMPRADMINUSERWRITE)GetProcAddress(
  470. h, SZ_MprAdminUserWrite))
  471. || !(g_pMprConfigBufferFree =
  472. (PMPRCONFIGBUFFERFREE)GetProcAddress(
  473. h, SZ_MprConfigBufferFree))
  474. || !(g_pMprConfigServerConnect =
  475. (PMPRCONFIGSERVERCONNECT)GetProcAddress(
  476. h, SZ_MprConfigServerConnect))
  477. || !(g_pMprConfigServerDisconnect =
  478. (PMPRCONFIGSERVERDISCONNECT)GetProcAddress(
  479. h, SZ_MprConfigServerDisconnect))
  480. || !(g_pMprConfigTransportGetInfo =
  481. (PMPRCONFIGTRANSPORTGETINFO)GetProcAddress(
  482. h, SZ_MprConfigTransportGetInfo))
  483. || !(g_pMprConfigTransportSetInfo =
  484. (PMPRCONFIGTRANSPORTSETINFO)GetProcAddress(
  485. h, SZ_MprConfigTransportSetInfo))
  486. || !(g_pMprConfigTransportGetHandle =
  487. (PMPRCONFIGTRANSPORTGETHANDLE)GetProcAddress(
  488. h, SZ_MprConfigTransportGetHandle))
  489. || !(g_pMprConfigInterfaceCreate =
  490. (PMPRCONFIGINTERFACECREATE)GetProcAddress(
  491. h, SZ_MprConfigInterfaceCreate))
  492. || !(g_pMprConfigInterfaceDelete =
  493. (PMPRCONFIGINTERFACEDELETE)GetProcAddress(
  494. h, SZ_MprConfigInterfaceDelete))
  495. || !(g_pMprConfigInterfaceGetHandle =
  496. (PMPRCONFIGINTERFACEGETHANDLE)GetProcAddress(
  497. h, SZ_MprConfigInterfaceGetHandle))
  498. || !(g_pMprConfigInterfaceEnum =
  499. (PMPRCONFIGINTERFACEENUM)GetProcAddress(
  500. h, SZ_MprConfigInterfaceEnum))
  501. || !(g_pMprConfigInterfaceTransportAdd =
  502. (PMPRCONFIGINTERFACETRANSPORTADD)GetProcAddress(
  503. h, SZ_MprConfigInterfaceTransportAdd))
  504. || !(g_pMprConfigInterfaceTransportGetInfo =
  505. (PMPRCONFIGINTERFACETRANSPORTGETINFO)GetProcAddress(
  506. h, SZ_MprConfigInterfaceTransportGetInfo))
  507. || !(g_pMprConfigInterfaceTransportSetInfo =
  508. (PMPRCONFIGINTERFACETRANSPORTSETINFO)GetProcAddress(
  509. h, SZ_MprConfigInterfaceTransportSetInfo))
  510. || !(g_pMprConfigInterfaceTransportGetHandle =
  511. (PMPRCONFIGINTERFACETRANSPORTGETHANDLE)GetProcAddress(
  512. h, SZ_MprConfigInterfaceTransportGetHandle))
  513. || !(g_pMprInfoCreate =
  514. (PMPRINFOCREATE)GetProcAddress(
  515. h, SZ_MprInfoCreate))
  516. || !(g_pMprInfoDelete =
  517. (PMPRINFODELETE)GetProcAddress(
  518. h, SZ_MprInfoDelete))
  519. || !(g_pMprInfoDuplicate =
  520. (PMPRINFODUPLICATE)GetProcAddress(
  521. h, SZ_MprInfoDuplicate))
  522. || !(g_pMprInfoBlockAdd =
  523. (PMPRINFOBLOCKADD)GetProcAddress(
  524. h, SZ_MprInfoBlockAdd))
  525. || !(g_pMprInfoBlockRemove =
  526. (PMPRINFOBLOCKREMOVE)GetProcAddress(
  527. h, SZ_MprInfoBlockRemove))
  528. || !(g_pMprInfoBlockSet =
  529. (PMPRINFOBLOCKSET)GetProcAddress(
  530. h, SZ_MprInfoBlockSet))
  531. || !(g_pMprInfoBlockFind =
  532. (PMPRINFOBLOCKFIND)GetProcAddress(
  533. h, SZ_MprInfoBlockFind)) )
  534. {
  535. return GetLastError();
  536. }
  537. g_hMpradminDll = h;
  538. return 0;
  539. }
  540. DWORD
  541. LoadRasapi32Dll(
  542. void )
  543. /*++
  544. Routine Description
  545. Loads the RASAPI32.DLL and it's entrypoints.
  546. Arguments
  547. Return Value
  548. Returns 0 if successful, otherwise a non-0 error code.
  549. --*/
  550. {
  551. HINSTANCE h;
  552. if (g_hRasapi32Dll)
  553. return 0;
  554. if (!(h = LoadLibrary( TEXT("RASAPI32.DLL") ))
  555. || !(g_pRasConnectionNotification =
  556. (PRASCONNECTIONNOTIFICATION )GetProcAddress(
  557. h, SZ_RasConnectionNotification ))
  558. || !(g_pRasDeleteEntry =
  559. (PRASDELETEENTRY )GetProcAddress(
  560. h, SZ_RasDeleteEntry ))
  561. || !(g_pRasDial =
  562. (PRASDIAL )GetProcAddress(
  563. h, SZ_RasDial ))
  564. || !(g_pRasEnumEntries =
  565. (PRASENUMENTRIES )GetProcAddress(
  566. h, SZ_RasEnumEntries ))
  567. || !(g_pRasEnumConnections =
  568. (PRASENUMCONNECTIONS )GetProcAddress(
  569. h, SZ_RasEnumConnections ))
  570. || !(g_pRasGetAutodialEnable =
  571. (PRASGETAUTODIALENABLE )GetProcAddress(
  572. h, SZ_RasGetAutodialEnable ))
  573. || !(g_pRasGetAutodialParam =
  574. (PRASGETAUTODIALPARAM )GetProcAddress(
  575. h, SZ_RasGetAutodialParam ))
  576. || !(g_pRasGetConnectStatus =
  577. (PRASGETCONNECTSTATUS )GetProcAddress(
  578. h, SZ_RasGetConnectStatus ))
  579. || !(g_pRasGetConnectResponse =
  580. (PRASGETCONNECTRESPONSE )GetProcAddress(
  581. h, SZ_RasGetConnectResponse ))
  582. || !(g_pRasGetCredentials =
  583. (PRASGETCREDENTIALS )GetProcAddress(
  584. h, SZ_RasGetCredentials ))
  585. || !(g_pRasGetEntryDialParams =
  586. (PRASGETENTRYDIALPARAMS )GetProcAddress(
  587. h, SZ_RasGetEntryDialParams ))
  588. || !(g_pRasGetErrorString =
  589. (PRASGETERRORSTRING )GetProcAddress(
  590. h, SZ_RasGetErrorString ))
  591. || !(g_pRasGetHport =
  592. (PRASGETHPORT )GetProcAddress(
  593. h, "RasGetHport" ))
  594. || !(g_pRasGetProjectionInfo =
  595. (PRASGETPROJECTIONINFO )GetProcAddress(
  596. h, SZ_RasGetProjectionInfo ))
  597. || !(g_pRasGetSubEntryHandle =
  598. (PRASGETSUBENTRYHANDLE )GetProcAddress(
  599. h, SZ_RasGetSubEntryHandle ))
  600. || !(g_pRasHangUp =
  601. (PRASHANGUP )GetProcAddress(
  602. h, SZ_RasHangUp ))
  603. || !(g_pRasSetAutodialEnable =
  604. (PRASSETAUTODIALENABLE )GetProcAddress(
  605. h, SZ_RasSetAutodialEnable ))
  606. || !(g_pRasSetAutodialParam =
  607. (PRASSETAUTODIALPARAM )GetProcAddress(
  608. h, SZ_RasSetAutodialParam ))
  609. || !(g_pRasSetCredentials =
  610. (PRASSETCREDENTIALS )GetProcAddress(
  611. h, SZ_RasSetCredentials ))
  612. || !(g_pRasSetOldPassword =
  613. (PRASSETOLDPASSWORD )GetProcAddress(
  614. h, "RasSetOldPassword" ))
  615. || !(g_pRasGetCountryInfo =
  616. (PRASGETCOUNTRYINFO )GetProcAddress(
  617. h, SZ_RasGetCountryInfo ))
  618. || !(g_pRasInvokeEapUI =
  619. (PRASINVOKEEAPUI)GetProcAddress(
  620. h, "RasInvokeEapUI"))
  621. || !(g_pRasSetEapUserData =
  622. (PRASSETEAPUSERDATA )GetProcAddress(
  623. h, SZ_RasSetEapUserData ))
  624. || !(g_pRasGetEntryProperties =
  625. (PRASGETENTRYPROPERTIES )GetProcAddress(
  626. h, SZ_RasGetEntryProperties))
  627. || !(g_pRasValidateEntryName =
  628. (PRASVALIDATEENTRYNAME )GetProcAddress(
  629. h, SZ_RasValidateEntryName)))
  630. {
  631. return GetLastError();
  632. }
  633. g_hRasapi32Dll = h;
  634. return 0;
  635. }
  636. DWORD
  637. LoadRasdlgDll(
  638. void )
  639. /*++
  640. Routine Description
  641. Loads the RASDLG.DLL and it's entrypoints.
  642. Arguments
  643. Return Value
  644. Returns 0 if successful, otherwise a non-0 error code.
  645. --*/
  646. {
  647. HINSTANCE h;
  648. if (g_hRasdlgDll)
  649. return 0;
  650. if (!(h = LoadLibrary( TEXT("RASDLG.DLL") ))
  651. || !(g_pRasPhonebookDlg =
  652. (PRASPHONEBOOKDLG )GetProcAddress(
  653. h, SZ_RasPhonebookDlg ))
  654. || !(g_pRasEntryDlg =
  655. (PRASENTRYDLG )GetProcAddress(
  656. h, SZ_RasEntryDlg ))
  657. || !(g_pRouterEntryDlg =
  658. (PROUTERENTRYDLG )GetProcAddress(
  659. h, SZ_RouterEntryDlg ))
  660. || !(g_pRasDialDlg =
  661. (PRASDIALDLG )GetProcAddress(
  662. h, SZ_RasDialDlg )))
  663. {
  664. return GetLastError();
  665. }
  666. g_hRasdlgDll = h;
  667. return 0;
  668. }
  669. DWORD
  670. LoadRasmanDll(
  671. void )
  672. /*++
  673. Routine Description
  674. Loads the RASMAN.DLL and it's entrypoints.
  675. Arguments
  676. Return Value
  677. Returns 0 if successful, otherwise a non-0 error code.
  678. --*/
  679. {
  680. HINSTANCE h;
  681. DWORD dwErr;
  682. if (g_hRasmanDll)
  683. return 0;
  684. if (!(h = LoadLibrary( TEXT("RASMAN.DLL") ))
  685. || !(g_pRasPortClearStatistics =
  686. (PRASPORTCLEARSTATISTICS )GetProcAddress(
  687. h, "RasPortClearStatistics" ))
  688. || !(g_pRasBundleClearStatistics =
  689. (PRASBUNDLECLEARSTATISTICS )GetProcAddress(
  690. h, "RasBundleClearStatistics" ))
  691. || !(g_pRasBundleClearStatisticsEx =
  692. (PRASBUNDLECLEARSTATISTICSEX ) GetProcAddress(
  693. h, "RasBundleClearStatisticsEx"))
  694. || !(g_pRasDeviceEnum =
  695. (PRASDEVICEENUM )GetProcAddress(
  696. h, "RasDeviceEnum" ))
  697. || !(g_pRasDeviceGetInfo =
  698. (PRASDEVICEGETINFO )GetProcAddress(
  699. h, "RasDeviceGetInfo" ))
  700. || !(g_pRasFreeBuffer =
  701. (PRASFREEBUFFER )GetProcAddress(
  702. h, "RasFreeBuffer" ))
  703. || !(g_pRasGetBuffer =
  704. (PRASGETBUFFER )GetProcAddress(
  705. h, "RasGetBuffer" ))
  706. || !(g_pRasGetInfo =
  707. (PRASGETINFO )GetProcAddress(
  708. h, "RasGetInfo" ))
  709. || !(g_pRasGetNdiswanDriverCaps =
  710. (PRASGETNDISWANDRIVERCAPS )GetProcAddress(
  711. h, "RasGetNdiswanDriverCaps" ))
  712. || !(g_pRasInitialize =
  713. (PRASINITIALIZE )GetProcAddress(
  714. h, "RasInitialize" ))
  715. || !(g_pRasInitializeNoWait =
  716. (PRASINITIALIZENOWAIT )GetProcAddress(
  717. h, "RasInitializeNoWait" ))
  718. || !(g_pRasPortCancelReceive =
  719. (PRASPORTCANCELRECEIVE )GetProcAddress(
  720. h, "RasPortCancelReceive" ))
  721. || !(g_pRasPortEnum =
  722. (PRASPORTENUM )GetProcAddress(
  723. h, "RasPortEnum" ))
  724. || !(g_pRasPortGetInfo =
  725. (PRASPORTGETINFO )GetProcAddress(
  726. h, "RasPortGetInfo" ))
  727. || !(g_pRasPortGetFramingEx =
  728. (PRASPORTGETFRAMINGEX )GetProcAddress(
  729. h, "RasPortGetFramingEx" ))
  730. || !(g_pRasPortGetStatistics =
  731. (PRASPORTGETSTATISTICS )GetProcAddress(
  732. h, "RasPortGetStatistics" ))
  733. || !(g_pRasBundleGetStatistics =
  734. (PRASBUNDLEGETSTATISTICS )GetProcAddress(
  735. h, "RasBundleGetStatistics" ))
  736. || !(g_pRasPortGetStatisticsEx =
  737. (PRASPORTGETSTATISTICSEX )GetProcAddress(
  738. h, "RasPortGetStatisticsEx"))
  739. || !(g_pRasBundleGetStatisticsEx =
  740. (PRASBUNDLEGETSTATISTICSEX)GetProcAddress(
  741. h, "RasBundleGetStatisticsEx" ))
  742. || !(g_pRasPortReceive =
  743. (PRASPORTRECEIVE )GetProcAddress(
  744. h, "RasPortReceive" ))
  745. || !(g_pRasPortReceiveEx =
  746. (PRASPORTRECEIVEEX )GetProcAddress(
  747. h, "RasPortReceiveEx"))
  748. || !(g_pRasPortSend =
  749. (PRASPORTSEND )GetProcAddress(
  750. h, "RasPortSend" ))
  751. || !(g_pRasPortGetBundle =
  752. (PRASPORTGETBUNDLE )GetProcAddress(
  753. h, "RasPortGetBundle" ))
  754. || !(g_pRasGetDevConfig =
  755. (PRASGETDEVCONFIG )GetProcAddress(
  756. h, "RasGetDevConfig" ))
  757. || !(g_pRasGetDevConfigEx =
  758. (PRASGETDEVCONFIG )GetProcAddress(
  759. h, "RasGetDevConfigEx" ))
  760. || !(g_pRasSetDevConfig =
  761. (PRASSETDEVCONFIG )GetProcAddress(
  762. h, "RasSetDevConfig" ))
  763. || !(g_pRasPortClose =
  764. (PRASPORTCLOSE )GetProcAddress(
  765. h, "RasPortClose" ))
  766. || !(g_pRasPortListen =
  767. (PRASPORTLISTEN )GetProcAddress(
  768. h, "RasPortListen" ))
  769. || !(g_pRasPortConnectComplete =
  770. (PRASPORTCONNECTCOMPLETE )GetProcAddress(
  771. h, "RasPortConnectComplete" ))
  772. || !(g_pRasPortDisconnect =
  773. (PRASPORTDISCONNECT )GetProcAddress(
  774. h, "RasPortDisconnect" ))
  775. || !(g_pRasRequestNotification =
  776. (PRASREQUESTNOTIFICATION )GetProcAddress(
  777. h, "RasRequestNotification" ))
  778. || !(g_pRasPortEnumProtocols =
  779. (PRASPORTENUMPROTOCOLS )GetProcAddress(
  780. h, "RasPortEnumProtocols" ))
  781. || !(g_pRasPortSetFraming =
  782. (PRASPORTSETFRAMING )GetProcAddress(
  783. h, "RasPortSetFraming" ))
  784. || !(g_pRasPortSetFramingEx =
  785. (PRASPORTSETFRAMINGEX )GetProcAddress(
  786. h, "RasPortSetFramingEx" ))
  787. || !(g_pRasSetCachedCredentials =
  788. (PRASSETCACHEDCREDENTIALS )GetProcAddress(
  789. h, "RasSetCachedCredentials" ))
  790. || !(g_pRasGetDialParams =
  791. (PRASGETDIALPARAMS )GetProcAddress(
  792. h, "RasGetDialParams" ))
  793. || !(g_pRasSetDialParams =
  794. (PRASSETDIALPARAMS )GetProcAddress(
  795. h, "RasSetDialParams" ))
  796. || !(g_pRasCreateConnection =
  797. (PRASCREATECONNECTION )GetProcAddress(
  798. h, "RasCreateConnection" ))
  799. || !(g_pRasDestroyConnection =
  800. (PRASDESTROYCONNECTION )GetProcAddress(
  801. h, "RasDestroyConnection" ))
  802. || !(g_pRasConnectionEnum =
  803. (PRASCONNECTIONENUM )GetProcAddress(
  804. h, "RasConnectionEnum" ))
  805. || !(g_pRasAddConnectionPort =
  806. (PRASADDCONNECTIONPORT )GetProcAddress(
  807. h, "RasAddConnectionPort" ))
  808. || !(g_pRasEnumConnectionPorts =
  809. (PRASENUMCONNECTIONPORTS )GetProcAddress(
  810. h, "RasEnumConnectionPorts" ))
  811. || !(g_pRasGetConnectionParams =
  812. (PRASGETCONNECTIONPARAMS )GetProcAddress(
  813. h, "RasGetConnectionParams" ))
  814. || !(g_pRasSetConnectionParams =
  815. (PRASSETCONNECTIONPARAMS )GetProcAddress(
  816. h, "RasSetConnectionParams" ))
  817. || !(g_pRasGetConnectionUserData =
  818. (PRASGETCONNECTIONUSERDATA )GetProcAddress(
  819. h, "RasGetConnectionUserData" ))
  820. || !(g_pRasSetConnectionUserData =
  821. (PRASSETCONNECTIONUSERDATA )GetProcAddress(
  822. h, "RasSetConnectionUserData" ))
  823. || !(g_pRasGetPortUserData =
  824. (PRASGETPORTUSERDATA )GetProcAddress(
  825. h, "RasGetPortUserData" ))
  826. || !(g_pRasSetPortUserData =
  827. (PRASSETPORTUSERDATA )GetProcAddress(
  828. h, "RasSetPortUserData" ))
  829. || !(g_pRasAddNotification =
  830. (PRASADDNOTIFICATION )GetProcAddress(
  831. h, "RasAddNotification" ))
  832. || !(g_pRasSignalNewConnection =
  833. (PRASSIGNALNEWCONNECTION )GetProcAddress(
  834. h, "RasSignalNewConnection" ))
  835. || !(g_pRasPppStop =
  836. (PRASPPPSTOP )GetProcAddress(
  837. h, "RasPppStop" ))
  838. || !(g_pRasPppCallback =
  839. (PRASPPPCALLBACK )GetProcAddress(
  840. h, "RasPppCallback" ))
  841. || !(g_pRasPppChangePassword =
  842. (PRASPPPCHANGEPASSWORD )GetProcAddress(
  843. h, "RasPppChangePassword" ))
  844. || !(g_pRasPppGetInfo =
  845. (PRASPPPGETINFO )GetProcAddress(
  846. h, "RasPppGetInfo" ))
  847. || !(g_pRasPppRetry =
  848. (PRASPPPRETRY )GetProcAddress(
  849. h, "RasPppRetry" ))
  850. || !(g_pRasPppStart =
  851. (PRASPPPSTART )GetProcAddress(
  852. h, "RasPppStart" ))
  853. || !(g_pRasPortOpen =
  854. (PRASPORTOPEN )GetProcAddress(
  855. h, "RasPortOpen" ))
  856. || !(g_pRasPortRegisterSlip =
  857. (PRASPORTREGISTERSLIP )GetProcAddress(
  858. h, "RasPortRegisterSlip" ))
  859. || !(g_pRasAllocateRoute =
  860. (PRASALLOCATEROUTE )GetProcAddress(
  861. h, "RasAllocateRoute" ))
  862. || !(g_pRasActivateRoute =
  863. (PRASACTIVATEROUTE )GetProcAddress(
  864. h, "RasActivateRoute" ))
  865. || !(g_pRasActivateRouteEx =
  866. (PRASACTIVATEROUTEEX )GetProcAddress(
  867. h, "RasActivateRouteEx" ))
  868. || !(g_pRasDeviceSetInfo =
  869. (PRASDEVICESETINFO )GetProcAddress(
  870. h, "RasDeviceSetInfo" ))
  871. || !(g_pRasDeviceConnect =
  872. (PRASDEVICECONNECT )GetProcAddress(
  873. h, "RasDeviceConnect" ))
  874. || !(g_pRasPortSetInfo =
  875. (PRASPORTSETINFO )GetProcAddress(
  876. h, "RasPortSetInfo" ))
  877. || !(g_pRasSetIoCompletionPort =
  878. (PRASSETIOCOMPLETIONPORT )GetProcAddress(
  879. h, "RasSetIoCompletionPort" ))
  880. || !(g_pRasSendPppMessageToRasman =
  881. (PRASSENDPPPMESSAGETORASMAN)GetProcAddress(
  882. h, "RasSendPppMessageToRasman"))
  883. || !(g_pRasSetRasdialInfo =
  884. (PRASSETRASDIALINFO)GetProcAddress(
  885. h, "RasSetRasdialInfo"))
  886. || !(g_pRasRpcConnect =
  887. (PRASRPCCONNECT)GetProcAddress(
  888. h, "RasRpcConnect"))
  889. || !(g_pRasRpcDisconnect =
  890. (PRASRPCDISCONNECT) GetProcAddress(
  891. h, "RasRpcDisconnect"))
  892. || !(g_pRasNumPortOpen =
  893. (PRASNUMPORTOPEN)GetProcAddress(
  894. h, "RasGetNumPortOpen"))
  895. || !(g_pRasRefConnection =
  896. (PRASREFCONNECTION) GetProcAddress(
  897. h, "RasRefConnection"))
  898. || !(g_pRasPppSetEapInfo =
  899. (PRASPPPSETEAPINFO) GetProcAddress(
  900. h, "RasPppSetEapInfo"))
  901. || !(g_pRasPppGetEapInfo =
  902. (PRASPPPGETEAPINFO) GetProcAddress(
  903. h, "RasPppGetEapInfo"))
  904. || !(g_pRasFindPrerequisiteEntry =
  905. (PRASFINDPREREQUISITEENTRY) GetProcAddress(
  906. h, "RasFindPrerequisiteEntry"))
  907. || !(g_pRasPortOpenEx =
  908. (PRASPORTOPENEX) GetProcAddress(
  909. h, "RasPortOpenEx"))
  910. || !(g_pRasLinkGetStatistics =
  911. (PRASLINKGETSTATISTICS) GetProcAddress(
  912. h, "RasLinkGetStatistics"))
  913. || !(g_pRasConnectionGetStatistics =
  914. (PRASCONNECTIONGETSTATISTICS) GetProcAddress(
  915. h, "RasConnectionGetStatistics"))
  916. || !(g_pRasGetHportFromConnection =
  917. (PRASGETHPORTFROMCONNECTION) GetProcAddress(
  918. h, "RasGetHportFromConnection"))
  919. || !(g_pRasRpcBind =
  920. (PRASRPCBIND) GetProcAddress(
  921. h, "RasRPCBind"))
  922. || !(g_pRasReferenceCustomCount =
  923. (PRASREFERENCECUSTOMCOUNT) GetProcAddress(
  924. h, "RasReferenceCustomCount"))
  925. || !(g_pRasGetHConnFromEntry =
  926. (PRASGETHCONNFROMENTRY)GetProcAddress(
  927. h, "RasGetHConnFromEntry"))
  928. || !(g_pRasGetDeviceName =
  929. (PRASGETDEVICENAME)GetProcAddress(
  930. h, "RasGetDeviceName"))
  931. || !(g_pRasEnableIpSec =
  932. (PRASENABLEIPSEC)GetProcAddress(
  933. h, "RasEnableIpSec"))
  934. || !(g_pRasIsIpSecEnabled =
  935. (PRASISIPSECENABLED)GetProcAddress(
  936. h, "RasIsIpSecEnabled"))
  937. || !(g_pRasGetEapUserInfo =
  938. (PRASGETEAPUSERINFO)GetProcAddress(
  939. h, "RasGetEapUserInfo"))
  940. || !(g_pRasSetEapUserInfo =
  941. (PRASSETEAPUSERINFO)GetProcAddress(
  942. h, "RasSetEapUserInfo"))
  943. || !(g_pRasSetEapLogonInfo =
  944. (PRASSETEAPLOGONINFO)GetProcAddress(
  945. h, "RasSetEapLogonInfo"))
  946. || !(g_pRasStartRasAutoIfRequired =
  947. (PRASSTARTRASAUTOIFREQUIRED) GetProcAddress(
  948. h, "RasStartRasAutoIfRequired"))
  949. )
  950. {
  951. return GetLastError();
  952. }
  953. g_hRasmanDll = h;
  954. return 0;
  955. }
  956. DWORD
  957. GetServerVersion(
  958. RPC_BINDING_HANDLE hServer,
  959. PDWORD pdwVersion
  960. )
  961. {
  962. DWORD dwStatus;
  963. #if DBG
  964. ASSERT(NULL != pdwVersion);
  965. ASSERT(NULL != hServer);
  966. #endif
  967. *pdwVersion = VERSION_501;
  968. //
  969. // Call the get version api
  970. //
  971. dwStatus = RemoteGetVersion(hServer, pdwVersion);
  972. //
  973. // If the api fails, we assume that the server we
  974. // are talking to is steelhead and initialize the
  975. // version to 4.0.
  976. //
  977. if (RPC_S_PROCNUM_OUT_OF_RANGE == dwStatus)
  978. {
  979. *pdwVersion = VERSION_40;
  980. dwStatus = NO_ERROR;
  981. }
  982. return dwStatus;
  983. }
  984. void
  985. UninitializeConnection(HANDLE hConnection)
  986. {
  987. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  988. #if DBG
  989. ASSERT(NULL != hConnection);
  990. //DbgPrint("rasman: Disconnecting from server. handle=0x%08x\n",
  991. // pRasRpcConnection->hRpcBinding);
  992. #endif
  993. (void) RpcBindingFree(pRasRpcConnection->hRpcBinding);
  994. LocalFree(pRasRpcConnection);
  995. /*
  996. //
  997. // Decrement the connect count and Unload rasapi32 dll
  998. // if this is the last client disconnecting.
  999. //
  1000. if(!InterlockedDecrement(&g_dwConnectCount))
  1001. {
  1002. UnloadRasapi32Dll();
  1003. UnloadRasmanDll();
  1004. }
  1005. */
  1006. }
  1007. DWORD
  1008. InitializeConnection(
  1009. LPTSTR lpszServer,
  1010. HANDLE *lpHConnection)
  1011. {
  1012. RAS_RPC *pRasRpcConnection = NULL;
  1013. DWORD dwError = ERROR_SUCCESS;
  1014. TCHAR szLocalComputer[MAX_COMPUTERNAME_LENGTH + 1] = {0};
  1015. DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
  1016. BOOL fLocal = FALSE;
  1017. LPTSTR lpszSrv = lpszServer;
  1018. RPC_BINDING_HANDLE hServer = NULL;
  1019. DWORD dwVersion;
  1020. //
  1021. // Do some parameter validation. If lpszServer is
  1022. // NULL then we connect to the local server
  1023. //
  1024. if(NULL == lpHConnection)
  1025. {
  1026. dwError = E_INVALIDARG;
  1027. goto done;
  1028. }
  1029. *lpHConnection = NULL;
  1030. //
  1031. // Get the local computername
  1032. //
  1033. if(!GetComputerName(szLocalComputer, &dwSize))
  1034. {
  1035. dwError = GetLastError();
  1036. goto done;
  1037. }
  1038. if( NULL != lpszServer
  1039. && TEXT('\0') != lpszServer[0]
  1040. && TEXT('\\') == lpszServer[0]
  1041. && TEXT('\\') == lpszServer[1])
  1042. {
  1043. lpszSrv += 2;
  1044. }
  1045. else if( NULL == lpszServer
  1046. || TEXT('\0') == lpszServer[0])
  1047. {
  1048. fLocal = TRUE;
  1049. }
  1050. if( !fLocal
  1051. && 0 == lstrcmpi(lpszSrv, szLocalComputer))
  1052. {
  1053. fLocal = TRUE;
  1054. }
  1055. if(fLocal)
  1056. {
  1057. lpszSrv = szLocalComputer;
  1058. }
  1059. //
  1060. // Always load rasman dll and rasapi32.dll if
  1061. // they are not already loaded
  1062. //
  1063. if( ERROR_SUCCESS != (dwError = LoadRasmanDll())
  1064. || ERROR_SUCCESS != (dwError = LoadRasapi32Dll()))
  1065. {
  1066. goto done;
  1067. }
  1068. #if DBG
  1069. //DbgPrint("Rasman: Binding to server %ws\n",
  1070. // lpszSrv);
  1071. #endif
  1072. //
  1073. // Bind to the server indicated by the servername
  1074. //
  1075. dwError = g_pRasRpcBind(lpszSrv, &hServer, fLocal);
  1076. #if DBG
  1077. //DbgPrint("Rasman: Bind returned 0x%08x. hServer=0x08x\n",
  1078. // dwError, hServer);
  1079. #endif
  1080. if(NO_ERROR != dwError)
  1081. {
  1082. goto done;
  1083. }
  1084. //
  1085. // Get version of the server
  1086. //
  1087. dwError = GetServerVersion(hServer, &dwVersion);
  1088. if(NO_ERROR != dwError)
  1089. {
  1090. goto done;
  1091. }
  1092. //
  1093. // Allocate and initialize the ControlBlock we
  1094. // keep around for this connection
  1095. //
  1096. if(NULL == (pRasRpcConnection =
  1097. LocalAlloc(LPTR, sizeof(RAS_RPC))))
  1098. {
  1099. dwError = GetLastError();
  1100. goto done;
  1101. }
  1102. pRasRpcConnection->hRpcBinding = hServer;
  1103. pRasRpcConnection->fLocal = fLocal;
  1104. if(fLocal)
  1105. {
  1106. pRasRpcConnection->dwVersion = VERSION_501;
  1107. }
  1108. else
  1109. {
  1110. pRasRpcConnection->dwVersion = dwVersion;
  1111. }
  1112. lstrcpyn(
  1113. pRasRpcConnection->szServer,
  1114. lpszSrv,
  1115. sizeof(pRasRpcConnection->szServer) / sizeof(TCHAR));
  1116. *lpHConnection = (HANDLE) pRasRpcConnection;
  1117. /*
  1118. InterlockedIncrement(&g_dwConnectCount);
  1119. */
  1120. done:
  1121. if( NO_ERROR != dwError
  1122. && NULL != hServer)
  1123. {
  1124. (void) RpcBindingFree(
  1125. hServer
  1126. );
  1127. }
  1128. return dwError;
  1129. }
  1130. #if 0
  1131. DWORD
  1132. LoadRasRpcDll(
  1133. LPTSTR lpszServer
  1134. )
  1135. {
  1136. DWORD dwErr;
  1137. RPC_STATUS rpcStatus;
  1138. HINSTANCE h;
  1139. TCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1] = {0};
  1140. DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
  1141. BOOL fLocal = (lpszServer ? FALSE : TRUE);
  1142. LPTSTR pszServer = lpszServer;
  1143. //
  1144. // Get the local computername
  1145. //
  1146. if (!GetComputerName(szComputerName, &dwSize))
  1147. {
  1148. dwErr = GetLastError();
  1149. return dwErr;
  1150. }
  1151. if ( lpszServer
  1152. && TEXT('\\') == lpszServer[0]
  1153. && TEXT('\\') == lpszServer[1])
  1154. {
  1155. pszServer += 2;
  1156. }
  1157. if ( pszServer
  1158. && 0 == lstrcmpi (pszServer, szComputerName))
  1159. {
  1160. fLocal = TRUE;
  1161. }
  1162. dwErr = LoadRasmanDll();
  1163. if (dwErr)
  1164. {
  1165. return dwErr;
  1166. }
  1167. //
  1168. // disconnect previous binding if we had one
  1169. //
  1170. if ( NULL != g_hBinding )
  1171. {
  1172. g_pRasRpcDisconnect ( &g_hBinding );
  1173. g_hBinding = NULL;
  1174. g_fRasmanPreviouslyLoaded = TRUE;
  1175. }
  1176. //
  1177. // this will connect to local server
  1178. // if lpszServer = NULL
  1179. //
  1180. dwErr = g_pRasRpcConnect( (fLocal ? NULL : pszServer), &g_hBinding );
  1181. if ( dwErr )
  1182. {
  1183. return dwErr;
  1184. }
  1185. if ( fLocal )
  1186. {
  1187. //
  1188. // LoadRasapi32Dll
  1189. //
  1190. dwErr = LoadRasapi32Dll();
  1191. g_fRasapi32PreviouslyLoaded = TRUE;
  1192. return 0;
  1193. }
  1194. g_fRasapi32PreviouslyLoaded = ( g_hRasapi32Dll != NULL );
  1195. if (g_fRasapi32PreviouslyLoaded)
  1196. {
  1197. UnloadRasapi32Dll();
  1198. }
  1199. //
  1200. // Get version of the server we are talking to
  1201. //
  1202. (void) GetServerVersion(g_hBinding, &g_Version);
  1203. //
  1204. // Remap the RPCable APIs. Note: We don't need
  1205. // to bother about the APIs exported by rasman
  1206. // as all rasman APIs always use RPC We need to
  1207. // remap only the APIs exported by dlls which
  1208. // are not exported by rasman.
  1209. //
  1210. /*
  1211. g_pRasEnumConnections = RemoteRasEnumConnections;
  1212. g_pRasDeleteEntry = RemoteRasDeleteEntry;
  1213. g_pRasGetErrorString = RemoteRasGetErrorString;
  1214. g_pRasGetCountryInfo = RemoteRasGetCountryInfo;
  1215. g_pGetInstalledProtocolsEx = RemoteGetInstalledProtocolsEx;
  1216. g_pGetUserPreferences = RemoteGetUserPreferences;
  1217. g_pSetUserPreferences = RemoteSetUserPreferences;
  1218. g_pGetSystemDirectory = RemoteGetSystemDirectory;
  1219. if ( VERSION_40 == g_Version )
  1220. {
  1221. g_pRasPortEnum = RemoteRasPortEnum;
  1222. g_pRasDeviceEnum = RemoteRasDeviceEnum;
  1223. g_pRasGetDevConfig = RemoteRasGetDevConfig;
  1224. g_pRasPortGetInfo = RemoteRasPortGetInfo;
  1225. } */
  1226. return 0;
  1227. }
  1228. #endif
  1229. BOOL
  1230. Rasapi32DllLoaded(
  1231. void
  1232. )
  1233. {
  1234. return (g_hRasapi32Dll != NULL);
  1235. }
  1236. BOOL
  1237. RasRpcDllLoaded(
  1238. void
  1239. )
  1240. {
  1241. return (g_hBinding != NULL);
  1242. }
  1243. LPTSTR
  1244. RemoteGetServerName(HANDLE hConnection)
  1245. {
  1246. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1247. if( NULL == pRasRpcConnection
  1248. || pRasRpcConnection->fLocal)
  1249. {
  1250. return NULL;
  1251. }
  1252. else
  1253. {
  1254. return pRasRpcConnection->szServer;
  1255. }
  1256. }
  1257. DWORD
  1258. RemoteGetServerVersion(HANDLE hConnection)
  1259. {
  1260. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1261. if( NULL == pRasRpcConnection
  1262. || pRasRpcConnection->fLocal)
  1263. {
  1264. return VERSION_501;
  1265. }
  1266. else
  1267. {
  1268. return pRasRpcConnection->dwVersion;
  1269. }
  1270. }
  1271. BOOL
  1272. IsRasRemoteConnection(
  1273. HANDLE hConnection
  1274. )
  1275. {
  1276. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1277. if(NULL == pRasRpcConnection)
  1278. {
  1279. return FALSE;
  1280. }
  1281. return TRUE;
  1282. }
  1283. DWORD
  1284. RemoteGetVersion(
  1285. RPC_BINDING_HANDLE hServer,
  1286. PDWORD pdwVersion
  1287. )
  1288. {
  1289. DWORD dwStatus;
  1290. #if DBG
  1291. ASSERT(NULL != pdwVersion);
  1292. ASSERT(NULL != hServer);
  1293. #endif
  1294. RpcTryExcept
  1295. {
  1296. dwStatus = RasRpcGetVersion(hServer, pdwVersion);
  1297. }
  1298. RasRpcCatchException(&dwStatus)
  1299. {
  1300. dwStatus = RpcExceptionCode();
  1301. }
  1302. RpcEndExcept
  1303. return dwStatus;
  1304. }
  1305. //---------------------------------------------------
  1306. // The following are remoted version of apis exported
  1307. // from rasman.dll. These should never be called if
  1308. // the version of the server is 50 since the rasman
  1309. // apis themselves are remoteable
  1310. //
  1311. /*++
  1312. Routine Description:
  1313. This api enumerates the port information on the
  1314. remote server. This api should not be called if
  1315. the server is local or if the version of the
  1316. remote server is VERSION_501.
  1317. Arguments:
  1318. hConnection - Handle which was obtained with the
  1319. RasServerConnect api. This cannot
  1320. be NULL.
  1321. lpPorts - Buffer to receive the port information
  1322. pdwcbPorts - address of the buffer to receive the
  1323. count of bytes required to get the
  1324. information
  1325. pdwcPorts - address of the buffer to receive the
  1326. count of ports/size of buffer passed
  1327. in
  1328. Return Value:
  1329. Rpc api errors
  1330. --*/
  1331. DWORD APIENTRY
  1332. RemoteRasPortEnum(
  1333. HANDLE hConnection,
  1334. PBYTE lpPorts,
  1335. PDWORD pdwcbPorts,
  1336. PDWORD pdwcPorts
  1337. )
  1338. {
  1339. DWORD dwStatus;
  1340. WORD wcbPorts;
  1341. WORD wcPorts;
  1342. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1343. #if DBG
  1344. ASSERT(NULL != pRasRpcConnection);
  1345. ASSERT(NULL != pRasRpcConnection->hRpcBinding);
  1346. ASSERT(VERSION_40 == pRasRpcConnection->dwVersion);
  1347. #endif
  1348. RpcTryExcept
  1349. {
  1350. wcbPorts = (WORD) *pdwcbPorts;
  1351. wcPorts = (WORD) *pdwcPorts;
  1352. dwStatus = RasRpcPortEnum(
  1353. pRasRpcConnection->hRpcBinding,
  1354. lpPorts,
  1355. &wcbPorts,
  1356. &wcPorts);
  1357. *pdwcbPorts = (DWORD) wcbPorts;
  1358. *pdwcPorts = (DWORD) wcPorts;
  1359. }
  1360. RasRpcCatchException(&dwStatus)
  1361. {
  1362. dwStatus = RpcExceptionCode();
  1363. }
  1364. RpcEndExcept
  1365. return dwStatus;
  1366. }
  1367. /*++
  1368. Routine Description:
  1369. This api enumerates the devices on the remote
  1370. computer. This api should not be called if the
  1371. server is local or if the version of the remote
  1372. server is VERSION_501.
  1373. Arguments:
  1374. hConnection - Handle which was obtained with the
  1375. RasServerConnect api. This cannot
  1376. be NULL.
  1377. pszDeviceType - string indicating the device type
  1378. lpDevices - Buffer to receive the device information
  1379. pdwcbDevices - address of the buffer to receive the
  1380. count of bytes required to get the
  1381. information
  1382. pdwcDevices - address of the buffer to receive the
  1383. count of devices/size of buffer passed
  1384. in
  1385. Return Value:
  1386. Rpc api errors
  1387. --*/
  1388. DWORD APIENTRY
  1389. RemoteRasDeviceEnum(
  1390. HANDLE hConnection,
  1391. PCHAR pszDeviceType,
  1392. PBYTE lpDevices,
  1393. PDWORD pdwcbDevices,
  1394. PDWORD pdwcDevices
  1395. )
  1396. {
  1397. DWORD dwStatus;
  1398. WORD wcbDevices;
  1399. WORD wcDevices;
  1400. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1401. #if DBG
  1402. ASSERT(NULL != pRasRpcConnection);
  1403. ASSERT(NULL != pRasRpcConnection->hRpcBinding);
  1404. ASSERT(VERSION_40 == pRasRpcConnection->dwVersion);
  1405. #endif
  1406. RpcTryExcept
  1407. {
  1408. wcbDevices = (WORD) *pdwcbDevices;
  1409. wcDevices = (WORD) *pdwcDevices;
  1410. dwStatus = RasRpcDeviceEnum(
  1411. pRasRpcConnection->hRpcBinding,
  1412. pszDeviceType,
  1413. lpDevices,
  1414. &wcbDevices,
  1415. &wcDevices);
  1416. *pdwcbDevices = (DWORD) wcbDevices;
  1417. *pdwcDevices = (DWORD) wcDevices;
  1418. }
  1419. RasRpcCatchException(&dwStatus)
  1420. {
  1421. dwStatus = RpcExceptionCode();
  1422. }
  1423. RpcEndExcept
  1424. return dwStatus;
  1425. }
  1426. /*++
  1427. Routine Description:
  1428. This api gets the device configuration information.
  1429. This api should not be called if the server is local
  1430. or if the version of the remote server is VERSION_501.
  1431. Arguments:
  1432. hConnection - Handle which was obtained with the
  1433. RasServerConnect api. This cannot
  1434. be NULL.
  1435. hPort - HPORT
  1436. pszDeviceType - string indicating Device type
  1437. lpConfig - buffer to receive the Config info
  1438. lpcbConfig - buffer to receive the count of bytes
  1439. required for the information/size of
  1440. buffer passed in
  1441. Return Value:
  1442. Rpc api errors
  1443. --*/
  1444. DWORD APIENTRY
  1445. RemoteRasGetDevConfig(
  1446. HANDLE hConnection,
  1447. HPORT hport,
  1448. PCHAR pszDeviceType,
  1449. PBYTE lpConfig,
  1450. LPDWORD lpcbConfig
  1451. )
  1452. {
  1453. DWORD dwStatus;
  1454. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1455. #if DBG
  1456. ASSERT(NULL != pRasRpcConnection);
  1457. ASSERT(NULL != pRasRpcConnection->hRpcBinding);
  1458. ASSERT(VERSION_40 == pRasRpcConnection->dwVersion);
  1459. #endif
  1460. RpcTryExcept
  1461. {
  1462. dwStatus = RasRpcGetDevConfig(
  1463. pRasRpcConnection->hRpcBinding,
  1464. HandleToUlong(hport),
  1465. pszDeviceType,
  1466. lpConfig,
  1467. lpcbConfig);
  1468. }
  1469. RasRpcCatchException(&dwStatus)
  1470. {
  1471. dwStatus = RpcExceptionCode();
  1472. }
  1473. RpcEndExcept
  1474. return dwStatus;
  1475. }
  1476. /*++
  1477. Routine Description:
  1478. This api gets the port information of the port
  1479. indicated by hport passed in for the remote
  1480. computer. This api should not be called if the
  1481. server is local or if the version of the remote
  1482. server is VERSION_501.
  1483. Arguments:
  1484. hConnection - Handle which was obtained with the
  1485. RasServerConnect api. This cannot
  1486. be NULL.
  1487. porthandle - HPORT
  1488. buffer - buffer to receive the Port information
  1489. pSize - buffer to receive the count of bytes
  1490. required for the information/size of buffer
  1491. Return Value:
  1492. Rpc api errors
  1493. --*/
  1494. DWORD
  1495. RemoteRasPortGetInfo(
  1496. HANDLE hConnection,
  1497. HPORT porthandle,
  1498. PBYTE buffer,
  1499. PDWORD pSize)
  1500. {
  1501. DWORD dwStatus;
  1502. WORD wSize;
  1503. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1504. #if DBG
  1505. ASSERT(NULL != pRasRpcConnection);
  1506. ASSERT(NULL != pRasRpcConnection->hRpcBinding);
  1507. ASSERT(VERSION_40 == pRasRpcConnection->dwVersion);
  1508. #endif
  1509. RpcTryExcept
  1510. {
  1511. wSize = (WORD) *pSize;
  1512. dwStatus = RasRpcPortGetInfo(
  1513. pRasRpcConnection->hRpcBinding,
  1514. HandleToUlong(porthandle),
  1515. buffer,
  1516. &wSize);
  1517. *pSize = (DWORD) wSize;
  1518. }
  1519. RasRpcCatchException(&dwStatus)
  1520. {
  1521. dwStatus = RpcExceptionCode();
  1522. }
  1523. RpcEndExcept
  1524. return dwStatus;
  1525. }
  1526. //
  1527. // End of remoted versions of Rasman Dll apis
  1528. //----------------------------------------------------
  1529. /*++
  1530. Routine Description:
  1531. This api gets the Installed protocols in the remote
  1532. server. This api should not be called if the server
  1533. is local.
  1534. Arguments:
  1535. hConnection - Handle which was obtained with the
  1536. RasServerConnect api. This cannot
  1537. be NULL.
  1538. Return Value:
  1539. Rpc api errors
  1540. --*/
  1541. DWORD
  1542. RemoteGetInstalledProtocols(
  1543. HANDLE hConnection
  1544. )
  1545. {
  1546. DWORD dwStatus;
  1547. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1548. #if DBG
  1549. ASSERT(NULL != pRasRpcConnection);
  1550. ASSERT(NULL != pRasRpcConnection->hRpcBinding);
  1551. #endif
  1552. RpcTryExcept
  1553. {
  1554. dwStatus = RasRpcGetInstalledProtocols(
  1555. pRasRpcConnection->hRpcBinding
  1556. );
  1557. }
  1558. RasRpcCatchException(&dwStatus)
  1559. {
  1560. dwStatus = RpcExceptionCode();
  1561. }
  1562. RpcEndExcept
  1563. return dwStatus;
  1564. }
  1565. /*++
  1566. Routine Description:
  1567. This api gets the Installed protocols in the remote
  1568. server. This api should not be called if the server
  1569. is local.
  1570. Arguments:
  1571. hConnection - Handle which was obtained with the
  1572. RasServerConnect api. This cannot
  1573. be NULL.
  1574. fRouter - indicates return protocols installed over
  1575. which routing is allowed
  1576. fRasCli - indicates return protocols installed over
  1577. which DialOut is allowed
  1578. fRasSrv - indicates return protocols installed over
  1579. which DialIn is allowed
  1580. Return Value:
  1581. Rpc api errors
  1582. --*/
  1583. DWORD
  1584. RemoteGetInstalledProtocolsEx(
  1585. HANDLE hConnection,
  1586. BOOL fRouter,
  1587. BOOL fRasCli,
  1588. BOOL fRasSrv
  1589. )
  1590. {
  1591. DWORD dwStatus;
  1592. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1593. #if DBG
  1594. ASSERT(NULL != pRasRpcConnection);
  1595. ASSERT(NULL != pRasRpcConnection->hRpcBinding);
  1596. #endif
  1597. if ( VERSION_40 == pRasRpcConnection->dwVersion )
  1598. {
  1599. //
  1600. // If the server we are talking to is a
  1601. // 4.0 server call the old api and bail.
  1602. //
  1603. dwStatus = RemoteGetInstalledProtocols(hConnection);
  1604. goto done;
  1605. }
  1606. RpcTryExcept
  1607. {
  1608. dwStatus = RasRpcGetInstalledProtocolsEx(
  1609. pRasRpcConnection->hRpcBinding,
  1610. fRouter,
  1611. fRasCli,
  1612. fRasSrv);
  1613. }
  1614. RasRpcCatchException(&dwStatus)
  1615. {
  1616. dwStatus = RpcExceptionCode();
  1617. }
  1618. RpcEndExcept
  1619. done:
  1620. return dwStatus;
  1621. }
  1622. /*++
  1623. Routine Description:
  1624. This api gets the System Directory of the remote
  1625. server. This api should not be called if the server
  1626. is local.
  1627. Arguments:
  1628. hConnection - Handle which was obtained with the
  1629. RasServerConnect api. This cannot
  1630. be NULL.
  1631. lpBuffer - same as the first parameter of the
  1632. GetSystemDirectory api
  1633. uSize - same as the second paramter of the
  1634. GetSystemDirectory api
  1635. Return Value:
  1636. Rpc api errors
  1637. --*/
  1638. UINT WINAPI
  1639. RemoteGetSystemDirectory(
  1640. HANDLE hConnection,
  1641. LPTSTR lpBuffer,
  1642. UINT uSize
  1643. )
  1644. {
  1645. DWORD dwStatus;
  1646. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1647. #if DBG
  1648. ASSERT(NULL != pRasRpcConnection);
  1649. ASSERT(NULL != pRasRpcConnection->hRpcBinding);
  1650. #endif
  1651. RpcTryExcept
  1652. {
  1653. dwStatus = RasRpcGetSystemDirectory(
  1654. pRasRpcConnection->hRpcBinding,
  1655. lpBuffer,
  1656. uSize);
  1657. }
  1658. RasRpcCatchException(&dwStatus)
  1659. {
  1660. dwStatus = RpcExceptionCode();
  1661. }
  1662. RpcEndExcept
  1663. return dwStatus;
  1664. }
  1665. /*++
  1666. Routine Description:
  1667. This api gets the System directory of the remote
  1668. server.
  1669. Arguments:
  1670. hConnection - Handle which was obtained with the
  1671. RasServerConnect api.
  1672. lpBuffer - same as the first parameter of the
  1673. GetSystemDirectory api
  1674. uSize - same as the second paramter of the
  1675. GetSystemDirectory api
  1676. Return Value:
  1677. Rpc api errors
  1678. --*/
  1679. UINT WINAPI
  1680. RasGetSystemDirectory(
  1681. HANDLE hConnection,
  1682. LPTSTR lpBuffer,
  1683. UINT uSize
  1684. )
  1685. {
  1686. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1687. if( NULL == pRasRpcConnection
  1688. || pRasRpcConnection->fLocal)
  1689. {
  1690. //
  1691. // Local Server
  1692. //
  1693. return GetSystemDirectory(lpBuffer,
  1694. uSize);
  1695. }
  1696. else
  1697. {
  1698. return RemoteGetSystemDirectory(
  1699. pRasRpcConnection,
  1700. lpBuffer,
  1701. uSize);
  1702. }
  1703. }
  1704. /*++
  1705. Routine Description:
  1706. This api gets the User Preferences set on the remote
  1707. server. This routine should not be called if for a
  1708. local server.
  1709. Arguments:
  1710. hConnection - Handle which was obtained with the
  1711. RasServerConnect api.
  1712. lpBuffer - same as the first parameter of the
  1713. GetSystemDirectory api
  1714. uSize - same as the second paramter of the
  1715. GetSystemDirectory api
  1716. Return Value:
  1717. Rpc api errors
  1718. --*/
  1719. DWORD
  1720. RemoteGetUserPreferences(
  1721. HANDLE hConnection,
  1722. OUT PBUSER* pPbuser,
  1723. IN DWORD dwMode
  1724. )
  1725. {
  1726. DWORD dwStatus;
  1727. RASRPC_PBUSER pbuser;
  1728. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1729. #if DBG
  1730. ASSERT(NULL != pRasRpcConnection);
  1731. ASSERT(NULL != pRasRpcConnection->hRpcBinding);
  1732. #endif
  1733. RtlZeroMemory(&pbuser, sizeof (RASRPC_PBUSER));
  1734. RpcTryExcept
  1735. {
  1736. dwStatus = RasRpcGetUserPreferences(
  1737. pRasRpcConnection->hRpcBinding,
  1738. &pbuser,
  1739. dwMode);
  1740. }
  1741. RasRpcCatchException(&dwStatus)
  1742. {
  1743. dwStatus = RpcExceptionCode();
  1744. }
  1745. RpcEndExcept
  1746. if (dwStatus)
  1747. {
  1748. return dwStatus;
  1749. }
  1750. //
  1751. // Convert RPC format to RAS format.
  1752. //
  1753. return RpcToRasPbuser(pPbuser, &pbuser);
  1754. }
  1755. //---------------------------------------------------
  1756. // The following are remoted version of apis exported
  1757. // from rasapi32.dll.
  1758. //
  1759. /*++
  1760. Routine Description:
  1761. This api is a remoted version of the RasDeleteEntry
  1762. win32 api.
  1763. Arguments:
  1764. hConnection - Handle which was obtained with the
  1765. RasServerConnect api.
  1766. lpszPhonebook - Same as the first argument of the
  1767. RasDeleteEntry win32 api
  1768. lpszEntry - same as the second argument of the
  1769. RasDeleteEntry win32 api.
  1770. Return Value:
  1771. Rpc api errors
  1772. --*/
  1773. DWORD APIENTRY
  1774. RemoteRasDeleteEntry(
  1775. HANDLE hConnection,
  1776. LPTSTR lpszPhonebook,
  1777. LPTSTR lpszEntry
  1778. )
  1779. {
  1780. DWORD dwStatus;
  1781. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1782. #if DBG
  1783. ASSERT(NULL != pRasRpcConnection);
  1784. ASSERT(NULL != pRasRpcConnection->hRpcBinding);
  1785. #endif
  1786. RpcTryExcept
  1787. {
  1788. dwStatus = RasRpcDeleteEntry(
  1789. pRasRpcConnection->hRpcBinding,
  1790. lpszPhonebook,
  1791. lpszEntry);
  1792. }
  1793. RasRpcCatchException(&dwStatus)
  1794. {
  1795. dwStatus = RpcExceptionCode();
  1796. }
  1797. RpcEndExcept
  1798. return dwStatus;
  1799. }
  1800. /*++
  1801. Routine Description:
  1802. This api is a remoted version of the RasEnumConnections
  1803. win32 api.
  1804. Arguments:
  1805. hConnection - Handle which was obtained with the
  1806. RasServerConnect api.
  1807. lpRasConn - Same as the first argument of the
  1808. RasEnumConnections win32 api
  1809. lpdwcbRasConn - same as the second argument of the
  1810. RasEnumConnections win32 api.
  1811. lpdwcRasConn - same as the third arguments of the
  1812. RasEnumConnections win32 api.
  1813. Return Value:
  1814. Rpc api errors
  1815. --*/
  1816. DWORD APIENTRY
  1817. RemoteRasEnumConnections(
  1818. HANDLE hConnection,
  1819. LPRASCONN lpRasConn,
  1820. LPDWORD lpdwcbRasConn,
  1821. LPDWORD lpdwcRasConn
  1822. )
  1823. {
  1824. DWORD dwStatus;
  1825. DWORD dwcbBufSize = *lpdwcbRasConn;
  1826. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1827. #if DBG
  1828. ASSERT(NULL != pRasRpcConnection);
  1829. ASSERT(NULL != pRasRpcConnection->hRpcBinding);
  1830. #endif
  1831. RpcTryExcept
  1832. {
  1833. dwStatus = RasRpcEnumConnections(
  1834. pRasRpcConnection->hRpcBinding,
  1835. (LPBYTE)lpRasConn,
  1836. lpdwcbRasConn,
  1837. lpdwcRasConn,
  1838. dwcbBufSize);
  1839. }
  1840. RasRpcCatchException(&dwStatus)
  1841. {
  1842. dwStatus = RpcExceptionCode();
  1843. }
  1844. RpcEndExcept
  1845. return dwStatus;
  1846. }
  1847. /*++
  1848. Routine Description:
  1849. This api is a remoted version of the RasGetCountryInfo
  1850. win32 api.
  1851. Arguments:
  1852. hConnection - Handle which was obtained with the
  1853. RasServerConnect api.
  1854. lpRasCountryInfo - Same as the first argument of the
  1855. RasGetCountryInfo win32 api
  1856. lpdwcbRasCountryInfo - same as the second argument of the
  1857. RasGetCountryInfo win32 api.
  1858. Return Value:
  1859. Rpc api errors
  1860. --*/
  1861. DWORD APIENTRY
  1862. RemoteRasGetCountryInfo(
  1863. HANDLE hConnection,
  1864. LPRASCTRYINFO lpRasCountryInfo,
  1865. LPDWORD lpdwcbRasCountryInfo
  1866. )
  1867. {
  1868. DWORD dwStatus;
  1869. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1870. #if DBG
  1871. ASSERT(NULL != pRasRpcConnection);
  1872. ASSERT(NULL != pRasRpcConnection->hRpcBinding);
  1873. #endif
  1874. RpcTryExcept
  1875. {
  1876. dwStatus = RasRpcGetCountryInfo(
  1877. pRasRpcConnection->hRpcBinding,
  1878. (LPBYTE)lpRasCountryInfo,
  1879. lpdwcbRasCountryInfo);
  1880. }
  1881. RasRpcCatchException(&dwStatus)
  1882. {
  1883. dwStatus = RpcExceptionCode();
  1884. }
  1885. RpcEndExcept
  1886. return dwStatus;
  1887. }
  1888. /*++
  1889. Routine Description:
  1890. This api is a remoted version of the RasGetErrorString
  1891. win32 api.
  1892. Arguments:
  1893. hConnection - Handle which was obtained with the
  1894. RasServerConnect api.
  1895. uErrorValue - Same as the first argument of the
  1896. RasGetErrorString win32 api
  1897. lpszBuf - same as the second argument of the
  1898. RasGetErrorString win32 api.
  1899. cbBuf - same as the third argument of the
  1900. RasGetErrorString win32 api
  1901. Return Value:
  1902. Rpc api errors
  1903. --*/
  1904. DWORD APIENTRY
  1905. RemoteRasGetErrorString(
  1906. HANDLE hConnection,
  1907. UINT uErrorValue,
  1908. LPTSTR lpszBuf,
  1909. DWORD cbBuf
  1910. )
  1911. {
  1912. DWORD dwStatus;
  1913. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1914. #if DBG
  1915. ASSERT(NULL != pRasRpcConnection);
  1916. ASSERT(NULL != pRasRpcConnection->hRpcBinding);
  1917. #endif
  1918. RpcTryExcept
  1919. {
  1920. dwStatus = RasRpcGetErrorString(
  1921. pRasRpcConnection->hRpcBinding,
  1922. uErrorValue,
  1923. lpszBuf,
  1924. cbBuf);
  1925. }
  1926. RasRpcCatchException(&dwStatus)
  1927. {
  1928. dwStatus = RpcExceptionCode();
  1929. }
  1930. RpcEndExcept
  1931. return dwStatus;
  1932. }
  1933. //
  1934. // End of remoted apis corresponding to apis in rasapi32.dll
  1935. //----------------------------------------------------------
  1936. /*++
  1937. Routine Description:
  1938. This api is a remoted version of the RasGetErrorString
  1939. win32 api.
  1940. Arguments:
  1941. hConnection - Handle which was obtained with the
  1942. RasServerConnect api.
  1943. pPbuser - PBUSER *
  1944. dwMode
  1945. Return Value:
  1946. Rpc api errors
  1947. --*/
  1948. DWORD
  1949. RemoteSetUserPreferences(
  1950. HANDLE hConnection,
  1951. OUT PBUSER* pPbuser,
  1952. IN DWORD dwMode
  1953. )
  1954. {
  1955. DWORD dwStatus;
  1956. RASRPC_PBUSER pbuser;
  1957. RAS_RPC *pRasRpcConnection = (RAS_RPC *) hConnection;
  1958. #if DBG
  1959. ASSERT(NULL != pRasRpcConnection);
  1960. ASSERT(NULL != pRasRpcConnection->hRpcBinding);
  1961. #endif
  1962. //
  1963. // Convert the RAS format to RPC format.
  1964. //
  1965. dwStatus = RasToRpcPbuser(&pbuser, pPbuser);
  1966. if (dwStatus)
  1967. {
  1968. return dwStatus;
  1969. }
  1970. RpcTryExcept
  1971. {
  1972. dwStatus = RasRpcSetUserPreferences(
  1973. pRasRpcConnection->hRpcBinding,
  1974. &pbuser,
  1975. dwMode);
  1976. }
  1977. RasRpcCatchException(&dwStatus)
  1978. {
  1979. dwStatus = RpcExceptionCode();
  1980. }
  1981. RpcEndExcept
  1982. return dwStatus;
  1983. }
  1984. VOID
  1985. UnloadMpradminDll(
  1986. void )
  1987. /*++
  1988. Routine Description
  1989. Unload the MPRAPI.DLL library and its entrypoints
  1990. Arguments
  1991. Return Value
  1992. --*/
  1993. {
  1994. if (g_hMpradminDll)
  1995. {
  1996. HINSTANCE h;
  1997. g_pMprAdminInterfaceCreate = NULL;
  1998. g_pMprAdminInterfaceDelete = NULL;
  1999. g_pMprAdminInterfaceGetCredentials = NULL;
  2000. g_pMprAdminInterfaceGetCredentialsEx = NULL;
  2001. g_pMprAdminInterfaceSetCredentials = NULL;
  2002. g_pMprAdminInterfaceSetCredentialsEx = NULL;
  2003. g_pMprAdminBufferFree = NULL;
  2004. g_pMprAdminInterfaceTransportSetInfo = NULL;
  2005. g_pMprAdminServerConnect = NULL;
  2006. g_pMprAdminServerDisconnect = NULL;
  2007. g_pRasAdminServerConnect = NULL;
  2008. g_pRasAdminServerDisconnect = NULL;
  2009. g_pRasAdminBufferFree = NULL;
  2010. g_pRasAdminConnectionEnum = NULL;
  2011. g_pRasAdminConnectionGetInfo = NULL;
  2012. g_pRasAdminPortEnum = NULL;
  2013. g_pRasAdminPortGetInfo = NULL;
  2014. g_pRasAdminPortDisconnect = NULL;
  2015. g_pRasAdminUserSetInfo = NULL;
  2016. g_pMprConfigBufferFree = NULL;
  2017. g_pMprConfigServerConnect = NULL;
  2018. g_pMprConfigServerDisconnect = NULL;
  2019. g_pMprConfigTransportGetInfo = NULL;
  2020. g_pMprConfigTransportSetInfo = NULL;
  2021. g_pMprConfigTransportGetHandle = NULL;
  2022. g_pMprConfigInterfaceCreate = NULL;
  2023. g_pMprConfigInterfaceDelete = NULL;
  2024. g_pMprConfigInterfaceGetHandle = NULL;
  2025. g_pMprConfigInterfaceEnum = NULL;
  2026. g_pMprConfigInterfaceTransportAdd = NULL;
  2027. g_pMprConfigInterfaceTransportGetInfo = NULL;
  2028. g_pMprConfigInterfaceTransportSetInfo = NULL;
  2029. g_pMprConfigInterfaceTransportGetHandle = NULL;
  2030. g_pMprInfoCreate = NULL;
  2031. g_pMprInfoDelete = NULL;
  2032. g_pMprInfoDuplicate = NULL;
  2033. g_pMprInfoBlockAdd = NULL;
  2034. g_pMprInfoBlockRemove = NULL;
  2035. g_pMprInfoBlockSet = NULL;
  2036. g_pMprInfoBlockFind = NULL;
  2037. h = g_hMpradminDll;
  2038. g_hMpradminDll = NULL;
  2039. FreeLibrary(h);
  2040. }
  2041. }
  2042. VOID
  2043. UnloadRasapi32Dll(
  2044. void )
  2045. /*++
  2046. Routine Description
  2047. Unload the RASAPI32.DLL library and it's entrypoints.
  2048. Arguments
  2049. Return Value
  2050. --*/
  2051. {
  2052. if (g_hRasapi32Dll)
  2053. {
  2054. HINSTANCE h;
  2055. g_pRasConnectionNotification = NULL;
  2056. g_pRasDeleteEntry = NULL;
  2057. g_pRasDial = NULL;
  2058. g_pRasEnumEntries = NULL;
  2059. g_pRasEnumConnections = NULL;
  2060. g_pRasGetConnectStatus = NULL;
  2061. g_pRasGetConnectResponse = NULL;
  2062. g_pRasGetCredentials = NULL;
  2063. g_pRasGetErrorString = NULL;
  2064. g_pRasHangUp = NULL;
  2065. g_pRasGetAutodialEnable = NULL;
  2066. g_pRasGetAutodialParam = NULL;
  2067. g_pRasGetProjectionInfo = NULL;
  2068. g_pRasSetAutodialEnable = NULL;
  2069. g_pRasSetAutodialParam = NULL;
  2070. g_pRasGetSubEntryHandle = NULL;
  2071. g_pRasGetHport = NULL;
  2072. g_pRasSetCredentials = NULL;
  2073. g_pRasSetOldPassword = NULL;
  2074. g_pRasGetCountryInfo = NULL;
  2075. g_pRasValidateEntryName = NULL;
  2076. h = g_hRasapi32Dll;
  2077. g_hRasapi32Dll = NULL;
  2078. FreeLibrary( h );
  2079. }
  2080. }
  2081. VOID
  2082. UnloadRasdlgDll(
  2083. void )
  2084. /*++
  2085. Routine Description
  2086. Unload the RASDLG.DLL library and it's entrypoints.
  2087. Arguments
  2088. Return Value
  2089. --*/
  2090. {
  2091. if (g_hRasdlgDll)
  2092. {
  2093. HINSTANCE h;
  2094. g_pRasPhonebookDlg = NULL;
  2095. g_pRasEntryDlg = NULL;
  2096. g_pRouterEntryDlg = NULL;
  2097. g_pRasDialDlg = NULL;
  2098. h = g_hRasdlgDll;
  2099. g_hRasdlgDll = NULL;
  2100. FreeLibrary( h );
  2101. }
  2102. }
  2103. VOID
  2104. UnloadRasmanDll(
  2105. void )
  2106. /*++
  2107. Routine Description
  2108. Unload the RASMAN.DLL library and it's entrypoints.
  2109. Arguments
  2110. Return Value
  2111. --*/
  2112. {
  2113. if (g_hRasmanDll)
  2114. {
  2115. HINSTANCE h;
  2116. if ( g_hBinding )
  2117. {
  2118. g_pRasRpcDisconnect( &g_hBinding );
  2119. g_hBinding = NULL;
  2120. }
  2121. g_pRasPortClearStatistics = NULL;
  2122. g_pRasDeviceEnum = NULL;
  2123. g_pRasDeviceGetInfo = NULL;
  2124. g_pRasFreeBuffer = NULL;
  2125. g_pRasGetBuffer = NULL;
  2126. g_pRasPortGetFramingEx = NULL;
  2127. g_pRasGetInfo = NULL;
  2128. g_pRasGetNdiswanDriverCaps = NULL;
  2129. g_pRasInitialize = NULL;
  2130. g_pRasPortCancelReceive = NULL;
  2131. g_pRasPortEnum = NULL;
  2132. g_pRasPortGetInfo = NULL;
  2133. g_pRasPortGetStatistics = NULL;
  2134. g_pRasPortReceive = NULL;
  2135. g_pRasPortReceiveEx = NULL;
  2136. g_pRasPortSend = NULL;
  2137. g_pRasPortGetBundle = NULL;
  2138. g_pRasGetDevConfig = NULL;
  2139. g_pRasGetDevConfigEx = NULL;
  2140. g_pRasSetDevConfig = NULL;
  2141. g_pRasPortOpen = NULL;
  2142. g_pRasPortRegisterSlip = NULL;
  2143. g_pRasAllocateRoute = NULL;
  2144. g_pRasActivateRoute = NULL;
  2145. g_pRasActivateRouteEx = NULL;
  2146. g_pRasDeviceSetInfo = NULL;
  2147. g_pRasDeviceConnect = NULL;
  2148. g_pRasPortSetInfo = NULL;
  2149. g_pRasPortClose = NULL;
  2150. g_pRasPortListen = NULL;
  2151. g_pRasPortConnectComplete = NULL;
  2152. g_pRasPortDisconnect = NULL;
  2153. g_pRasRequestNotification = NULL;
  2154. g_pRasPortEnumProtocols = NULL;
  2155. g_pRasPortSetFraming = NULL;
  2156. g_pRasPortSetFramingEx = NULL;
  2157. g_pRasSetCachedCredentials = NULL;
  2158. g_pRasGetDialParams = NULL;
  2159. g_pRasSetDialParams = NULL;
  2160. g_pRasCreateConnection = NULL;
  2161. g_pRasDestroyConnection = NULL;
  2162. g_pRasConnectionEnum = NULL;
  2163. g_pRasAddConnectionPort = NULL;
  2164. g_pRasEnumConnectionPorts = NULL;
  2165. g_pRasGetConnectionParams = NULL;
  2166. g_pRasSetConnectionParams = NULL;
  2167. g_pRasGetConnectionUserData = NULL;
  2168. g_pRasSetConnectionUserData = NULL;
  2169. g_pRasGetPortUserData = NULL;
  2170. g_pRasSetPortUserData = NULL;
  2171. g_pRasAddNotification = NULL;
  2172. g_pRasSignalNewConnection = NULL;
  2173. g_pRasPppStop = NULL;
  2174. g_pRasPppCallback = NULL;
  2175. g_pRasPppChangePassword = NULL;
  2176. g_pRasPppGetInfo = NULL;
  2177. g_pRasPppRetry = NULL;
  2178. g_pRasPppStart = NULL;
  2179. g_pRasSetIoCompletionPort = NULL;
  2180. g_pRasSetRasdialInfo = NULL;
  2181. g_pRasRpcConnect = NULL;
  2182. g_pRasRpcDisconnect = NULL;
  2183. g_pRasNumPortOpen = NULL;
  2184. h = g_hRasmanDll;
  2185. g_hRasmanDll = NULL;
  2186. FreeLibrary( h );
  2187. }
  2188. }
  2189. DWORD
  2190. UnloadRasRpcDll(
  2191. void
  2192. )
  2193. {
  2194. DWORD dwErr = 0;
  2195. if ( g_hRasapi32Dll == NULL )
  2196. {
  2197. g_pRasEnumConnections = NULL;
  2198. g_pRasDeleteEntry = NULL;
  2199. g_pRasGetErrorString = NULL;
  2200. g_pRasGetCountryInfo = NULL;
  2201. }
  2202. g_pGetInstalledProtocols = GetInstalledProtocolsEx;
  2203. g_pGetUserPreferences = GetUserPreferences;
  2204. g_pSetUserPreferences = SetUserPreferences;
  2205. g_pGetSystemDirectory = RasGetSystemDirectory;
  2206. if ( VERSION_40 == g_Version )
  2207. {
  2208. if ( g_hRasmanDll == NULL )
  2209. {
  2210. dwErr = E_FAIL;
  2211. goto done;
  2212. }
  2213. //
  2214. // rasman dll should always be loaded
  2215. //
  2216. g_pRasPortEnum = (PRASPORTENUM) GetProcAddress(
  2217. g_hRasmanDll,
  2218. "RasPortEnum"
  2219. );
  2220. g_pRasDeviceEnum = (PRASDEVICEENUM) GetProcAddress(
  2221. g_hRasmanDll,
  2222. "RasDeviceEnum"
  2223. );
  2224. g_pRasGetDevConfig = (PRASGETDEVCONFIG) GetProcAddress(
  2225. g_hRasmanDll,
  2226. "RasGetDevConfig"
  2227. );
  2228. g_pRasPortGetInfo = (PRASPORTGETINFO) GetProcAddress(
  2229. g_hRasmanDll,
  2230. "RasPortGetInfo"
  2231. );
  2232. }
  2233. g_Version = VERSION_501;
  2234. //
  2235. // Release the binding resources.
  2236. //
  2237. g_pRasRpcDisconnect ( &g_hBinding );
  2238. g_hBinding = NULL;
  2239. if ( g_fRasapi32PreviouslyLoaded )
  2240. {
  2241. dwErr = LoadRasapi32Dll();
  2242. goto done;
  2243. }
  2244. if ( g_fRasmanPreviouslyLoaded )
  2245. {
  2246. //
  2247. // restore connection to local server
  2248. //
  2249. if ( g_pRasRpcConnect )
  2250. {
  2251. dwErr = g_pRasRpcConnect ( NULL, g_hBinding );
  2252. goto done;
  2253. }
  2254. }
  2255. done:
  2256. return dwErr;
  2257. }