ReactOS  0.4.13-dev-66-gc714b7f
rasdial.c
Go to the documentation of this file.
1 /*
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)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <ws2_32.h>
12 
13 #define NDEBUG
14 #include <debug.h>
15 
16 /* DATA **********************************************************************/
17 
18 typedef BOOL
21  IN INT NameLength
22 );
23 
24 typedef BOOL
26 
27 typedef VOID
29  IN CONST CHAR FAR *Name,
31 );
32 
39 
40 #define WsRasLock() EnterCriticalSection(&WsRasHelperLock)
41 #define WsRasUnlock() LeaveCriticalSection(&WsRasHelperLock)
42 
43 /* FUNCTIONS *****************************************************************/
44 
45 VOID
46 WSAAPI
48 {
49  /* Initialize the autodial lock */
51 }
52 
53 VOID
54 WSAAPI
56 {
57  /* Acquire lock */
58  WsRasLock();
59 
60  /* Free the library if it's loaded */
63 
64  /* Release and delete lock */
65  WsRasUnlock();
67 }
68 
69 INT
70 WSAAPI
72 {
73  CHAR HelperPath[MAX_PATH];
74  HKEY WinsockKey;
75  INT ErrorCode;
76  DWORD RegType = REG_SZ;
77  DWORD RegSize = MAX_PATH;
78 
79  /* Acquire the lock */
80  WsRasLock();
81 
82  /* Check if we were already initialized */
83  if (!WsRasInitialized)
84  {
85  /* Open the registry root key */
86  WinsockKey = WsOpenRegistryRoot();
87  if (WinsockKey)
88  {
89  /* Read the helper's location */
90  ErrorCode = RegQueryValueEx(WinsockKey,
91  "AutodialDLL",
92  0,
93  &RegType,
94  (LPBYTE)&HelperPath,
95  &RegSize);
96  RegCloseKey(WinsockKey);
97 
98  /* Make sure we read the path */
99  if (ErrorCode == ERROR_SUCCESS)
100  {
101  /* Now load it */
102  WsRasDllHandle = LoadLibrary(HelperPath);
103  }
104  }
105 
106  /* Check if we weren't able to load it and load the default */
107  if (!WsRasDllHandle) WsRasDllHandle = LoadLibrary("rasadhlp.dll");
108 
109  /* Check again if we loaded it */
110  if (WsRasDllHandle)
111  {
112  /* Get function pointers */
115  "WSAttemptAutodialAddr");
118  "WSAttemptAutodialName");
121  "WSNoteSuccessfulHostentLookup");
122  }
123 
124  /* Mark us as loaded */
126  }
127 
128  /* Release lock */
129  WsRasUnlock();
130 
131  /* Return status */
132  return WsRasInitialized;
133 }
134 
135 BOOL
136 WSAAPI
138  IN INT NameLength)
139 {
140  /* Load the helper DLL and make sure it exports this routine */
141  if (!(WsRasLoadHelperDll()) || !(lpfnWSAttemptAutodialAddr)) return FALSE;
142 
143  /* Call the function in the helper */
144  return lpfnWSAttemptAutodialAddr(Name, NameLength);
145 }
146 
147 BOOL
148 WSAAPI
150 {
151  /* Load the helper DLL and make sure it exports this routine */
152  if (!(WsRasLoadHelperDll()) || !(lpfnWSAttemptAutodialName)) return FALSE;
153 
154  /* Call the function in the helper */
155  return lpfnWSAttemptAutodialName(lpqsRestrictions);
156 }
157 
158 VOID
159 WSAAPI
162 {
163  /* Load the helper DLL and make sure it exports this routine */
165 
166  /* Call the function in the helper */
168 }
#define RegQueryValueEx
Definition: winreg.h:524
HKEY WSAAPI WsOpenRegistryRoot(VOID)
Definition: wsautil.c:17
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4418
#define WsRasLock()
Definition: rasdial.c:40
#define ERROR_SUCCESS
Definition: deptool.c:10
#define LoadLibrary
Definition: winbase.h:3676
VOID WSAAPI WsRasUninitializeAutodial(VOID)
Definition: rasdial.c:55
char CHAR
Definition: xmlstorage.h:175
BOOL WSAAPI WSAttemptAutodialName(IN CONST LPWSAQUERYSETW lpqsRestrictions)
Definition: rasdial.c:149
static LPWSAQUERYSETW
Definition: sock.c:91
VOID(WSAAPI * PWS_NOTE_SUCCESSFUL_HOSTENT_LOOKUP)(IN CONST CHAR FAR *Name, IN CONST ULONG Address)
Definition: rasdial.c:28
INT WSAAPI WsRasLoadHelperDll(VOID)
Definition: rasdial.c:71
#define BOOL
Definition: nt_native.h:43
int32_t INT
Definition: typedefs.h:56
PWS_ATTEMPT_AUTODIAL_NAME lpfnWSAttemptAutodialName
Definition: rasdial.c:37
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FAR
Definition: guiddef.h:36
struct NameRec_ * Name
Definition: cdprocs.h:464
unsigned char BOOLEAN
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:697
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
void * PVOID
Definition: retypes.h:9
#define FreeLibrary(x)
Definition: compat.h:405
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
CRITICAL_SECTION WsRasHelperLock
Definition: rasdial.c:35
#define MAX_PATH
Definition: compat.h:26
PWS_NOTE_SUCCESSFUL_HOSTENT_LOOKUP lpfnWSNoteSuccessfulHostentLookup
Definition: rasdial.c:38
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID WSAAPI WSNoteSuccessfulHostentLookup(IN CONST CHAR FAR *Name, IN CONST ULONG Address)
Definition: rasdial.c:160
BOOL(WSAAPI * PWS_ATTEMPT_AUTODIAL_ADDR)(IN CONST SOCKADDR FAR *Name, IN INT NameLength)
Definition: rasdial.c:19
#define VOID
Definition: acefi.h:82
BOOLEAN WsRasInitialized
Definition: rasdial.c:33
BOOL WSAAPI WSAttemptAutodialAddr(IN CONST SOCKADDR FAR *Name, IN INT NameLength)
Definition: rasdial.c:137
VOID WSAAPI WsRasInitializeAutodial(VOID)
Definition: rasdial.c:47
#define WSAAPI
Definition: winsock2.h:584
BOOL(WSAAPI * PWS_ATTEMPT_AUTODIAL_NAME)(IN CONST LPWSAQUERYSETW lpqsRestrictions)
Definition: rasdial.c:25
unsigned int ULONG
Definition: retypes.h:1
#define GetProcAddress(x, y)
Definition: compat.h:410
#define WsRasUnlock()
Definition: rasdial.c:41
PWS_ATTEMPT_AUTODIAL_ADDR lpfnWSAttemptAutodialAddr
Definition: rasdial.c:36
HINSTANCE WsRasDllHandle
Definition: rasdial.c:34
#define CONST
Definition: pedump.c:81
#define REG_SZ
Definition: layer.c:22