ReactOS
0.4.16-dev-1204-gb627a42
Toggle main menu visibility
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
Variables
_
c
d
e
f
g
h
i
l
m
n
o
p
s
t
u
x
Typedefs
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
x
Enumerations
_
a
b
c
d
f
i
l
m
o
p
s
t
w
x
Enumerator
a
b
c
d
e
f
g
h
i
m
n
o
p
r
s
t
u
v
w
x
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
z
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Related Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
x
Files
File List
File Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Examples
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
21
HANDLE
WsSockHeap
;
22
HINSTANCE
WsDllHandle
;
23
DWORD
GlobalTlsIndex
=
TLS_OUT_OF_INDEXES
;
24
25
/* FUNCTIONS *****************************************************************/
26
27
#if (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA)
28
BOOL
29
APIENTRY
30
Ws2HelpDllMain
(
31
HANDLE
hModule
,
32
DWORD
dwReason
,
33
LPVOID
lpReserved
);
34
#endif
35
36
BOOL
37
APIENTRY
38
DllMain
(
HANDLE
hModule
,
39
DWORD
dwReason
,
40
LPVOID
lpReserved
)
41
{
42
PWSPROCESS
WsProcess;
43
44
#if (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA)
45
/* Initialize ws2help */
46
if
(!
Ws2HelpDllMain
(
hModule
,
dwReason
,
lpReserved
))
47
{
48
/* Should never happen */
49
ASSERT
(
FALSE
);
50
return
FALSE
;
51
}
52
#endif
53
54
/* Main Entrypoint */
55
switch
(
dwReason
)
56
{
57
case
DLL_PROCESS_ATTACH
:
58
/* Save DLL Handle */
59
WsDllHandle
=
hModule
;
60
61
/* Get Global Heap */
62
WsSockHeap
=
GetProcessHeap
();
63
64
/* TLS Allocation */
65
if
(
GlobalTlsIndex
==
TLS_OUT_OF_INDEXES
)
66
{
67
GlobalTlsIndex
=
TlsAlloc
();
68
if
(
GlobalTlsIndex
==
TLS_OUT_OF_INDEXES
)
69
{
70
return
FALSE
;
71
}
72
}
73
74
/* Initialize some critical sections */
75
WsCreateStartupSynchronization
();
76
WsAsyncGlobalInitialize
();
77
WsRasInitializeAutodial
();
78
break
;
79
80
case
DLL_THREAD_ATTACH
:
81
break
;
82
83
case
DLL_THREAD_DETACH
:
84
/* Destroy the attached Winsock Thread */
85
WsThreadDestroyCurrentThread
();
86
break
;
87
88
case
DLL_PROCESS_DETACH
:
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 */
96
WsThreadDestroyCurrentThread
();
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 */
103
WsThreadCleanup
();
104
WsSockCleanup
();
105
106
/* Cleanup critical sections */
107
WsDestroyStartupSynchronization
();
108
WsAsyncGlobalTerminate
();
109
110
/* Free the TLS Index */
111
TlsFree
(
GlobalTlsIndex
);
112
}
113
114
/* Cleanup RAS auto-dial helper */
115
WsRasUninitializeAutodial
();
116
117
/* Clear our handle */
118
WsDllHandle
=
NULL
;
119
break
;
120
}
121
122
/* Return to OS */
123
return
TRUE
;
124
}
125
126
/*
127
* @implemented
128
*/
129
INT
130
WSAAPI
131
WSAGetLastError
(
VOID
)
132
{
133
/* Let the Windows Function do the work */
134
return
GetLastError
();
135
}
136
137
/*
138
* @implemented
139
*/
140
VOID
141
WSAAPI
142
WSASetLastError
(
IN
INT
iError)
143
{
144
/* Let the Windows Function do the work */
145
SetLastError
(iError);
146
}
lpReserved
static DWORD const LPVOID const lpReserved
Definition:
appcrt_dllmain.cpp:58
dwReason
DWORD dwReason
Definition:
misc.cpp:135
NULL
#define NULL
Definition:
types.h:112
TRUE
#define TRUE
Definition:
types.h:120
FALSE
#define FALSE
Definition:
types.h:117
DllMain
BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
Definition:
dllmain.c:52
APIENTRY
#define APIENTRY
Definition:
api.h:79
hModule
HMODULE hModule
Definition:
animate.c:44
GetProcessHeap
#define GetProcessHeap()
Definition:
compat.h:736
DLL_THREAD_DETACH
#define DLL_THREAD_DETACH
Definition:
compat.h:133
DLL_PROCESS_ATTACH
#define DLL_PROCESS_ATTACH
Definition:
compat.h:131
DLL_PROCESS_DETACH
#define DLL_PROCESS_DETACH
Definition:
compat.h:130
SetLastError
#define SetLastError(x)
Definition:
compat.h:752
DLL_THREAD_ATTACH
#define DLL_THREAD_ATTACH
Definition:
compat.h:132
TlsAlloc
DWORD WINAPI TlsAlloc(VOID)
Definition:
thread.c:1100
TlsFree
BOOL WINAPI TlsFree(IN DWORD Index)
Definition:
thread.c:1166
Ws2HelpDllMain
BOOL APIENTRY Ws2HelpDllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
Definition:
dllmain.c:123
GlobalTlsIndex
DWORD GlobalTlsIndex
Definition:
dllmain.c:23
WSASetLastError
VOID WSAAPI WSASetLastError(IN INT iError)
Definition:
dllmain.c:142
WsDllHandle
HINSTANCE WsDllHandle
Definition:
dllmain.c:22
WsSockHeap
HANDLE WsSockHeap
Definition:
dllmain.c:21
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
DWORD
unsigned long DWORD
Definition:
ntddk_ex.h:95
void
Definition:
nsiface.idl:2307
ASSERT
#define ASSERT(a)
Definition:
mode.c:44
_WSPROCESS
Definition:
ws2_32p.h:161
INT
int32_t INT
Definition:
typedefs.h:58
IN
#define IN
Definition:
typedefs.h:39
GetLastError
DWORD WINAPI GetLastError(void)
Definition:
except.c:1042
TLS_OUT_OF_INDEXES
#define TLS_OUT_OF_INDEXES
Definition:
winbase.h:585
WSAAPI
#define WSAAPI
Definition:
winsock2.h:605
WSAGetLastError
int PASCAL FAR WSAGetLastError(void)
Definition:
dllmain.c:131
WsSockCleanup
VOID WSAAPI WsSockCleanup(VOID)
Definition:
dsocket.c:36
WsRasInitializeAutodial
VOID WSAAPI WsRasInitializeAutodial(VOID)
Definition:
rasdial.c:47
WsGetProcess
FORCEINLINE PWSPROCESS WsGetProcess(VOID)
Definition:
ws2_32p.h:885
WsThreadCleanup
VOID WSAAPI WsThreadCleanup(VOID)
Definition:
dthread.c:170
WsProcDelete
VOID WSAAPI WsProcDelete(IN PWSPROCESS Process)
Definition:
dprocess.c:247
WsDestroyStartupSynchronization
VOID WSAAPI WsDestroyStartupSynchronization(VOID)
Definition:
startup.c:36
WsCreateStartupSynchronization
VOID WSAAPI WsCreateStartupSynchronization(VOID)
Definition:
startup.c:28
WsRasUninitializeAutodial
VOID WSAAPI WsRasUninitializeAutodial(VOID)
Definition:
rasdial.c:55
WsThreadDestroyCurrentThread
VOID WSAAPI WsThreadDestroyCurrentThread(VOID)
Definition:
dthread.c:225
WsAsyncGlobalTerminate
VOID WSAAPI WsAsyncGlobalTerminate(VOID)
Definition:
async.c:39
WsAsyncGlobalInitialize
VOID WSAAPI WsAsyncGlobalInitialize(VOID)
Definition:
async.c:31
dll
win32
ws2_32
src
dllmain.c
Generated on Wed May 28 2025 06:16:42 for ReactOS by
1.9.6