ReactOS 0.4.15-dev-7674-gc0b4db1
dllmain.c File Reference
#include <precomp.h>
Include dependency graph for dllmain.c:

Go to the source code of this file.

Functions

BOOL WINAPI DllMain (_In_ HANDLE hDll, _In_ ULONG dwReason, _In_opt_ PVOID pReserved)
 
VOID WINAPI GdiProcessSetup (VOID)
 
VOID WINAPI GdiProcessShutdown (VOID)
 
BOOL WINAPI GdiDllInitialize (_In_ HANDLE hDll, _In_ ULONG dwReason, _In_opt_ PVOID pReserved)
 

Variables

static BOOL gbInitialized = FALSE
 
HGDIOBJ stock_objects []
 
BOOL SetStockObjects = FALSE
 
PDEVCAPS GdiDevCaps = NULL
 
PGDIHANDLECACHE GdiHandleCache = NULL
 
BOOL gbLpk = FALSE
 
RTL_CRITICAL_SECTION semLocal
 
CRITICAL_SECTION gcsClientObjLinks
 

Function Documentation

◆ DllMain()

BOOL WINAPI DllMain ( _In_ HANDLE  hDll,
_In_ ULONG  dwReason,
_In_opt_ PVOID  pReserved 
)

Definition at line 23 of file dllmain.c.

27{
28 UNREFERENCED_PARAMETER(pReserved);
29
30 switch (dwReason)
31 {
34 break;
35
36 default:
37 break;
38 }
39 return TRUE;
40}
DWORD dwReason
Definition: misc.cpp:154
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

◆ GdiDllInitialize()

BOOL WINAPI GdiDllInitialize ( _In_ HANDLE  hDll,
_In_ ULONG  dwReason,
_In_opt_ PVOID  pReserved 
)

Definition at line 79 of file dllmain.c.

83{
84 UNREFERENCED_PARAMETER(pReserved);
85
86 switch (dwReason)
87 {
89 {
90 /* Don't bother us for each thread */
91 // DisableThreadLibraryCalls(hDll);
92
93 /* Initialize the kernel part of GDI first */
94 if (!NtGdiInit()) return FALSE;
95
96 /* Now initialize ourselves */
98 break;
99 }
100
102 {
103 NtCurrentTeb()->GdiTebBatch.Offset = 0;
104 NtCurrentTeb()->GdiBatchCount = 0;
105 break;
106 }
107
109 {
110 /* Cleanup */
112 return TRUE;
113 }
114
115 default:
116 return FALSE;
117 }
118
119 /* Very simple, the list will fill itself as it is needed */
120 if (!SetStockObjects)
121 {
122 RtlZeroMemory(&stock_objects, NB_STOCK_OBJECTS); // Assume ROS is dirty
124 }
125
126 return TRUE;
127}
#define FALSE
Definition: types.h:117
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define DLL_THREAD_ATTACH
Definition: compat.h:132
#define NtCurrentTeb
__kernel_entry W32KAPI BOOL APIENTRY NtGdiInit(VOID)
Definition: init.c:107
#define NB_STOCK_OBJECTS
Definition: ntgdityp.h:192
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
VOID WINAPI GdiProcessShutdown(VOID)
Definition: dllmain.c:67
HGDIOBJ stock_objects[]
Definition: gdiobj.c:6
VOID WINAPI GdiProcessSetup(VOID)
Definition: dllmain.c:45
BOOL SetStockObjects
Definition: dllmain.c:9

Referenced by DllMain().

◆ GdiProcessSetup()

VOID WINAPI GdiProcessSetup ( VOID  )

Definition at line 45 of file dllmain.c.

46{
47 if (!gbInitialized)
48 {
51
52 /* map the gdi handle table to user space */
53 GdiHandleTable = NtCurrentTeb()->ProcessEnvironmentBlock->GdiSharedHandleTable;
54 GdiSharedHandleTable = NtCurrentTeb()->ProcessEnvironmentBlock->GdiSharedHandleTable;
56 CurrentProcessId = NtCurrentTeb()->ClientId.UniqueProcess;
57 GDI_BatchLimit = (DWORD) NtCurrentTeb()->ProcessEnvironmentBlock->GdiDCAttributeList;
58 GdiHandleCache = (PGDIHANDLECACHE)NtCurrentTeb()->ProcessEnvironmentBlock->GdiHandleBuffer;
62 }
63}
#define GetProcessHeap()
Definition: compat.h:736
HANDLE CurrentProcessId
Definition: misc.c:35
VOID WINAPI GdiInitializeLanguagePack(_In_ DWORD InitParam)
PGDI_SHARED_HANDLE_TABLE GdiSharedHandleTable
Definition: misc.c:34
DWORD GDI_BatchLimit
Definition: misc.c:36
HANDLE hProcessHeap
Definition: kbswitch.c:43
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define DWORD
Definition: nt_native.h:44
struct _GDIHANDLECACHE * PGDIHANDLECACHE
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define GdiHandleTable
Definition: win32nt.h:37
RTL_CRITICAL_SECTION semLocal
Definition: dllmain.c:13
CRITICAL_SECTION gcsClientObjLinks
Definition: clientobj.c:10
PDEVCAPS GdiDevCaps
Definition: dllmain.c:10
static BOOL gbInitialized
Definition: dllmain.c:7
PGDIHANDLECACHE GdiHandleCache
Definition: dllmain.c:11

Referenced by ClientThreadSetupHelper(), and GdiDllInitialize().

◆ GdiProcessShutdown()

VOID WINAPI GdiProcessShutdown ( VOID  )

Definition at line 67 of file dllmain.c.

68{
71}
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by GdiDllInitialize().

Variable Documentation

◆ gbInitialized

BOOL gbInitialized = FALSE
static

Definition at line 7 of file dllmain.c.

Referenced by GdiProcessSetup().

◆ gbLpk

BOOL gbLpk = FALSE

Definition at line 12 of file dllmain.c.

Referenced by GdiInitializeLanguagePack(), and GetFontLanguageInfo().

◆ gcsClientObjLinks

◆ GdiDevCaps

PDEVCAPS GdiDevCaps = NULL

Definition at line 10 of file dllmain.c.

Referenced by GdiProcessSetup(), and GetDeviceCaps().

◆ GdiHandleCache

PGDIHANDLECACHE GdiHandleCache = NULL

Definition at line 11 of file dllmain.c.

Referenced by GdiProcessSetup(), and hGetPEBHandle().

◆ semLocal

Definition at line 13 of file dllmain.c.

Referenced by GdiProcessSetup(), GdiProcessShutdown(), and LoadTheSpoolerDrv().

◆ SetStockObjects

BOOL SetStockObjects = FALSE

Definition at line 9 of file dllmain.c.

Referenced by GdiDllInitialize().

◆ stock_objects

HGDIOBJ stock_objects[]
extern

Definition at line 6 of file gdiobj.c.

Referenced by GdiDllInitialize(), and GetStockObject().