ReactOS  0.4.14-dev-384-g5b37caa
dprovide.c File Reference
#include <ws2_32.h>
#include <debug.h>
Include dependency graph for dprovide.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

PTPROVIDER WSAAPI WsTpAllocate (VOID)
 
DWORD WSAAPI WsTpInitialize (IN PTPROVIDER Provider, IN LPSTR DllName, IN LPWSAPROTOCOL_INFOW ProtocolInfo)
 
DWORD WSAAPI WsTpWSPCleanup (IN PTPROVIDER Provider, IN LPINT lpErrNo)
 
VOID WSAAPI WsTpDelete (IN PTPROVIDER Provider)
 
VOID WSAAPI WsTpDereference (IN PTPROVIDER Provider)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file dprovide.c.

Function Documentation

◆ 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 }
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
HANDLE WsSockHeap
Definition: dllmain.c:21

Referenced by WsTcLoadProvider().

◆ WsTpDelete()

VOID WSAAPI WsTpDelete ( IN PTPROVIDER  Provider)

Definition at line 122 of file dprovide.c.

123 {
124  INT ErrorCode;
125 
126  /* Make sure we have a loaded handle */
127  if (Provider->DllHandle)
128  {
129  /* Clean us up */
131 
132  /* Unload the library */
133  FreeLibrary(Provider->DllHandle);
134  Provider->DllHandle = NULL;
135  }
136 
137  /* Delete us */
139 }
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
#define FreeLibrary(x)
Definition: compat.h:413
DWORD WSAAPI WsTpWSPCleanup(IN PTPROVIDER Provider, IN LPINT lpErrNo)
Definition: dprovide.c:100
HANDLE WsSockHeap
Definition: dllmain.c:21
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by WsTpDereference().

◆ WsTpDereference()

VOID WSAAPI WsTpDereference ( IN PTPROVIDER  Provider)

Definition at line 143 of file dprovide.c.

144 {
145  /* Decrease the reference count and check if it's zero */
146  if (!InterlockedDecrement(&Provider->RefCount))
147  {
148  /* Delete us*/
150  }
151 }
VOID WSAAPI WsTpDelete(IN PTPROVIDER Provider)
Definition: dprovide.c:122
#define InterlockedDecrement
Definition: armddk.h:52

Referenced by WsTcEntryDelete(), and WsTcLoadProvider().

◆ WsTpInitialize()

DWORD WSAAPI WsTpInitialize ( IN PTPROVIDER  Provider,
IN LPSTR  DllName,
IN LPWSAPROTOCOL_INFOW  ProtocolInfo 
)

Definition at line 38 of file dprovide.c.

41 {
42  WORD VersionRequested = MAKEWORD(2,2);
43  LPWSPSTARTUP WSPStartupProc;
44  WSPDATA WspData;
45  CHAR ExpandedDllPath[MAX_PATH];
47  DPRINT("WsTpInitialize: %p, %p, %p\n", Provider, DllName, ProtocolInfo);
48 
49  /* Clear the tables */
50  RtlZeroMemory(&Provider->UpcallTable, sizeof(Provider->UpcallTable));
51  RtlZeroMemory(&Provider->Service, sizeof(Provider->Service));
52 
53  /* Set up the Upcall Table */
54  Provider->UpcallTable.lpWPUCloseEvent = WPUCloseEvent;
55  Provider->UpcallTable.lpWPUCloseSocketHandle = WPUCloseSocketHandle;
56  Provider->UpcallTable.lpWPUCreateEvent = WPUCreateEvent;
57  Provider->UpcallTable.lpWPUCreateSocketHandle = WPUCreateSocketHandle;
58  Provider->UpcallTable.lpWPUFDIsSet = WPUFDIsSet;
59  Provider->UpcallTable.lpWPUGetProviderPath = WPUGetProviderPath;
60  Provider->UpcallTable.lpWPUModifyIFSHandle = WPUModifyIFSHandle;
61  Provider->UpcallTable.lpWPUPostMessage = WPUPostMessage;
62  Provider->UpcallTable.lpWPUQueryBlockingCallback = WPUQueryBlockingCallback;
63  Provider->UpcallTable.lpWPUQuerySocketHandleContext = WPUQuerySocketHandleContext;
64  Provider->UpcallTable.lpWPUQueueApc = WPUQueueApc;
65  Provider->UpcallTable.lpWPUResetEvent = WPUResetEvent;
66  Provider->UpcallTable.lpWPUSetEvent = WPUSetEvent;
67  Provider->UpcallTable.lpWPUOpenCurrentThread = WPUOpenCurrentThread;
68  Provider->UpcallTable.lpWPUCloseThread = WPUCloseThread;
69 
70  /* Expand the DLL Path */
71  ExpandEnvironmentStrings(DllName, ExpandedDllPath, MAX_PATH);
72 
73  /* Load the DLL */
74  Provider->DllHandle = LoadLibrary(ExpandedDllPath);
75 
76  if (!Provider->DllHandle)
77  {
78  return SOCKET_ERROR;
79  }
80  /* Get the pointer to WSPStartup */
81  WSPStartupProc = (LPWSPSTARTUP)GetProcAddress(Provider->DllHandle, "WSPStartup");
82 
83  if (!WSPStartupProc)
84  {
85  return SOCKET_ERROR;
86  }
87  /* Call it */
88  ErrorCode = (*WSPStartupProc)(VersionRequested,
89  &WspData,
90  ProtocolInfo,
91  Provider->UpcallTable,
92  &Provider->Service);
93 
94  /* Return */
95  return ErrorCode;
96 }
SOCKET WSPAPI WPUCreateSocketHandle(IN DWORD dwCatalogEntryId, IN DWORD_PTR dwContext, OUT LPINT lpErrno)
Definition: socklife.c:188
#define SOCKET_ERROR
Definition: winsock.h:333
INT WSPAPI WPUQuerySocketHandleContext(IN SOCKET s, OUT PDWORD_PTR lpContext, OUT LPINT lpErrno)
Definition: socklife.c:289
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define LoadLibrary
Definition: winbase.h:3686
#define MAKEWORD(a, b)
Definition: typedefs.h:247
char CHAR
Definition: xmlstorage.h:175
#define ExpandEnvironmentStrings
Definition: winbase.h:3598
SOCKET WSPAPI WPUModifyIFSHandle(IN DWORD dwCatalogEntryId, IN SOCKET ProposedHandle, OUT LPINT lpErrno)
Definition: socklife.c:201
INT WSPAPI WPUFDIsSet(IN SOCKET s, IN LPFD_SET set)
Definition: select.c:122
WSAEVENT WSPAPI WPUCreateEvent(OUT LPINT lpErrno)
Definition: sputil.c:62
INT WSPAPI WPUQueryBlockingCallback(IN DWORD dwCatalogEntryId, OUT LPBLOCKINGCALLBACK FAR *lplpfnCallback, OUT PDWORD_PTR lpdwContext, OUT LPINT lpErrno)
Definition: sputil.c:102
Definition: ws2spi.h:46
void DPRINT(...)
Definition: polytest.cpp:61
INT WSPAPI WPUCloseSocketHandle(IN SOCKET s, OUT LPINT lpErrno)
Definition: socklife.c:176
BOOL WSPAPI WPUCloseEvent(IN WSAEVENT hEvent, OUT LPINT lpErrno)
Definition: sputil.c:38
BOOL WSPAPI WPUResetEvent(IN WSAEVENT hEvent, OUT LPINT lpErrno)
Definition: sputil.c:187
BOOL WSPAPI WPUSetEvent(IN WSAEVENT hEvent, OUT LPINT lpErrno)
Definition: sputil.c:199
#define MAX_PATH
Definition: compat.h:26
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
INT WSPAPI WPUOpenCurrentThread(OUT LPWSATHREADID lpThreadId, OUT LPINT lpErrno)
Definition: sputil.c:73
INT WSPAPI WPUCloseThread(IN LPWSATHREADID lpThreadId, OUT LPINT lpErrno)
Definition: sputil.c:50
INT WSPAPI WPUQueueApc(IN LPWSATHREADID lpThreadId, IN LPWSAUSERAPC lpfnUserApc, IN DWORD_PTR dwContext, OUT LPINT lpErrno)
Definition: sputil.c:173
_Must_inspect_result_ int(WSPAPI * LPWSPSTARTUP)(_In_ WORD wVersionRequested, _In_ LPWSPDATA lpWSPData, _In_ LPWSAPROTOCOL_INFOW lpProtocolInfo, _In_ WSPUPCALLTABLE UpcallTable, _Out_ LPWSPPROC_TABLE lpProcTable)
Definition: ws2spi.h:622
INT WSPAPI WPUGetProviderPath(IN LPGUID lpProviderId, OUT LPWSTR lpszProviderDllPath, IN OUT LPINT lpProviderDllPathLen, OUT LPINT lpErrno)
Definition: enumprot.c:297
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define GetProcAddress(x, y)
Definition: compat.h:418
BOOL WSPAPI WPUPostMessage(IN HWND hWnd, IN UINT Msg, IN WPARAM wParam, IN LPARAM lParam)
Definition: sputil.c:85

◆ WsTpWSPCleanup()

DWORD WSAAPI WsTpWSPCleanup ( IN PTPROVIDER  Provider,
IN LPINT  lpErrNo 
)

Definition at line 100 of file dprovide.c.

102 {
105 
106  /* Make sure we have a loaded handle */
107  if (Provider->DllHandle)
108  {
109  /* Get the pointer and clear it */
110  WSPCleanup = InterlockedExchangePointer((PVOID*)&Provider->Service.lpWSPCleanup,
111  NULL);
112  /* If it's not NULL, call it */
113  if (WSPCleanup) ErrorCode = WSPCleanup(lpErrNo);
114  }
115 
116  /* Return */
117  return ErrorCode;
118 }
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
int(WSPAPI * LPWSPCLEANUP)(_Out_ LPINT lpErrno)
Definition: ws2spi.h:100
int32_t INT
Definition: typedefs.h:56
INT WSPAPI WSPCleanup(OUT LPINT lpErrno)
Definition: dllmain.c:3234
smooth NULL
Definition: ftsmooth.c:416
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45

Referenced by WsTpDelete().