ReactOS  0.4.12-dev-916-gffc4e30
dllmain.c
Go to the documentation of this file.
1 /*
2  * dllmain.c
3  */
4 
5 #include <precomp.h>
6 
7 extern HGDIOBJ stock_objects[];
14 
15 /*
16  * GDI32.DLL does have an entry point for disable threadlibrarycall,. The initialization is done by a call
17  * to GdiDllInitialize(). This call is done from the entry point of USER32.DLL.
18  */
19 BOOL
20 WINAPI
22  HANDLE hDll,
24  LPVOID lpReserved)
25 {
26  switch (dwReason)
27  {
28  case DLL_PROCESS_ATTACH :
30  break;
31 
32  default:
33  break;
34  }
35  return TRUE;
36 }
37 
38 
39 VOID
40 WINAPI
42 {
44 
45  /* map the gdi handle table to user space */
46  GdiHandleTable = NtCurrentTeb()->ProcessEnvironmentBlock->GdiSharedHandleTable;
47  GdiSharedHandleTable = NtCurrentTeb()->ProcessEnvironmentBlock->GdiSharedHandleTable;
49  CurrentProcessId = NtCurrentTeb()->ClientId.UniqueProcess;
50  GDI_BatchLimit = (DWORD) NtCurrentTeb()->ProcessEnvironmentBlock->GdiDCAttributeList;
51  GdiHandleCache = (PGDIHANDLECACHE)NtCurrentTeb()->ProcessEnvironmentBlock->GdiHandleBuffer;
55 }
56 
57 VOID
58 WINAPI
60 {
63 }
64 
65 
66 /*
67  * @implemented
68  */
69 BOOL
70 WINAPI
72  HANDLE hDll,
74  LPVOID lpReserved)
75 {
76  switch (dwReason)
77  {
78  case DLL_PROCESS_ATTACH:
79  {
80  /* Don't bother us for each thread */
81  // DisableThreadLibraryCalls(hDll);
82 
83  /* Initialize the kernel part of GDI first */
84  if (!NtGdiInit()) return FALSE;
85 
86  /* Now initialize ourselves */
88  break;
89  }
90 
91  case DLL_THREAD_ATTACH:
92  {
93  NtCurrentTeb()->GdiTebBatch.Offset = 0;
94  NtCurrentTeb()->GdiBatchCount = 0;
95  break;
96  }
97 
98  case DLL_PROCESS_DETACH:
99  {
100  /* Cleanup */
102  return TRUE;
103  }
104 
105  default:
106  return FALSE;
107  }
108 
109  /* Very simple, the list will fill itself as it is needed */
110  if (!SetStockObjects)
111  {
112  RtlZeroMemory(&stock_objects, NB_STOCK_OBJECTS); // Assume ROS is dirty
114  }
115 
116  return TRUE;
117 }
118 
119 /* EOF */
#define TRUE
Definition: types.h:120
BOOL gbLpk
Definition: dllmain.c:11
__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:189
VOID WINAPI GdiProcessShutdown(VOID)
Definition: dllmain.c:59
#define DLL_THREAD_ATTACH
Definition: compat.h:121
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
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:41
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID WINAPI GdiInitializeLanguagePack(_In_ DWORD InitParam)
PGDIHANDLECACHE GdiHandleCache
Definition: dllmain.c:10
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:697
smooth NULL
Definition: ftsmooth.c:416
CRITICAL_SECTION gcsClientObjLinks
Definition: clientobj.c:10
#define DLL_PROCESS_DETACH
Definition: compat.h:119
HANDLE CurrentProcessId
Definition: misc.c:35
#define GdiHandleTable
Definition: win32nt.h:36
struct _GDIHANDLECACHE * PGDIHANDLECACHE
#define GetProcessHeap()
Definition: compat.h:395
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define WINAPI
Definition: msvc.h:8
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:71
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
RTL_CRITICAL_SECTION semLocal
Definition: dllmain.c:12
PDEVCAPS GdiDevCaps
Definition: dllmain.c:9
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
BOOL SetStockObjects
Definition: dllmain.c:8
HGDIOBJ stock_objects[]
Definition: gdiobj.c:6
HANDLE hProcessHeap
Definition: kbswitch.c:25