ReactOS 0.4.16-dev-1204-gb627a42
dllmain.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 API
4 * FILE: dll/win32/ws2_32/src/dllmain.c
5 * PURPOSE: DLL Entrypoint
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
7 */
8
9/*
10 * BUGS:
11 * - GetAddrInfoW is completely IPv4 hacked and has some dirty code.
12 * - LookupNodeByAddr is missing some IPv6 support.
13 */
14
15/* INCLUDES ******************************************************************/
16
17#include <ws2_32.h>
18
19/* DATA **********************************************************************/
20
24
25/* FUNCTIONS *****************************************************************/
26
27#if (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA)
28BOOL
34#endif
35
36BOOL
41{
42 PWSPROCESS WsProcess;
43
44#if (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA)
45 /* Initialize ws2help */
47 {
48 /* Should never happen */
50 return FALSE;
51 }
52#endif
53
54 /* Main Entrypoint */
55 switch (dwReason)
56 {
58 /* Save DLL Handle */
60
61 /* Get Global Heap */
63
64 /* TLS Allocation */
66 {
69 {
70 return FALSE;
71 }
72 }
73
74 /* Initialize some critical sections */
78 break;
79
81 break;
82
84 /* Destroy the attached Winsock Thread */
86 break;
87
89 /* Make sure we were initialized */
90 if (!WsDllHandle) break;
91
92 /* Check if this was a FreeLibrary call (ie: not process cleanup) */
93 if (lpReserved)
94 {
95 /* Destroy the thread which is exiting */
97
98 /* Check if we have a process and destroy it */
99 WsProcess = WsGetProcess();
100 if (WsProcess) WsProcDelete(WsProcess);
101
102 /* Cleanup the Thread and Socket managers */
105
106 /* Cleanup critical sections */
109
110 /* Free the TLS Index */
112 }
113
114 /* Cleanup RAS auto-dial helper */
116
117 /* Clear our handle */
119 break;
120 }
121
122 /* Return to OS */
123 return TRUE;
124}
125
126/*
127 * @implemented
128 */
129INT
130WSAAPI
132{
133 /* Let the Windows Function do the work */
134 return GetLastError();
135}
136
137/*
138 * @implemented
139 */
140VOID
141WSAAPI
143{
144 /* Let the Windows Function do the work */
145 SetLastError(iError);
146}
static DWORD const LPVOID const lpReserved
DWORD dwReason
Definition: misc.cpp:135
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
Definition: dllmain.c:52
#define APIENTRY
Definition: api.h:79
HMODULE hModule
Definition: animate.c:44
#define GetProcessHeap()
Definition: compat.h:736
#define DLL_THREAD_DETACH
Definition: compat.h:133
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define SetLastError(x)
Definition: compat.h:752
#define DLL_THREAD_ATTACH
Definition: compat.h:132
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1100
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1166
BOOL APIENTRY Ws2HelpDllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
Definition: dllmain.c:123
DWORD GlobalTlsIndex
Definition: dllmain.c:23
VOID WSAAPI WSASetLastError(IN INT iError)
Definition: dllmain.c:142
HINSTANCE WsDllHandle
Definition: dllmain.c:22
HANDLE WsSockHeap
Definition: dllmain.c:21
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ASSERT(a)
Definition: mode.c:44
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define TLS_OUT_OF_INDEXES
Definition: winbase.h:585
#define WSAAPI
Definition: winsock2.h:605
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:131
VOID WSAAPI WsSockCleanup(VOID)
Definition: dsocket.c:36
VOID WSAAPI WsRasInitializeAutodial(VOID)
Definition: rasdial.c:47
FORCEINLINE PWSPROCESS WsGetProcess(VOID)
Definition: ws2_32p.h:885
VOID WSAAPI WsThreadCleanup(VOID)
Definition: dthread.c:170
VOID WSAAPI WsProcDelete(IN PWSPROCESS Process)
Definition: dprocess.c:247
VOID WSAAPI WsDestroyStartupSynchronization(VOID)
Definition: startup.c:36
VOID WSAAPI WsCreateStartupSynchronization(VOID)
Definition: startup.c:28
VOID WSAAPI WsRasUninitializeAutodial(VOID)
Definition: rasdial.c:55
VOID WSAAPI WsThreadDestroyCurrentThread(VOID)
Definition: dthread.c:225
VOID WSAAPI WsAsyncGlobalTerminate(VOID)
Definition: async.c:39
VOID WSAAPI WsAsyncGlobalInitialize(VOID)
Definition: async.c:31