ReactOS  0.4.15-dev-1184-g23e04ae
dllmain.c
Go to the documentation of this file.
1 /*
2  * dllmain.c
3  */
4 
5 #include <precomp.h>
6 
8 extern HGDIOBJ stock_objects[];
15 
16 /*
17  * GDI32.DLL does have an entry point for disable threadlibrarycall,. The initialization is done by a call
18  * to GdiDllInitialize(). This call is done from the entry point of USER32.DLL.
19  */
20 BOOL
21 WINAPI
23  HANDLE hDll,
25  LPVOID lpReserved)
26 {
27  switch (dwReason)
28  {
29  case DLL_PROCESS_ATTACH :
31  break;
32 
33  default:
34  break;
35  }
36  return TRUE;
37 }
38 
39 
40 VOID
41 WINAPI
43 {
44  if (!gbInitialized)
45  {
48 
49  /* map the gdi handle table to user space */
50  GdiHandleTable = NtCurrentTeb()->ProcessEnvironmentBlock->GdiSharedHandleTable;
51  GdiSharedHandleTable = NtCurrentTeb()->ProcessEnvironmentBlock->GdiSharedHandleTable;
53  CurrentProcessId = NtCurrentTeb()->ClientId.UniqueProcess;
54  GDI_BatchLimit = (DWORD) NtCurrentTeb()->ProcessEnvironmentBlock->GdiDCAttributeList;
55  GdiHandleCache = (PGDIHANDLECACHE)NtCurrentTeb()->ProcessEnvironmentBlock->GdiHandleBuffer;
59  }
60 }
61 
62 VOID
63 WINAPI
65 {
68 }
69 
70 
71 /*
72  * @implemented
73  */
74 BOOL
75 WINAPI
77  HANDLE hDll,
79  LPVOID lpReserved)
80 {
81  switch (dwReason)
82  {
83  case DLL_PROCESS_ATTACH:
84  {
85  /* Don't bother us for each thread */
86  // DisableThreadLibraryCalls(hDll);
87 
88  /* Initialize the kernel part of GDI first */
89  if (!NtGdiInit()) return FALSE;
90 
91  /* Now initialize ourselves */
93  break;
94  }
95 
96  case DLL_THREAD_ATTACH:
97  {
98  NtCurrentTeb()->GdiTebBatch.Offset = 0;
99  NtCurrentTeb()->GdiBatchCount = 0;
100  break;
101  }
102 
103  case DLL_PROCESS_DETACH:
104  {
105  /* Cleanup */
107  return TRUE;
108  }
109 
110  default:
111  return FALSE;
112  }
113 
114  /* Very simple, the list will fill itself as it is needed */
115  if (!SetStockObjects)
116  {
117  RtlZeroMemory(&stock_objects, NB_STOCK_OBJECTS); // Assume ROS is dirty
119  }
120 
121  return TRUE;
122 }
123 
124 /* EOF */
BOOL gbLpk
Definition: dllmain.c:12
__kernel_entry W32KAPI BOOL APIENTRY NtGdiInit(VOID)
Definition: init.c:85
DWORD GDI_BatchLimit
Definition: misc.c:36
#define NB_STOCK_OBJECTS
Definition: ntgdityp.h:192
#define TRUE
Definition: types.h:120
VOID WINAPI GdiProcessShutdown(VOID)
Definition: dllmain.c:64
#define DLL_THREAD_ATTACH
Definition: compat.h:132
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
Definition: dllmain.c:52
#define DWORD
Definition: nt_native.h:44
DWORD dwReason
Definition: misc.cpp:154
VOID WINAPI GdiProcessSetup(VOID)
Definition: dllmain.c:42
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID WINAPI GdiInitializeLanguagePack(_In_ DWORD InitParam)
PGDIHANDLECACHE GdiHandleCache
Definition: dllmain.c:11
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
smooth NULL
Definition: ftsmooth.c:416
CRITICAL_SECTION gcsClientObjLinks
Definition: clientobj.c:10
#define DLL_PROCESS_DETACH
Definition: compat.h:130
HANDLE CurrentProcessId
Definition: misc.c:35
#define GdiHandleTable
Definition: win32nt.h:35
struct _GDIHANDLECACHE * PGDIHANDLECACHE
#define GetProcessHeap()
Definition: compat.h:484
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
static BOOL gbInitialized
Definition: dllmain.c:7
#define WINAPI
Definition: msvc.h:6
PGDI_SHARED_HANDLE_TABLE GdiSharedHandleTable
Definition: misc.c:34
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI GdiDllInitialize(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
Definition: dllmain.c:76
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
RTL_CRITICAL_SECTION semLocal
Definition: dllmain.c:13
PDEVCAPS GdiDevCaps
Definition: dllmain.c:10
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
BOOL SetStockObjects
Definition: dllmain.c:9
HGDIOBJ stock_objects[]
Definition: gdiobj.c:6
HANDLE hProcessHeap
Definition: kbswitch.c:25