ReactOS 0.4.15-dev-7961-gdcf9eb0
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
27BOOL
31 LPVOID lpReserved)
32{
33 PWSPROCESS WsProcess;
34
35 /* Main Entrypoint */
36 switch (dwReason)
37 {
39 /* Save DLL Handle */
41
42 /* Get Global Heap */
44
45 /* TLS Allocation */
47 {
50 {
51 return FALSE;
52 }
53 }
54
55 /* Initialize some critical sections */
59 break;
60
62 break;
63
65 /* Destroy the attached Winsock Thread */
67 break;
68
70 /* Make sure we were initialized */
71 if (!WsDllHandle) break;
72
73 /* Check if this was a FreeLibrary call (ie: not process cleanup) */
74 if (lpReserved)
75 {
76 /* Destroy the thread which is exiting */
78
79 /* Check if we have a process and destroy it */
80 WsProcess = WsGetProcess();
81 if (WsProcess) WsProcDelete(WsProcess);
82
83 /* Cleanup the Thread and Socket managers */
86
87 /* Cleanup critical sections */
90
91 /* Free the TLS Index */
93 }
94
95 /* Cleanup RAS auto-dial helper */
97
98 /* Clear our handle */
100 break;
101 }
102
103 /* Return to OS */
104 return TRUE;
105}
106
107/*
108 * @implemented
109 */
110INT
111WSAAPI
113{
114 /* Let the Windows Function do the work */
115 return GetLastError();
116}
117
118/*
119 * @implemented
120 */
121VOID
122WSAAPI
124{
125 /* Let the Windows Function do the work */
126 SetLastError(iError);
127}
DWORD dwReason
Definition: misc.cpp:154
#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
DWORD GlobalTlsIndex
Definition: dllmain.c:23
VOID WSAAPI WSASetLastError(IN INT iError)
Definition: dllmain.c:123
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
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:549
#define WSAAPI
Definition: winsock2.h:605
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:112
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