ReactOS 0.4.15-dev-5893-g1bb4167
ws2_32p.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _WSASYNCBLOCK
 
struct  _WSASYNCCONTEXT
 
struct  _WSPROTO_BUFFER
 
struct  _TPROVIDER
 
struct  _TCATALOG_ENTRY
 
struct  _TCATALOG
 
struct  _NSPROVIDER
 
struct  _NSQUERY_PROVIDER
 
struct  _NSCATALOG_ENTRY
 
struct  _NSCATALOG
 
struct  _NSQUERY
 
struct  _WSPROCESS
 
struct  _WSTHREAD
 
struct  _WSSOCKET
 
struct  _ENUM_CONTEXT
 
struct  _NSPROVIDER_ENUM_CONTEXT
 
struct  _PROTOCOL_ENUM_CONTEXT
 
struct  _PROVIDER_ENUM_CONTEXT
 
struct  _WS_BUFFER
 

Macros

#define WINSOCK_ROOT   "System\\CurrentControlSet\\Services\\WinSock2\\Parameters"
 
#define MAXALIASES   35
 
#define TlsIndex   GlobalTlsIndex
 

Typedefs

typedef enum _WSASYNCOPS WSASYNCOPS
 
typedef struct _WSASYNCBLOCK WSASYNCBLOCK
 
typedef struct _WSASYNCBLOCKPWSASYNCBLOCK
 
typedef struct _WSASYNCCONTEXT WSASYNCCONTEXT
 
typedef struct _WSASYNCCONTEXTPWSASYNCCONTEXT
 
typedef struct _WSPROTO_BUFFER WSPROTO_BUFFER
 
typedef struct _WSPROTO_BUFFERPWSPROTO_BUFFER
 
typedef struct _TPROVIDER TPROVIDER
 
typedef struct _TPROVIDERPTPROVIDER
 
typedef struct _TCATALOG_ENTRY TCATALOG_ENTRY
 
typedef struct _TCATALOG_ENTRYPTCATALOG_ENTRY
 
typedef struct _TCATALOG TCATALOG
 
typedef struct _TCATALOGPTCATALOG
 
typedef struct _NSPROVIDER NSPROVIDER
 
typedef struct _NSPROVIDERPNS_PROVIDER
 
typedef struct _NSQUERY_PROVIDER NSQUERY_PROVIDER
 
typedef struct _NSQUERY_PROVIDERPNSQUERY_PROVIDER
 
typedef struct _NSCATALOG_ENTRY NSCATALOG_ENTRY
 
typedef struct _NSCATALOG_ENTRYPNSCATALOG_ENTRY
 
typedef struct _NSCATALOG NSCATALOG
 
typedef struct _NSCATALOGPNSCATALOG
 
typedef struct _NSQUERY NSQUERY
 
typedef struct _NSQUERYPNSQUERY
 
typedef struct _WSPROCESS WSPROCESS
 
typedef struct _WSPROCESSPWSPROCESS
 
typedef struct _WSTHREAD WSTHREAD
 
typedef struct _WSTHREADPWSTHREAD
 
typedef struct _WSSOCKET WSSOCKET
 
typedef struct _WSSOCKETPWSSOCKET
 
typedef struct _ENUM_CONTEXT ENUM_CONTEXT
 
typedef struct _ENUM_CONTEXTPENUM_CONTEXT
 
typedef struct _NSPROVIDER_ENUM_CONTEXT NSPROVIDER_ENUM_CONTEXT
 
typedef struct _NSPROVIDER_ENUM_CONTEXTPNSPROVIDER_ENUM_CONTEXT
 
typedef struct _PROTOCOL_ENUM_CONTEXT PROTOCOL_ENUM_CONTEXT
 
typedef struct _PROTOCOL_ENUM_CONTEXTPPROTOCOL_ENUM_CONTEXT
 
typedef struct _PROVIDER_ENUM_CONTEXT PROVIDER_ENUM_CONTEXT
 
typedef struct _PROVIDER_ENUM_CONTEXTPPROVIDER_ENUM_CONTEXT
 
typedef struct _WS_BUFFER WS_BUFFER
 
typedef struct _WS_BUFFERPWS_BUFFER
 
typedef BOOL(WINAPIPNSCATALOG_ENUMERATE_PROC) (IN PVOID Context, IN PNSCATALOG_ENTRY Entry)
 
typedef BOOL(WINAPIPTCATALOG_ENUMERATE_PROC) (IN PVOID Context, IN PTCATALOG_ENTRY Entry)
 
typedef BOOL(WINAPIPWS_SOCK_POST_ROUTINE) (IN HWND hWnd, IN UINT wMsg, IN WPARAM wParam, IN LPARAM lParam)
 

Enumerations

enum  _WSASYNCOPS {
  WsAsyncGetHostByAddr , WsAsyncGetHostByName , WsAsyncGetProtoByName , WsAsyncGetProtoByNumber ,
  WsAsyncGetServByName , WsAsyncGetServByPort , WsAsyncTerminate
}
 

Functions

LPSTR WSAAPI AnsiDupFromUnicode (IN LPCWSTR UnicodeString)
 
LPWSTR WSAAPI UnicodeDupFromAnsi (IN LPCSTR AnsiString)
 
VOID WSAAPI WsRasInitializeAutodial (VOID)
 
VOID WSAAPI WsRasUninitializeAutodial (VOID)
 
BOOL WSAAPI WSAttemptAutodialName (IN CONST LPWSAQUERYSETW lpqsRestrictions)
 
BOOL WSAAPI WSAttemptAutodialAddr (IN CONST SOCKADDR FAR *Name, IN INT NameLength)
 
VOID WSAAPI WSNoteSuccessfulHostentLookup (IN CONST CHAR FAR *Name, IN CONST ULONG Address)
 
INT WSAAPI MapUnicodeProtocolInfoToAnsi (IN LPWSAPROTOCOL_INFOW UnicodeInfo, OUT LPWSAPROTOCOL_INFOA AnsiInfo)
 
INT WSAAPI MapAnsiQuerySetToUnicode (IN LPWSAQUERYSETA AnsiSet, IN OUT PSIZE_T SetSize, OUT LPWSAQUERYSETW UnicodeSet)
 
INT WSAAPI MapUnicodeQuerySetToAnsi (IN LPWSAQUERYSETW UnicodeSet, IN OUT PSIZE_T SetSize, OUT LPWSAQUERYSETA AnsiSet)
 
INT WSAAPI CopyQuerySetW (IN LPWSAQUERYSETW UnicodeSet, OUT LPWSAQUERYSETW *UnicodeCopy)
 
INT WSAAPI WsSlowProlog (VOID)
 
INT WSAAPI WsSlowPrologTid (OUT LPWSATHREADID *ThreadId)
 
PWSSOCKET WSAAPI WsSockGetSocket (IN SOCKET Handle)
 
INT WSAAPI WsApiProlog (OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
 
HKEY WSAAPI WsOpenRegistryRoot (VOID)
 
VOID WSAAPI WsCreateStartupSynchronization (VOID)
 
VOID WSAAPI WsDestroyStartupSynchronization (VOID)
 
INT WSAAPI WsSetupCatalogProtection (IN HKEY CatalogKey, IN HANDLE CatalogEvent, OUT LPDWORD UniqueId)
 
BOOL WSAAPI WsCheckCatalogState (IN HANDLE Event)
 
PNSCATALOG WSAAPI WsNcAllocate (VOID)
 
VOID WSAAPI WsNcDelete (IN PNSCATALOG Catalog)
 
INT WSAAPI WsNcInitializeFromRegistry (IN PNSCATALOG Catalog, IN HKEY ParentKey, IN HANDLE CatalogEvent)
 
INT WSAAPI WsNcRefreshFromRegistry (IN PNSCATALOG Catalog, IN HANDLE CatalogEvent)
 
VOID WSAAPI WsNcUpdateNamespaceList (IN PNSCATALOG Catalog, IN PLIST_ENTRY List)
 
BOOL WSAAPI WsNcMatchProtocols (IN DWORD NameSpace, IN LONG AddressFamily, IN LPWSAQUERYSETW QuerySet)
 
INT WSAAPI WsNcLoadProvider (IN PNSCATALOG Catalog, IN PNSCATALOG_ENTRY CatalogEntry)
 
INT WSAAPI WsNcGetCatalogFromProviderId (IN PNSCATALOG Catalog, IN LPGUID ProviderId, OUT PNSCATALOG_ENTRY *CatalogEntry)
 
VOID WSAAPI WsNcEnumerateCatalogItems (IN PNSCATALOG Catalog, IN PNSCATALOG_ENUMERATE_PROC Callback, IN PVOID Context)
 
INT WSAAPI WsNcGetServiceClassInfo (IN PNSCATALOG Catalog, IN OUT LPDWORD BugSize, IN OUT LPWSASERVICECLASSINFOW lpServiceClassInfo)
 
PNSCATALOG_ENTRY WSAAPI WsNcEntryAllocate (VOID)
 
INT WSAAPI WsNcEntryInitializeFromRegistry (IN PNSCATALOG_ENTRY CatalogEntry, IN HKEY ParentKey, IN ULONG UniqueId)
 
VOID WSAAPI WsNcEntryDereference (IN PNSCATALOG_ENTRY CatalogEntry)
 
VOID WSAAPI WsNcEntrySetProvider (IN PNSCATALOG_ENTRY Entry, IN PNS_PROVIDER Provider)
 
BOOL WSAAPI WsNqAddProvider (IN PNSQUERY NsQuery, IN PNS_PROVIDER Provider)
 
PNSQUERY WSAAPI WsNqAllocate (VOID)
 
BOOL WSAAPI WsNqBeginEnumerationProc (PVOID Context, PNSCATALOG_ENTRY CatalogEntry)
 
VOID WSAAPI WsNqDelete (IN PNSQUERY NsQuery)
 
DWORD WSAAPI WsNqInitialize (IN PNSQUERY NsQuery)
 
DWORD WSAAPI WsNqLookupServiceBegin (IN PNSQUERY NsQuery, IN LPWSAQUERYSETW QuerySet, IN DWORD ControlFlags, IN PNSCATALOG Catalog)
 
DWORD WSAAPI WsNqLookupServiceEnd (IN PNSQUERY NsQuery)
 
DWORD WSAAPI WsNqLookupServiceNext (PNSQUERY NsQuery, DWORD, PDWORD, OUT LPWSAQUERYSETW QuerySet)
 
PNSQUERY_PROVIDER WSAAPI WsNqNextProvider (PNSQUERY NsQuery, IN PNSQUERY_PROVIDER Provider)
 
PNSQUERY_PROVIDER WSAAPI WsNqPreviousProvider (IN PNSQUERY Query, IN PNSQUERY_PROVIDER Provider)
 
VOID WSAAPI WsNqDereference (IN PNSQUERY Query)
 
BOOL WSAAPI WsNqValidateAndReference (IN PNSQUERY Query)
 
DWORD WSAAPI WsNqProvLookupServiceNext (IN PNSQUERY_PROVIDER QueryProvider, DWORD, PDWORD, LPWSAQUERYSETW QuerySet)
 
DWORD WSAAPI WsNqProvLookupServiceEnd (IN PNSQUERY_PROVIDER QueryProvider)
 
DWORD WSAAPI WsNqProvInitialize (IN PNSQUERY_PROVIDER QueryProvider, IN PNS_PROVIDER Provider)
 
PNSQUERY_PROVIDER WSAAPI WsNqProvAllocate (VOID)
 
VOID WSAAPI WsNqProvDelete (IN PNSQUERY_PROVIDER QueryProvider)
 
DWORD WSAAPI WsNqProvLookupServiceBegin (IN PNSQUERY_PROVIDER QueryProvider, IN LPWSAQUERYSETW QuerySet, IN LPWSASERVICECLASSINFOW ServiceClassInfo, IN DWORD)
 
VOID WSAAPI WsNpDelete (IN PNS_PROVIDER Provider)
 
DWORD WSAAPI WsNpLookupServiceBegin (IN PNS_PROVIDER Provider, IN LPWSAQUERYSETW Restrictions, struct _WSAServiceClassInfoW *, IN DWORD ControlFlags, OUT PHANDLE LookupHandle)
 
DWORD WSAAPI WsNpNSPCleanup (IN PNS_PROVIDER Provider)
 
DWORD WSAAPI WsNpLookupServiceEnd (IN PNS_PROVIDER Provider, IN HANDLE LookupHandle)
 
DWORD WSAAPI WsNpInitialize (IN PNS_PROVIDER Provider, IN LPWSTR DllPath, IN LPGUID ProviderGuid)
 
PNS_PROVIDER WSAAPI WsNpAllocate (VOID)
 
VOID WSAAPI WsNpDereference (IN PNS_PROVIDER Provider)
 
DWORD WSAAPI WsNpLookupServiceNext (IN PNS_PROVIDER Provider, IN HANDLE LookupHandle, IN DWORD ControlFlags, OUT PDWORD BufferLength, OUT LPWSAQUERYSETW Results)
 
VOID WSAAPI WsTpDelete (IN PTPROVIDER Provider)
 
DWORD WSAAPI WsTpWSPCleanup (IN PTPROVIDER Provider, int *)
 
PTPROVIDER WSAAPI WsTpAllocate (VOID)
 
DWORD WSAAPI WsTpInitialize (IN PTPROVIDER Provider, IN LPSTR DllName, LPWSAPROTOCOL_INFOW ProtocolInfo)
 
VOID WSAAPI WsTpDereference (IN PTPROVIDER Provider)
 
VOID WSAAPI WsThreadDelete (IN PWSTHREAD Thread)
 
VOID WSAAPI WsThreadDestroyCurrentThread (VOID)
 
DWORD WSAAPI WsThreadCreate (IN PWSPROCESS Process, IN PWSTHREAD *Thread)
 
DWORD WSAAPI WsThreadGetCurrentThread (IN PWSPROCESS Process, IN PWSTHREAD *Thread)
 
LPWSATHREADID WSAAPI WsThreadGetThreadId (IN PWSPROCESS Process)
 
DWORD WSAAPI WsThreadStartup (VOID)
 
VOID WSAAPI WsThreadCleanup (VOID)
 
DWORD WSAAPI WsThreadCancelBlockingCall (IN PWSTHREAD Thread)
 
DWORD WSAAPI WsThreadUnhookBlockingHook (IN PWSTHREAD Thread)
 
FARPROC WSAAPI WsThreadSetBlockingHook (IN PWSTHREAD Thread, IN FARPROC BlockingHook)
 
PHOSTENT WSAAPI WsThreadBlobToHostent (IN PWSTHREAD Thread, IN LPBLOB Blob)
 
PSERVENT WSAAPI WsThreadBlobToServent (IN PWSTHREAD Thread, IN LPBLOB Blob)
 
PWSPROTO_BUFFER WSAAPI WsThreadGetProtoBuffer (IN PWSTHREAD Thread)
 
PWSTHREAD WSAAPI WsThreadAllocate (VOID)
 
DWORD WSAAPI WsThreadDefaultBlockingHook (VOID)
 
DWORD WSAAPI WsThreadInitialize (IN PWSTHREAD Thread, IN PWSPROCESS Process)
 
DWORD WSAAPI WsTcFindIfsProviderForSocket (IN PTCATALOG TCatalog, SOCKET Socket)
 
DWORD WSAAPI WsTcEntryInitializeFromRegistry (IN PTCATALOG_ENTRY CatalogEntry, IN HKEY, unsigned long)
 
DWORD WSAAPI WsTcGetEntryFromAf (IN PTCATALOG TCatalog, IN INT AddressFamily, IN PTCATALOG_ENTRY *CatalogEntry)
 
PTCATALOG_ENTRY WSAAPI WsTcEntryAllocate (VOID)
 
VOID WSAAPI WsTcEntrySetProvider (IN PTCATALOG_ENTRY CatalogEntry, IN PTPROVIDER Provider)
 
DWORD WSAAPI WsTcRefreshFromRegistry (IN PTCATALOG TCatalog, PVOID)
 
BOOL WSAAPI WsTcOpen (IN PTCATALOG TCatalog, IN HKEY)
 
PTPROVIDER WSAAPI WsTcFindProvider (IN PTCATALOG TCatalog, IN LPGUID ProviderId)
 
VOID WSAAPI WsTcEnumerateCatalogItems (IN PTCATALOG Catalog, IN PTCATALOG_ENUMERATE_PROC Callback, IN PVOID Context)
 
VOID WSAAPI WsTcEntryDereference (IN PTCATALOG_ENTRY CatalogEntry)
 
PTCATALOG WSAAPI WsTcAllocate (VOID)
 
VOID WSAAPI WsTcDelete (IN PTCATALOG Catalog)
 
DWORD WSAAPI WsTcGetEntryFromTriplet (IN PTCATALOG TCatalog, IN INT AddressFamily, IN INT SocketType, IN INT Protocol, IN DWORD StartId, IN PTCATALOG_ENTRY *CatalogEntry)
 
VOID WSAAPI WsTcUpdateProtocolList (IN PTCATALOG TCatalog, PLIST_ENTRY ProtocolList)
 
VOID WSAAPI WsTcEntryDelete (IN PTCATALOG_ENTRY CatalogEntry)
 
DWORD WSAAPI WsTcGetEntryFromCatalogEntryId (IN PTCATALOG TCatalog, IN DWORD CatalogEntryId, IN PTCATALOG_ENTRY *CatalogEntry)
 
DWORD WSAAPI WsTcLoadProvider (IN PTCATALOG TCatalog, IN PTCATALOG_ENTRY CatalogEntry)
 
DWORD WSAAPI WsTcInitializeFromRegistry (IN PTCATALOG TCatalog, HKEY, PVOID)
 
INT WSAAPI WsSockStartup (VOID)
 
VOID WSAAPI WsSockCleanup (VOID)
 
BOOL WSAAPI WsSockDeleteSockets (IN LPVOID Context, IN PWAH_HANDLE Handle)
 
VOID WSAAPI WsSockDereference (IN PWSSOCKET Socket)
 
PWSSOCKET WSAAPI WsSockAllocate (VOID)
 
INT WSAAPI WsSockInitialize (IN PWSSOCKET Socket, IN PTCATALOG_ENTRY CatalogEntry)
 
INT WSAAPI WsSockAssociateHandle (IN PWSSOCKET Socket, IN SOCKET Handle, IN BOOLEAN IsProvider)
 
INT WSAAPI WsSockDisassociateHandle (IN PWSSOCKET Socket)
 
INT WSAAPI WsSockAddApiReference (IN SOCKET Handle)
 
PTCATALOG WSAAPI WsProcGetTCatalog (IN PWSPROCESS Process)
 
BOOL WSAAPI WsProcDetachSocket (IN PWSPROCESS Process, IN PWAH_HANDLE Handle)
 
INT WSAAPI WsProcGetAsyncHelper (IN PWSPROCESS Process, OUT PHANDLE Handle)
 
VOID WSAAPI WsProcDelete (IN PWSPROCESS Process)
 
INT WSAAPI WsProcStartup (VOID)
 
PNSCATALOG WSAAPI WsProcGetNsCatalog (IN PWSPROCESS Process)
 
VOID WSAAPI WsProcSetVersion (IN PWSPROCESS Process, IN WORD VersionRequested)
 
VOID WSAAPI WsAsyncQueueRequest (IN PWSASYNCBLOCK AsyncBlock)
 
BOOL WSAAPI WsAsyncCheckAndInitThread (VOID)
 
INT WSAAPI WsAsyncCancelRequest (IN HANDLE TaskHandle)
 
PWSASYNCBLOCK WSAAPI WsAsyncAllocateBlock (IN SIZE_T ExtraLength)
 
VOID WSAAPI WsAsyncTerminateThread (VOID)
 
VOID WSAAPI WsAsyncGlobalTerminate (VOID)
 
VOID WSAAPI WsAsyncGlobalInitialize (VOID)
 
FORCEINLINE PWSPROCESS WsGetProcess (VOID)
 
FORCEINLINE DWORD WsQuickProlog (VOID)
 
FORCEINLINE DWORD WsQuickPrologTid (LPWSATHREADID *Tid)
 

Variables

HINSTANCE WsDllHandle
 
HANDLE WsSockHeap
 
PWAH_HANDLE_TABLE WsSockHandleTable
 
PWSPROCESS CurrentWsProcess
 
DWORD GlobalTlsIndex
 
BOOLEAN WsAsyncThreadInitialized
 
PWS_SOCK_POST_ROUTINE WsSockPostRoutine
 

Macro Definition Documentation

◆ MAXALIASES

#define MAXALIASES   35

Definition at line 11 of file ws2_32p.h.

◆ TlsIndex

#define TlsIndex   GlobalTlsIndex

Definition at line 277 of file ws2_32p.h.

◆ WINSOCK_ROOT

#define WINSOCK_ROOT   "System\\CurrentControlSet\\Services\\WinSock2\\Parameters"

Definition at line 10 of file ws2_32p.h.

Typedef Documentation

◆ ENUM_CONTEXT

◆ NSCATALOG

◆ NSCATALOG_ENTRY

◆ NSPROVIDER

◆ NSPROVIDER_ENUM_CONTEXT

◆ NSQUERY

◆ NSQUERY_PROVIDER

◆ PENUM_CONTEXT

◆ PNS_PROVIDER

◆ PNSCATALOG

◆ PNSCATALOG_ENTRY

◆ PNSCATALOG_ENUMERATE_PROC

typedef BOOL(WINAPI * PNSCATALOG_ENUMERATE_PROC) (IN PVOID Context, IN PNSCATALOG_ENTRY Entry)

Definition at line 252 of file ws2_32p.h.

◆ PNSPROVIDER_ENUM_CONTEXT

◆ PNSQUERY

◆ PNSQUERY_PROVIDER

◆ PPROTOCOL_ENUM_CONTEXT

◆ PPROVIDER_ENUM_CONTEXT

◆ PROTOCOL_ENUM_CONTEXT

◆ PROVIDER_ENUM_CONTEXT

◆ PTCATALOG

◆ PTCATALOG_ENTRY

◆ PTCATALOG_ENUMERATE_PROC

typedef BOOL(WINAPI * PTCATALOG_ENUMERATE_PROC) (IN PVOID Context, IN PTCATALOG_ENTRY Entry)

Definition at line 258 of file ws2_32p.h.

◆ PTPROVIDER

◆ PWS_BUFFER

◆ PWS_SOCK_POST_ROUTINE

typedef BOOL(WINAPI * PWS_SOCK_POST_ROUTINE) (IN HWND hWnd, IN UINT wMsg, IN WPARAM wParam, IN LPARAM lParam)

Definition at line 264 of file ws2_32p.h.

◆ PWSASYNCBLOCK

◆ PWSASYNCCONTEXT

◆ PWSPROCESS

◆ PWSPROTO_BUFFER

◆ PWSSOCKET

◆ PWSTHREAD

◆ TCATALOG

◆ TCATALOG_ENTRY

◆ TPROVIDER

◆ WS_BUFFER

◆ WSASYNCBLOCK

◆ WSASYNCCONTEXT

◆ WSASYNCOPS

◆ WSPROCESS

◆ WSPROTO_BUFFER

◆ WSSOCKET

◆ WSTHREAD

Enumeration Type Documentation

◆ _WSASYNCOPS

Enumerator
WsAsyncGetHostByAddr 
WsAsyncGetHostByName 
WsAsyncGetProtoByName 
WsAsyncGetProtoByNumber 
WsAsyncGetServByName 
WsAsyncGetServByPort 
WsAsyncTerminate 

Definition at line 13 of file ws2_32p.h.

14{
@ WsAsyncGetProtoByName
Definition: ws2_32p.h:17
@ WsAsyncGetServByPort
Definition: ws2_32p.h:20
@ WsAsyncGetHostByAddr
Definition: ws2_32p.h:15
@ WsAsyncGetHostByName
Definition: ws2_32p.h:16
@ WsAsyncGetProtoByNumber
Definition: ws2_32p.h:18
@ WsAsyncGetServByName
Definition: ws2_32p.h:19
@ WsAsyncTerminate
Definition: ws2_32p.h:21
enum _WSASYNCOPS WSASYNCOPS

Function Documentation

◆ AnsiDupFromUnicode()

LPSTR WSAAPI AnsiDupFromUnicode ( IN LPCWSTR  UnicodeString)

Definition at line 20 of file qshelpr.c.

21{
22 INT Length = 0;
23 BOOL GoOn = TRUE;
24 LPSTR DuplicatedString = NULL;
26
27 /* Start a loop (which should only run twice) */
28 while (GoOn)
29 {
30 /* Call the conversion function */
32 0,
34 -1,
35 DuplicatedString,
36 Length,
37 NULL,
38 NULL);
39 if (ReturnValue > Length)
40 {
41 /* This is the first loop, and we have the real size now */
43
44 /* Allocate buffer for it */
45 DuplicatedString = HeapAlloc(WsSockHeap, 0, Length);
46 if (!DuplicatedString) GoOn = FALSE;
47 }
48 else if (ReturnValue > 0)
49 {
50 /* The second loop was successful and we have the string */
51 GoOn = FALSE;
52 }
53 else
54 {
55 /* Some weird error happened */
56 if (DuplicatedString) HeapFree(WsSockHeap, 0, DuplicatedString);
57 DuplicatedString = NULL;
58 GoOn = FALSE;
59 }
60 }
61
62 /* Return the duplicate */
63 return DuplicatedString;
64}
UINT32 void void ** ReturnValue
Definition: acevents.h:216
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
int32_t INT
Definition: typedefs.h:58
HANDLE WsSockHeap
Definition: dllmain.c:21
char * LPSTR
Definition: xmlstorage.h:182

Referenced by ConvertAddrinfoFromUnicodeToAnsi(), and MapUnicodeQuerySetToAnsi().

◆ CopyQuerySetW()

INT WSAAPI CopyQuerySetW ( IN LPWSAQUERYSETW  UnicodeSet,
OUT LPWSAQUERYSETW UnicodeCopy 
)

Definition at line 1050 of file qshelpr.c.

1052{
1053 SIZE_T SetSize;
1054
1055 /* Get the size */
1056 SetSize = WSAComputeQuerySetSizeW(UnicodeSet);
1057
1058 /* Allocate memory for copy */
1059 *UnicodeCopy = HeapAlloc(WsSockHeap, 0, SetSize);
1060 if (!(*UnicodeCopy)) return WSA_NOT_ENOUGH_MEMORY;
1061
1062 /* Build a copy and return */
1063 return WSABuildQuerySetBufferW(UnicodeSet, SetSize, *UnicodeCopy);
1064}
INT WSAAPI WSABuildQuerySetBufferW(IN LPWSAQUERYSETW UnicodeSet, IN SIZE_T BufferSize, OUT LPWSAQUERYSETW RelativeSet)
Definition: qshelpr.c:771
SIZE_T WSAAPI WSAComputeQuerySetSizeW(IN LPWSAQUERYSETW UnicodeSet)
Definition: qshelpr.c:248
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define WSA_NOT_ENOUGH_MEMORY
Definition: winsock2.h:620

Referenced by WsNqLookupServiceBegin().

◆ MapAnsiQuerySetToUnicode()

INT WSAAPI MapAnsiQuerySetToUnicode ( IN LPWSAQUERYSETA  AnsiSet,
IN OUT PSIZE_T  SetSize,
OUT LPWSAQUERYSETW  UnicodeSet 
)

Definition at line 808 of file qshelpr.c.

811{
813 SIZE_T AnsiSize, UnicodeSize;
814 LPWSAQUERYSETA AnsiCopy = NULL;
815 LPWSAQUERYSETW UnicodeCopy;
816 LPWSTR ServiceCopy = NULL, CommentCopy = NULL;
817 LPWSTR ContextCopy = NULL, QueryCopy = NULL;
818
819 /* Calculate the size of the Ansi version and allocate space for a copy */
820 AnsiSize = WSAComputeQuerySetSizeA(AnsiSet);
821 AnsiCopy = HeapAlloc(WsSockHeap, 0, AnsiSize);
822 if (!AnsiCopy)
823 {
824 /* Fail, couldn't allocate memory */
826 goto Exit;
827 }
828
829 /* Build the relative buffer version */
830 ErrorCode = WSABuildQuerySetBufferA(AnsiSet, AnsiSize, AnsiCopy);
831 if (ErrorCode != ERROR_SUCCESS) goto Exit;
832
833 /* Re-use the ANSI version since the fields match */
834 UnicodeCopy = (LPWSAQUERYSETW)AnsiCopy;
835
836 /* Check if we have a service instance name */
837 if (AnsiCopy->lpszServiceInstanceName)
838 {
839 /* Duplicate it into unicode form */
840 ServiceCopy = UnicodeDupFromAnsi(AnsiCopy->lpszServiceInstanceName);
841 if (!ServiceCopy)
842 {
843 /* Fail */
845 goto Exit;
846 }
847
848 /* Set the new string pointer */
849 UnicodeCopy->lpszServiceInstanceName = ServiceCopy;
850 }
851
852 /* Check if we have a service instance name */
853 if (AnsiCopy->lpszContext)
854 {
855 /* Duplicate it into unicode form */
856 ContextCopy = UnicodeDupFromAnsi(AnsiCopy->lpszContext);
857 if (!ContextCopy)
858 {
859 /* Fail */
861 goto Exit;
862 }
863
864 /* Set the new string pointer */
865 UnicodeCopy->lpszContext = ContextCopy;
866 }
867
868 /* Check if we have a service instance name */
869 if (AnsiCopy->lpszComment)
870 {
871 /* Duplicate it into unicode form */
872 CommentCopy = UnicodeDupFromAnsi(AnsiCopy->lpszComment);
873 if (!CommentCopy)
874 {
875 /* Fail */
877 goto Exit;
878 }
879
880 /* Set the new string pointer */
881 UnicodeCopy->lpszComment = CommentCopy;
882 }
883
884 /* Check if we have a query name */
885 if (AnsiCopy->lpszQueryString)
886 {
887 /* Duplicate it into unicode form */
888 QueryCopy = UnicodeDupFromAnsi(AnsiCopy->lpszQueryString);
889 if (!QueryCopy)
890 {
891 /* Fail */
893 goto Exit;
894 }
895
896 /* Set the new string pointer */
897 UnicodeCopy->lpszQueryString = QueryCopy;
898 }
899
900 /* Now that we have the absolute unicode buffer, calculate its size */
901 UnicodeSize = WSAComputeQuerySetSizeW(UnicodeCopy);
902 if (UnicodeSize > *SetSize)
903 {
904 /* The buffer wasn't large enough; return how much we need */
905 *SetSize = UnicodeSize;
907 goto Exit;
908 }
909
910 /* Build the relative unicode buffer */
911 ErrorCode = WSABuildQuerySetBufferW(UnicodeCopy, *SetSize, UnicodeSet);
912
913Exit:
914 /* Free the Ansi copy if we had one */
915 if (AnsiCopy) HeapFree(WsSockHeap, 0, AnsiCopy);
916
917 /* Free all the strings */
918 if (ServiceCopy) HeapFree(WsSockHeap, 0, ServiceCopy);
919 if (CommentCopy) HeapFree(WsSockHeap, 0, CommentCopy);
920 if (ContextCopy) HeapFree(WsSockHeap, 0, ContextCopy);
921 if (QueryCopy) HeapFree(WsSockHeap, 0, QueryCopy);
922
923 /* Return error code */
924 return ErrorCode;
925}
#define ERROR_SUCCESS
Definition: deptool.c:10
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
SIZE_T WSAAPI WSAComputeQuerySetSizeA(IN LPWSAQUERYSETA AnsiSet)
Definition: qshelpr.c:240
INT WSAAPI WSABuildQuerySetBufferA(IN LPWSAQUERYSETA AnsiSet, IN SIZE_T BufferSize, OUT LPWSAQUERYSETA RelativeSet)
Definition: qshelpr.c:734
LPWSTR WSAAPI UnicodeDupFromAnsi(IN LPCSTR AnsiString)
Definition: qshelpr.c:68
static void Exit(void)
Definition: sock.c:1330
static LPWSAQUERYSETW
Definition: sock.c:90
LPSTR lpszQueryString
Definition: winsock2.h:812
LPSTR lpszComment
Definition: winsock2.h:806
LPSTR lpszContext
Definition: winsock2.h:809
LPSTR lpszServiceInstanceName
Definition: winsock2.h:803
#define WSAEFAULT
Definition: winerror.h:1945
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by WSALookupServiceBeginA().

◆ 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}
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define WSASYSCALLFAILURE
Definition: winerror.h:1994

Referenced by getsockopt(), and WSADuplicateSocketA().

◆ MapUnicodeQuerySetToAnsi()

INT WSAAPI MapUnicodeQuerySetToAnsi ( IN LPWSAQUERYSETW  UnicodeSet,
IN OUT PSIZE_T  SetSize,
OUT LPWSAQUERYSETA  AnsiSet 
)

Definition at line 929 of file qshelpr.c.

932{
934 SIZE_T UnicodeSize, AnsiSize;
935 LPWSAQUERYSETW UnicodeCopy = NULL;
936 LPWSAQUERYSETA AnsiCopy;
937 LPSTR ServiceCopy = NULL, CommentCopy = NULL;
938 LPSTR ContextCopy = NULL, QueryCopy = NULL;
939
940 /* Calculate the size of the Ansi version and allocate space for a copy */
941 UnicodeSize = WSAComputeQuerySetSizeW(UnicodeSet);
942 UnicodeCopy = HeapAlloc(WsSockHeap, 0, UnicodeSize);
943 if (!UnicodeCopy)
944 {
945 /* Fail, couldn't allocate memory */
947 goto Exit;
948 }
949
950 /* Build the relative buffer version */
951 ErrorCode = WSABuildQuerySetBufferW(UnicodeSet, UnicodeSize, UnicodeCopy);
952 if (ErrorCode != ERROR_SUCCESS) goto Exit;
953
954 /* Re-use the Unicode version since the fields match */
955 AnsiCopy = (LPWSAQUERYSETA)UnicodeCopy;
956
957 /* Check if we have a service instance name */
958 if (UnicodeCopy->lpszServiceInstanceName)
959 {
960 /* Duplicate it into unicode form */
961 ServiceCopy = AnsiDupFromUnicode(UnicodeCopy->lpszServiceInstanceName);
962 if (!ServiceCopy)
963 {
964 /* Fail */
966 goto Exit;
967 }
968
969 /* Set the new string pointer */
970 AnsiCopy->lpszServiceInstanceName = ServiceCopy;
971 }
972
973 /* Check if we have a service instance name */
974 if (UnicodeCopy->lpszContext)
975 {
976 /* Duplicate it into unicode form */
977 ContextCopy = AnsiDupFromUnicode(UnicodeCopy->lpszContext);
978 if (!ContextCopy)
979 {
980 /* Fail */
982 goto Exit;
983 }
984
985 /* Set the new string pointer */
986 AnsiCopy->lpszContext = ContextCopy;
987 }
988
989 /* Check if we have a service instance name */
990 if (UnicodeCopy->lpszComment)
991 {
992 /* Duplicate it into unicode form */
993 CommentCopy = AnsiDupFromUnicode(UnicodeCopy->lpszComment);
994 if (!CommentCopy)
995 {
996 /* Fail */
998 goto Exit;
999 }
1000
1001 /* Set the new string pointer */
1002 AnsiCopy->lpszComment = CommentCopy;
1003 }
1004
1005 /* Check if we have a query name */
1006 if (UnicodeCopy->lpszQueryString)
1007 {
1008 /* Duplicate it into unicode form */
1009 QueryCopy = AnsiDupFromUnicode(UnicodeCopy->lpszQueryString);
1010 if (!QueryCopy)
1011 {
1012 /* Fail */
1014 goto Exit;
1015 }
1016
1017 /* Set the new string pointer */
1018 AnsiCopy->lpszQueryString = QueryCopy;
1019 }
1020
1021 /* Now that we have the absolute unicode buffer, calculate its size */
1022 AnsiSize = WSAComputeQuerySetSizeA(AnsiCopy);
1023 if (AnsiSize > *SetSize)
1024 {
1025 /* The buffer wasn't large enough; return how much we need */
1026 *SetSize = AnsiSize;
1028 goto Exit;
1029 }
1030
1031 /* Build the relative unicode buffer */
1032 ErrorCode = WSABuildQuerySetBufferA(AnsiCopy, *SetSize, AnsiSet);
1033
1034Exit:
1035 /* Free the Ansi copy if we had one */
1036 if (UnicodeCopy) HeapFree(WsSockHeap, 0, UnicodeCopy);
1037
1038 /* Free all the strings */
1039 if (ServiceCopy) HeapFree(WsSockHeap, 0, ServiceCopy);
1040 if (CommentCopy) HeapFree(WsSockHeap, 0, CommentCopy);
1041 if (ContextCopy) HeapFree(WsSockHeap, 0, ContextCopy);
1042 if (QueryCopy) HeapFree(WsSockHeap, 0, QueryCopy);
1043
1044 /* Return error code */
1045 return ErrorCode;
1046}
LPSTR WSAAPI AnsiDupFromUnicode(IN LPCWSTR UnicodeString)
Definition: qshelpr.c:20
struct _WSAQuerySetA * LPWSAQUERYSETA

Referenced by WSALookupServiceNextA().

◆ UnicodeDupFromAnsi()

LPWSTR WSAAPI UnicodeDupFromAnsi ( IN LPCSTR  AnsiString)

Definition at line 68 of file qshelpr.c.

69{
70 INT Length = 0;
71 BOOL GoOn = TRUE;
72 LPWSTR DuplicatedString = NULL;
74
75 /* Start a loop (which should only run twice) */
76 while (GoOn)
77 {
78 /* Call the conversion function */
80 0,
82 -1,
83 DuplicatedString,
84 Length);
85 if (ReturnValue > Length)
86 {
87 /* This is the first loop, and we have the real size now */
89
90 /* Allocate buffer for it */
91 DuplicatedString = HeapAlloc(WsSockHeap, 0, Length * sizeof(WCHAR));
92 if (!DuplicatedString) GoOn = FALSE;
93 }
94 else if (ReturnValue > 0)
95 {
96 /* The second loop was successful and we have the string */
97 GoOn = FALSE;
98 }
99 else
100 {
101 /* Some weird error happened */
102 if (DuplicatedString) HeapFree(WsSockHeap, 0, DuplicatedString);
103 DuplicatedString = NULL;
104 GoOn = FALSE;
105 }
106 }
107
108 /* Return the duplicate */
109 return DuplicatedString;
110}
#define MultiByteToWideChar
Definition: compat.h:110
@ AnsiString
Definition: dnslib.h:19
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by getaddrinfo(), and MapAnsiQuerySetToUnicode().

◆ 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
#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().

◆ WsAsyncAllocateBlock()

PWSASYNCBLOCK WSAAPI WsAsyncAllocateBlock ( IN SIZE_T  ExtraLength)

Definition at line 439 of file async.c.

440{
441 PWSASYNCBLOCK AsyncBlock;
442
443 /* Add the size of the block */
444 ExtraLength += sizeof(WSASYNCBLOCK);
445
446 /* Allocate it */
447 AsyncBlock = HeapAlloc(WsSockHeap, 0, ExtraLength);
448
449 /* Get a handle to it */
451
452 /* Return it */
453 return AsyncBlock;
454}
#define InterlockedIncrement
Definition: armddk.h:53
LONG WsAsyncTaskHandle
Definition: async.c:16
#define UlongToPtr(u)
Definition: config.h:106
HANDLE TaskHandle
Definition: ws2_32p.h:27
struct _WSASYNCBLOCK WSASYNCBLOCK

Referenced by WSAAsyncGetHostByAddr(), WSAAsyncGetHostByName(), WSAAsyncGetProtoByName(), WSAAsyncGetProtoByNumber(), WSAAsyncGetServByName(), WSAAsyncGetServByPort(), and WsAsyncTerminateThread().

◆ WsAsyncCancelRequest()

INT WSAAPI WsAsyncCancelRequest ( IN HANDLE  TaskHandle)

Definition at line 936 of file async.c.

937{
939 PWSASYNCBLOCK AsyncBlock;
940
941 /* Make sure we're initialized */
943
944 /* Acquire the lock */
945 WsAsyncLock();
946
947 /* Check if we're cancelling the current task */
948 if (TaskHandle == WsAsyncCurrentTaskHandle)
949 {
950 /* Mark us as cancelled, the async thread will see this later */
951 WsAsyncCancelledTaskHandle = TaskHandle;
952
953 /* Release lock and return */
955 return NO_ERROR;
956 }
957
958 /* Loop the queue */
960 while (Entry != WsAsyncQueue)
961 {
962 /* Get the Async Block */
963 AsyncBlock = CONTAINING_RECORD(Entry, WSASYNCBLOCK, AsyncQueue);
964
965 /* Check if this is the one */
966 if (TaskHandle == AsyncBlock->TaskHandle)
967 {
968 /* It is, remove it */
970
971 /* Release the lock, free the block, and return */
973 WsAsyncFreeBlock(AsyncBlock);
974 return NO_ERROR;
975 }
976
977 /* Move to the next entry */
978 Entry = Entry->Flink;
979 }
980
981 /* Nothing found, fail */
983 return WSAEINVAL;
984}
#define WsAsyncLock()
Definition: async.c:24
VOID WSAAPI WsAsyncFreeBlock(IN PWSASYNCBLOCK AsyncBlock)
Definition: async.c:473
#define WsAsyncUnlock()
Definition: async.c:25
PLIST_ENTRY WsAsyncQueue
Definition: async.c:17
HANDLE WsAsyncCancelledTaskHandle
Definition: async.c:21
BOOLEAN WsAsyncThreadInitialized
Definition: async.c:15
HANDLE WsAsyncCurrentTaskHandle
Definition: async.c:20
#define NO_ERROR
Definition: dderror.h:5
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define WSAEINVAL
Definition: winerror.h:1946

Referenced by WSACancelAsyncRequest().

◆ WsAsyncCheckAndInitThread()

BOOL WSAAPI WsAsyncCheckAndInitThread ( VOID  )

Definition at line 832 of file async.c.

833{
834 HANDLE ThreadHandle;
835 DWORD Tid;
837 WSADATA WsaData;
838
839 /* Make sure we're not initialized */
840 if (WsAsyncThreadInitialized) return TRUE;
841
842 /* Acquire the lock */
843 WsAsyncLock();
844
845 /* Make sure we're not initialized */
847 {
848 /* Initialize Thread Context */
849 Context = HeapAlloc(WsSockHeap, 0, sizeof(*Context));
850 if (!Context)
851 goto Exit;
852
853 /* Initialize the Queue and event */
854 WsAsyncQueue = &Context->AsyncQueue;
856 Context->AsyncEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
857 WsAsyncEvent = Context->AsyncEvent;
858
859 /* Prevent us from ever being killed while running */
860 if (WSAStartup(MAKEWORD(2,2), &WsaData) != ERROR_SUCCESS)
861 goto Fail;
862
863 /* Create the thread */
864 ThreadHandle = CreateThread(NULL,
865 0,
867 Context,
868 0,
869 &Tid);
870 if (ThreadHandle == NULL)
871 {
872 /* Cleanup and fail */
873 WSACleanup();
874 goto Fail;
875 }
876
877 /* Close the handle and set init */
878 CloseHandle(ThreadHandle);
880 }
881
882Exit:
883 /* Release the lock */
886
887Fail:
888 /* Close the event, free the Context */
889 if (Context->AsyncEvent)
890 CloseHandle(Context->AsyncEvent);
892
893 /* Bail out */
894 goto Exit;
895}
HANDLE WsAsyncEvent
Definition: async.c:19
DWORD WINAPI WsAsyncThread(IN PVOID ThreadContext)
Definition: async.c:703
#define CloseHandle
Definition: compat.h:739
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
int Fail
Definition: ehthrow.cxx:24
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MAKEWORD(a, b)
Definition: typedefs.h:248
#define CreateEvent
Definition: winbase.h:3619
int PASCAL FAR WSACleanup(void)
Definition: startup.c:60

Referenced by WSAAsyncGetHostByAddr(), WSAAsyncGetHostByName(), WSAAsyncGetProtoByName(), WSAAsyncGetProtoByNumber(), WSAAsyncGetServByName(), and WSAAsyncGetServByPort().

◆ WsAsyncGlobalInitialize()

VOID WSAAPI WsAsyncGlobalInitialize ( VOID  )

Definition at line 31 of file async.c.

32{
33 /* Initialize the async lock */
35}
CRITICAL_SECTION WsAsyncCritSect
Definition: async.c:18
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751

Referenced by DllMain().

◆ WsAsyncGlobalTerminate()

VOID WSAAPI WsAsyncGlobalTerminate ( VOID  )

Definition at line 39 of file async.c.

40{
41 /* Destroy the async lock */
43}
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by DllMain().

◆ WsAsyncQueueRequest()

VOID WSAAPI WsAsyncQueueRequest ( IN PWSASYNCBLOCK  AsyncBlock)

Definition at line 919 of file async.c.

920{
921 /* Get the lock */
922 WsAsyncLock();
923
924 /* Insert it into the queue */
925 InsertTailList(WsAsyncQueue, &AsyncBlock->AsyncQueue);
926
927 /* Wake up the thread */
929
930 /* Release lock and return */
932}
#define InsertTailList(ListHead, Entry)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733

Referenced by WSAAsyncGetHostByAddr(), WSAAsyncGetHostByName(), WSAAsyncGetProtoByName(), WSAAsyncGetProtoByNumber(), WSAAsyncGetServByName(), WSAAsyncGetServByPort(), and WsAsyncTerminateThread().

◆ WsAsyncTerminateThread()

VOID WSAAPI WsAsyncTerminateThread ( VOID  )

Definition at line 899 of file async.c.

900{
901 PWSASYNCBLOCK AsyncBlock;
902
903 /* Make sure we're initialized */
904 if (!WsAsyncThreadInitialized) return;
905
906 /* Allocate a block */
907 AsyncBlock = WsAsyncAllocateBlock(0);
908
909 /* Initialize it for termination */
910 AsyncBlock->Operation = WsAsyncTerminate;
911
912 /* Queue the request and return */
913 WsAsyncQueueRequest(AsyncBlock);
915}
VOID WSAAPI WsAsyncQueueRequest(IN PWSASYNCBLOCK AsyncBlock)
Definition: async.c:919
PWSASYNCBLOCK WSAAPI WsAsyncAllocateBlock(IN SIZE_T ExtraLength)
Definition: async.c:439
WSASYNCOPS Operation
Definition: ws2_32p.h:28

Referenced by WSACleanup().

◆ WSAttemptAutodialAddr()

BOOL WSAAPI WSAttemptAutodialAddr ( IN CONST SOCKADDR FAR Name,
IN INT  NameLength 
)

Definition at line 20 of file winsock.c.

22{
25 AUTODIAL_ADDR AutodialAddress;
26
27 /* Check the family type */
28 switch (Name->sa_family)
29 {
30 case AF_INET:
31 /* Normal IPv4, set the Autodial Address Data */
32 AutodialAddress.Family = AutoDialIp;
33 AutodialAddress.Ip4Address = Ip->sin_addr;
34 break;
35
36 case AF_NETBIOS:
37 /* NetBIOS, set the Autodial Address Data*/
38 AutodialAddress.Family = AutoDialNetBios;
39 RtlCopyMemory(&AutodialAddress.NetBiosAddress,
40 NetBios->snb_name,
42 break;
43
44 default:
45 /* Unsupported family type */
46 return FALSE;
47 }
48
49 /* Call the public routine */
50 return AcsHlpAttemptConnection(&AutodialAddress);
51}
BOOLEAN WINAPI AcsHlpAttemptConnection(IN PAUTODIAL_ADDR ConnectionAddress)
Definition: autodial.c:89
@ AutoDialNetBios
Definition: precomp.h:41
@ AutoDialIp
Definition: precomp.h:39
#define AF_INET
Definition: tcpip.h:117
IN_ADDR Ip4Address
Definition: precomp.h:58
CHAR NetBiosAddress[NETBIOS_NAME_LENGTH]
Definition: precomp.h:60
AUTODIAL_FAMILY Family
Definition: precomp.h:55
struct in_addr sin_addr
Definition: winsock.h:512
char snb_name[NETBIOS_NAME_LENGTH]
Definition: wsnetbs.h:14
#define AF_NETBIOS
Definition: winsock.h:363
struct sockaddr_in * PSOCKADDR_IN
Definition: winsock.h:488
struct sockaddr_nb * PSOCKADDR_NB
#define NETBIOS_NAME_LENGTH
Definition: wsnetbs.h:4

Referenced by connect().

◆ WSAttemptAutodialName()

BOOL WSAAPI WSAttemptAutodialName ( IN CONST LPWSAQUERYSETW  lpqsRestrictions)

Definition at line 58 of file winsock.c.

59{
60 AUTODIAL_ADDR AutodialAddress;
61 CHAR AnsiIp[17];
62 LPGUID Guid = Restrictions->lpServiceClassId;
63
64 /* Make sure we actually have a name */
65 if (!Restrictions->lpszServiceInstanceName) return FALSE;
66
67 /* Check if this is the Hostname GUID */
68 if (!memcmp(Guid, &HostnameGuid, sizeof(GUID)))
69 {
70 /* It is. Set up the Autodial Address Data */
71 AutodialAddress.Family = AutoDialIpHost;
73 0,
74 Restrictions->lpszServiceInstanceName,
75 -1,
76 AutodialAddress.HostName,
78 0,
79 0);
80
81 /* Call the public routine */
82 return AcsHlpAttemptConnection(&AutodialAddress);
83 }
84 else if (!memcmp(Guid, &AddressGuid, sizeof(GUID)))
85 {
86 /* It's actually the IP String GUID */
87 AutodialAddress.Family = AutoDialIp;
88
89 /* Convert the IP String to ANSI and then convert it to IP */
91 0,
92 Restrictions->lpszServiceInstanceName,
93 -1,
94 AnsiIp,
95 sizeof(AnsiIp) - 1,
96 0,
97 0);
98 _strlwr(AnsiIp);
99 AutodialAddress.Ip4Address.S_un.S_addr = inet_addr(AnsiIp);
100
101 /* Make sure the IP is valid */
102 if (AutodialAddress.Ip4Address.S_un.S_addr == -1) return FALSE;
103
104 /* Call the public routine */
105 return AcsHlpAttemptConnection(&AutodialAddress);
106 }
107 else
108 {
109 /* Unknown GUID type */
110 return FALSE;
111 }
112}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
@ AutoDialIpHost
Definition: precomp.h:42
#define inet_addr(cp)
Definition: inet.h:98
const GUID DECLSPEC_SELECTANY HostnameGuid
Definition: nsp_dns.h:17
const GUID DECLSPEC_SELECTANY AddressGuid
Definition: nsp_dns.h:18
_CRTIMP char *__cdecl _strlwr(_Inout_z_ char *_String)
CHAR HostName[INTERNET_MAX_PATH_LENGTH]
Definition: precomp.h:61
u_long S_addr
Definition: tcpip.h:131
union in_addr::@1002 S_un
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
#define INTERNET_MAX_PATH_LENGTH
Definition: wininet.h:49
char CHAR
Definition: xmlstorage.h:175

Referenced by WsNqLookupServiceNext().

◆ 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}
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().

◆ WsCreateStartupSynchronization()

VOID WSAAPI WsCreateStartupSynchronization ( VOID  )

Definition at line 28 of file startup.c.

29{
30 /* Initialize the startup lock */
32}
#define WsStartupLock()
Definition: startup.c:21

Referenced by DllMain().

◆ WsDestroyStartupSynchronization()

VOID WSAAPI WsDestroyStartupSynchronization ( VOID  )

Definition at line 36 of file startup.c.

37{
38 /* Destroy the startup lock */
40}

Referenced by DllMain().

◆ WsGetProcess()

FORCEINLINE PWSPROCESS WsGetProcess ( VOID  )

◆ WsNcAllocate()

PNSCATALOG WSAAPI WsNcAllocate ( VOID  )

Definition at line 25 of file nscatalo.c.

26{
27 PNSCATALOG Catalog;
28
29 /* Allocate the catalog */
30 Catalog = HeapAlloc(WsSockHeap, HEAP_ZERO_MEMORY, sizeof(*Catalog));
31
32 /* Return it */
33 return Catalog;
34}
#define HEAP_ZERO_MEMORY
Definition: compat.h:134

Referenced by WsProcInitialize().

◆ WsNcDelete()

VOID WSAAPI WsNcDelete ( IN PNSCATALOG  Catalog)

Definition at line 624 of file nscatalo.c.

625{
627 PNSCATALOG_ENTRY CatalogEntry;
628
629 /* Check if we're initialized */
630 if (!Catalog->CatalogList.Flink) return;
631
632 /* Acquire lock */
633 WsNcLock();
634
635 /* Loop every entry */
636 Entry = Catalog->CatalogList.Flink;
637 while (Entry != &Catalog->CatalogList)
638 {
639 /* Get this entry */
640 CatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink);
641
642 /* Remove it and dereference it */
643 WsNcRemoveCatalogItem(Catalog, CatalogEntry);
644 WsNcEntryDereference(CatalogEntry);
645
646 /* Move to the next entry */
647 Entry = Catalog->CatalogList.Flink;
648 }
649
650 /* Check if the catalog key is opened */
651 if (Catalog->CatalogKey)
652 {
653 /* Close it */
654 RegCloseKey(Catalog->CatalogKey);
655 Catalog->CatalogKey = NULL;
656 }
657
658 /* Release and delete the lock */
659 WsNcUnlock();
660 DeleteCriticalSection(&Catalog->Lock);
661
662 /* Delete the object */
663 HeapFree(WsSockHeap, 0, Catalog);
664}
#define RegCloseKey(hKey)
Definition: registry.h:47
VOID WSAAPI WsNcRemoveCatalogItem(IN PNSCATALOG Catalog, IN PNSCATALOG_ENTRY Entry)
Definition: nscatalo.c:612
#define WsNcLock()
Definition: nscatalo.c:18
#define WsNcUnlock()
Definition: nscatalo.c:19
Definition: ws2_32p.h:122
VOID WSAAPI WsNcEntryDereference(IN PNSCATALOG_ENTRY CatalogEntry)
Definition: nscatent.c:53

Referenced by WsProcDelete().

◆ WsNcEntryAllocate()

PNSCATALOG_ENTRY WSAAPI WsNcEntryAllocate ( VOID  )

Definition at line 17 of file nscatent.c.

18{
19 PNSCATALOG_ENTRY CatalogEntry;
20
21 /* Allocate the catalog */
22 CatalogEntry = HeapAlloc(WsSockHeap, HEAP_ZERO_MEMORY, sizeof(*CatalogEntry));
23 if (CatalogEntry)
24 {
25 /* Set the default non-null members */
26 CatalogEntry->RefCount = 1;
27 CatalogEntry->Enabled = TRUE;
28 CatalogEntry->AddressFamily = -1;
29 }
30
31 /* Return it */
32 return CatalogEntry;
33}
LONG RefCount
Definition: ws2_32p.h:124
LONG AddressFamily
Definition: ws2_32p.h:126
BOOLEAN Enabled
Definition: ws2_32p.h:130

Referenced by WsNcRefreshFromRegistry().

◆ WsNcEntryDereference()

VOID WSAAPI WsNcEntryDereference ( IN PNSCATALOG_ENTRY  CatalogEntry)

Definition at line 53 of file nscatent.c.

54{
55 /* Dereference and check if it's now 0 */
56 if (!(InterlockedDecrement(&CatalogEntry->RefCount)))
57 {
58 /* We can delete the Provider now */
59 WsNcEntryDelete(CatalogEntry);
60 }
61}
#define InterlockedDecrement
Definition: armddk.h:52
VOID WSAAPI WsNcEntryDelete(IN PNSCATALOG_ENTRY CatalogEntry)
Definition: nscatent.c:37

Referenced by WsNcDelete(), WsNcRefreshFromRegistry(), and WsNcUpdateNamespaceList().

◆ WsNcEntryInitializeFromRegistry()

INT WSAAPI WsNcEntryInitializeFromRegistry ( IN PNSCATALOG_ENTRY  CatalogEntry,
IN HKEY  ParentKey,
IN ULONG  UniqueId 
)

Definition at line 65 of file nscatent.c.

68{
70 CHAR CatalogEntryName[13];
71 HKEY EntryKey;
72 ULONG RegType = REG_SZ;
73 ULONG RegSize = MAX_PATH;
74 ULONG RegValue;
75
76 /* Convert to a 00000xxx string */
77 sprintf(CatalogEntryName, "%0""12""i", (int)UniqueId);
78
79 /* Open the Entry */
81 CatalogEntryName,
82 0,
84 &EntryKey);
85 if (ErrorCode != ERROR_SUCCESS) return ErrorCode;
86 /* Read the Library Path */
87 ErrorCode = RegQueryValueExW(EntryKey,
88 L"LibraryPath",
89 0,
90 &RegType,
91 (LPBYTE)&CatalogEntry->DllPath,
92 &RegSize);
93 if (ErrorCode != ERROR_SUCCESS) goto out;
94 /* Query Display String Size*/
95 ErrorCode = RegQueryValueExW(EntryKey,
96 L"DisplayString",
97 0,
98 NULL,
99 NULL,
100 &RegSize);
101 if (ErrorCode != ERROR_SUCCESS) goto out;
102 /* Allocate it */
103 CatalogEntry->ProviderName = (LPWSTR)HeapAlloc(WsSockHeap, 0, RegSize);
104
105 /* Read it */
106 ErrorCode = RegQueryValueExW(EntryKey,
107 L"DisplayString",
108 0,
109 &RegType,
110 (LPBYTE)CatalogEntry->ProviderName,
111 &RegSize);
112 if (ErrorCode != ERROR_SUCCESS) goto out;
113 /* Read the Provider Id */
114 RegType = REG_BINARY;
115 RegSize = sizeof(GUID);
116 ErrorCode = RegQueryValueEx(EntryKey,
117 "ProviderId",
118 0,
119 &RegType,
120 (LPBYTE)&CatalogEntry->ProviderId,
121 &RegSize);
122 if (ErrorCode != ERROR_SUCCESS) goto out;
123 /* Read the Address Family */
124 RegType = REG_DWORD;
125 RegSize = sizeof(DWORD);
126 ErrorCode = RegQueryValueEx(EntryKey,
127 "AddressFamily",
128 0,
129 &RegType,
130 (LPBYTE)&CatalogEntry->AddressFamily,
131 &RegSize);
132 if (ErrorCode != ERROR_SUCCESS) goto out;
133 /* Read the Namespace Id */
134 ErrorCode = RegQueryValueEx(EntryKey,
135 "SupportedNamespace",
136 0,
137 &RegType,
138 (LPBYTE)&CatalogEntry->NamespaceId,
139 &RegSize);
140 if (ErrorCode != ERROR_SUCCESS) goto out;
141 /* Read the Enabled Flag */
142 ErrorCode = RegQueryValueEx(EntryKey,
143 "Enabled",
144 0,
145 &RegType,
146 (LPBYTE)&RegValue,
147 &RegSize);
148 if (ErrorCode != ERROR_SUCCESS) goto out;
149 CatalogEntry->Enabled = RegValue != 0;
150
151 /* Read the Version */
152 ErrorCode = RegQueryValueEx(EntryKey,
153 "Version",
154 0,
155 &RegType,
156 (LPBYTE)&CatalogEntry->Version,
157 &RegSize);
158 if (ErrorCode != ERROR_SUCCESS) goto out;
159 /* Read the Support Service Class Info Flag */
160 ErrorCode = RegQueryValueEx(EntryKey,
161 "StoresServiceClassInfo",
162 0,
163 &RegType,
164 (LPBYTE)&RegValue,
165 &RegSize);
166 CatalogEntry->StoresServiceClassInfo = RegValue != 0;
167out:
168 /* Done */
169 RegCloseKey(EntryKey);
170 return ErrorCode;
171}
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4121
#define MAX_PATH
Definition: compat.h:34
#define REG_SZ
Definition: layer.c:22
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_READ
Definition: nt_native.h:1023
#define DWORD
Definition: nt_native.h:44
#define L(x)
Definition: ntvdm.h:50
static FILE * out
Definition: regtests2xml.c:44
#define REG_DWORD
Definition: sdbapi.c:596
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_opt_ WDFKEY ParentKey
Definition: wdfregistry.h:69
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegQueryValueEx
Definition: winreg.h:524

Referenced by WsNcRefreshFromRegistry().

◆ WsNcEntrySetProvider()

VOID WSAAPI WsNcEntrySetProvider ( IN PNSCATALOG_ENTRY  Entry,
IN PNS_PROVIDER  Provider 
)

Definition at line 175 of file nscatent.c.

177{
178 /* Reference the provider */
179 InterlockedIncrement(&Provider->RefCount);
180
181 /* Set it */
182 Entry->Provider = Provider;
183}

Referenced by WsNcLoadProvider().

◆ WsNcEnumerateCatalogItems()

VOID WSAAPI WsNcEnumerateCatalogItems ( IN PNSCATALOG  Catalog,
IN PNSCATALOG_ENUMERATE_PROC  Callback,
IN PVOID  Context 
)

Definition at line 371 of file nscatalo.c.

374{
376 PNSCATALOG_ENTRY CatalogEntry;
377 BOOL GoOn = TRUE;
378
379 /* Lock the catalog */
380 WsNcLock();
381
382 /* Loop the entries */
383 Entry = Catalog->CatalogList.Flink;
384 while (GoOn && (Entry != &Catalog->CatalogList))
385 {
386 /* Get the entry */
387 CatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink);
388
389 /* Move to the next one and call the callback */
390 Entry = Entry->Flink;
391 GoOn = Callback(Context, CatalogEntry);
392 }
393
394 /* Release the lock */
395 WsNcUnlock();
396}
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458

Referenced by WSAEnumNameSpaceProvidersInternal(), WSCGetProviderPath(), WsNqLookupServiceBegin(), and WsProcDelete().

◆ WsNcGetCatalogFromProviderId()

INT WSAAPI WsNcGetCatalogFromProviderId ( IN PNSCATALOG  Catalog,
IN LPGUID  ProviderId,
OUT PNSCATALOG_ENTRY CatalogEntry 
)

Definition at line 517 of file nscatalo.c.

520{
522 PLIST_ENTRY NextEntry;
524
525 /* Lock the catalog */
526 WsNcLock();
527
528 /* Match the Id with all the entries in the List */
529 NextEntry = Catalog->CatalogList.Flink;
530 while (NextEntry != &Catalog->CatalogList)
531 {
532 /* Get the Current Entry */
533 Entry = CONTAINING_RECORD(NextEntry, NSCATALOG_ENTRY, CatalogLink);
534 NextEntry = NextEntry->Flink;
535
536 /* Check if this is the Catalog Entry ID we want */
537 if (IsEqualGUID(&Entry->ProviderId, ProviderId))
538 {
539 /* If it doesn't already have a provider, load the provider */
540 if (!Entry->Provider)
541 ErrorCode = WsNcLoadProvider(Catalog, Entry);
542
543 /* If we succeeded, reference the entry and return it */
544 if (Entry->Provider /* || ErrorCode == ERROR_SUCCESS */)
545 {
546 InterlockedIncrement(&Entry->RefCount);
547 *CatalogEntry = Entry;
549 break;
550 }
551 }
552 }
553
554 /* Release the lock and return */
555 WsNcUnlock();
556 return ErrorCode;
557}
INT WSAAPI WsNcLoadProvider(IN PNSCATALOG Catalog, IN PNSCATALOG_ENTRY CatalogEntry)
Definition: nscatalo.c:400
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147

Referenced by WsNqLookupServiceBegin().

◆ WsNcGetServiceClassInfo()

INT WSAAPI WsNcGetServiceClassInfo ( IN PNSCATALOG  Catalog,
IN OUT LPDWORD  BugSize,
IN OUT LPWSASERVICECLASSINFOW  lpServiceClassInfo 
)

Definition at line 444 of file nscatalo.c.

447{
448 /* Not yet implemented in the spec? */
450 return SOCKET_ERROR;
451}
#define SetLastError(x)
Definition: compat.h:752
#define SOCKET_ERROR
Definition: winsock.h:333

Referenced by WsNqLookupServiceBegin().

◆ WsNcInitializeFromRegistry()

INT WSAAPI WsNcInitializeFromRegistry ( IN PNSCATALOG  Catalog,
IN HKEY  ParentKey,
IN HANDLE  CatalogEvent 
)

Definition at line 211 of file nscatalo.c.

214{
216
217 /* Open the catalog */
218 if (WsNcOpen(Catalog, ParentKey))
219 {
220 /* Refresh it */
221 ErrorCode = WsNcRefreshFromRegistry(Catalog, CatalogEvent);
222 }
223
224 /* Return the status */
225 return ErrorCode;
226}
BOOLEAN WSAAPI WsNcOpen(IN PNSCATALOG Catalog, IN HKEY ParentKey)
Definition: nscatalo.c:38
INT WSAAPI WsNcRefreshFromRegistry(IN PNSCATALOG Catalog, IN HANDLE CatalogEvent)
Definition: nscatalo.c:230

Referenced by WsProcInitialize().

◆ WsNcLoadProvider()

INT WSAAPI WsNcLoadProvider ( IN PNSCATALOG  Catalog,
IN PNSCATALOG_ENTRY  CatalogEntry 
)

Definition at line 400 of file nscatalo.c.

402{
405
406 /* Lock the catalog */
407 WsNcLock();
408
409 /* Check if we have a provider already */
410 if (!CatalogEntry->Provider)
411 {
412 /* Allocate a provider */
413 if ((Provider = WsNpAllocate()))
414 {
415 /* Initialize it */
417 CatalogEntry->DllPath,
418 &CatalogEntry->ProviderId);
419
420 /* Ensure success */
422 {
423 /* Set the provider */
424 WsNcEntrySetProvider(CatalogEntry, Provider);
425 }
426
427 /* Dereference it */
429 }
430 else
431 {
432 /* No memory */
434 }
435 }
436
437 /* Release the lock and return */
438 WsNcUnlock();
439 return ErrorCode;
440}
DWORD WSAAPI WsNpInitialize(IN PNS_PROVIDER Provider, IN LPWSTR DllPath, IN LPGUID ProviderGuid)
Definition: nsprovid.c:82
VOID WSAAPI WsNcEntrySetProvider(IN PNSCATALOG_ENTRY Entry, IN PNS_PROVIDER Provider)
Definition: nscatent.c:175
VOID WSAAPI WsNpDereference(IN PNS_PROVIDER Provider)
Definition: nsprovid.c:180
PNS_PROVIDER WSAAPI WsNpAllocate(VOID)
Definition: nsprovid.c:63

Referenced by WsNcGetCatalogFromProviderId(), and WsNqBeginEnumerationProc().

◆ WsNcMatchProtocols()

BOOL WSAAPI WsNcMatchProtocols ( IN DWORD  NameSpace,
IN LONG  AddressFamily,
IN LPWSAQUERYSETW  QuerySet 
)

Definition at line 561 of file nscatalo.c.

564{
565 DWORD ProtocolCount = QuerySet->dwNumberOfProtocols;
566 LPAFPROTOCOLS AfpProtocols = QuerySet->lpafpProtocols;
567 LONG Family;
568
569 /* Check for valid family */
570 if (AddressFamily != -1)
571 {
572 /* Check if it's the magic */
573 if (AddressFamily == AF_UNSPEC) return TRUE;
575 }
576 else
577 {
578 /* No family given, check for namespace */
579 if (NameSpace == NS_SAP)
580 {
581 /* Use IPX family */
582 Family = AF_IPX;
583 }
584 else
585 {
586 /* Other namespace, it's valid */
587 return TRUE;
588 }
589 }
590
591 /* Now try to get a match */
592 while (ProtocolCount--)
593 {
594 /* Check this protocol entry */
595 if ((AfpProtocols->iAddressFamily == AF_UNSPEC) ||
596 (AfpProtocols->iAddressFamily == Family))
597 {
598 /* Match found */
599 return TRUE;
600 }
601
602 /* Move to the next one */
603 AfpProtocols++;
604 }
605
606 /* No match */
607 return FALSE;
608}
IN PCO_ADDRESS_FAMILY AddressFamily
Definition: ndis.h:1906
#define NS_SAP
Definition: nspapi.h:10
long LONG
Definition: pedump.c:60
static int Family
Definition: ping.c:62
INT iAddressFamily
Definition: winsock2.h:787
#define AF_IPX
Definition: winsock.h:350
#define AF_UNSPEC
Definition: winsock.h:344

Referenced by WsNqBeginEnumerationProc().

◆ WsNcRefreshFromRegistry()

INT WSAAPI WsNcRefreshFromRegistry ( IN PNSCATALOG  Catalog,
IN HANDLE  CatalogEvent 
)

Definition at line 230 of file nscatalo.c.

232{
234 BOOLEAN LocalEvent = FALSE;
235 LIST_ENTRY LocalList;
236 DWORD UniqueId;
237 HKEY EntriesKey;
238 DWORD CatalogEntries;
239 PNSCATALOG_ENTRY CatalogEntry;
240 BOOL NewChangesMade;
242 DWORD RegType = REG_DWORD;
243 DWORD RegSize = sizeof(DWORD);
244 DWORD i;
245
246 /* Check if we got an event */
247 if (!CatalogEvent)
248 {
249 /* Create an event ourselves */
250 CatalogEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
251 if (!CatalogEvent) return WSASYSCALLFAILURE;
252 LocalEvent = TRUE;
253 }
254
255 /* Lock the catalog */
256 WsNcLock();
257
258 /* Initialize our local list for the loop */
259 InitializeListHead(&LocalList);
260
261 /* Start looping */
262 do
263 {
264 /* Setup notifications for the catalog entry */
265 ErrorCode = WsSetupCatalogProtection(Catalog->CatalogKey,
266 CatalogEvent,
267 &UniqueId);
268 if (ErrorCode != ERROR_SUCCESS) break;
269
270 /* Check if we've changed till now */
271 if (UniqueId == Catalog->UniqueId)
272 {
273 /* We haven't, so return */
275 break;
276 }
277
278 /* Now Open the Entries */
279 ErrorCode = RegOpenKeyEx(Catalog->CatalogKey,
280 "Catalog_Entries",
281 0,
283 &EntriesKey);
285 {
286 /* Critical failure */
288 break;
289 }
290
291 /* Find out how many there are */
292 ErrorCode = RegQueryValueEx(Catalog->CatalogKey,
293 "Num_Catalog_Entries",
294 0,
295 &RegType,
296 (LPBYTE)&CatalogEntries,
297 &RegSize);
299 {
300 /* Critical failure */
302 break;
303 }
304
305 /* Initialize them all */
306 for (i = 1; i <= CatalogEntries; i++)
307 {
308 /* Allocate a Catalog Entry Structure */
309 CatalogEntry = WsNcEntryAllocate();
310 if (!CatalogEntry)
311 {
312 /* Not enough memory, fail */
314 break;
315 }
316
317 /* Initialize it from the Registry Key */
319 EntriesKey,
320 i);
322 {
323 /* We failed to get it, dereference the entry and leave */
324 WsNcEntryDereference(CatalogEntry);
325 break;
326 }
327
328 /* Insert it to our List */
329 InsertTailList(&LocalList, &CatalogEntry->CatalogLink);
330 }
331
332 /* Close the catalog key */
333 RegCloseKey(EntriesKey);
334
335 /* Check if we changed during our read and if we have success */
336 NewChangesMade = WsCheckCatalogState(CatalogEvent);
337 if (!NewChangesMade && ErrorCode == ERROR_SUCCESS)
338 {
339 /* All is good, update the protocol list */
340 WsNcUpdateNamespaceList(Catalog, &LocalList);
341
342 /* Update and return */
343 Catalog->UniqueId = UniqueId;
344 break;
345 }
346
347 /* We failed and/or catalog data changed, free what we did till now */
348 while (!IsListEmpty(&LocalList))
349 {
350 /* Get the LP Catalog Item */
351 Entry = RemoveHeadList(&LocalList);
352 CatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink);
353
354 /* Dereference it */
355 WsNcEntryDereference(CatalogEntry);
356 }
357 } while (NewChangesMade);
358
359 /* Release the lock */
360 WsNcUnlock();
361
362 /* Close the event, if any was created by us */
363 if (LocalEvent) CloseHandle(CatalogEvent);
364
365 /* All Done */
366 return ErrorCode;
367}
unsigned char BOOLEAN
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID WSAAPI WsNcUpdateNamespaceList(IN PNSCATALOG Catalog, IN PLIST_ENTRY List)
Definition: nscatalo.c:455
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
LIST_ENTRY CatalogLink
Definition: ws2_32p.h:123
INT WSAAPI WsSetupCatalogProtection(IN HKEY CatalogKey, IN HANDLE CatalogEvent, OUT LPDWORD UniqueId)
Definition: wsautil.c:142
PNSCATALOG_ENTRY WSAAPI WsNcEntryAllocate(VOID)
Definition: nscatent.c:17
BOOL WSAAPI WsCheckCatalogState(IN HANDLE Event)
Definition: wsautil.c:75
INT WSAAPI WsNcEntryInitializeFromRegistry(IN PNSCATALOG_ENTRY CatalogEntry, IN HKEY ParentKey, IN ULONG UniqueId)
Definition: nscatent.c:65

Referenced by WsNcInitializeFromRegistry(), and WsProcGetNsCatalog().

◆ WsNcUpdateNamespaceList()

VOID WSAAPI WsNcUpdateNamespaceList ( IN PNSCATALOG  Catalog,
IN PLIST_ENTRY  List 
)

Definition at line 455 of file nscatalo.c.

457{
458 LIST_ENTRY TempList;
459 PNSCATALOG_ENTRY CatalogEntry, OldCatalogEntry;
461
462 /* First move from our list to the old one */
463 InsertHeadList(&Catalog->CatalogList, &TempList);
464 RemoveEntryList(&Catalog->CatalogList);
465 InitializeListHead(&Catalog->CatalogList);
466
467 /* Loop every item on the list */
468 while (!IsListEmpty(List))
469 {
470 /* Get the catalog entry */
472 CatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink);
473
474 /* Check if this item is already on our list */
475 Entry = TempList.Flink;
476 while (Entry != &TempList)
477 {
478 /* Get the catalog entry */
479 OldCatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink);
480 Entry = Entry->Flink;
481
482 /* Check if they match */
483 if (IsEqualGUID(&CatalogEntry->ProviderId,
484 &OldCatalogEntry->ProviderId))
485 {
486 /* We have a match, use the old item instead */
487 WsNcEntryDereference(CatalogEntry);
488 CatalogEntry = OldCatalogEntry;
489 RemoveEntryList(&CatalogEntry->CatalogLink);
490
491 /* Decrease the number of protocols we have */
492 Catalog->ItemCount--;
493 break;
494 }
495 }
496
497 /* Add this item */
498 InsertTailList(&Catalog->CatalogList, &CatalogEntry->CatalogLink);
499 Catalog->ItemCount++;
500 }
501
502 /* If there's anything left on the temporary list */
503 while (!IsListEmpty(&TempList))
504 {
505 /* Get the entry */
506 Entry = RemoveHeadList(&TempList);
507 CatalogEntry = CONTAINING_RECORD(Entry, NSCATALOG_ENTRY, CatalogLink);
508
509 /* Remove it */
510 Catalog->ItemCount--;
511 WsNcEntryDereference(CatalogEntry);
512 }
513}
#define InsertHeadList(ListHead, Entry)
GUID ProviderId
Definition: ws2_32p.h:132
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by WsNcRefreshFromRegistry().

◆ WSNoteSuccessfulHostentLookup()

VOID WSAAPI WSNoteSuccessfulHostentLookup ( IN CONST CHAR FAR Name,
IN CONST ULONG  Address 
)

Definition at line 119 of file winsock.c.

121{
122 AUTODIAL_ADDR AutodialAddress;
123 AUTODIAL_CONN AutodialConnection;
124
125 /* Make sure there actually is a name */
126 if (!(Name) || !strlen(Name)) return;
127
128 /* Setup the Address */
129 AutodialAddress.Family = AutoDialIpHost;
130 strcpy(AutodialAddress.HostName, Name);
131
132 /* Setup the new connection */
133 AutodialConnection.Family = ConnectionIp;
134 AutodialConnection.Ip4Address = Address;
135 AcsHlpNoteNewConnection(&AutodialAddress, &AutodialConnection);
136}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
BOOLEAN WINAPI AcsHlpNoteNewConnection(IN PAUTODIAL_ADDR ConnectionAddress, IN PAUTODIAL_CONN Connection)
Definition: autodial.c:108
@ ConnectionIp
Definition: precomp.h:48
static WCHAR Address[46]
Definition: ping.c:68
ULONG Ip4Address
Definition: precomp.h:71
CONNECTION_FAMILY Family
Definition: precomp.h:67

Referenced by gethostbyname().

◆ WsNpAllocate()

PNS_PROVIDER WSAAPI WsNpAllocate ( VOID  )

Definition at line 63 of file nsprovid.c.

64{
66
67 /* Allocate the object */
69 if (Provider)
70 {
71 /* Set non-null data */
72 Provider->RefCount = 1;
73 Provider->Service.cbSize = sizeof(NSP_ROUTINE);
74 }
75
76 /* Return it */
77 return Provider;
78}
struct _NSP_ROUTINE NSP_ROUTINE

Referenced by WsNcLoadProvider().

◆ WsNpDelete()

VOID WSAAPI WsNpDelete ( IN PNS_PROVIDER  Provider)

Definition at line 161 of file nsprovid.c.

162{
163 /* Make sure we have a loaded handle */
164 if (Provider->DllHandle)
165 {
166 /* Clean us up */
168
169 /* Unload the library */
170 FreeLibrary(Provider->DllHandle);
171 Provider->DllHandle = NULL;
172 }
173
174 /* Delete us */
176}
#define FreeLibrary(x)
Definition: compat.h:748
DWORD WSAAPI WsNpNSPCleanup(IN PNS_PROVIDER Provider)
Definition: nsprovid.c:140

Referenced by WsNpDereference().

◆ WsNpDereference()

VOID WSAAPI WsNpDereference ( IN PNS_PROVIDER  Provider)

Definition at line 180 of file nsprovid.c.

181{
182 /* Decrease the reference count and check if it's zero */
183 if (!InterlockedDecrement(&Provider->RefCount))
184 {
185 /* Delete us*/
187 }
188}
VOID WSAAPI WsNpDelete(IN PNS_PROVIDER Provider)
Definition: nsprovid.c:161

Referenced by WsNcEntryDelete(), WsNcLoadProvider(), and WsNqProvDelete().

◆ WsNpInitialize()

DWORD WSAAPI WsNpInitialize ( IN PNS_PROVIDER  Provider,
IN LPWSTR  DllPath,
IN LPGUID  ProviderGuid 
)

Definition at line 82 of file nsprovid.c.

85{
87 LPNSPSTARTUP NSPStartupProc;
88 CHAR AnsiPath[MAX_PATH], ExpandedDllPath[MAX_PATH];
89
90 /* Convert the path to ANSI */
92 0,
93 DllName,
94 -1,
95 AnsiPath,
97 NULL,
98 NULL);
99
100 /* Expand the DLL Path */
102 ExpandedDllPath,
103 MAX_PATH);
104
105 /* Load the DLL */
106 Provider->DllHandle = LoadLibraryA(ExpandedDllPath);
107 if (!Provider->DllHandle)
108 {
109 /* Fail */
111 goto Fail;
112 }
113
114 /* Get the pointer to NSPStartup */
115 NSPStartupProc = (LPNSPSTARTUP)GetProcAddress(Provider->DllHandle,
116 "NSPStartup");
117 if (!NSPStartupProc)
118 {
119 /* Fail */
121 goto Fail;
122 }
123
124 /* Call it */
125 (*NSPStartupProc)(ProviderId, &Provider->Service);
126
127 /* Save the provider ID */
128 Provider->ProviderId = *ProviderId;
129 return ErrorCode;
130
131Fail:
132 /* Bail out */
133 if (Provider->DllHandle) FreeLibrary(Provider->DllHandle);
134 Provider->DllHandle = NULL;
135 return ErrorCode;
136}
#define GetProcAddress(x, y)
Definition: compat.h:753
DWORD WINAPI ExpandEnvironmentStringsA(IN LPCSTR lpSrc, IN LPSTR lpDst, IN DWORD nSize)
Definition: environ.c:399
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define WSAEPROVIDERFAILEDINIT
Definition: winerror.h:1993
_Must_inspect_result_ INT(WSAAPI * LPNSPSTARTUP)(_In_ LPGUID lpProviderId, _Inout_ LPNSP_ROUTINE lpnspRoutines)
Definition: ws2spi.h:671

Referenced by WsNcLoadProvider().

◆ WsNpLookupServiceBegin()

DWORD WSAAPI WsNpLookupServiceBegin ( IN PNS_PROVIDER  Provider,
IN LPWSAQUERYSETW  Restrictions,
struct _WSAServiceClassInfoW ,
IN DWORD  ControlFlags,
OUT PHANDLE  LookupHandle 
)

◆ WsNpLookupServiceEnd()

DWORD WSAAPI WsNpLookupServiceEnd ( IN PNS_PROVIDER  Provider,
IN HANDLE  LookupHandle 
)

Definition at line 231 of file nsprovid.c.

233{
234 /* Call the NSP */
235 return Provider->Service.NSPLookupServiceEnd(LookupHandle);
236}

Referenced by WsNqProvLookupServiceEnd().

◆ WsNpLookupServiceNext()

DWORD WSAAPI WsNpLookupServiceNext ( IN PNS_PROVIDER  Provider,
IN HANDLE  LookupHandle,
IN DWORD  ControlFlags,
OUT PDWORD  BufferLength,
OUT LPWSAQUERYSETW  Results 
)

Definition at line 240 of file nsprovid.c.

245{
246 /* Call the NSP */
247 return Provider->Service.NSPLookupServiceNext(LookupHandle,
248 ControlFlags,
250 Results);
251}
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771

Referenced by WsNqProvLookupServiceNext().

◆ WsNpNSPCleanup()

DWORD WSAAPI WsNpNSPCleanup ( IN PNS_PROVIDER  Provider)

Definition at line 140 of file nsprovid.c.

141{
143 LPNSPCLEANUP lpNSPCleanup = NULL;
144
145 /* Make sure we have a loaded handle */
146 if (Provider->DllHandle)
147 {
148 /* Get the pointer and clear it */
149 lpNSPCleanup = InterlockedExchangePointer((PVOID*)&Provider->Service.NSPCleanup,
150 NULL);
151 /* If it's not NULL, call it */
152 if (lpNSPCleanup) ErrorCode = lpNSPCleanup(&Provider->ProviderId);
153 }
154
155 /* Return */
156 return ErrorCode;
157}
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
INT(WSAAPI * LPNSPCLEANUP)(_In_ LPGUID lpProviderId)
Definition: ws2spi.h:494

Referenced by CleanupNamespaceProviders(), and WsNpDelete().

◆ WsNqAddProvider()

BOOL WSAAPI WsNqAddProvider ( IN PNSQUERY  NsQuery,
IN PNS_PROVIDER  Provider 
)

Definition at line 552 of file nsquery.c.

554{
555 BOOL Success = TRUE;
556 PNSQUERY_PROVIDER QueryProvider;
557
558 /* Allocate a new Query Provider */
559 if ((QueryProvider = WsNqProvAllocate()))
560 {
561 /* Initialize it */
562 WsNqProvInitialize(QueryProvider, Provider);
563
564 /* Insert it into the provider list */
565 InsertTailList(&Query->ProviderList, &QueryProvider->QueryLink);
566 }
567 else
568 {
569 /* We failed */
571 Success = FALSE;
572 }
573
574 /* Return */
575 return Success;
576}
BOOL Query(LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended)
Definition: query.c:292
@ Success
Definition: eventcreate.c:712
LIST_ENTRY QueryLink
Definition: ws2_32p.h:116
PNSQUERY_PROVIDER WSAAPI WsNqProvAllocate(VOID)
Definition: nsprovid.c:17
DWORD WSAAPI WsNqProvInitialize(IN PNSQUERY_PROVIDER QueryProvider, IN PNS_PROVIDER Provider)
Definition: nsprovid.c:30

Referenced by WsNqBeginEnumerationProc(), and WsNqLookupServiceBegin().

◆ WsNqAllocate()

PNSQUERY WSAAPI WsNqAllocate ( VOID  )

Definition at line 22 of file nsquery.c.

23{
24 PNSQUERY NsQuery;
25
26 /* Allocate the object */
27 NsQuery = HeapAlloc(WsSockHeap, HEAP_ZERO_MEMORY, sizeof(*NsQuery));
28 if (NsQuery)
29 {
30 /* Set non-zero fields */
31 NsQuery->Signature = ~0xBEADFACE;
33 NsQuery->TryAgain = TRUE;
34 }
35
36 /* Return it */
37 return NsQuery;
38}
LIST_ENTRY ProviderList
Definition: ws2_32p.h:150
DWORD Signature
Definition: ws2_32p.h:147
DWORD TryAgain
Definition: ws2_32p.h:157

Referenced by WSALookupServiceBeginW().

◆ WsNqBeginEnumerationProc()

BOOL WSAAPI WsNqBeginEnumerationProc ( PVOID  Context,
PNSCATALOG_ENTRY  CatalogEntry 
)

Definition at line 117 of file nsquery.c.

119{
121 BOOLEAN GoOn = TRUE;
122 PENUM_CONTEXT EnumContext = (PENUM_CONTEXT)Context;
123 PNSQUERY NsQuery = EnumContext->NsQuery;
124 DWORD NamespaceId = Entry->NamespaceId;
125
126 /* Match the namespace ID, protocols and make sure it's enabled */
127 if ((((EnumContext->lpqsRestrictions->dwNameSpace == NamespaceId) ||
128 (EnumContext->lpqsRestrictions->dwNameSpace == NS_ALL)) &&
129 (!(EnumContext->lpqsRestrictions->dwNumberOfProtocols) ||
130 (WsNcMatchProtocols(NamespaceId,
131 Entry->AddressFamily,
132 EnumContext->lpqsRestrictions)))) &&
133 (Entry->Enabled))
134 {
135 /* Get the provider */
136 if (!(Provider = Entry->Provider))
137 {
138 /* None was loaded, load it */
139 if (WsNcLoadProvider(EnumContext->Catalog, Entry) != ERROR_SUCCESS)
140 {
141 /* Return TRUE to continue enumerating */
142 return TRUE;
143 }
144
145 /* Set the provider */
146 Provider = Entry->Provider;
147 }
148
149 /* Add it to the query */
150 if (!WsNqAddProvider(NsQuery, Provider))
151 {
152 /* We failed */
153 EnumContext->ErrorCode = WSASYSCALLFAILURE;
154 GoOn = FALSE;
155 }
156 }
157
158 /* Return to caller */
159 return GoOn;
160}
struct _ENUM_CONTEXT * PENUM_CONTEXT
#define NS_ALL
Definition: nspapi.h:8
BOOL WSAAPI WsNqAddProvider(IN PNSQUERY Query, IN PNS_PROVIDER Provider)
Definition: nsquery.c:552
PNSCATALOG Catalog
Definition: ws2_32p.h:211
PNSQUERY NsQuery
Definition: ws2_32p.h:210
INT ErrorCode
Definition: ws2_32p.h:209
LPWSAQUERYSETW lpqsRestrictions
Definition: ws2_32p.h:208
BOOL WSAAPI WsNcMatchProtocols(IN DWORD NameSpace, IN LONG AddressFamily, IN LPWSAQUERYSETW QuerySet)
Definition: nscatalo.c:561
INT WSAAPI WsNcLoadProvider(IN PNSCATALOG Catalog, IN PNSCATALOG_ENTRY CatalogEntry)
Definition: nscatalo.c:400

Referenced by WsNqLookupServiceBegin().

◆ WsNqDelete()

VOID WSAAPI WsNqDelete ( IN PNSQUERY  NsQuery)

Definition at line 74 of file nsquery.c.

75{
78
79 /* Make sure that we got initialized */
80 if (!NsQuery->ProviderList.Flink) return;
81
82 /* Loop the provider list */
83 while (!IsListEmpty(&NsQuery->ProviderList))
84 {
85 /* Remove the entry */
86 Entry = RemoveHeadList(&NsQuery->ProviderList);
87
88 /* Get the provider */
90
91 /* Delete it */
93 }
94
95 /* Remove the signature and delete the lock */
96 NsQuery->Signature = ~0xBEADFACE;
97 DeleteCriticalSection(&NsQuery->Lock);
98
99 /* Free us */
100 HeapFree(WsSockHeap, 0, NsQuery);
101}
VOID WSAAPI WsNqProvDelete(IN PNSQUERY_PROVIDER QueryProvider)
Definition: nsprovid.c:45

Referenced by WSALookupServiceBeginW(), and WsNqDereference().

◆ WsNqDereference()

VOID WSAAPI WsNqDereference ( IN PNSQUERY  Query)

Definition at line 105 of file nsquery.c.

106{
107 /* Decrease the reference count and check if it's zero */
108 if (!InterlockedDecrement(&Query->RefCount))
109 {
110 /* Delete us*/
112 }
113}
VOID WSAAPI WsNqDelete(IN PNSQUERY NsQuery)
Definition: nsquery.c:74

Referenced by WSALookupServiceEnd(), and WSALookupServiceNextW().

◆ WsNqInitialize()

DWORD WSAAPI WsNqInitialize ( IN PNSQUERY  NsQuery)

Definition at line 42 of file nsquery.c.

43{
44 /* Initialize the lock */
46
47 /* Set initial reference count and signature */
48 Query->RefCount = 1;
49 Query->Signature = 0xBEADFACE;
50
51 /* Return success */
52 return ERROR_SUCCESS;
53}

Referenced by WSALookupServiceBeginW().

◆ WsNqLookupServiceBegin()

DWORD WSAAPI WsNqLookupServiceBegin ( IN PNSQUERY  NsQuery,
IN LPWSAQUERYSETW  QuerySet,
IN DWORD  ControlFlags,
IN PNSCATALOG  Catalog 
)

Definition at line 347 of file nsquery.c.

351{
352 WSASERVICECLASSINFOW ClassInfo;
353 LPWSASERVICECLASSINFOW pClassInfo = &ClassInfo;
354 PNSQUERY_PROVIDER Provider, NextProvider;
357 DWORD ClassInfoSize;
358 PNSCATALOG_ENTRY CatalogEntry = NULL;
359 ENUM_CONTEXT EnumContext;
361
362 /* Check for RAS Auto-dial attempt */
363 if (NsQuery->TryAgain)
364 {
365 /* Make a copy of the query set */
366 ErrorCode = CopyQuerySetW(Restrictions, &NsQuery->QuerySet);
368
369 /* Check if we'll try again */
370 if (!TryAgain)
371 {
372 /* We won't, fail */
375 NsQuery->TryAgain = FALSE;
376 goto Exit;
377 }
378
379 /* Cache the information for a restart */
380 NsQuery->ControlFlags = ControlFlags;
381 NsQuery->Catalog = Catalog;
382 }
383
384 /* Check if we have a specific ID */
385 if (Restrictions->lpNSProviderId)
386 {
387 /* Get the catalog entry */
389 Restrictions->lpNSProviderId,
390 &CatalogEntry);
391 /* Check for failure */
393 {
394 /* Fail */
397 goto Exit;
398 }
399 /* We succeeded, add this provider */
400 else if (!WsNqAddProvider(NsQuery, CatalogEntry->Provider))
401 {
402 /* Fail */
405 goto Exit;
406 }
407 }
408 else
409 {
410 /* Setup the lookup context */
411 EnumContext.lpqsRestrictions = Restrictions;
412 EnumContext.ErrorCode = ERROR_SUCCESS;
413 EnumContext.NsQuery = NsQuery;
414 EnumContext.Catalog = Catalog;
415
416 /* Do a lookup for every entry */
419 &EnumContext);
420 ErrorCode = EnumContext.ErrorCode;
421
422 /* Check for success */
424 {
425 /* Fail */
428 goto Exit;
429 }
430 }
431
432 /* Get the class information */
433 ClassInfo.lpServiceClassId = Restrictions->lpServiceClassId;
434 ErrorCode = WsNcGetServiceClassInfo(Catalog, &ClassInfoSize, pClassInfo);
435
436 /* Check if more buffer space is needed */
437 if ((ErrorCode == SOCKET_ERROR) && (GetLastError() == WSAEFAULT))
438 {
439 /* FIXME: The WS 2.2 spec hasn't been finalized yet on this... */
440 }
441 else
442 {
443 /* Assume success */
445 }
446
447 /* Check if the provider list is empty */
448 if (IsListEmpty(&NsQuery->ProviderList))
449 {
450 /* We don't have any providers to handle this! */
453 goto Exit;
454 }
455
456 /* Get the first provider and loop */
457 Entry = NsQuery->ProviderList.Flink;
458 NextProvider = CONTAINING_RECORD(Entry, NSQUERY_PROVIDER, QueryLink);
459 while (NextProvider)
460 {
461 /* Call it */
463 Restrictions,
464 pClassInfo,
465 ControlFlags);
466 /* Check for error */
467 if (ErrorCode == SOCKET_ERROR)
468 {
469 /* Remove this provider, get the next one, delete the old one */
470 Provider = NextProvider;
471 NextProvider = WsNqNextProvider(NsQuery, NextProvider);
472 RemoveEntryList(&Provider->QueryLink);
474 }
475 else
476 {
477 /* Get the next provider */
478 NextProvider = WsNqNextProvider(NsQuery, NextProvider);
479 }
480 }
481
482Exit:
483 /* Check if we had an error somewhere */
484 if (ErrorCode == SOCKET_ERROR)
485 {
486 /* Loop the list */
487 while (!IsListEmpty(&NsQuery->ProviderList))
488 {
489 /* Remove this provider */
490 Entry = RemoveHeadList(&NsQuery->ProviderList);
491
492 /* Get the failed provider and delete it */
495 }
496 }
497 else
498 {
499 /* Set the active provider */
500 Entry = NsQuery->ProviderList.Flink;
501 NsQuery->ActiveProvider = CONTAINING_RECORD(Entry,
503 QueryLink);
504 }
505
506 /* Return */
507 return ErrorCode;
508}
@ TryAgain
Definition: bl.h:896
PNSQUERY_PROVIDER WSAAPI WsNqNextProvider(IN PNSQUERY Query, IN PNSQUERY_PROVIDER Provider)
Definition: nsquery.c:512
BOOL WSAAPI WsNqBeginEnumerationProc(PVOID Context, PNSCATALOG_ENTRY Entry)
Definition: nsquery.c:117
PNS_PROVIDER Provider
Definition: ws2_32p.h:125
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
#define WSASERVICE_NOT_FOUND
Definition: winerror.h:1995
INT WSAAPI WsNcGetCatalogFromProviderId(IN PNSCATALOG Catalog, IN LPGUID ProviderId, OUT PNSCATALOG_ENTRY *CatalogEntry)
Definition: nscatalo.c:517
INT WSAAPI CopyQuerySetW(IN LPWSAQUERYSETW UnicodeSet, OUT LPWSAQUERYSETW *UnicodeCopy)
Definition: qshelpr.c:1050
INT WSAAPI WsNcGetServiceClassInfo(IN PNSCATALOG Catalog, IN OUT LPDWORD BugSize, IN OUT LPWSASERVICECLASSINFOW lpServiceClassInfo)
Definition: nscatalo.c:444
VOID WSAAPI WsNcEnumerateCatalogItems(IN PNSCATALOG Catalog, IN PNSCATALOG_ENUMERATE_PROC Callback, IN PVOID Context)
Definition: nscatalo.c:371
DWORD WSAAPI WsNqProvLookupServiceBegin(IN PNSQUERY_PROVIDER QueryProvider, IN LPWSAQUERYSETW QuerySet, IN LPWSASERVICECLASSINFOW ServiceClassInfo, IN DWORD)
Definition: nsprovid.c:216

Referenced by WSALookupServiceBeginW(), and WsNqLookupServiceNext().

◆ WsNqLookupServiceEnd()

DWORD WSAAPI WsNqLookupServiceEnd ( IN PNSQUERY  NsQuery)

Definition at line 164 of file nsquery.c.

165{
168
169 /* Protect us from closure */
170 WsNqLock();
171 NsQuery->ShuttingDown = TRUE;
172
173 /* Get the list and loop */
174 Entry = NsQuery->ProviderList.Flink;
175 while (Entry != &NsQuery->ProviderList)
176 {
177 /* Get the provider */
179
180 /* Call its routine */
182
183 /* Move to the next one */
184 Entry = Entry->Flink;
185 }
186
187 /* Release lock and return success */
188 WsNqUnlock();
189 return ERROR_SUCCESS;
190}
#define WsNqUnlock()
Definition: nsquery.c:16
#define WsNqLock()
Definition: nsquery.c:15
DWORD WSAAPI WsNqProvLookupServiceEnd(IN PNSQUERY_PROVIDER QueryProvider)
Definition: nsprovid.c:192

Referenced by WSALookupServiceEnd().

◆ WsNqLookupServiceNext()

DWORD WSAAPI WsNqLookupServiceNext ( PNSQUERY  NsQuery,
DWORD  ,
PDWORD  ,
OUT LPWSAQUERYSETW  QuerySet 
)

Referenced by WSALookupServiceNextW().

◆ WsNqNextProvider()

PNSQUERY_PROVIDER WSAAPI WsNqNextProvider ( PNSQUERY  NsQuery,
IN PNSQUERY_PROVIDER  Provider 
)

◆ WsNqPreviousProvider()

PNSQUERY_PROVIDER WSAAPI WsNqPreviousProvider ( IN PNSQUERY  Query,
IN PNSQUERY_PROVIDER  Provider 
)

Definition at line 532 of file nsquery.c.

534{
535 PNSQUERY_PROVIDER PrevProvider = NULL;
537
538 /* Get the last entry and get its provider */
539 Entry = Provider->QueryLink.Blink;
540 if (Entry != &Query->ProviderList)
541 {
542 /* Get the current provider */
543 PrevProvider = CONTAINING_RECORD(Entry, NSQUERY_PROVIDER, QueryLink);
544 }
545
546 /* Return it */
547 return PrevProvider;
548}

Referenced by WsNqLookupServiceNext().

◆ WsNqProvAllocate()

PNSQUERY_PROVIDER WSAAPI WsNqProvAllocate ( VOID  )

Definition at line 17 of file nsprovid.c.

18{
20
21 /* Allocate the object */
23
24 /* Return it */
25 return Provider;
26}

Referenced by WsNqAddProvider().

◆ WsNqProvDelete()

VOID WSAAPI WsNqProvDelete ( IN PNSQUERY_PROVIDER  QueryProvider)

Definition at line 45 of file nsprovid.c.

46{
47 /* Check if we have a provider */
48 if (QueryProvider->Provider)
49 {
50 /* Dereference it */
51 WsNpDereference(QueryProvider->Provider);
52
53 /* Clear it */
54 QueryProvider->Provider = NULL;
55 }
56
57 /* Delete us */
58 HeapFree(WsSockHeap, 0, QueryProvider);
59}
VOID WSAAPI WsNpDereference(IN PNS_PROVIDER Provider)
Definition: nsprovid.c:180

Referenced by WsNqDelete(), WsNqLookupServiceBegin(), and WsNqLookupServiceNext().

◆ WsNqProvInitialize()

DWORD WSAAPI WsNqProvInitialize ( IN PNSQUERY_PROVIDER  QueryProvider,
IN PNS_PROVIDER  Provider 
)

Definition at line 30 of file nsprovid.c.

32{
33 /* Reference the provider */
35
36 /* Set it as our own */
37 QueryProvider->Provider = Provider;
38
39 /* Return success */
40 return ERROR_SUCCESS;
41}

Referenced by WsNqAddProvider().

◆ WsNqProvLookupServiceBegin()

DWORD WSAAPI WsNqProvLookupServiceBegin ( IN PNSQUERY_PROVIDER  QueryProvider,
IN LPWSAQUERYSETW  QuerySet,
IN LPWSASERVICECLASSINFOW  ServiceClassInfo,
IN  DWORD 
)

Definition at line 216 of file nsprovid.c.

220{
221 /* Simply call the provider */
222 return WsNpLookupServiceBegin(QueryProvider->Provider,
223 Restrictions,
224 ServiceClassInfo,
225 ControlFlags,
226 &QueryProvider->LookupHandle);
227}
DWORD WSAAPI WsNpLookupServiceBegin(IN PNS_PROVIDER Provider, IN LPWSAQUERYSETW Restrictions, IN LPWSASERVICECLASSINFOW ServiceClassInfo, IN DWORD ControlFlags, OUT PHANDLE LookupHandle)
Definition: nsprovid.c:255

Referenced by WsNqLookupServiceBegin().

◆ WsNqProvLookupServiceEnd()

DWORD WSAAPI WsNqProvLookupServiceEnd ( IN PNSQUERY_PROVIDER  QueryProvider)

Definition at line 192 of file nsprovid.c.

193{
194 /* Simply call the provider */
195 return WsNpLookupServiceEnd(QueryProvider->Provider,
196 QueryProvider->LookupHandle);
197}
DWORD WSAAPI WsNpLookupServiceEnd(IN PNS_PROVIDER Provider, IN HANDLE LookupHandle)
Definition: nsprovid.c:231

Referenced by WsNqLookupServiceEnd(), and WsNqLookupServiceNext().

◆ WsNqProvLookupServiceNext()

DWORD WSAAPI WsNqProvLookupServiceNext ( IN PNSQUERY_PROVIDER  QueryProvider,
DWORD  ,
PDWORD  ,
LPWSAQUERYSETW  QuerySet 
)

Referenced by WsNqLookupServiceNext().

◆ WsNqValidateAndReference()

BOOL WSAAPI WsNqValidateAndReference ( IN PNSQUERY  Query)

Definition at line 57 of file nsquery.c.

58{
59 /* Check the signature first */
60 if (Query->Signature != 0xBEADFACE) return FALSE;
61
62 /* Validate the reference count */
63 if (!Query->RefCount) return FALSE;
64
65 /* Increase reference count */
66 InterlockedIncrement(&Query->RefCount);
67
68 /* Return success */
69 return TRUE;
70}

Referenced by WSALookupServiceEnd(), and WSALookupServiceNextW().

◆ 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 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
_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 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().

◆ WsProcDelete()

VOID WSAAPI WsProcDelete ( IN PWSPROCESS  Process)

Definition at line 247 of file dprocess.c.

248{
249 /* Check if we didn't even initialize yet */
250 if (!Process->LockReady) return;
251
252 /* No more current process */
254
255 /* If we have a socket table */
257 {
258 /* Enumerate the sockets with a delete callback */
261 Process);
262 }
263
264 /* Close APC Helper */
265 if (Process->ApcHelper) WahCloseApcHelper(Process->ApcHelper);
266
267 /* Close handle helper */
268 if (Process->HandleHelper) WahCloseHandleHelper(Process->HandleHelper);
269
270 /* Check for notification helper */
271 if (Process->NotificationHelper)
272 {
273 /* Close notification helper */
274 WahCloseNotificationHandleHelper(Process->NotificationHelper);
275 }
276
277 /* Check if we have a protocol catalog*/
278 if (Process->ProtocolCatalog)
279 {
280 /* Enumerate it to clean it up */
281 WsTcEnumerateCatalogItems(Process->ProtocolCatalog,
283 NULL);
284
285 /* Delete it */
286 WsTcDelete(Process->ProtocolCatalog);
287 Process->ProtocolCatalog = NULL;
288 }
289
290 /* Check if we have a namespace catalog*/
291 if (Process->NamespaceCatalog)
292 {
293 /* Enumerate it to clean it up */
294 WsNcEnumerateCatalogItems(Process->NamespaceCatalog,
296 NULL);
297
298 /* Delete it */
299 WsNcDelete(Process->NamespaceCatalog);
300 Process->NamespaceCatalog = NULL;
301 }
302
303 /* Delete the thread lock */
304 DeleteCriticalSection(&Process->ThreadLock);
305
306 /* Delete us */
308}
DWORD WINAPI WahCloseApcHelper(IN HANDLE ApcHelperHandle)
Definition: apc.c:42
BOOL WINAPI WahEnumerateHandleContexts(IN PWAH_HANDLE_TABLE Table, IN PWAH_HANDLE_ENUMERATE_PROC Callback, IN PVOID Context)
Definition: context.c:280
DWORD WINAPI WahCloseHandleHelper(IN HANDLE HelperHandle)
Definition: handle.c:86
DWORD WINAPI WahCloseNotificationHandleHelper(IN HANDLE HelperHandle)
Definition: notify.c:22
BOOL WSAAPI CleanupNamespaceProviders(IN PVOID Callback, IN PNSCATALOG_ENTRY Entry)
Definition: dprocess.c:208
PWSPROCESS CurrentWsProcess
Definition: dprocess.c:15
BOOL WSAAPI CleanupProtocolProviders(IN PVOID Callback, IN PTCATALOG_ENTRY Entry)
Definition: dprocess.c:227
VOID WSAAPI WsNcDelete(IN PNSCATALOG Catalog)
Definition: nscatalo.c:624
VOID WSAAPI WsTcEnumerateCatalogItems(IN PTCATALOG Catalog, IN PTCATALOG_ENUMERATE_PROC Callback, IN PVOID Context)
Definition: dcatalog.c:750
PWAH_HANDLE_TABLE WsSockHandleTable
Definition: dsocket.c:15
BOOL WSAAPI WsSockDeleteSockets(IN LPVOID Context, IN PWAH_HANDLE Handle)
Definition: dsocket.c:180
VOID WSAAPI WsTcDelete(IN PTCATALOG Catalog)
Definition: dcatalog.c:883

Referenced by DllMain(), and WSACleanup().

◆ WsProcDetachSocket()

BOOL WSAAPI WsProcDetachSocket ( IN PWSPROCESS  Process,
IN PWAH_HANDLE  Handle 
)

Definition at line 182 of file dprocess.c.

184{
185 PWSSOCKET Socket = (PWSSOCKET)Handle;
186
187 /* Disassociate this socket from the table */
189
190 /* If this is isn't an IFS socket */
191 if (!Socket->Provider)
192 {
193 /* Check if we have an active handle helper */
194 if (Process->HandleHelper)
195 {
196 /* Close it */
197 WahCloseSocketHandle(Process->HandleHelper, (SOCKET)Socket->Handle);
198 }
199 }
200
201 /* Remove a reference and return */
202 WsSockDereference(Socket);
203 return TRUE;
204}
DWORD WINAPI WahRemoveHandleContext(IN PWAH_HANDLE_TABLE Table, IN PWAH_HANDLE Handle)
Definition: context.c:564
DWORD WINAPI WahCloseSocketHandle(IN HANDLE HelperHandle, IN SOCKET Socket)
Definition: handle.c:113
ULONG Handle
Definition: gdb_input.c:15
PTPROVIDER Provider
Definition: ws2_32p.h:199
HANDLE Handle
Definition: ws2_32p.h:197
UINT_PTR SOCKET
Definition: winsock.h:47
struct _WSSOCKET * PWSSOCKET
VOID WSAAPI WsSockDereference(IN PWSSOCKET Socket)
Definition: dsocket.c:205

Referenced by WsSockDeleteSockets().

◆ WsProcGetAsyncHelper()

INT WSAAPI WsProcGetAsyncHelper ( IN PWSPROCESS  Process,
OUT PHANDLE  Handle 
)

Definition at line 107 of file dprocess.c.

109{
110 /* Check if we have it already set up */
111 if (Process->ApcHelper)
112 {
113 /* Just return it */
114 *Handle = Process->ApcHelper;
115 return ERROR_SUCCESS;
116 }
117 else
118 {
119 /* Open it for the first time */
121 }
122}
INT WSAAPI WsProcOpenAsyncHelperDevice(IN PWSPROCESS Process, OUT PHANDLE Handle)
Definition: dprocess.c:83

Referenced by WsThreadInitialize().

◆ WsProcGetNsCatalog()

PNSCATALOG WSAAPI WsProcGetNsCatalog ( IN PWSPROCESS  Process)

Definition at line 166 of file dprocess.c.

167{
168 /* Check if the catalogs have been modified */
169 if (WsCheckCatalogState(Process->NamespaceCatalogEvent))
170 {
171 /* Modification happened, reload them */
172 WsNcRefreshFromRegistry(Process->NamespaceCatalog,
173 Process->NamespaceCatalogEvent);
174 }
175
176 /* Return it */
177 return Process->NamespaceCatalog;
178}
INT WSAAPI WsNcRefreshFromRegistry(IN PNSCATALOG Catalog, IN HANDLE CatalogEvent)
Definition: nscatalo.c:230

Referenced by WSAEnumNameSpaceProvidersInternal(), WSALookupServiceBeginW(), and WSCGetProviderPath().

◆ WsProcGetTCatalog()

PTCATALOG WSAAPI WsProcGetTCatalog ( IN PWSPROCESS  Process)

Definition at line 150 of file dprocess.c.

151{
152 /* Check if the catalogs have been modified */
153 if (WsCheckCatalogState(Process->ProtocolCatalogEvent))
154 {
155 /* Modification happened, reload them */
156 WsTcRefreshFromRegistry(Process->ProtocolCatalog,
157 Process->ProtocolCatalogEvent);
158 }
159
160 /* Return it */
161 return Process->ProtocolCatalog;
162}
DWORD WSAAPI WsTcRefreshFromRegistry(IN PTCATALOG TCatalog, PVOID)

Referenced by WPUModifyIFSHandle(), WPUQueryBlockingCallback(), WSAAddressToStringA(), WSAAddressToStringW(), WSASocketW(), WSAStringToAddressA(), WSAStringToAddressW(), and WsSockFindIfsSocket().

◆ WsProcSetVersion()

VOID WSAAPI WsProcSetVersion ( IN PWSPROCESS  Process,
IN WORD  VersionRequested 
)

Definition at line 312 of file dprocess.c.

314{
315 WORD Major, Minor;
316 WORD OldMajor, OldMinor;
317
318 /* Get the version data */
319 Major = LOBYTE(VersionRequested);
320 Minor = HIBYTE(VersionRequested);
321 OldMajor = LOBYTE(Process->Version);
322 OldMinor = HIBYTE(Process->Version);
323
324 /* Check if we're going lower */
325 if ((Major < OldMajor) || ((Major == OldMajor) && (Minor < OldMinor)))
326 {
327 /* Set the new version */
328 Process->Version = VersionRequested;
329 }
330}
unsigned short WORD
Definition: ntddk_ex.h:93
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44

Referenced by WSAStartup().

◆ WsProcStartup()

INT WSAAPI WsProcStartup ( VOID  )

Definition at line 126 of file dprocess.c.

127{
129
130 /* Create a new process */
132
133 /* Initialize it */
135 {
136 /* Initialize the process */
138 }
139 else
140 {
141 /* No memory for the process object */
143 }
144
145 return ErrorCode;
146}
INT WSAAPI WsProcInitialize(IN PWSPROCESS Process)
Definition: dprocess.c:24
PWSPROCESS WSAAPI WsProcAllocate(VOID)
Definition: dprocess.c:65

Referenced by WSAStartup().

◆ WsQuickProlog()

FORCEINLINE DWORD WsQuickProlog ( VOID  )

Definition at line 892 of file ws2_32p.h.

893{
894 /* Try to see if we're initialized. If not, do the full prolog */
896}
INT WSAAPI WsSlowProlog(VOID)
Definition: wsautil.c:109

Referenced by bind(), closesocket(), getaddrinfo(), getnameinfo(), getpeername(), getsockname(), listen(), select(), shutdown(), WSAAsyncSelect(), WSAConnect(), WSADuplicateSocketW(), WSAEnumNetworkEvents(), WSAEventSelect(), WSAGetOverlappedResult(), WSAGetQOSByName(), WSAHtonl(), WSAHtons(), WSANtohl(), and WSANtohs().

◆ WsQuickPrologTid()

FORCEINLINE DWORD WsQuickPrologTid ( LPWSATHREADID Tid)

Definition at line 900 of file ws2_32p.h.

901{
902 /* Try to see if we're initialized. If not, do the full prolog */
903 if ((WsGetProcess()) && (*Tid = WsThreadGetThreadId(WsGetProcess())))
904 {
905 return ERROR_SUCCESS;
906 }
907 else
908 {
909 return WsSlowPrologTid(Tid);
910 }
911}
LPWSATHREADID WSAAPI WsThreadGetThreadId(IN PWSPROCESS Process)
Definition: dthread.c:297
INT WSAAPI WsSlowPrologTid(OUT LPWSATHREADID *ThreadId)
Definition: wsautil.c:120

Referenced by recv(), recvfrom(), send(), sendto(), WSAIoctl(), WSARecv(), WSARecvFrom(), WSASend(), and WSASendTo().

◆ WsRasInitializeAutodial()

VOID WSAAPI WsRasInitializeAutodial ( VOID  )

Definition at line 47 of file rasdial.c.

48{
49 /* Initialize the autodial lock */
51}
CRITICAL_SECTION WsRasHelperLock
Definition: rasdial.c:35

Referenced by DllMain().

◆ WsRasUninitializeAutodial()

VOID WSAAPI WsRasUninitializeAutodial ( VOID  )

Definition at line 55 of file rasdial.c.

56{
57 /* Acquire lock */
58 WsRasLock();
59
60 /* Free the library if it's loaded */
63
64 /* Release and delete lock */
67}
HINSTANCE WsRasDllHandle
Definition: rasdial.c:34
#define WsRasUnlock()
Definition: rasdial.c:41
#define WsRasLock()
Definition: rasdial.c:40

Referenced by DllMain().

◆ 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}
LONG WINAPI RegNotifyChangeKeyValue(HKEY hKey, BOOL bWatchSubtree, DWORD dwNotifyFilter, HANDLE hEvent, BOOL fAsynchronous)
Definition: reg.c:3175
#define ERROR_KEY_DELETED
Definition: winerror.h:597
#define WSANO_RECOVERY
Definition: winerror.h:2002
#define REG_NOTIFY_CHANGE_NAME
Definition: winreg.h:38

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().

◆ WsSockAddApiReference()

INT WSAAPI WsSockAddApiReference ( IN SOCKET  Handle)

Definition at line 159 of file dsocket.c.

160{
161 PWSSOCKET Socket;
162
163 /* Get the Socket now */
164 if ((Socket = WsSockGetSocketNoExport(Handle)))
165 {
166 /* Mark it as an API Socket */
167 if (Socket) Socket->ApiSocket = TRUE;
168
169 /* Remove a reference and return */
170 WsSockDereference(Socket);
171 return ERROR_SUCCESS;
172 }
173
174 /* Return error */
175 return WSASYSCALLFAILURE;
176}
PWSSOCKET WSAAPI WsSockGetSocketNoExport(IN SOCKET Handle)
Definition: dsocket.c:92
VOID WSAAPI WsSockDereference(IN PWSSOCKET Socket)
Definition: dsocket.c:205
BOOLEAN ApiSocket
Definition: ws2_32p.h:202

Referenced by WSAAccept(), WSAJoinLeaf(), and WSASocketW().

◆ WsSockAllocate()

PWSSOCKET WSAAPI WsSockAllocate ( VOID  )

Definition at line 48 of file dsocket.c.

49{
50 PWSSOCKET Socket;
51
52 /* Allocate the socket object */
53 Socket = HeapAlloc(WsSockHeap, HEAP_ZERO_MEMORY, sizeof(*Socket));
54 if (Socket)
55 {
56 /* Setup default non-zero values */
57 Socket->RefCount = 2;
58 Socket->Overlapped = TRUE;
59 }
60
61 /* Return it */
62 return Socket;
63}
LONG RefCount
Definition: ws2_32p.h:196
BOOLEAN Overlapped
Definition: ws2_32p.h:201

Referenced by WPUModifyIFSHandle().

◆ WsSockAssociateHandle()

INT WSAAPI WsSockAssociateHandle ( IN PWSSOCKET  Socket,
IN SOCKET  Handle,
IN BOOLEAN  IsProvider 
)

Definition at line 225 of file dsocket.c.

228{
230 PWSSOCKET OldSocket;
231
232 /* Save the socket and provider */
233 Socket->IsProvider = IsProvider;
234 Socket->Handle = (HANDLE)Handle;
235
236 /* Insert it into the handle table */
238 (PWAH_HANDLE)Socket);
239
240 /* Check if a socket already existed */
241 if (OldSocket != Socket)
242 {
243 /* We'll dereference it */
244 WsSockDereference(OldSocket);
245 }
246 else if (!OldSocket)
247 {
248 /* No memory to allocate it */
250 }
251
252 /* Return */
253 return ErrorCode;
254}
PWAH_HANDLE WINAPI WahInsertHandleContext(IN PWAH_HANDLE_TABLE Table, IN PWAH_HANDLE Handle)
Definition: context.c:336
PWAH_HANDLE_TABLE WsSockHandleTable
Definition: dsocket.c:15
BOOLEAN IsProvider
Definition: ws2_32p.h:203
PVOID HANDLE
Definition: typedefs.h:73
#define WSAENOBUFS
Definition: winerror.h:1968

Referenced by WPUModifyIFSHandle().

◆ WsSockCleanup()

VOID WSAAPI WsSockCleanup ( VOID  )

Definition at line 36 of file dsocket.c.

37{
38 /* Check if we have a socket table */
40 {
41 /* Destroy it */
43 }
44}
DWORD WINAPI WahDestroyHandleContextTable(IN PWAH_HANDLE_TABLE Table)
Definition: context.c:246

Referenced by DllMain().

◆ WsSockDeleteSockets()

BOOL WSAAPI WsSockDeleteSockets ( IN LPVOID  Context,
IN PWAH_HANDLE  Handle 
)

Definition at line 180 of file dsocket.c.

182{
183 /* Call the detach routine */
185}
BOOL WSAAPI WsProcDetachSocket(IN PWSPROCESS Process, IN PWAH_HANDLE Handle)
Definition: dprocess.c:182

Referenced by WsProcDelete().

◆ WsSockDereference()

◆ WsSockDisassociateHandle()

INT WSAAPI WsSockDisassociateHandle ( IN PWSSOCKET  Socket)

Definition at line 217 of file dsocket.c.

218{
219 /* Remove it from the list */
221}

Referenced by closesocket().

◆ WsSockGetSocket()

PWSSOCKET WSAAPI WsSockGetSocket ( IN SOCKET  Handle)

Definition at line 140 of file dsocket.c.

141{
142 PWSSOCKET Socket;
143
144 /* Let WAH do the translation */
145 if ((WsSockHandleTable != NULL) &&
147 {
148 return Socket;
149 }
150 else
151 {
152 /* WAH didn't find it, use IFS */
154 }
155}
PWAH_HANDLE WINAPI WahReferenceContextByHandle(IN PWAH_HANDLE_TABLE Table, IN HANDLE Handle)
Definition: context.c:524
PWSSOCKET WSAAPI WsSockFindIfsSocket(IN SOCKET Handle)
Definition: dsocket.c:101

Referenced by bind(), closesocket(), connect(), getpeername(), getsockname(), getsockopt(), listen(), recv(), recvfrom(), select(), send(), sendto(), setsockopt(), shutdown(), WSAAccept(), WSAAsyncSelect(), WSAConnect(), WSADuplicateSocketW(), WSAEnumNetworkEvents(), WSAEventSelect(), WSAGetOverlappedResult(), WSAGetQOSByName(), WSAHtonl(), WSAHtons(), WSAIoctl(), WSAJoinLeaf(), WSANtohl(), WSANtohs(), WSARecv(), WSARecvDisconnect(), WSARecvFrom(), WSASend(), WSASendDisconnect(), and WSASendTo().

◆ WsSockInitialize()

INT WSAAPI WsSockInitialize ( IN PWSSOCKET  Socket,
IN PTCATALOG_ENTRY  CatalogEntry 
)

Definition at line 67 of file dsocket.c.

69{
70 PWSTHREAD CurrentThread;
71
72 /* Associate this catalog and reference it */
73 Socket->CatalogEntry = CatalogEntry;
74 InterlockedIncrement(&CatalogEntry->RefCount);
75
76 /* Associate the Provider and Process Objects */
77 Socket->Provider = CatalogEntry->Provider;
78
79 /* Get the current Thread Object */
80 if ((CurrentThread = TlsGetValue(TlsIndex)))
81 {
82 /* Set the overlapped mode */
83 Socket->Overlapped = (CurrentThread->OpenType == 0);
84 }
85
86 /* Return status */
87 return ERROR_SUCCESS;
88}
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1240
DWORD OpenType
Definition: ws2_32p.h:190
#define TlsIndex
Definition: ws2_32p.h:277

Referenced by WPUModifyIFSHandle().

◆ WsSockStartup()

INT WSAAPI WsSockStartup ( VOID  )

Definition at line 21 of file dsocket.c.

22{
23 /* Check if we have a socket table */
25 {
26 /* Create it */
28 }
29
30 /* Nothing to do */
31 return NO_ERROR;
32}
DWORD WINAPI WahCreateHandleContextTable(OUT PWAH_HANDLE_TABLE *Table)
Definition: context.c:189

Referenced by WSAStartup().

◆ WsTcAllocate()

PTCATALOG WSAAPI WsTcAllocate ( VOID  )

Definition at line 25 of file dcatalog.c.

26{
27 PTCATALOG Catalog;
28
29 /* Allocate the object */
30 Catalog = HeapAlloc(WsSockHeap, HEAP_ZERO_MEMORY, sizeof(*Catalog));
31
32 /* Return it */
33 return Catalog;
34}

Referenced by OpenInitializedCatalog(), and WsProcInitialize().

◆ WsTcDelete()

VOID WSAAPI WsTcDelete ( IN PTCATALOG  Catalog)

Definition at line 883 of file dcatalog.c.

884{
886 PTCATALOG_ENTRY CatalogEntry;
887
888 /* Check if we're initialized */
889 if (!Catalog->ProtocolList.Flink) return;
890
891 /* Acquire lock */
892 WsTcLock();
893
894 /* Loop every entry */
895 Entry = Catalog->ProtocolList.Flink;
896 while (Entry != &Catalog->ProtocolList)
897 {
898 /* Get this entry */
899 CatalogEntry = CONTAINING_RECORD(Entry, TCATALOG_ENTRY, CatalogLink);
900
901 /* Remove it and dereference it */
902 WsTcRemoveCatalogItem(Catalog, CatalogEntry);
903 WsTcEntryDereference(CatalogEntry);
904
905 /* Move to the next entry */
906 Entry = Catalog->ProtocolList.Flink;
907 }
908
909 /* Check if the catalog key is opened */
910 if (Catalog->CatalogKey)
911 {
912 /* Close it */
913 RegCloseKey(Catalog->CatalogKey);
914 Catalog->CatalogKey = NULL;
915 }
916
917 /* Release and delete the lock */
918 WsTcUnlock();
919 DeleteCriticalSection(&Catalog->Lock);
920
921 /* Delete the object */
922 HeapFree(WsSockHeap, 0, Catalog);
923}
VOID WSAAPI WsTcRemoveCatalogItem(IN PTCATALOG Catalog, IN PTCATALOG_ENTRY Entry)
Definition: dcatalog.c:871
#define WsTcUnlock()
Definition: dcatalog.c:19
#define WsTcLock()
Definition: dcatalog.c:18
Definition: ws2_32p.h:86
VOID WSAAPI WsTcEntryDereference(IN PTCATALOG_ENTRY CatalogEntry)
Definition: dcatitem.c:51

Referenced by WSCEnumProtocols(), and WsProcDelete().

◆ WsTcEntryAllocate()

PTCATALOG_ENTRY WSAAPI WsTcEntryAllocate ( VOID  )

Definition at line 17 of file dcatitem.c.

18{
19 PTCATALOG_ENTRY CatalogEntry;
20
21 /* Allocate the catalog entry */
22 CatalogEntry = HeapAlloc(WsSockHeap, HEAP_ZERO_MEMORY, sizeof(*CatalogEntry));
23 if (CatalogEntry)
24 {
25 /* Set the default non-null members */
26 CatalogEntry->RefCount = 1;
27 }
28
29 /* Return it */
30 return CatalogEntry;
31}
LONG RefCount
Definition: ws2_32p.h:88

Referenced by WsTcRefreshFromRegistry().

◆ WsTcEntryDelete()

VOID WSAAPI WsTcEntryDelete ( IN PTCATALOG_ENTRY  CatalogEntry)

Definition at line 35 of file dcatitem.c.

36{
37 /* Check if a provider is loaded */
38 if (CatalogEntry->Provider)
39 {
40 /* Dereference it too */
41 WsTpDereference(CatalogEntry->Provider);
42 CatalogEntry->Provider = NULL;
43 }
44
45 /* Delete us */
46 HeapFree(WsSockHeap, 0, CatalogEntry);
47}
VOID WSAAPI WsTpDereference(IN PTPROVIDER Provider)
Definition: dprovide.c:143

Referenced by WsTcEntryDereference().

◆ WsTcEntryDereference()

VOID WSAAPI WsTcEntryDereference ( IN PTCATALOG_ENTRY  CatalogEntry)

Definition at line 51 of file dcatitem.c.

52{
53 /* Dereference and check if it's now 0 */
54 if (!(InterlockedDecrement(&CatalogEntry->RefCount)))
55 {
56 /* We can delete the Provider now */
57 WsTcEntryDelete(CatalogEntry);
58 }
59}
VOID WSAAPI WsTcEntryDelete(IN PTCATALOG_ENTRY CatalogEntry)
Definition: dcatitem.c:35

Referenced by WPUModifyIFSHandle(), WPUQueryBlockingCallback(), WSAAddressToStringA(), WSAAddressToStringW(), WSASocketW(), WSAStringToAddressA(), WSAStringToAddressW(), WsSockDelete(), WsTcDelete(), WsTcFindIfsProviderForSocket(), WsTcRefreshFromRegistry(), and WsTcUpdateProtocolList().

◆ WsTcEntryInitializeFromRegistry()

DWORD WSAAPI WsTcEntryInitializeFromRegistry ( IN PTCATALOG_ENTRY  CatalogEntry,
IN  HKEY,
unsigned long   
)

Referenced by WsTcRefreshFromRegistry().

◆ WsTcEntrySetProvider()

VOID WSAAPI WsTcEntrySetProvider ( IN PTCATALOG_ENTRY  CatalogEntry,
IN PTPROVIDER  Provider 
)

Definition at line 121 of file dcatitem.c.

123{
124 /* Reference the provider */
125 InterlockedIncrement(&Provider->RefCount);
126
127 /* Set it */
128 Entry->Provider = Provider;
129}

Referenced by WsTcLoadProvider().

◆ WsTcEnumerateCatalogItems()

VOID WSAAPI WsTcEnumerateCatalogItems ( IN PTCATALOG  Catalog,
IN PTCATALOG_ENUMERATE_PROC  Callback,
IN PVOID  Context 
)

Definition at line 750 of file dcatalog.c.

753{
755 PTCATALOG_ENTRY CatalogEntry;
756 BOOL GoOn = TRUE;
757
758 /* Lock the catalog */
759 WsTcLock();
760
761 /* Loop the entries */
762 Entry = Catalog->ProtocolList.Flink;
763 while (GoOn && (Entry != &Catalog->ProtocolList))
764 {
765 /* Get the entry */
766 CatalogEntry = CONTAINING_RECORD(Entry, TCATALOG_ENTRY, CatalogLink);
767
768 /* Move to the next one and call the callback */
769 Entry = Entry->Flink;
770 GoOn = Callback(Context, CatalogEntry);
771 }
772
773 /* Release lock */
774 WsTcUnlock();
775}

Referenced by WSCEnumProtocols(), and WsProcDelete().

◆ WsTcFindIfsProviderForSocket()

DWORD WSAAPI WsTcFindIfsProviderForSocket ( IN PTCATALOG  TCatalog,
SOCKET  Socket 
)

Referenced by WsSockFindIfsSocket().

◆ WsTcFindProvider()

PTPROVIDER WSAAPI WsTcFindProvider ( IN PTCATALOG  TCatalog,
IN LPGUID  ProviderId 
)

Definition at line 596 of file dcatalog.c.

598{
601 PTCATALOG_ENTRY CatalogEntry;
602
603 /* Loop the provider list */
604 Entry = Catalog->ProtocolList.Flink;
605 while (Entry != &Catalog->ProtocolList)
606 {
607 /* Get the entry */
608 CatalogEntry = CONTAINING_RECORD(Entry, TCATALOG_ENTRY, CatalogLink);
609
610 /* Move to the next one, get the provider */
611 Entry = Entry->Flink;
612 Provider = CatalogEntry->Provider;
613
614 /* Check for a match */
615 if (Provider &&
616 IsEqualGUID(&CatalogEntry->ProtocolInfo.ProviderId, ProviderId))
617 {
618 /* Found a match */
619 return Provider;
620 }
621 }
622
623 /* No match here */
624 return NULL;
625}
PTPROVIDER Provider
Definition: ws2_32p.h:89
WSAPROTOCOL_INFOW ProtocolInfo
Definition: ws2_32p.h:91

Referenced by WsTcLoadProvider().

◆ WsTcGetEntryFromAf()

DWORD WSAAPI WsTcGetEntryFromAf ( IN PTCATALOG  TCatalog,
IN INT  AddressFamily,
IN PTCATALOG_ENTRY CatalogEntry 
)

Definition at line 403 of file dcatalog.c.

406{
408 PLIST_ENTRY NextEntry;
410
411 /* Assume failure */
412 *CatalogEntry = NULL;
413
414 /* Lock the catalog */
415 WsTcLock();
416
417 /* Match the Id with all the entries in the List */
418 NextEntry = Catalog->ProtocolList.Flink;
419 while (NextEntry != &Catalog->ProtocolList)
420 {
421 /* Get the Current Entry */
422 Entry = CONTAINING_RECORD(NextEntry, TCATALOG_ENTRY, CatalogLink);
423 NextEntry = NextEntry->Flink;
424
425 /* Check if this is the Catalog Entry ID we want */
426 if (Entry->ProtocolInfo.iAddressFamily == AddressFamily)
427 {
428 /* Check if it doesn't already have a provider */
429 if (!Entry->Provider)
430 {
431 /* Match, load the Provider */
432 ErrorCode = WsTcLoadProvider(Catalog, Entry);
433
434 /* Make sure this didn't fail */
435 if (ErrorCode != ERROR_SUCCESS) break;
436 }
437
438 /* Reference the entry and return it */
439 InterlockedIncrement(&Entry->RefCount);
440 *CatalogEntry = Entry;
442 break;
443 }
444 }
445
446 /* Release the catalog */
447 WsTcUnlock();
448
449 /* Return */
450 return ErrorCode;
451}
DWORD WSAAPI WsTcLoadProvider(IN PTCATALOG Catalog, IN PTCATALOG_ENTRY CatalogEntry)
Definition: dcatalog.c:629

Referenced by WSAAddressToStringA(), WSAAddressToStringW(), WSAStringToAddressA(), and WSAStringToAddressW().

◆ WsTcGetEntryFromCatalogEntryId()

DWORD WSAAPI WsTcGetEntryFromCatalogEntryId ( IN PTCATALOG  TCatalog,
IN DWORD  CatalogEntryId,
IN PTCATALOG_ENTRY CatalogEntry 
)

Definition at line 455 of file dcatalog.c.

458{
460 PLIST_ENTRY NextEntry;
462
463 /* Lock the catalog */
464 WsTcLock();
465
466 /* Match the Id with all the entries in the List */
467 NextEntry = Catalog->ProtocolList.Flink;
468 while (NextEntry != &Catalog->ProtocolList)
469 {
470 /* Get the Current Entry */
471 Entry = CONTAINING_RECORD(NextEntry, TCATALOG_ENTRY, CatalogLink);
472 NextEntry = NextEntry->Flink;
473
474 /* Check if this is the Catalog Entry ID we want */
475 if (Entry->ProtocolInfo.dwCatalogEntryId == CatalogEntryId)
476 {
477 /* Check if it doesn't already have a provider */
478 if (!Entry->Provider)
479 {
480 /* Match, load the Provider */
481 WsTcLoadProvider(Catalog, Entry);
482 }
483
484 /* Reference the entry and return it */
485 InterlockedIncrement(&Entry->RefCount);
486 *CatalogEntry = Entry;
488 break;
489 }
490 }
491
492 /* Release the catalog */
493 WsTcUnlock();
494
495 /* Return */
496 return ErrorCode;
497}
DWORD CatalogEntryId
Definition: dllmain.c:21

Referenced by WPUModifyIFSHandle(), WPUQueryBlockingCallback(), WSAAddressToStringA(), WSAAddressToStringW(), WSASocketW(), WSAStringToAddressA(), and WSAStringToAddressW().

◆ WsTcGetEntryFromTriplet()

DWORD WSAAPI WsTcGetEntryFromTriplet ( IN PTCATALOG  TCatalog,
IN INT  AddressFamily,
IN INT  SocketType,
IN INT  Protocol,
IN DWORD  StartId,
IN PTCATALOG_ENTRY CatalogEntry 
)

Definition at line 501 of file dcatalog.c.

507{
509 PLIST_ENTRY NextEntry;
511 DPRINT("WsTcGetEntryFromTriplet: %lx, %lx, %lx, %lx\n", af, type, protocol, StartId);
512
513 /* Assume failure */
514 *CatalogEntry = NULL;
515
516 /* Lock the catalog */
517 WsTcLock();
518
519 NextEntry = Catalog->ProtocolList.Flink;
520
521 /* Check if we are starting past 0 */
522 if (StartId)
523 {
524 /* Loop the list */
525 while (NextEntry != &Catalog->ProtocolList)
526 {
527 /* Get the Current Entry */
528 Entry = CONTAINING_RECORD(NextEntry, TCATALOG_ENTRY, CatalogLink);
529 NextEntry = NextEntry->Flink;
530
531 /* Check if this is the ID where we are starting */
532 if (Entry->ProtocolInfo.dwCatalogEntryId == StartId) break;
533 }
534 }
535
536 /* Match the Id with all the entries in the List */
537 while (NextEntry != &Catalog->ProtocolList)
538 {
539 /* Get the Current Entry */
540 Entry = CONTAINING_RECORD(NextEntry, TCATALOG_ENTRY, CatalogLink);
541 NextEntry = NextEntry->Flink;
542
543 /* Check if Address Family Matches or if it's wildcard */
544 if ((Entry->ProtocolInfo.iAddressFamily == af) || (af == AF_UNSPEC))
545 {
546 /* Check if Socket Type Matches or if it's wildcard */
547 if ((Entry->ProtocolInfo.iSocketType == type) || (type == 0))
548 {
549 /* Check if Protocol is In Range or if it's wildcard */
550 if (((Entry->ProtocolInfo.iProtocol <= protocol) &&
551 ((Entry->ProtocolInfo.iProtocol +
552 Entry->ProtocolInfo.iProtocolMaxOffset) >= protocol)) ||
553 (protocol == 0))
554 {
555 /* Check if it doesn't already have a provider */
556 if (!Entry->Provider)
557 {
558 /* Match, load the Provider */
559 ErrorCode = WsTcLoadProvider(Catalog, Entry);
560
561 /* Make sure this didn't fail */
562 if (ErrorCode != ERROR_SUCCESS) break;
563 }
564
565 /* Reference the entry and return it */
566 InterlockedIncrement(&Entry->RefCount);
567 *CatalogEntry = Entry;
569 break;
570 }
571 else
572 {
574 }
575 }
576 else
577 {
579 }
580 }
581 else
582 {
584 }
585 }
586
587 /* Release the catalog */
588 WsTcUnlock();
589
590 /* Return */
591 return ErrorCode;
592}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define DPRINT
Definition: sndvol32.h:71
#define WSAEPROTONOSUPPORT
Definition: winerror.h:1956
#define WSAESOCKTNOSUPPORT
Definition: winerror.h:1957
#define WSAEAFNOSUPPORT
Definition: winerror.h:1960

Referenced by WSASocketW().

◆ WsTcInitializeFromRegistry()

DWORD WSAAPI WsTcInitializeFromRegistry ( IN PTCATALOG  TCatalog,
HKEY  ,
PVOID   
)

◆ WsTcLoadProvider()

DWORD WSAAPI WsTcLoadProvider ( IN PTCATALOG  TCatalog,
IN PTCATALOG_ENTRY  CatalogEntry 
)

Definition at line 629 of file dcatalog.c.

631{
634 DPRINT("WsTcLoadProvider: %p, %p\n", Catalog, CatalogEntry);
635
636 /* Lock the catalog */
637 WsTcLock();
638
639 /* Check if we have a provider already */
640 if (!CatalogEntry->Provider)
641 {
642 /* Try to find another instance */
643 Provider = WsTcFindProvider(Catalog,
644 &CatalogEntry->ProtocolInfo.ProviderId);
645
646 /* Check if we found one now */
647 if (Provider)
648 {
649 /* Set this one as the provider */
650 WsTcEntrySetProvider(CatalogEntry, Provider);
652 }
653 else
654 {
655 /* Nothing found, Allocate a provider */
656 if ((Provider = WsTpAllocate()))
657 {
658 /* Initialize it */
660 CatalogEntry->DllPath,
661 &CatalogEntry->ProtocolInfo);
662
663 /* Ensure success */
665 {
666 /* Set the provider */
667 WsTcEntrySetProvider(CatalogEntry, Provider);
668 }
669
670 /* Dereference it */
672 }
673 else
674 {
675 /* No memory */
677 }
678 }
679 }
680
681 /* Release the lock */
682 WsTcUnlock();
683 return ErrorCode;
684}
PTPROVIDER WSAAPI WsTcFindProvider(IN PTCATALOG Catalog, IN LPGUID ProviderId)
Definition: dcatalog.c:596
VOID WSAAPI WsTcEntrySetProvider(IN PTCATALOG_ENTRY CatalogEntry, IN PTPROVIDER Provider)
Definition: dcatitem.c:121
PTPROVIDER WSAAPI WsTpAllocate(VOID)
Definition: dprovide.c:20
DWORD WSAAPI WsTpInitialize(IN PTPROVIDER Provider, IN LPSTR DllName, LPWSAPROTOCOL_INFOW ProtocolInfo)

Referenced by WsTcFindIfsProviderForSocket(), WsTcGetEntryFromAf(), WsTcGetEntryFromCatalogEntryId(), and WsTcGetEntryFromTriplet().

◆ WsTcOpen()

BOOL WSAAPI WsTcOpen ( IN PTCATALOG  TCatalog,
IN  HKEY 
)

Definition at line 38 of file dcatalog.c.

40{
43 HKEY CatalogKey, NewKey;
44 //DWORD CatalogEntries = 0;
45 DWORD RegType = REG_DWORD;
46 DWORD RegSize = sizeof(DWORD);
47 DWORD UniqueId = 0;
48 DWORD NewData = 0;
49 CHAR* CatalogKeyName;
50
51 /* Initialize the catalog lock and namespace list */
52 InitializeCriticalSection(&Catalog->Lock);
53 InitializeListHead(&Catalog->ProtocolList);
54
55 /* Read the catalog name */
57 "Current_Protocol_Catalog",
58 0,
59 &RegType,
60 NULL,
61 &RegSize);
63 {
64 static const CHAR DefaultCatalogName[] = "Protocol_Catalog9";
65 RegSize = sizeof(DefaultCatalogName);
66 CatalogKeyName = HeapAlloc(WsSockHeap, 0, RegSize);
67 memcpy(CatalogKeyName, DefaultCatalogName, RegSize);
68 }
69 else
70 {
72 {
73 DPRINT1("Failed to get protocol catalog name: %d.\n", ErrorCode);
74 return FALSE;
75 }
76
77 if (RegType != REG_SZ)
78 {
79 DPRINT1("Protocol catalog name is not a string (Type %d).\n", RegType);
80 return FALSE;
81 }
82
83 CatalogKeyName = HeapAlloc(WsSockHeap, 0, RegSize);
84
85 /* Read the catalog name */
87 "Current_Protocol_Catalog",
88 0,
89 &RegType,
90 (LPBYTE)CatalogKeyName,
91 &RegSize);
92
93 /* Open the Catalog Key */
95 CatalogKeyName,
96 0,
98 &CatalogKey);
99 }
100
101 /* If we didn't find the key, create it */
103 {
104 /* Fake that we opened an existing key */
106 }
108 {
109 /* Create the Catalog Name */
111 CatalogKeyName,
112 0,
113 NULL,
116 NULL,
117 &CatalogKey,
119 }
120
121 HeapFree(WsSockHeap, 0, CatalogKeyName);
122 RegType = REG_DWORD;
123 RegSize = sizeof(DWORD);
124
125 /* Fail if that didn't work */
126 if (ErrorCode != ERROR_SUCCESS) return FALSE;
127
128 /* Check if we had to create the key */
130 {
131 /* Write the count of entries (0 now) */
132 ErrorCode = RegSetValueEx(CatalogKey,
133 "Num_Catalog_Entries",
134 0,
135 REG_DWORD,
136 (LPBYTE)&NewData,
137 sizeof(NewData));
139 {
140 /* Close the key and fail */
141 RegCloseKey(CatalogKey);
142 return FALSE;
143 }
144
145 /* Write the first catalog entry ID */
146 NewData = 1001;
147 ErrorCode = RegSetValueEx(CatalogKey,
148 "Next_Catalog_Entry_ID",
149 0,
150 REG_DWORD,
151 (LPBYTE)&NewData,
152 sizeof(NewData));
154 {
155 /* Close the key and fail */
156 RegCloseKey(CatalogKey);
157 return FALSE;
158 }
159
160 /* Write the first catalog entry Uniqe ID */
161 NewData = 1;
162 ErrorCode = RegSetValueEx(CatalogKey,
163 "Serial_Access_Num",
164 0,
165 REG_DWORD,
166 (LPBYTE)&NewData,
167 sizeof(NewData));
169 {
170 /* Close the key and fail */
171 RegCloseKey(CatalogKey);
172 return FALSE;
173 }
174
175 /* Create a key for this entry */
176 ErrorCode = RegCreateKeyEx(CatalogKey,
177 "Catalog_Entries",
178 0,
179 NULL,
182 NULL,
183 &NewKey,
186 {
187 /* Close the key and fail */
188 RegCloseKey(CatalogKey);
189 return FALSE;
190 }
191
192 /* Close the key since we don't need it */
193 RegCloseKey(NewKey);
194 }
195 else
196 {
197 RegSize = sizeof(DWORD);
198 /* Read the serial number */
199 ErrorCode = RegQueryValueEx(CatalogKey,
200 "Serial_Access_Num",
201 0,
202 &RegType,
203 (LPBYTE)&UniqueId,
204 &RegSize);
205
206 /* Check if it's missing for some reason */
208 {
209 /* Write the first catalog entry Unique ID */
210 NewData = 1;
211 ErrorCode = RegSetValueEx(CatalogKey,
212 "Serial_Access_Num",
213 0,
214 REG_DWORD,
215 (LPBYTE)&NewData,
216 sizeof(NewData));
217 }
218 }
219
220 /* Set the Catalog Key */
221 Catalog->CatalogKey = CatalogKey;
222 return TRUE;
223}
#define DPRINT1
Definition: precomp.h:8
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by WsTcInitializeFromRegistry().

◆ WsTcRefreshFromRegistry()

DWORD WSAAPI WsTcRefreshFromRegistry ( IN PTCATALOG  TCatalog,
PVOID   
)

Referenced by WsProcGetTCatalog().

◆ WsTcUpdateProtocolList()

VOID WSAAPI WsTcUpdateProtocolList ( IN PTCATALOG  TCatalog,
PLIST_ENTRY  ProtocolList 
)

◆ WsThreadAllocate()

PWSTHREAD WSAAPI WsThreadAllocate ( VOID  )

Definition at line 135 of file dthread.c.

136{
138
139 /* Allocate the object */
141 if (Thread)
142 {
143 /* Set non-zero data */
145 }
146
147 /* Return it */
148 return Thread;
149}
int(* FARPROC)()
Definition: compat.h:36
DWORD WSAAPI WsThreadDefaultBlockingHook(VOID)
Definition: dthread.c:17

Referenced by WsThreadCreate().

◆ WsThreadBlobToHostent()

PHOSTENT WSAAPI WsThreadBlobToHostent ( IN PWSTHREAD  Thread,
IN LPBLOB  Blob 
)

Definition at line 316 of file dthread.c.

318{
319 /* Check if our buffer is too small */
320 if (Thread->HostentSize < Blob->cbSize)
321 {
322 /* Delete the current buffer and allocate a new one */
323 HeapFree(WsSockHeap, 0, Thread->Hostent);
324 Thread->Hostent = HeapAlloc(WsSockHeap, 0, Blob->cbSize);
325
326 /* Set the new size */
327 Thread->HostentSize = Blob->cbSize;
328 }
329
330 /* Do we have a buffer? */
331 if (Thread->Hostent)
332 {
333 /* Copy the data inside */
334 RtlMoveMemory(Thread->Hostent, Blob->pBlobData, Blob->cbSize);
335 }
336 else
337 {
338 /* No buffer space! */
339 Thread->HostentSize = 0;
341 }
342
343 /* Return the buffer */
344 return (PHOSTENT)Thread->Hostent;
345}
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264

Referenced by gethostbyaddr(), and gethostbyname().

◆ WsThreadBlobToServent()

PSERVENT WSAAPI WsThreadBlobToServent ( IN PWSTHREAD  Thread,
IN LPBLOB  Blob 
)

Definition at line 349 of file dthread.c.

351{
352 /* Check if our buffer is too small */
353 if (Thread->ServentSize < Blob->cbSize)
354 {
355 /* Delete the current buffer and allocate a new one */
356 HeapFree(WsSockHeap, 0, Thread->Servent);
357 Thread->Servent = HeapAlloc(WsSockHeap, 0, Blob->cbSize);
358
359 /* Set the new size */
360 Thread->ServentSize = Blob->cbSize;
361 }
362
363 /* Do we have a buffer? */
364 if (Thread->Servent)
365 {
366 /* Copy the data inside */
367 RtlMoveMemory(Thread->Servent, Blob->pBlobData, Blob->cbSize);
368 }
369 else
370 {
371 /* No buffer space! */
372 Thread->ServentSize = 0;
374 }
375
376 /* Return the buffer */
377 return (PSERVENT)Thread->Servent;
378}

Referenced by getservbyname(), and getservbyport().

◆ WsThreadCancelBlockingCall()

DWORD WSAAPI WsThreadCancelBlockingCall ( IN PWSTHREAD  Thread)

Definition at line 96 of file dthread.c.

97{
99
100 /* Make sure that the Thread is really in a blocking call */
101 if (!Thread->Blocking) return WSAEINVAL;
102
103 /* Make sure we haven't already been cancelled */
104 if (!Thread->Cancelled)
105 {
106 /* Call the cancel procedure */
107 ReturnValue = Thread->CancelBlockingCall(&ErrorCode);
108 if (ReturnValue != ERROR_SUCCESS) return ErrorCode;
109
110 /* Set us as cancelled */
111 Thread->Cancelled = TRUE;
112 }
113
114 /* Success */
115 return ERROR_SUCCESS;
116}

Referenced by WSACancelBlockingCall().

◆ WsThreadCleanup()

VOID WSAAPI WsThreadCleanup ( VOID  )

Definition at line 170 of file dthread.c.

171{
172}

Referenced by DllMain().

◆ WsThreadCreate()

DWORD WSAAPI WsThreadCreate ( IN PWSPROCESS  Process,
IN PWSTHREAD Thread 
)

Definition at line 244 of file dthread.c.

246{
249
250 /* Make sure we have TLS */
252 {
253 /* Allocate the thread */
254 if ((Thread = WsThreadAllocate()))
255 {
256 /* Initialize it */
258 {
259 /* Set the TLS */
261 {
262 /* Return it and success */
263 *CurrentThread = Thread;
265 }
266 }
267
268 /* Check for any failures */
270 }
271 }
272
273 /* Return */
274 return ErrorCode;
275}
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1276
DWORD WSAAPI WsThreadInitialize(IN PWSTHREAD Thread, IN PWSPROCESS Process)
Definition: dthread.c:176
PWSTHREAD WSAAPI WsThreadAllocate(VOID)
Definition: dthread.c:135
VOID WSAAPI WsThreadDelete(IN PWSTHREAD Thread)
Definition: dthread.c:202
#define TLS_OUT_OF_INDEXES
Definition: winbase.h:549

Referenced by WsThreadGetCurrentThread().

◆ WsThreadDefaultBlockingHook()

DWORD WSAAPI WsThreadDefaultBlockingHook ( VOID  )

Definition at line 17 of file dthread.c.

18{
20 BOOL GotMessage = FALSE;
21
22 /* Get the message */
23 GotMessage = PeekMessage(&Message, NULL, 0, 0, PM_REMOVE);
24
25 /* Check if we got one */
26 if (GotMessage)
27 {
28 /* Process it */
31 }
32
33 /* return */
34 return GotMessage;
35}
static const WCHAR Message[]
Definition: register.c:74
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define PM_REMOVE
Definition: winuser.h:1186
#define PeekMessage
Definition: winuser.h:5820
#define DispatchMessage
Definition: winuser.h:5755

Referenced by WsThreadAllocate(), WsThreadSetBlockingHook(), and WsThreadUnhookBlockingHook().

◆ WsThreadDelete()

VOID WSAAPI WsThreadDelete ( IN PWSTHREAD  Thread)

Definition at line 202 of file dthread.c.

203{
204 /* Remove the blocking hook */
205 Thread->BlockingHook = NULL;
206
207 /* Free our buffers */
208 if (Thread->Hostent) HeapFree(WsSockHeap, 0, Thread->Hostent);
209 if (Thread->Servent) HeapFree(WsSockHeap, 0, Thread->Servent);
210 if (Thread->ProtocolInfo) HeapFree(WsSockHeap, 0, Thread->ProtocolInfo);
211
212 /* Clear the TLS */
214
215 /* Close the WAH Handle */
216 WahCloseThread(Thread->AsyncHelper, &Thread->WahThreadId);
217
218 /* Unlink the process and free us */
219 Thread->Process = NULL;
221}
DWORD WINAPI WahCloseThread(IN HANDLE ApcHelperHandle, IN LPWSATHREADID ThreadId)
Definition: apc.c:59

Referenced by WsThreadCreate(), and WsThreadDestroyCurrentThread().

◆ WsThreadDestroyCurrentThread()

VOID WSAAPI WsThreadDestroyCurrentThread ( VOID  )

Definition at line 225 of file dthread.c.

226{
228
229 /* Make sure we have TLS */
231 {
232 /* Get the thread */
233 if ((Thread = TlsGetValue(TlsIndex)))
234 {
235 /* Delete it */
238 }
239 }
240}

Referenced by DllMain().

◆ WsThreadGetCurrentThread()

DWORD WSAAPI WsThreadGetCurrentThread ( IN PWSPROCESS  Process,
IN PWSTHREAD Thread 
)

Definition at line 279 of file dthread.c.

281{
282 /* Get the thread */
283 if ((*Thread = TlsGetValue(TlsIndex)))
284 {
285 /* Success */
286 return ERROR_SUCCESS;
287 }
288 else
289 {
290 /* We failed, initialize it */
292 }
293}
DWORD WSAAPI WsThreadCreate(IN PWSPROCESS Process, IN PWSTHREAD *CurrentThread)
Definition: dthread.c:244

Referenced by WsApiProlog().

◆ WsThreadGetProtoBuffer()

PWSPROTO_BUFFER WSAAPI WsThreadGetProtoBuffer ( IN PWSTHREAD  Thread)

Definition at line 120 of file dthread.c.

121{
122 /* See if it already exists */
123 if (!Thread->ProtocolInfo)
124 {
125 /* We don't have a buffer; allocate it */
126 Thread->ProtocolInfo = HeapAlloc(WsSockHeap, 0, sizeof(WSPROTO_BUFFER));
127 }
128
129 /* Return it */
130 return Thread->ProtocolInfo;
131}

Referenced by getprotobyname(), and getprotobynumber().

◆ WsThreadGetThreadId()

LPWSATHREADID WSAAPI WsThreadGetThreadId ( IN PWSPROCESS  Process)

Definition at line 297 of file dthread.c.

298{
300
301 /* Get the thread */
302 if ((Thread = TlsGetValue(TlsIndex)))
303 {
304 /* Return the ID */
305 return &Thread->WahThreadId;
306 }
307 else
308 {
309 /* Not a valid thread */
310 return NULL;
311 }
312}

Referenced by WsQuickPrologTid().

◆ WsThreadInitialize()

DWORD WSAAPI WsThreadInitialize ( IN PWSTHREAD  Thread,
IN PWSPROCESS  Process 
)

Definition at line 176 of file dthread.c.

178{
180
181 /* Set the process */
182 Thread->Process = Process;
183
184 /* Get the helper device */
185 if ((WsProcGetAsyncHelper(Process, &Thread->AsyncHelper)) == ERROR_SUCCESS)
186 {
187 /* Initialize a WAH Thread ID */
188 if ((WahOpenCurrentThread(Thread->AsyncHelper,
189 &Thread->WahThreadId)) == ERROR_SUCCESS)
190 {
191 /* Success */
193 }
194 }
195
196 /* Return */
197 return ErrorCode;
198}
DWORD WINAPI WahOpenCurrentThread(IN HANDLE ApcHelperHandle, OUT LPWSATHREADID ThreadId)
Definition: apc.c:118
INT WSAAPI WsProcGetAsyncHelper(IN PWSPROCESS Process, OUT PHANDLE Handle)
Definition: dprocess.c:107

Referenced by WsThreadCreate().

◆ WsThreadSetBlockingHook()

FARPROC WSAAPI WsThreadSetBlockingHook ( IN PWSTHREAD  Thread,
IN FARPROC  BlockingHook 
)

Definition at line 60 of file dthread.c.

62{
63 FARPROC OldHook = Thread->BlockingHook;
64
65 /* Check if we're resetting to our default hook */
66 if (BlockingHook == (FARPROC)WsThreadDefaultBlockingHook)
67 {
68 /* Clear out the blocking callback */
69 Thread->BlockingCallback = NULL;
70 }
71 else
72 {
73 /* Set the blocking callback */
74 Thread->BlockingCallback = WsThreadBlockingCallback;
75 }
76
77 /* Set the new blocking hook and return the previous */
78 Thread->BlockingHook = BlockingHook;
79 return OldHook;
80}
BOOL WSAAPI WsThreadBlockingCallback(IN DWORD_PTR Context)
Definition: dthread.c:39

Referenced by WSASetBlockingHook().

◆ WsThreadStartup()

DWORD WSAAPI WsThreadStartup ( VOID  )

Definition at line 153 of file dthread.c.

154{
156
157 /* Check if we have a valid TLS */
159 {
160 /* TLS was already OK */
162 }
163
164 /* Return */
165 return ErrorCode;
166}

Referenced by WSAStartup().

◆ WsThreadUnhookBlockingHook()

DWORD WSAAPI WsThreadUnhookBlockingHook ( IN PWSTHREAD  Thread)

Definition at line 84 of file dthread.c.

85{
86 /* Reset the hook to the default, and remove the callback */
88 Thread->BlockingCallback = NULL;
89
90 /* Return success */
91 return ERROR_SUCCESS;
92}

Referenced by WSAUnhookBlockingHook().

◆ WsTpAllocate()

PTPROVIDER WSAAPI WsTpAllocate ( VOID  )

Definition at line 20 of file dprovide.c.

21{
23
24 /* Allocate the object */
26 if (Provider)
27 {
28 /* Setup non-zero data */
29 Provider->RefCount = 1;
30 }
31
32 /* Return it */
33 return Provider;
34}

Referenced by WsTcLoadProvider().

◆ WsTpDelete()

VOID WSAAPI WsTpDelete ( IN PTPROVIDER  Provider)

Definition at line 122 of file dprovide.c.

123{
125
126 /* Make sure we have a loaded handle */
127 if (Provider->DllHandle)
128 {
129 /* Clean us up */
131