ReactOS 0.4.16-dev-112-g52265ae
ntuser.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: ntuser init. and main funcs.
5 * FILE: win32ss/user/ntuser/ntuser.c
6 */
7
8#include <win32k.h>
10
12
13/* GLOBALS ********************************************************************/
14
19ATOM AtomMessage; // Window Message atom.
20ATOM AtomWndObj; // Window Object atom.
21ATOM AtomLayer; // Window Layer atom.
22ATOM AtomFlashWndState; // Window Flash State atom.
23ATOM AtomDDETrack; // Window DDE Tracking atom.
24ATOM AtomQOS; // Window DDE Quality of Service atom.
29
30/* PRIVATE FUNCTIONS **********************************************************/
31
32static
35{
37
38 gpsi->atomSysClass[ICLS_MENU] = 32768;
44
45 /* System Message Atom */
47 gpsi->atomSysClass[ICLS_HWNDMESSAGE] = AtomMessage;
48
49 /* System Context Help Id Atom */
51
54
55 gpsi->atomFrostedWindowProp = IntAddGlobalAtom(L"SysFrostedWindow", TRUE);
56
58 AtomQOS = IntAddGlobalAtom(L"SysQOS", TRUE);
60
61 /*
62 * FIXME: AddPropW uses the global kernel atom table, thus leading to conflicts if we use
63 * the win32k atom table for this one. What is the right thing to do ?
64 */
65 // AtomWndObj = IntAddGlobalAtom(L"SysWNDO", TRUE);
66 NtAddAtom(L"SysWNDO", 14, &AtomWndObj);
67
68 AtomLayer = IntAddGlobalAtom(L"SysLayer", TRUE);
70
71 return STATUS_SUCCESS;
72}
73
74/* FUNCTIONS ******************************************************************/
75
76CODE_SEG("INIT")
80{
82 HKEY hKey;
83
85 {
86 ERR("Failed creating handle table\n");
88 }
89
91 if (!NT_SUCCESS(Status))
92 {
93 ERR("Error init session impl.\n");
94 return Status;
95 }
96
98
99 Status = RegOpenKey(L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows",
100 &hKey);
101 if (NT_SUCCESS(Status))
102 {
103 DWORD dwValue = 0;
104 RegReadDWORD(hKey, L"DisplayVersion", &dwValue);
105 g_AlwaysDisplayVersion = !!dwValue;
106 ZwClose(hKey);
107 }
108
110
111 return STATUS_SUCCESS;
112}
113
115NTAPI
117{
118 static const DWORD wPattern55AA[] = /* 32 bit aligned */
119 { 0x55555555, 0xaaaaaaaa, 0x55555555, 0xaaaaaaaa,
120 0x55555555, 0xaaaaaaaa, 0x55555555, 0xaaaaaaaa };
121 HBITMAP hPattern55AABitmap = NULL;
123
125
126// Create Event for Disconnect Desktop.
127
129 if (!NT_SUCCESS(Status)) return Status;
130
131 /* Initialize the Video */
132 Status = InitVideo();
133 if (!NT_SUCCESS(Status))
134 {
135 /* We failed, bugcheck */
136 KeBugCheckEx(VIDEO_DRIVER_INIT_FAILURE, Status, 0, 0, USER_VERSION);
137 }
138
139// {
140// DrvInitConsole.
141// DrvChangeDisplaySettings.
142// Update Shared Device Caps.
143// Initialize User Screen.
144// }
145
146// Set Global SERVERINFO Error flags.
147// Load Resources.
148
150
151 if (gpsi->hbrGray == NULL)
152 {
153 hPattern55AABitmap = GreCreateBitmap(8, 8, 1, 1, (LPBYTE)wPattern55AA);
154 if (hPattern55AABitmap == NULL)
156
157 gpsi->hbrGray = IntGdiCreatePatternBrush(hPattern55AABitmap);
158
159 if (gpsi->hbrGray == NULL)
161 }
162
163 return STATUS_SUCCESS;
164}
165
166/*
167 * Called from usersrv.
168 */
172 DWORD dwWinVersion,
173 HANDLE hPowerRequestEvent,
174 HANDLE hMediaRequestEvent)
175{
177
178 TRACE("Enter NtUserInitialize(%lx, %p, %p)\n",
179 dwWinVersion, hPowerRequestEvent, hMediaRequestEvent);
180
181 /* Check if we are already initialized */
182 if (gpepCSRSS)
183 return STATUS_UNSUCCESSFUL;
184
185 /* Check Windows USER subsystem version */
186 if (dwWinVersion != USER_VERSION)
187 {
188 /* No match, bugcheck */
189 KeBugCheckEx(WIN32K_INIT_OR_RIT_FAILURE, 0, 0, dwWinVersion, USER_VERSION);
190 }
191
192 /* Acquire exclusive lock */
194
195 /* Save the EPROCESS of CSRSS */
196 InitCsrProcess(/*PsGetCurrentProcess()*/);
197
198 /* Initialize Power Request List */
199 Status = IntInitWin32PowerManagement(hPowerRequestEvent);
200 if (!NT_SUCCESS(Status))
201 {
202 UserLeave();
203 return Status;
204 }
205
206// Initialize Media Change (use hMediaRequestEvent).
207
208 /* Initialize various GDI stuff (DirectX, fonts, language ID etc.) */
209 if (!InitializeGreCSRSS())
210 return STATUS_UNSUCCESSFUL;
211
212 /* Initialize USER */
214
215 /* Return */
216 UserLeave();
217 return Status;
218}
219
220
221/*
222RETURN
223 True if current thread owns the lock (possibly shared)
224*/
226{
229}
230
232{
234}
235
237{
239}
240
241// Win: EnterSharedCrit
243{
246}
247
248// Win: EnterCrit
250{
255}
256
257// Win: LeaveCrit
259{
264}
265
266/* EOF */
#define CODE_SEG(...)
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: precomp.h:57
HBITMAP NTAPI GreCreateBitmap(_In_ ULONG nWidth, _In_ ULONG nHeight, _In_ ULONG cPlanes, _In_ ULONG cBitsPixel, _In_opt_ PVOID pvBits)
Definition: bitmaps.c:172
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
HBRUSH NTAPI IntGdiCreatePatternBrush(HBITMAP hbmPattern)
Definition: brush.cpp:303
static const WORD wPattern55AA[]
Definition: commctrl.c:86
PEPROCESS gpepCSRSS
Definition: csr.c:15
VOID InitCsrProcess(VOID)
Definition: csr.c:20
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define APIENTRY
Definition: api.h:79
PSERVERINFO gpsi
Definition: imm.c:18
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
#define ExDeleteResourceLite(res)
Definition: env_spec_w32.h:647
ULONG ERESOURCE
Definition: env_spec_w32.h:594
#define ExAcquireResourceSharedLite(res, wait)
Definition: env_spec_w32.h:621
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define ASSERT_NOGDILOCKS()
Definition: gdidebug.h:10
Status
Definition: gdiplustypes.h:25
#define ICLS_DIALOG
Definition: ntuser.h:930
#define ICLS_ICONTITLE
Definition: ntuser.h:933
#define USER_VERSION
Definition: ntuser.h:1149
#define ICLS_MENU
Definition: ntuser.h:931
BOOL NTAPI NtUserUpdatePerUserSystemParameters(DWORD dwReserved, BOOL bEnable)
Definition: sysparams.c:375
#define ICLS_SWITCH
Definition: ntuser.h:932
#define ICLS_DESKTOP
Definition: ntuser.h:929
#define ICLS_TOOLTIPS
Definition: ntuser.h:934
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
#define ASSERT(a)
Definition: mode.c:44
static HBITMAP
Definition: button.c:44
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define FASTCALL
Definition: nt_native.h:50
NTSTATUS NTAPI NtAddAtom(IN PWSTR AtomName, IN ULONG AtomNameLength, OUT PRTL_ATOM Atom)
Definition: atom.c:86
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:1624
ULONG NTAPI ExIsResourceAcquiredSharedLite(IN PERESOURCE Resource)
Definition: resource.c:1663
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
NTSTATUS NTAPI UserCreateWinstaDirectory(VOID)
Definition: winsta.c:51
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
NTSTATUS NTAPI UserInitialize(VOID)
Definition: ntuser.c:116
ATOM AtomWndObj
Definition: ntuser.c:20
ATOM AtomImeLevel
Definition: ntuser.c:28
BOOL FASTCALL UserIsEntered(VOID)
Definition: ntuser.c:225
HINSTANCE hModClient
Definition: ntuser.c:25
BOOL g_AlwaysDisplayVersion
Definition: ntuser.c:17
BOOL FASTCALL RegisterControlAtoms(VOID)
Definition: class.c:401
ATOM AtomFlashWndState
Definition: ntuser.c:22
NTSTATUS NTAPI InitUserImpl(VOID)
Definition: ntuser.c:79
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
BOOL ClientPfnInit
Definition: ntuser.c:26
VOID FASTCALL CleanupUserImpl(VOID)
Definition: ntuser.c:236
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
static NTSTATUS FASTCALL InitUserAtoms(VOID)
Definition: ntuser.c:34
ATOM AtomDDETrack
Definition: ntuser.c:23
ERESOURCE UserLock
Definition: ntuser.c:18
ATOM AtomQOS
Definition: ntuser.c:24
ATOM AtomLayer
Definition: ntuser.c:21
NTSTATUS APIENTRY NtUserInitialize(DWORD dwWinVersion, HANDLE hPowerRequestEvent, HANDLE hMediaRequestEvent)
Definition: ntuser.c:171
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:242
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
ATOM gaGuiConsoleWndClass
Definition: ntuser.c:27
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:231
ATOM AtomMessage
Definition: ntuser.c:19
#define L(x)
Definition: ntvdm.h:50
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE(s)
Definition: solgame.cpp:4
ATOM atomIconProp
Definition: ntuser.h:1066
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1060
ATOM atomContextHelpIdProp
Definition: ntuser.h:1067
ATOM atomFrostedWindowProp
Definition: ntuser.h:1068
ATOM atomIconSmProp
Definition: ntuser.h:1065
BOOL InitSysParams()
unsigned char * LPBYTE
Definition: typedefs.h:53
#define NTAPI
Definition: typedefs.h:36
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
RTL_ATOM FASTCALL IntAddGlobalAtom(LPWSTR lpBuffer, BOOL PinAtom)
Definition: useratom.c:62
BOOL InitializeGreCSRSS(VOID)
Definition: init.c:80
BOOL NTAPI RegReadDWORD(HKEY hkey, PCWSTR pwszValue, PDWORD pdwData)
Definition: registry.c:149
NTSTATUS NTAPI InitVideo(VOID)
Definition: display.c:151
BOOL FASTCALL UserCreateHandleTable(VOID)
Definition: object.c:536
NTSTATUS NTAPI IntInitWin32PowerManagement(_In_ HANDLE hPowerRequestEvent)
Initializes the power management side of Win32 kernel-mode subsystem component. This enables communic...
Definition: power.c:271
NTSTATUS FASTCALL InitSessionImpl(VOID)
Definition: session.c:18
#define RegOpenKey
Definition: winreg.h:519
#define NT_ASSERT
Definition: rtlfuncs.h:3324