ReactOS 0.4.15-dev-7934-g1dc8d80
wsautil.c File Reference
#include <ws2_32.h>
Include dependency graph for wsautil.c:

Go to the source code of this file.

Functions

HKEY WSAAPI WsOpenRegistryRoot (VOID)
 
BOOL WSAAPI WsCheckCatalogState (IN HANDLE Event)
 
INT WSAAPI WsApiProlog (OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
 
INT WSAAPI WsSlowProlog (VOID)
 
INT WSAAPI WsSlowPrologTid (OUT LPWSATHREADID *ThreadId)
 
INT WSAAPI WsSetupCatalogProtection (IN HKEY CatalogKey, IN HANDLE CatalogEvent, OUT LPDWORD UniqueId)
 
INT WSAAPI MapUnicodeProtocolInfoToAnsi (IN LPWSAPROTOCOL_INFOW UnicodeInfo, OUT LPWSAPROTOCOL_INFOA AnsiInfo)
 
VOID WSAAPI WEP (VOID)
 

Function Documentation

◆ MapUnicodeProtocolInfoToAnsi()

INT WSAAPI MapUnicodeProtocolInfoToAnsi ( IN LPWSAPROTOCOL_INFOW  UnicodeInfo,
OUT LPWSAPROTOCOL_INFOA  AnsiInfo 
)

Definition at line 224 of file wsautil.c.

226{
228
229 /* Copy all the data that doesn't need converting */
230 RtlCopyMemory(AnsiInfo,
231 UnicodeInfo,
232 FIELD_OFFSET(WSAPROTOCOL_INFOA, szProtocol));
233
234 /* Now convert the protocol string */
236 0,
237 UnicodeInfo->szProtocol,
238 -1,
239 AnsiInfo->szProtocol,
240 sizeof(AnsiInfo->szProtocol),
241 NULL,
242 NULL);
243 if (!ReturnValue) return WSASYSCALLFAILURE;
244
245 /* Return success */
246 return ERROR_SUCCESS;
247}
UINT32 void void ** ReturnValue
Definition: acevents.h:216
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define WSASYSCALLFAILURE
Definition: winerror.h:1994

Referenced by getsockopt(), and WSADuplicateSocketA().

◆ WEP()

VOID WSAAPI WEP ( VOID  )

Definition at line 254 of file wsautil.c.

255{
256 return;
257}

◆ WsApiProlog()

INT WSAAPI WsApiProlog ( OUT PWSPROCESS Process,
OUT PWSTHREAD Thread 
)

Definition at line 91 of file wsautil.c.

93{
95
96 /* Try to get the current process */
97 if ((*Process = WsGetProcess()))
98 {
99 /* And the current thread */
101 }
102
103 /* Return init status */
104 return ErrorCode;
105}
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define WSANOTINITIALISED
Definition: winerror.h:1987
DWORD WSAAPI WsThreadGetCurrentThread(IN PWSPROCESS Process, IN PWSTHREAD *Thread)
Definition: dthread.c:279
FORCEINLINE PWSPROCESS WsGetProcess(VOID)
Definition: ws2_32p.h:885

Referenced by connect(), gethostbyaddr(), gethostbyname(), getprotobyname(), getprotobynumber(), getservbyname(), getservbyport(), getsockopt(), inet_ntoa(), setsockopt(), socket(), WPUQueryBlockingCallback(), WSAAccept(), WSAAddressToStringA(), WSAAddressToStringW(), WSAAsyncGetHostByAddr(), WSAAsyncGetHostByName(), WSAAsyncGetProtoByName(), WSAAsyncGetProtoByNumber(), WSAAsyncGetServByName(), WSAAsyncGetServByPort(), WSACancelAsyncRequest(), WSACancelBlockingCall(), WSACleanup(), WSAIsBlocking(), WSAJoinLeaf(), WSALookupServiceBeginW(), WSALookupServiceEnd(), WSALookupServiceNextW(), WSARecvDisconnect(), WSASendDisconnect(), WSASetBlockingHook(), WSASocketW(), WSAStringToAddressA(), WSAStringToAddressW(), WSAUnhookBlockingHook(), WSCGetProviderPath(), WsSlowProlog(), and WsSlowPrologTid().

◆ WsCheckCatalogState()

BOOL WSAAPI WsCheckCatalogState ( IN HANDLE  Event)

Definition at line 75 of file wsautil.c.

76{
77 DWORD Return;
78
79 /* Wait for the object */
80 Return = WaitForSingleObject(Event, 0);
81
82 /* Check for the value */
83 if (Return == WAIT_OBJECT_0) return TRUE;
84
85 /* If it timedout or anything else, return false */
86 return FALSE;
87}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WAIT_OBJECT_0
Definition: winbase.h:406

Referenced by WsNcRefreshFromRegistry(), WsProcGetNsCatalog(), WsProcGetTCatalog(), and WsTcRefreshFromRegistry().

◆ WsOpenRegistryRoot()

HKEY WSAAPI WsOpenRegistryRoot ( VOID  )

Definition at line 17 of file wsautil.c.

18{
19 HKEY WinsockRootKey;
22
23 /* Open Registry Key */
26 0,
28 &WinsockRootKey);
29
30 /* Check if it wasn't found */
32 {
33 /* Create it */
36 0,
37 NULL,
40 NULL,
41 &WinsockRootKey,
43 }
44 else if (ErrorCode == ERROR_SUCCESS)
45 {
46 /* It already exists */
48 }
49
50 /* Check for failure */
51 if (ErrorCode != ERROR_SUCCESS) return NULL;
52
53 /* Check if we had to create a new key */
55 {
56 /* Write the Winsock Version */
57 RegSetValueEx(WinsockRootKey,
58 "WinSock_Registry_Version",
59 0,
60 REG_SZ,
61 (BYTE*)"2.2",
62 4);
63 }
64 else
65 {
66 /* Read the Winsock Version */
67 }
68
69 /* Return the key */
70 return WinsockRootKey;
71}
#define REG_SZ
Definition: layer.c:22
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
#define REG_OPENED_EXISTING_KEY
Definition: nt_native.h:1085
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG _Out_opt_ PULONG CreateDisposition
Definition: wdfregistry.h:120
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define WINSOCK_ROOT
Definition: ws2_32p.h:10
unsigned char BYTE
Definition: xxhash.c:193

Referenced by OpenInitializedCatalog(), WsProcInitialize(), and WsRasLoadHelperDll().

◆ WsSetupCatalogProtection()

INT WSAAPI WsSetupCatalogProtection ( IN HKEY  CatalogKey,
IN HANDLE  CatalogEvent,
OUT LPDWORD  UniqueId 
)

Definition at line 142 of file wsautil.c.

145{
147 HKEY RegistryKey;
148 DWORD NewUniqueId;
149 CHAR KeyBuffer[32];
150 DWORD RegType = REG_DWORD;
151 DWORD RegSize = sizeof(DWORD);
152
153 /* Start loop */
154 do
155 {
156#if 0
157 /* Ask for notifications */
159 FALSE,
161 CatalogEvent,
162 TRUE);
164 {
165 /* Normalize error code */
167 break;
168 }
169#endif
170
171 /* Read the current ID */
172 ErrorCode = RegQueryValueEx(CatalogKey,
173 "Serial_Access_Num",
174 0,
175 &RegType,
176 (LPBYTE)&NewUniqueId,
177 &RegSize);
179 {
180 /* Critical failure */
182 break;
183 }
184
185 /* Try to open it for writing */
186 sprintf(KeyBuffer, "%8.8lX", NewUniqueId);
187 ErrorCode = RegOpenKeyEx(CatalogKey,
188 KeyBuffer,
189 0,
191 &RegistryKey);
192
193 /* If the key doesn't exist or is being delete, that's ok for us */
196 {
197 /* Set success and return the new ID */
199 *UniqueId = NewUniqueId;
200 break;
201 }
202 else if (ErrorCode != ERROR_SUCCESS)
203 {
204 /* Any other failure is bad */
206 break;
207 }
208
209 /* If we could actually open the key, someone is using it :/ */
210 ErrorCode = RegCloseKey(RegistryKey);
211
212 /* In case we break out prematurely */
214
215 /* Keep looping until they let go of the registry writing */
216 } while (!WaitForSingleObject(CatalogEvent, 180 * 1000));
217
218 /* Return error code */
219 return ErrorCode;
220}
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegNotifyChangeKeyValue(HKEY hKey, BOOL bWatchSubtree, DWORD dwNotifyFilter, HANDLE hEvent, BOOL fAsynchronous)
Definition: reg.c:3152
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define DWORD
Definition: nt_native.h:44
#define REG_DWORD
Definition: sdbapi.c:596
unsigned char * LPBYTE
Definition: typedefs.h:53
#define ERROR_KEY_DELETED
Definition: winerror.h:597
#define WSANO_RECOVERY
Definition: winerror.h:2002
#define REG_NOTIFY_CHANGE_NAME
Definition: winreg.h:38
#define RegQueryValueEx
Definition: winreg.h:524
char CHAR
Definition: xmlstorage.h:175

Referenced by WsNcRefreshFromRegistry(), and WsTcRefreshFromRegistry().

◆ WsSlowProlog()

INT WSAAPI WsSlowProlog ( VOID  )

Definition at line 109 of file wsautil.c.

110{
113
114 /* Call the prolog */
115 return WsApiProlog(&Process, &Thread);
116}
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91

Referenced by WsQuickProlog().

◆ WsSlowPrologTid()

INT WSAAPI WsSlowPrologTid ( OUT LPWSATHREADID ThreadId)

Definition at line 120 of file wsautil.c.

121{
125
126 /* Call the prolog */
128
129 /* Check for success */
131 {
132 /* Return the Thread ID */
133 *ThreadId = &Thread->WahThreadId;
134 }
135
136 /* Return status */
137 return ErrorCode;
138}

Referenced by WsQuickPrologTid().