ReactOS  0.4.15-dev-5452-g3c95c95
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 DisableThreadLibraryCalls().
18  * The initialization is done by a call to GdiDllInitialize(). This
19  * call is done from the entry point of USER32.DLL.
20  */
21 BOOL
22 WINAPI
24  _In_ HANDLE hDll,
26  _In_opt_ PVOID pReserved)
27 {
28  UNREFERENCED_PARAMETER(pReserved);
29 
30  switch (dwReason)
31  {
32  case DLL_PROCESS_ATTACH :
34  break;
35 
36  default:
37  break;
38  }
39  return TRUE;
40 }
41 
42 
43 VOID
44 WINAPI
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 }
64 
65 VOID
66 WINAPI
68 {
71 }
72 
73 
74 /*
75  * @implemented
76  */
77 BOOL
78 WINAPI
80  _In_ HANDLE hDll,
82  _In_opt_ PVOID pReserved)
83 {
84  UNREFERENCED_PARAMETER(pReserved);
85 
86  switch (dwReason)
87  {
88  case DLL_PROCESS_ATTACH:
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 
101  case DLL_THREAD_ATTACH:
102  {
103  NtCurrentTeb()->GdiTebBatch.Offset = 0;
104  NtCurrentTeb()->GdiBatchCount = 0;
105  break;
106  }
107 
108  case DLL_PROCESS_DETACH:
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 }
128 
129 /* EOF */
BOOL gbLpk
Definition: dllmain.c:12
__kernel_entry W32KAPI BOOL APIENTRY NtGdiInit(VOID)
Definition: init.c:85
#define _In_opt_
Definition: ms_sal.h:309
DWORD GDI_BatchLimit
Definition: misc.c:36
#define NB_STOCK_OBJECTS
Definition: ntgdityp.h:192
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
VOID WINAPI GdiProcessShutdown(VOID)
Definition: dllmain.c:67
#define DLL_THREAD_ATTACH
Definition: compat.h:132
BOOL WINAPI GdiDllInitialize(_In_ HANDLE hDll, _In_ ULONG dwReason, _In_opt_ PVOID pReserved)
Definition: dllmain.c:79
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:45
#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
CRITICAL_SECTION gcsClientObjLinks
Definition: clientobj.c:10
#define _In_
Definition: ms_sal.h:308
#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:736
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
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
RTL_CRITICAL_SECTION semLocal
Definition: dllmain.c:13
#define NULL
Definition: types.h:112
PDEVCAPS GdiDevCaps
Definition: dllmain.c:10
unsigned int ULONG
Definition: retypes.h:1
#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:34