ReactOS 0.4.15-dev-5667-ged97270
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 (use hPowerRequestEvent).
199// Initialize Media Change (use hMediaRequestEvent).
200
201// InitializeGreCSRSS();
202// {
203// Startup DxGraphics.
204// calls ** UserGetLanguageID() and sets it **.
205// Enables Fonts drivers, Initialize Font table & Stock Fonts.
206// }
207
208 /* Initialize USER */
210
211 /* Return */
212 UserLeave();
213 return Status;
214}
215
216
217/*
218RETURN
219 True if current thread owns the lock (possibly shared)
220*/
222{
225}
226
228{
230}
231
233{
235}
236
237// Win: EnterSharedCrit
239{
242}
243
244// Win: EnterCrit
246{
251}
252
253// Win: LeaveCrit
255{
260}
261
262/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
HBITMAP NTAPI GreCreateBitmap(_In_ ULONG nWidth, _In_ ULONG nHeight, _In_ ULONG cPlanes, _In_ ULONG cBitsPixel, _In_opt_ PVOID pvBits)
Definition: bitmaps.c:172
#define ERR(fmt,...)
Definition: debug.h:110
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:103
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:32
#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:925
#define ICLS_ICONTITLE
Definition: ntuser.h:928
#define USER_VERSION
Definition: ntuser.h:1144
#define ICLS_MENU
Definition: ntuser.h:926
BOOL NTAPI NtUserUpdatePerUserSystemParameters(DWORD dwReserved, BOOL bEnable)
Definition: sysparams.c:374
#define ICLS_SWITCH
Definition: ntuser.h:927
#define ICLS_DESKTOP
Definition: ntuser.h:924
#define ICLS_TOOLTIPS
Definition: ntuser.h:929
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
#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:1817
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:1619
ULONG NTAPI ExIsResourceAcquiredSharedLite(IN PERESOURCE Resource)
Definition: resource.c:1658
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:221
HINSTANCE hModClient
Definition: ntuser.c:25
BOOL g_AlwaysDisplayVersion
Definition: ntuser.c:17
BOOL FASTCALL RegisterControlAtoms(VOID)
Definition: class.c:396
ATOM AtomFlashWndState
Definition: ntuser.c:22
NTSTATUS NTAPI InitUserImpl(VOID)
Definition: ntuser.c:79
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:254
BOOL ClientPfnInit
Definition: ntuser.c:26
VOID FASTCALL CleanupUserImpl(VOID)
Definition: ntuser.c:232
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:238
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
ATOM gaGuiConsoleWndClass
Definition: ntuser.c:27
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:227
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:1061
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1055
ATOM atomContextHelpIdProp
Definition: ntuser.h:1062
ATOM atomFrostedWindowProp
Definition: ntuser.h:1063
ATOM atomIconSmProp
Definition: ntuser.h:1060
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 NTAPI RegReadDWORD(HKEY hkey, PWSTR pwszValue, PDWORD pdwData)
Definition: registry.c:150
NTSTATUS NTAPI InitVideo(VOID)
Definition: display.c:151
BOOL FASTCALL UserCreateHandleTable(VOID)
Definition: object.c:536
NTSTATUS FASTCALL InitSessionImpl(VOID)
Definition: session.c:18
#define RegOpenKey
Definition: winreg.h:519
#define NT_ASSERT
Definition: rtlfuncs.h:3310