2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 API
5 * PURPOSE: DLL Entrypoint
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
11 * - GetAddrInfoW is completely IPv4 hacked and has some dirty code.
12 * - LookupNodeByAddr is missing some IPv6 support.
15 /* INCLUDES ******************************************************************/
19 /* DATA **********************************************************************/
22 HINSTANCE WsDllHandle
;
23 DWORD GlobalTlsIndex
= TLS_OUT_OF_INDEXES
;
25 /* FUNCTIONS *****************************************************************/
29 DllMain(HANDLE hModule
,
38 case DLL_PROCESS_ATTACH
:
40 WsDllHandle
= hModule
;
43 WsSockHeap
= GetProcessHeap();
46 if (GlobalTlsIndex
== TLS_OUT_OF_INDEXES
)
48 GlobalTlsIndex
= TlsAlloc();
49 if (GlobalTlsIndex
== TLS_OUT_OF_INDEXES
)
55 /* Initialize some critical sections */
56 WsCreateStartupSynchronization();
57 WsAsyncGlobalInitialize();
58 WsRasInitializeAutodial();
61 case DLL_THREAD_ATTACH
:
64 case DLL_THREAD_DETACH
:
65 /* Destroy the attached Winsock Thread */
66 WsThreadDestroyCurrentThread();
69 case DLL_PROCESS_DETACH
:
70 /* Make sure we were initialized */
71 if (!WsDllHandle
) break;
73 /* Check if this was a FreeLibrary call (ie: not process cleanup) */
76 /* Destroy the thread which is exiting */
77 WsThreadDestroyCurrentThread();
79 /* Check if we have a process and destroy it */
80 WsProcess
= WsGetProcess();
81 if (WsProcess
) WsProcDelete(WsProcess
);
83 /* Cleanup the Thread and Socket managers */
87 /* Cleanup critical sections */
88 WsDestroyStartupSynchronization();
89 WsAsyncGlobalTerminate();
91 /* Free the TLS Index */
92 TlsFree(GlobalTlsIndex
);
95 /* Cleanup RAS auto-dial helper */
96 WsRasUninitializeAutodial();
98 /* Clear our handle */
112 WSAGetLastError(VOID
)
114 /* Let the Windows Function do the work */
115 return GetLastError();
123 WSASetLastError(IN INT iError
)
125 /* Let the Windows Function do the work */
126 SetLastError(iError
);