ReactOS  0.4.14-dev-55-g2da92ac
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 INIT_FUNCTION
76 NTAPI
78 {
80  HKEY hKey;
81 
83 
84  if (!UserCreateHandleTable())
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 
97  InitUserAtoms();
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 
109  InitSysParams();
110 
111  return STATUS_SUCCESS;
112 }
113 
114 NTSTATUS
115 NTAPI
116 InitVideo(VOID);
117 
118 NTSTATUS
119 NTAPI
121 {
122  static const DWORD wPattern55AA[] = /* 32 bit aligned */
123  { 0x55555555, 0xaaaaaaaa, 0x55555555, 0xaaaaaaaa,
124  0x55555555, 0xaaaaaaaa, 0x55555555, 0xaaaaaaaa };
125  HBITMAP hPattern55AABitmap = NULL;
127 
129 
130 // Create Event for Disconnect Desktop.
131 
133  if (!NT_SUCCESS(Status)) return Status;
134 
135  /* Initialize the Video */
136  Status = InitVideo();
137  if (!NT_SUCCESS(Status))
138  {
139  /* We failed, bugcheck */
140  KeBugCheckEx(VIDEO_DRIVER_INIT_FAILURE, Status, 0, 0, USER_VERSION);
141  }
142 
143 // {
144 // DrvInitConsole.
145 // DrvChangeDisplaySettings.
146 // Update Shared Device Caps.
147 // Initialize User Screen.
148 // }
149 
150 // Set Global SERVERINFO Error flags.
151 // Load Resources.
152 
154 
155  if (gpsi->hbrGray == NULL)
156  {
157  hPattern55AABitmap = GreCreateBitmap(8, 8, 1, 1, (LPBYTE)wPattern55AA);
158  if (hPattern55AABitmap == NULL)
160 
161  gpsi->hbrGray = IntGdiCreatePatternBrush(hPattern55AABitmap);
162 
163  if (gpsi->hbrGray == NULL)
165  }
166 
167  return STATUS_SUCCESS;
168 }
169 
170 /*
171  * Called from usersrv.
172  */
173 NTSTATUS
174 APIENTRY
176  DWORD dwWinVersion,
177  HANDLE hPowerRequestEvent,
178  HANDLE hMediaRequestEvent)
179 {
181 
182  TRACE("Enter NtUserInitialize(%lx, %p, %p)\n",
183  dwWinVersion, hPowerRequestEvent, hMediaRequestEvent);
184 
185  /* Check if we are already initialized */
186  if (gpepCSRSS)
187  return STATUS_UNSUCCESSFUL;
188 
189  /* Check Windows USER subsystem version */
190  if (dwWinVersion != USER_VERSION)
191  {
192  /* No match, bugcheck */
193  KeBugCheckEx(WIN32K_INIT_OR_RIT_FAILURE, 0, 0, dwWinVersion, USER_VERSION);
194  }
195 
196  /* Acquire exclusive lock */
198 
199  /* Save the EPROCESS of CSRSS */
200  InitCsrProcess(/*PsGetCurrentProcess()*/);
201 
202 // Initialize Power Request List (use hPowerRequestEvent).
203 // Initialize Media Change (use hMediaRequestEvent).
204 
205 // InitializeGreCSRSS();
206 // {
207 // Startup DxGraphics.
208 // calls ** UserGetLanguageID() and sets it **.
209 // Enables Fonts drivers, Initialize Font table & Stock Fonts.
210 // }
211 
212  /* Initialize USER */
214 
215  /* Return */
216  UserLeave();
217  return Status;
218 }
219 
220 
221 /*
222 RETURN
223  True if current thread owns the lock (possibly shared)
224 */
226 {
229 }
230 
232 {
234 }
235 
237 {
239 }
240 
242 {
245 }
246 
248 {
253 }
254 
256 {
261 }
262 
263 /* EOF */
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:241
#define TRUE
Definition: types.h:120
#define ICLS_ICONTITLE
Definition: ntuser.h:894
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
BOOL FASTCALL UserIsEntered(VOID)
Definition: ntuser.c:225
WORD ATOM
Definition: dimm.idl:113
ATOM atomFrostedWindowProp
Definition: ntuser.h:1021
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:890
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
ERESOURCE UserLock
Definition: ntuser.c:18
#define USER_VERSION
Definition: ntuser.h:1098
ATOM gaGuiConsoleWndClass
Definition: ntuser.c:27
ATOM atomContextHelpIdProp
Definition: ntuser.h:1020
#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:891
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
HBRUSH NTAPI IntGdiCreatePatternBrush(HBITMAP hbmPattern)
Definition: brush.cpp:292
unsigned char * LPBYTE
Definition: typedefs.h:52
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSTATUS APIENTRY NtUserInitialize(DWORD dwWinVersion, HANDLE hPowerRequestEvent, HANDLE hMediaRequestEvent)
Definition: ntuser.c:175
NTSTATUS NTAPI UserCreateWinstaDirectory(VOID)
Definition: winsta.c:51
BOOL g_AlwaysDisplayVersion
Definition: ntuser.c:17
INIT_FUNCTION NTSTATUS NTAPI InitUserImpl(VOID)
Definition: ntuser.c:77
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:1619
BOOL InitSysParams(VOID)
Definition: sysparams.c:342
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define ICLS_TOOLTIPS
Definition: ntuser.h:895
DBG_DEFAULT_CHANNEL(UserMisc)
#define TRACE(s)
Definition: solgame.cpp:4
static NTSTATUS FASTCALL InitUserAtoms(VOID)
Definition: ntuser.c:33
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOL FASTCALL RegisterControlAtoms(VOID)
Definition: class.c:373
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:893
ATOM AtomDDETrack
Definition: ntuser.c:23
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#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:83
ATOM atomIconProp
Definition: ntuser.h:1019
BOOL NTAPI NtUserUpdatePerUserSystemParameters(DWORD dwReserved, BOOL bEnable)
Definition: sysparams.c:352
ATOM AtomWndObj
Definition: ntuser.c:20
Status
Definition: gdiplustypes.h:24
VOID InitCsrProcess(VOID)
Definition: csr.c:20
#define ERR(fmt,...)
Definition: debug.h:109
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
ATOM AtomMessage
Definition: ntuser.c:19
BOOL FASTCALL UserCreateHandleTable(VOID)
Definition: object.c:503
ATOM atomIconSmProp
Definition: ntuser.h:1018
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:231
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
ULONG ERESOURCE
Definition: env_spec_w32.h:594
NTSTATUS NTAPI UserInitialize(VOID)
Definition: ntuser.c:120
ULONG NTAPI ExIsResourceAcquiredSharedLite(IN PERESOURCE Resource)
Definition: resource.c:1658
HINSTANCE hModClient
Definition: ntuser.c:25
static HBITMAP
Definition: button.c:44
#define ICLS_MENU
Definition: ntuser.h:892
NTSTATUS NTAPI InitVideo(VOID)
Definition: display.c:156
#define ASSERT_NOGDILOCKS()
Definition: gdidebug.h:10
#define RegOpenKey
Definition: winreg.h:519
return STATUS_SUCCESS
Definition: btrfs.c:2966
ATOM AtomFlashWndState
Definition: ntuser.c:22
static const WORD wPattern55AA[]
Definition: commctrl.c:86
VOID FASTCALL CleanupUserImpl(VOID)
Definition: ntuser.c:236
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:107
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:1013
#define NT_ASSERT
Definition: rtlfuncs.h:3312
HBITMAP NTAPI GreCreateBitmap(_In_ ULONG nWidth, _In_ ULONG nHeight, _In_ ULONG cPlanes, _In_ ULONG cBitsPixel, _In_opt_ PVOID pvBits)
Definition: bitmaps.c:172