2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 API
4 * FILE: dll/win32/ws2_32_new/src/rasdial.c
5 * PURPOSE: RAS Auto-Dial Support
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
9 /* INCLUDES ******************************************************************/
16 /* DATA **********************************************************************/
19 (WSAAPI
*PWS_ATTEMPT_AUTODIAL_ADDR
)(
20 IN CONST SOCKADDR FAR
*Name
,
25 (WSAAPI
*PWS_ATTEMPT_AUTODIAL_NAME
)(IN CONST LPWSAQUERYSETW lpqsRestrictions
);
28 (WSAAPI
*PWS_NOTE_SUCCESSFUL_HOSTENT_LOOKUP
)(
29 IN CONST CHAR FAR
*Name
,
30 IN CONST ULONG Address
33 BOOLEAN WsRasInitialized
;
34 HINSTANCE WsRasDllHandle
;
35 CRITICAL_SECTION WsRasHelperLock
;
36 PWS_ATTEMPT_AUTODIAL_ADDR lpfnWSAttemptAutodialAddr
;
37 PWS_ATTEMPT_AUTODIAL_NAME lpfnWSAttemptAutodialName
;
38 PWS_NOTE_SUCCESSFUL_HOSTENT_LOOKUP lpfnWSNoteSuccessfulHostentLookup
;
40 #define WsRasLock() EnterCriticalSection(&WsRasHelperLock);
41 #define WsRasUnlock() LeaveCriticalSection(&WsRasHelperLock);
43 /* FUNCTIONS *****************************************************************/
47 WsRasInitializeAutodial(VOID
)
49 /* Initialize the autodial lock */
50 InitializeCriticalSection(&WsRasHelperLock
);
55 WsRasUninitializeAutodial(VOID
)
60 /* Free the library if it's loaded */
61 if (WsRasDllHandle
) FreeLibrary(WsRasDllHandle
);
62 WsRasDllHandle
= NULL
;
64 /* Release and delete lock */
66 DeleteCriticalSection(&WsRasHelperLock
);
71 WsRasLoadHelperDll(VOID
)
73 CHAR HelperPath
[MAX_PATH
];
76 DWORD RegType
= REG_SZ
;
77 DWORD RegSize
= MAX_PATH
;
79 /* Acquire the lock */
82 /* Check if we were already initialiazed */
83 if (!WsRasInitialized
)
85 /* Open the registry root key */
86 WinsockKey
= WsOpenRegistryRoot();
89 /* Read the helper's location */
90 ErrorCode
= RegQueryValueEx(WinsockKey
,
96 RegCloseKey(WinsockKey
);
98 /* Make sure we read the path */
99 if (ErrorCode
== ERROR_SUCCESS
)
102 WsRasDllHandle
= LoadLibrary(HelperPath
);
106 /* Check if we weren't able to load it and load the default */
107 if (!WsRasDllHandle
) WsRasDllHandle
= LoadLibrary("rasadhlp.dll");
109 /* Check again if we loaded it */
112 /* Get function pointers */
113 lpfnWSAttemptAutodialAddr
=
114 (PVOID
)GetProcAddress(WsRasDllHandle
,
115 "WSAttemptAutodialAddr");
116 lpfnWSAttemptAutodialName
=
117 (PVOID
)GetProcAddress(WsRasDllHandle
,
118 "WSAttemptAutodialName");
119 lpfnWSNoteSuccessfulHostentLookup
=
120 (PVOID
)GetProcAddress(WsRasDllHandle
,
121 "WSNoteSuccessfulHostentLookup");
124 /* Mark us as loaded */
125 WsRasInitialized
= TRUE
;
132 return WsRasInitialized
;
137 WSAttemptAutodialAddr(IN CONST SOCKADDR FAR
*Name
,
140 /* Load the helper DLL and make sure it exports this routine */
141 if (!(WsRasLoadHelperDll()) || !(lpfnWSAttemptAutodialAddr
)) return FALSE
;
143 /* Call the function in the helper */
144 return lpfnWSAttemptAutodialAddr(Name
, NameLength
);
149 WSAttemptAutodialName(IN CONST LPWSAQUERYSETW lpqsRestrictions
)
151 /* Load the helper DLL and make sure it exports this routine */
152 if (!(WsRasLoadHelperDll()) || !(lpfnWSAttemptAutodialName
)) return FALSE
;
154 /* Call the function in the helper */
155 return lpfnWSAttemptAutodialName(lpqsRestrictions
);
160 WSNoteSuccessfulHostentLookup(IN CONST CHAR FAR
*Name
,
161 IN CONST ULONG Address
)
163 /* Load the helper DLL and make sure it exports this routine */
164 if (!(WsRasLoadHelperDll()) || !(lpfnWSNoteSuccessfulHostentLookup
)) return;
166 /* Call the function in the helper */
167 lpfnWSNoteSuccessfulHostentLookup(Name
, Address
);