ReactOS  0.4.14-dev-593-g1793dcc
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 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 29 of file dllmain.c.

32 {
33  PWSPROCESS WsProcess;
34 
35  /* Main Entrypoint */
36  switch (dwReason)
37  {
38  case DLL_PROCESS_ATTACH:
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 
61  case DLL_THREAD_ATTACH:
62  break;
63 
64  case DLL_THREAD_DETACH:
65  /* Destroy the attached Winsock Thread */
67  break;
68 
69  case DLL_PROCESS_DETACH:
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 */
85  WsSockCleanup();
86 
87  /* Cleanup critical sections */
90 
91  /* Free the TLS Index */
93  }
94 
95  /* Cleanup RAS auto-dial helper */
97 
98  /* Clear our handle */
99  WsDllHandle = NULL;
100  break;
101  }
102 
103  /* Return to OS */
104  return TRUE;
105 }
#define TRUE
Definition: types.h:120
#define DLL_THREAD_ATTACH
Definition: compat.h:121
HANDLE WsSockHeap
Definition: dllmain.c:21
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
VOID WSAAPI WsCreateStartupSynchronization(VOID)
Definition: startup.c:28
#define DLL_THREAD_DETACH
Definition: compat.h:122
VOID WSAAPI WsAsyncGlobalInitialize(VOID)
Definition: async.c:31
DWORD dwReason
Definition: misc.cpp:154
DWORD GlobalTlsIndex
Definition: dllmain.c:23
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PWSPROCESS WsGetProcess(VOID)
Definition: ws2_32p.h:885
VOID WSAAPI WsRasInitializeAutodial(VOID)
Definition: rasdial.c:47
VOID WSAAPI WsSockCleanup(VOID)
Definition: dsocket.c:36
VOID WSAAPI WsThreadCleanup(VOID)
Definition: dthread.c:170
#define DLL_PROCESS_DETACH
Definition: compat.h:119
#define GetProcessHeap()
Definition: compat.h:403
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1154
VOID WSAAPI WsDestroyStartupSynchronization(VOID)
Definition: startup.c:36
VOID WSAAPI WsProcDelete(IN PWSPROCESS Process)
Definition: dprocess.c:247
VOID WSAAPI WsThreadDestroyCurrentThread(VOID)
Definition: dthread.c:225
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1088
#define TLS_OUT_OF_INDEXES
Definition: winbase.h:530
VOID WSAAPI WsAsyncGlobalTerminate(VOID)
Definition: async.c:39
VOID WSAAPI WsRasUninitializeAutodial(VOID)
Definition: rasdial.c:55
HINSTANCE WsDllHandle
Definition: dllmain.c:22
HMODULE hModule
Definition: animate.c:44

◆ WSAGetLastError()

INT WSAAPI WSAGetLastError ( VOID  )

Definition at line 112 of file dllmain.c.

113 {
114  /* Let the Windows Function do the work */
115  return GetLastError();
116 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059

Referenced by __rpc_fd2sockinfo(), __rpc_get_time_offset(), AcceptConnections(), AdapterDiscoveryThread(), AreLegacyFunctionsSupported(), bindresvport_sa(), clnt_vc_create(), create_netconn_socket(), CreateSocket(), dataconn(), detectChange(), do_bind(), do_getservbyname(), drain_socket_thread(), EchoIncomingPackets(), ErrorExit(), event_client(), Exit(), fputcSocket(), fputSocket(), FTP_Connect(), FTPFILE_WriteFile(), getdomainname(), GetIpHostName(), got_one(), IcmpSendEcho(), 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_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_connector_socket(), setup_iocp_src(), setup_server_socket(), SetUpListener(), ShutdownConnection(), sock_recv(), sock_send(), START_TEST(), svc_run(), test_accept(), test_AcceptEx(), test_addr_to_print(), test_address_list_query(), Test_CloseDuplicatedSocket(), Test_CloseWhileSelectDuplicatedSocket(), Test_CloseWhileSelectSameSocket(), test_completion_port(), test_ConnectEx(), test_DisconnectEx(), test_errors(), test_events(), test_extendedSocketOptions(), test_getaddrinfo(), test_GetAddrInfoExW(), test_GetAddrInfoW(), test_gethostbyname(), test_gethostbyname_hack(), test_gethostname(), test_getpeername(), test_getsockname(), test_inet_pton(), test_ioctlsocket(), test_ip_pktinfo(), test_ipv6only(), test_listen(), test_select(), test_send(), test_sendto(), test_set_getsockopt(), test_sioAddressListChange(), test_sioRoutingInterfaceQuery(), test_so_reuseaddr(), test_synchronous_WSAIoctl(), test_TransmitFile(), test_WithoutWSAStartup(), test_WithWSAStartup(), test_WSAAddressToStringA(), test_WSAAddressToStringW(), test_WSADuplicateSocket(), test_WSAEnumNameSpaceProvidersA(), test_WSAEnumNameSpaceProvidersW(), test_WSAEnumProtocolsA(), test_WSAEnumProtocolsW(), Test_WSAIoctl_GetInterfaceList(), test_WSALookupService(), test_WSAPoll(), Test_WSARecv(), test_WSARecv(), test_WSASendMsg(), test_WSASendTo(), test_WSASocket(), test_WSAStringToAddressA(), test_WSAStringToAddressW(), TestBind(), TestNodeName(), TestServiceName(), verify_ipv6_addrinfo(), 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