ReactOS 0.4.16-dev-1946-g52006dd
dllmain.c File Reference
#include <ws2_32.h>
Include dependency graph for dllmain.c:

Go to the source code of this file.

Functions

BOOL APIENTRY Ws2HelpDllMain (HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
 
BOOL APIENTRY DllMain (HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
 
INT WSAAPI WSAGetLastError (VOID)
 
VOID WSAAPI WSASetLastError (IN INT iError)
 

Variables

HANDLE WsSockHeap
 
HINSTANCE WsDllHandle
 
DWORD GlobalTlsIndex = TLS_OUT_OF_INDEXES
 

Function Documentation

◆ DllMain()

BOOL APIENTRY DllMain ( HANDLE  hModule,
DWORD  dwReason,
LPVOID  lpReserved 
)

Definition at line 38 of file dllmain.c.

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}
DWORD dwReason
Definition: misc.cpp:135
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#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 DLL_THREAD_ATTACH
Definition: compat.h:132
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1166
DWORD WINAPI DECLSPEC_HOTPATCH TlsAlloc(void)
Definition: thread.c:657
BOOL APIENTRY Ws2HelpDllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
Definition: dllmain.c:123
DWORD GlobalTlsIndex
Definition: dllmain.c:23
HINSTANCE WsDllHandle
Definition: dllmain.c:22
HANDLE WsSockHeap
Definition: dllmain.c:21
#define ASSERT(a)
Definition: mode.c:44
HMODULE hModule
Definition: netsh.c:17
#define TLS_OUT_OF_INDEXES
Definition: winbase.h:529
_In_ DWORD _In_ int _In_ int _In_opt_ LPNLSVERSIONINFO _In_opt_ LPVOID lpReserved
Definition: winnls.h:1268
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

◆ Ws2HelpDllMain()

BOOL APIENTRY Ws2HelpDllMain ( HANDLE  hModule,
DWORD  dwReason,
LPVOID  lpReserved 
)

Definition at line 123 of file dllmain.c.

127{
128 switch (dwReason)
129 {
131
132 /* Save our handle */
134
135 /* Improve Performance */
137
138 /* Initialize startup CS */
140
141 /* Get Global Heap */
143 break;
144
147 break;
148
150
151 /* Make sure we loaded */
152 if (!LibraryHdl) break;
153
154 /* Check if we are cleaning up */
155 if (lpReserved)
156 {
157 /* Free the security descriptor */
159
160 /* Close the event */
162
163 /* Delete the startup CS */
166 }
167 break;
168 }
169
170 return TRUE;
171}
#define CloseHandle
Definition: compat.h:739
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HANDLE GlobalHeap
Definition: dllmain.c:19
HANDLE ghWriterEvent
Definition: context.c:17
HINSTANCE LibraryHdl
Definition: dllmain.c:17
BOOL Ws2helpInitialized
Definition: dllmain.c:15
CRITICAL_SECTION StartupSynchronization
Definition: dllmain.c:16
PSECURITY_DESCRIPTOR pSDPipe
Definition: notify.c:16
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by DllMain().

◆ WSAGetLastError()

INT WSAAPI WSAGetLastError ( VOID  )

Definition at line 131 of file dllmain.c.

132{
133 /* Let the Windows Function do the work */
134 return GetLastError();
135}
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by __rpc_fd2sockinfo(), __rpc_get_time_offset(), AcceptConnections(), AdapterDiscoveryThread(), AreLegacyFunctionsSupported(), bindresvport_sa(), clnt_vc_create(), create_netconn_socket(), CreateSocket(), dataconn(), detectChange(), do_bind(), drain_socket_thread(), EchoIncomingPackets(), ErrorExit(), event_client(), Exit(), fputcSocket(), fputSocket(), FTP_Connect(), FTPFILE_WriteFile(), getdomainname(), GetIpHostName(), got_one(), InternetTransport_ReadLine(), InternetTransport_WndProc(), InternetTransport_Write(), IsWinsockInitialized(), main(), make_listening_socket(), mwsNSPLookupServiceBegin(), mwsNSPLookupServiceNext(), NetBTRecv(), NETCON_is_alive(), NETCON_recv(), NETCON_send(), NETCON_set_timeout(), netconn_create(), netconn_is_alive(), netconn_set_timeout(), netfinger(), open_http(), POP3Transport_ParseResponse(), print_getaddrinfo(), processRequest(), read_ssl_chunk(), read_vc(), ReceiveIncomingPackets(), recvrequest(), ResolveTarget(), rpcrt4_conn_tcp_read(), rpcrt4_conn_tcp_write(), rpcrt4_ip_tcp_get_top_of_tower(), rpcrt4_ip_tcp_parse_top_of_tower(), rpcrt4_ncacn_ip_tcp_open(), rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(), rpcrt4_protseq_sock_get_wait_array(), rpcrt4_sock_wait_for_recv(), rpcrt4_sock_wait_for_send(), rtime(), SConnect(), select_server(), send_file(), SendLine(), sendrequest(), SendRequest(), SendTime(), SError(), setup_iocp_src(), SetUpListener(), ShutdownConnection(), sock_recv(), sock_send(), START_TEST(), svc_run(), Test_CloseDuplicatedSocket(), Test_CloseWhileSelectDuplicatedSocket(), Test_CloseWhileSelectSameSocket(), test_events(), test_GetAddrInfoW(), test_GetExtendedTcpTable_owner(), test_GetExtendedUdpTable_owner(), test_gethostbyname(), test_ip_pktinfo(), Test_Overread(), test_select(), test_send(), test_sendto(), test_set_getsockopt(), test_WithoutWSAStartup(), test_WithWSAStartup(), test_WSAEnumProtocolsA(), test_WSAEnumProtocolsW(), Test_WSAIoctl_GetInterfaceList(), Test_WSARecv(), TestBind(), TestNodeName(), TestServiceName(), wmain(), write_vc(), WspiapiLegacyGetNameInfo(), and WspiapiQueryDNS().

◆ WSASetLastError()

Variable Documentation

◆ GlobalTlsIndex

DWORD GlobalTlsIndex = TLS_OUT_OF_INDEXES

Definition at line 23 of file dllmain.c.

Referenced by DllMain().

◆ WsDllHandle

HINSTANCE WsDllHandle

Definition at line 22 of file dllmain.c.

Referenced by DllMain(), and WSAStartup().

◆ WsSockHeap