ReactOS 0.4.15-dev-7906-g1b85a5f
dllmain.c File Reference
#include "precomp.h"
Include dependency graph for dllmain.c:

Go to the source code of this file.

Functions

VOID WINAPI NewCtxInit (VOID)
 
DWORD WINAPI Ws2helpInitialize (VOID)
 
BOOL APIENTRY DllMain (HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
 

Variables

HANDLE GlobalHeap
 
BOOL Ws2helpInitialized = FALSE
 
CRITICAL_SECTION StartupSynchronization
 
HINSTANCE LibraryHdl
 

Function Documentation

◆ DllMain()

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

Definition at line 123 of file dllmain.c.

126{
127 switch (dwReason)
128 {
130
131 /* Save our handle */
133
134 /* Improve Performance */
136
137 /* Initialize startup CS */
139
140 /* Get Global Heap */
142 break;
143
146 break;
147
149
150 /* Make sure we loaded */
151 if (!LibraryHdl) break;
152
153 /* Check if we are cleaning up */
154 if (lpReserved)
155 {
156 /* Free the security descriptor */
158
159 /* Close the event */
161
162 /* Delete the startup CS */
165 }
166 break;
167 }
168
169 return TRUE;
170}
DWORD dwReason
Definition: misc.cpp:154
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HMODULE hModule
Definition: animate.c:44
#define CloseHandle
Definition: compat.h:739
#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 HeapFree(x, y, z)
Definition: compat.h:735
#define DLL_THREAD_ATTACH
Definition: compat.h:132
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)

◆ NewCtxInit()

VOID WINAPI NewCtxInit ( VOID  )

Definition at line 23 of file dllmain.c.

24{
25 NT_PRODUCT_TYPE ProductType = NtProductWinNt;
26 SYSTEM_INFO SystemInfo;
27 DWORD NumHandleBuckets;
29 DWORD RegSize = sizeof(DWORD);
30 DWORD RegType;
31 DWORD Mask;
32
33 /* Try to figure out if this is a workstation or server install */
34 RtlGetNtProductType(&ProductType);
35
36 /* Get the system info */
37 GetSystemInfo(&SystemInfo);
38
39 /* If this is an MP machine, set the default spinlock */
40 if (SystemInfo.dwNumberOfProcessors > 1) gdwSpinCount = 2000;
41
42 /* Figure how many "Handle Buckets" we'll use. Start with the default */
43 NumHandleBuckets = ProductType == NtProductWinNt ? 8 : 32;
44
45 /* Open the registry settings */
47 "System\\CurrentControlSet\\Services\\Winsock2\\Parameters",
48 0,
51 {
52 /* Query the key */
54 "Ws2_32NumHandleBuckets",
55 0,
56 &RegType,
57 (LPBYTE)&NumHandleBuckets,
58 &RegSize);
59
60 /* Are we on MP? */
61 if (SystemInfo.dwNumberOfProcessors > 1)
62 {
63 /* Also check for a custom spinlock setting */
65 "Ws2_32SpinCount",
66 0,
67 &RegType,
69 &RegSize);
70 }
71
72 /* Close the key, we're done */
74 }
75
76 /* Now get the bucket count and normalize it to be log2 and within 256 */
77 for (Mask = 256; !(Mask & NumHandleBuckets); Mask >>= 1);
78 NumHandleBuckets = Mask;
79
80 /* Normalize it again, to be within OS parameters */
81 if (ProductType == NtProductWinNt)
82 {
83 /* Is it within norms for non-server editions? */
84 if (NumHandleBuckets > 32) NumHandleBuckets = 32;
85 else if (NumHandleBuckets < 8) NumHandleBuckets = 8;
86 }
87 else
88 {
89 /* Is it within norms for server editions? */
90 if (NumHandleBuckets > 256) NumHandleBuckets = 256;
91 else if (NumHandleBuckets < 32) NumHandleBuckets = 32;
92 }
93
94 /* Normalize the spincount */
95 if (gdwSpinCount > 8000) gdwSpinCount = 8000;
96
97 /* Set the final mask */
98 gHandleToIndexMask = NumHandleBuckets -1;
99}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOLEAN NTAPI RtlGetNtProductType(_Out_ PNT_PRODUCT_TYPE ProductType)
Definition: version.c:96
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
enum _NT_PRODUCT_TYPE NT_PRODUCT_TYPE
@ NtProductWinNt
Definition: shellpath.c:64
DWORD gdwSpinCount
Definition: context.c:18
DWORD gHandleToIndexMask
Definition: context.c:19
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned int Mask
Definition: fpcontrol.c:82
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define DWORD
Definition: nt_native.h:44
DWORD dwNumberOfProcessors
Definition: winbase.h:1177
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegQueryValueEx
Definition: winreg.h:524

Referenced by Ws2helpInitialize().

◆ Ws2helpInitialize()

DWORD WINAPI Ws2helpInitialize ( VOID  )

Definition at line 103 of file dllmain.c.

104{
105 /* Enter the startup CS */
107
108 /* Check again for init */
110 {
111 /* Initialize us */
112 NewCtxInit();
114 }
115
116 /* Leave the CS and return */
118 return ERROR_SUCCESS;
119}
VOID WINAPI NewCtxInit(VOID)
Definition: dllmain.c:23
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Variable Documentation

◆ GlobalHeap

HANDLE GlobalHeap

Definition at line 14 of file dllmain.c.

◆ LibraryHdl

HINSTANCE LibraryHdl

Definition at line 17 of file dllmain.c.

Referenced by DllMain().

◆ StartupSynchronization

CRITICAL_SECTION StartupSynchronization

Definition at line 16 of file dllmain.c.

Referenced by DllMain(), and Ws2helpInitialize().

◆ Ws2helpInitialized

BOOL Ws2helpInitialized = FALSE

Definition at line 15 of file dllmain.c.

Referenced by DllMain(), and Ws2helpInitialize().