ReactOS  0.4.15-dev-3308-g9455def
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>
9 DBG_DEFAULT_CHANNEL(UserMisc);
10 
12 
13 /* GLOBALS ********************************************************************/
14 
19 ATOM AtomMessage; // Window Message atom.
20 ATOM AtomWndObj; // Window Object atom.
21 ATOM AtomLayer; // Window Layer atom.
22 ATOM AtomFlashWndState; // Window Flash State atom.
23 ATOM AtomDDETrack; // Window DDE Tracking atom.
24 ATOM AtomQOS; // Window DDE Quality of Service atom.
28 
29 /* PRIVATE FUNCTIONS **********************************************************/
30 
31 static
34 {
36 
37  gpsi->atomSysClass[ICLS_MENU] = 32768;
38  gpsi->atomSysClass[ICLS_DESKTOP] = 32769;
39  gpsi->atomSysClass[ICLS_DIALOG] = 32770;
40  gpsi->atomSysClass[ICLS_SWITCH] = 32771;
43 
44  /* System Message Atom */
45  AtomMessage = IntAddGlobalAtom(L"Message", TRUE);
46  gpsi->atomSysClass[ICLS_HWNDMESSAGE] = AtomMessage;
47 
48  /* System Context Help Id Atom */
50 
53 
54  gpsi->atomFrostedWindowProp = IntAddGlobalAtom(L"SysFrostedWindow", TRUE);
55 
57  AtomQOS = IntAddGlobalAtom(L"SysQOS", TRUE);
58 
59  /*
60  * FIXME: AddPropW uses the global kernel atom table, thus leading to conflicts if we use
61  * the win32k atom table for this one. What is the right thing to do ?
62  */
63  // AtomWndObj = IntAddGlobalAtom(L"SysWNDO", TRUE);
64  NtAddAtom(L"SysWNDO", 14, &AtomWndObj);
65 
66  AtomLayer = IntAddGlobalAtom(L"SysLayer", TRUE);
67  AtomFlashWndState = IntAddGlobalAtom(L"FlashWState", TRUE);
68 
69  return STATUS_SUCCESS;
70 }
71 
72 /* FUNCTIONS ******************************************************************/
73 
74 CODE_SEG("INIT")
76 NTAPI
78 {
80  HKEY hKey;
81 
82  if (!UserCreateHandleTable())
83  {
84  ERR("Failed creating handle table\n");
86  }
87 
89  if (!NT_SUCCESS(Status))
90  {
91  ERR("Error init session impl.\n");
92  return Status;
93  }
94 
95  InitUserAtoms();
96 
97  Status = RegOpenKey(L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows",
98  &hKey);
99  if (NT_SUCCESS(Status))
100  {
101  DWORD dwValue = 0;
102  RegReadDWORD(hKey, L"DisplayVersion", &dwValue);
103  g_AlwaysDisplayVersion = !!dwValue;
104  ZwClose(hKey);
105  }
106 
107  InitSysParams();
108 
109  return STATUS_SUCCESS;
110 }
111 
112 NTSTATUS
113 NTAPI
114 InitVideo(VOID);
115 
116 NTSTATUS
117 NTAPI
119 {
120  static const DWORD wPattern55AA[] = /* 32 bit aligned */
121  { 0x55555555, 0xaaaaaaaa, 0x55555555, 0xaaaaaaaa,
122  0x55555555, 0xaaaaaaaa, 0x55555555, 0xaaaaaaaa };
123  HBITMAP hPattern55AABitmap = NULL;
125 
127 
128 // Create Event for Disconnect Desktop.
129 
131  if (!NT_SUCCESS(Status)) return Status;
132 
133  /* Initialize the Video */
134  Status = InitVideo();
135  if (!NT_SUCCESS(Status))
136  {
137  /* We failed, bugcheck */
138  KeBugCheckEx(VIDEO_DRIVER_INIT_FAILURE, Status, 0, 0, USER_VERSION);
139  }
140 
141 // {
142 // DrvInitConsole.
143 // DrvChangeDisplaySettings.
144 // Update Shared Device Caps.
145 // Initialize User Screen.
146 // }
147 
148 // Set Global SERVERINFO Error flags.
149 // Load Resources.
150 
152 
153  if (gpsi->hbrGray == NULL)
154  {
155  hPattern55AABitmap = GreCreateBitmap(8, 8, 1, 1, (LPBYTE)wPattern55AA);
156  if (hPattern55AABitmap == NULL)
158 
159  gpsi->hbrGray = IntGdiCreatePatternBrush(hPattern55AABitmap);
160 
161  if (gpsi->hbrGray == NULL)
163  }
164 
165  return STATUS_SUCCESS;
166 }
167 
168 /*
169  * Called from usersrv.
170  */
171 NTSTATUS
172 APIENTRY
174  DWORD dwWinVersion,
175  HANDLE hPowerRequestEvent,
176  HANDLE hMediaRequestEvent)
177 {
179 
180  TRACE("Enter NtUserInitialize(%lx, %p, %p)\n",
181  dwWinVersion, hPowerRequestEvent, hMediaRequestEvent);
182 
183  /* Check if we are already initialized */
184  if (gpepCSRSS)
185  return STATUS_UNSUCCESSFUL;
186 
187  /* Check Windows USER subsystem version */
188  if (dwWinVersion != USER_VERSION)
189  {
190  /* No match, bugcheck */
191  KeBugCheckEx(WIN32K_INIT_OR_RIT_FAILURE, 0, 0, dwWinVersion, USER_VERSION);
192  }
193 
194  /* Acquire exclusive lock */
196 
197  /* Save the EPROCESS of CSRSS */
198  InitCsrProcess(/*PsGetCurrentProcess()*/);
199 
200 // Initialize Power Request List (use hPowerRequestEvent).
201 // Initialize Media Change (use hMediaRequestEvent).
202 
203 // InitializeGreCSRSS();
204 // {
205 // Startup DxGraphics.
206 // calls ** UserGetLanguageID() and sets it **.
207 // Enables Fonts drivers, Initialize Font table & Stock Fonts.
208 // }
209 
210  /* Initialize USER */
212 
213  /* Return */
214  UserLeave();
215  return Status;
216 }
217 
218 
219 /*
220 RETURN
221  True if current thread owns the lock (possibly shared)
222 */
224 {
227 }
228 
230 {
232 }
233 
235 {
237 }
238 
240 {
243 }
244 
246 {
251 }
252 
254 {
259 }
260 
261 /* EOF */
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
#define ICLS_ICONTITLE
Definition: ntuser.h:903
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
BOOL FASTCALL UserIsEntered(VOID)
Definition: ntuser.c:223
WORD ATOM
Definition: dimm.idl:113
ATOM atomFrostedWindowProp
Definition: ntuser.h:1030
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
PEPROCESS gpepCSRSS
Definition: csr.c:15
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTSTATUS
Definition: precomp.h:26
#define ICLS_DESKTOP
Definition: ntuser.h:899
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
ERESOURCE UserLock
Definition: ntuser.c:18
#define USER_VERSION
Definition: ntuser.h:1107
ATOM gaGuiConsoleWndClass
Definition: ntuser.c:27
ATOM atomContextHelpIdProp
Definition: ntuser.h:1029
#define FASTCALL
Definition: nt_native.h:50
PSERVERINFO gpsi
Definition: main.c:27
BOOL ClientPfnInit
Definition: ntuser.c:26
#define ICLS_DIALOG
Definition: ntuser.h:900
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
HBRUSH NTAPI IntGdiCreatePatternBrush(HBITMAP hbmPattern)
Definition: brush.cpp:303
unsigned char * LPBYTE
Definition: typedefs.h:53
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSTATUS APIENTRY NtUserInitialize(DWORD dwWinVersion, HANDLE hPowerRequestEvent, HANDLE hMediaRequestEvent)
Definition: ntuser.c:173
NTSTATUS NTAPI UserCreateWinstaDirectory(VOID)
Definition: winsta.c:51
BOOL g_AlwaysDisplayVersion
Definition: ntuser.c:17
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:1619
BOOL InitSysParams(VOID)
Definition: sysparams.c:348
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
Status
Definition: gdiplustypes.h:24
#define ICLS_TOOLTIPS
Definition: ntuser.h:904
DBG_DEFAULT_CHANNEL(UserMisc)
#define TRACE(s)
Definition: solgame.cpp:4
#define ASSERT(a)
Definition: mode.c:44
static NTSTATUS FASTCALL InitUserAtoms(VOID)
Definition: ntuser.c:33
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOL FASTCALL RegisterControlAtoms(VOID)
Definition: class.c:396
BOOL NTAPI RegReadDWORD(HKEY hkey, PWSTR pwszValue, PDWORD pdwData)
Definition: registry.c:150
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define ICLS_SWITCH
Definition: ntuser.h:902
ATOM AtomDDETrack
Definition: ntuser.c:23
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS NTAPI NtAddAtom(IN PWSTR AtomName, IN ULONG AtomNameLength, OUT PRTL_ATOM Atom)
Definition: atom.c:88
static const WCHAR L[]
Definition: oid.c:1250
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
ATOM atomIconProp
Definition: ntuser.h:1028
BOOL NTAPI NtUserUpdatePerUserSystemParameters(DWORD dwReserved, BOOL bEnable)
Definition: sysparams.c:358
ATOM AtomWndObj
Definition: ntuser.c:20
VOID InitCsrProcess(VOID)
Definition: csr.c:20
#define ERR(fmt,...)
Definition: debug.h:110
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
ATOM AtomMessage
Definition: ntuser.c:19
BOOL FASTCALL UserCreateHandleTable(VOID)
Definition: object.c:503
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
ATOM atomIconSmProp
Definition: ntuser.h:1027
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:229
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
NTSTATUS FASTCALL InitSessionImpl(VOID)
Definition: session.c:18
ATOM AtomLayer
Definition: ntuser.c:21
ATOM AtomQOS
Definition: ntuser.c:24
NTSTATUS NTAPI InitUserImpl(VOID)
Definition: ntuser.c:77
ULONG ERESOURCE
Definition: env_spec_w32.h:594
NTSTATUS NTAPI UserInitialize(VOID)
Definition: ntuser.c:118
ULONG NTAPI ExIsResourceAcquiredSharedLite(IN PERESOURCE Resource)
Definition: resource.c:1658
HINSTANCE hModClient
Definition: ntuser.c:25
static HBITMAP
Definition: button.c:44
#define STATUS_SUCCESS
Definition: shellext.h:65
#define ICLS_MENU
Definition: ntuser.h:901
NTSTATUS NTAPI InitVideo(VOID)
Definition: display.c:156
#define ASSERT_NOGDILOCKS()
Definition: gdidebug.h:10
#define RegOpenKey
Definition: winreg.h:519
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
ATOM AtomFlashWndState
Definition: ntuser.c:22
static const WORD wPattern55AA[]
Definition: commctrl.c:86
VOID FASTCALL CleanupUserImpl(VOID)
Definition: ntuser.c:234
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
RTL_ATOM FASTCALL IntAddGlobalAtom(LPWSTR lpBuffer, BOOL PinAtom)
Definition: useratom.c:62
#define APIENTRY
Definition: api.h:79
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1022
#define NT_ASSERT
Definition: rtlfuncs.h:3310
HBITMAP NTAPI GreCreateBitmap(_In_ ULONG nWidth, _In_ ULONG nHeight, _In_ ULONG cPlanes, _In_ ULONG cBitsPixel, _In_opt_ PVOID pvBits)
Definition: bitmaps.c:172