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
9 DBG_DEFAULT_CHANNEL(UserMisc
);
11 /* GLOBALS ********************************************************************/
13 PTHREADINFO gptiCurrent
= NULL
;
14 PPROCESSINFO gppiInputProvider
= NULL
;
16 ATOM AtomMessage
; // Window Message atom.
17 ATOM AtomWndObj
; // Window Object atom.
18 ATOM AtomLayer
; // Window Layer atom.
19 ATOM AtomFlashWndState
; // Window Flash State atom.
20 HINSTANCE hModClient
= NULL
;
21 BOOL ClientPfnInit
= FALSE
;
22 ATOM gaGuiConsoleWndClass
;
24 /* PRIVATE FUNCTIONS **********************************************************/
30 gpsi
->atomSysClass
[ICLS_MENU
] = 32768;
31 gpsi
->atomSysClass
[ICLS_DESKTOP
] = 32769;
32 gpsi
->atomSysClass
[ICLS_DIALOG
] = 32770;
33 gpsi
->atomSysClass
[ICLS_SWITCH
] = 32771;
34 gpsi
->atomSysClass
[ICLS_ICONTITLE
] = 32772;
35 gpsi
->atomSysClass
[ICLS_TOOLTIPS
] = 32774;
37 /* System Message Atom */
38 AtomMessage
= IntAddGlobalAtom(L
"Message", TRUE
);
39 gpsi
->atomSysClass
[ICLS_HWNDMESSAGE
] = AtomMessage
;
41 /* System Context Help Id Atom */
42 gpsi
->atomContextHelpIdProp
= IntAddGlobalAtom(L
"SysCH", TRUE
);
44 gpsi
->atomIconSmProp
= IntAddGlobalAtom(L
"SysICS", TRUE
);
45 gpsi
->atomIconProp
= IntAddGlobalAtom(L
"SysIC", TRUE
);
47 gpsi
->atomFrostedWindowProp
= IntAddGlobalAtom(L
"SysFrostedWindow", TRUE
);
50 * FIXME: AddPropW uses the global kernel atom table, thus leading to conflicts if we use
51 * the win32k atom table for this ones. What is the right thing to do ?
53 // AtomWndObj = IntAddGlobalAtom(L"SysWNDO", TRUE);
54 NtAddAtom(L
"SysWNDO", 14, &AtomWndObj
);
55 AtomLayer
= IntAddGlobalAtom(L
"SysLayer", TRUE
);
56 AtomFlashWndState
= IntAddGlobalAtom(L
"FlashWState", TRUE
);
58 return STATUS_SUCCESS
;
61 /* FUNCTIONS ******************************************************************/
70 ExInitializeResourceLite(&UserLock
);
72 if (!UserCreateHandleTable())
74 ERR("Failed creating handle table\n");
75 return STATUS_INSUFFICIENT_RESOURCES
;
78 Status
= InitSessionImpl();
79 if (!NT_SUCCESS(Status
))
81 ERR("Error init session impl.\n");
89 return STATUS_SUCCESS
;
100 static const DWORD wPattern55AA
[] = /* 32 bit aligned */
101 { 0x55555555, 0xaaaaaaaa, 0x55555555, 0xaaaaaaaa,
102 0x55555555, 0xaaaaaaaa, 0x55555555, 0xaaaaaaaa };
103 HBITMAP hPattern55AABitmap
= NULL
;
106 // Set W32PF_Flags |= (W32PF_READSCREENACCESSGRANTED | W32PF_IOWINSTA)
107 // Create Event for Diconnect Desktop.
109 Status
= UserCreateWinstaDirectory();
110 if (!NT_SUCCESS(Status
)) return Status
;
112 /* Initialize Video */
113 Status
= InitVideo();
114 if (!NT_SUCCESS(Status
)) return Status
;
118 // DrvChangeDisplaySettings.
119 // Update Shared Device Caps.
120 // Initialize User Screen.
122 // Create ThreadInfo for this Thread!
125 /* Initialize the current thread */
126 Status
= UserCreateThreadInfo(PsGetCurrentThread());
127 if (!NT_SUCCESS(Status
)) return Status
;
130 // Set Global SERVERINFO Error flags.
133 NtUserUpdatePerUserSystemParameters(0, TRUE
);
135 if (gpsi
->hbrGray
== NULL
)
137 hPattern55AABitmap
= GreCreateBitmap(8, 8, 1, 1, (LPBYTE
)wPattern55AA
);
138 gpsi
->hbrGray
= IntGdiCreatePatternBrush(hPattern55AABitmap
);
139 GreDeleteObject(hPattern55AABitmap
);
140 GreSetBrushOwner(gpsi
->hbrGray
, GDI_OBJ_HMGR_PUBLIC
);
143 return STATUS_SUCCESS
;
147 * Called from usersrv.
153 HANDLE hPowerRequestEvent
,
154 HANDLE hMediaRequestEvent
)
158 TRACE("Enter NtUserInitialize(%lx, %p, %p)\n",
159 dwWinVersion
, hPowerRequestEvent
, hMediaRequestEvent
);
161 /* Check if we are already initialized */
163 return STATUS_UNSUCCESSFUL
;
165 /* Check Windows USER subsystem version */
166 if (dwWinVersion
!= USER_VERSION
)
168 // FIXME: Should bugcheck!
169 return STATUS_UNSUCCESSFUL
;
172 /* Acquire exclusive lock */
173 UserEnterExclusive();
175 /* Save the EPROCESS of CSRSS */
176 InitCsrProcess(/*PsGetCurrentProcess()*/);
178 // Initialize Power Request List (use hPowerRequestEvent).
179 // Initialize Media Change (use hMediaRequestEvent).
181 // InitializeGreCSRSS();
183 // Startup DxGraphics.
184 // calls ** UserGetLanguageID() and sets it **.
185 // Enables Fonts drivers, Initialize Font table & Stock Fonts.
188 /* Initialize USER */
189 Status
= UserInitialize();
199 True if current thread owns the lock (possibly shared)
201 BOOL FASTCALL
UserIsEntered(VOID
)
203 return ExIsResourceAcquiredExclusiveLite(&UserLock
) ||
204 ExIsResourceAcquiredSharedLite(&UserLock
);
207 BOOL FASTCALL
UserIsEnteredExclusive(VOID
)
209 return ExIsResourceAcquiredExclusiveLite(&UserLock
);
212 VOID FASTCALL
CleanupUserImpl(VOID
)
214 ExDeleteResourceLite(&UserLock
);
217 VOID FASTCALL
UserEnterShared(VOID
)
219 KeEnterCriticalRegion();
220 ExAcquireResourceSharedLite(&UserLock
, TRUE
);
223 VOID FASTCALL
UserEnterExclusive(VOID
)
226 KeEnterCriticalRegion();
227 ExAcquireResourceExclusiveLite(&UserLock
, TRUE
);
228 gptiCurrent
= PsGetCurrentThreadWin32Thread();
231 VOID FASTCALL
UserLeave(VOID
)
234 ASSERT(UserIsEntered());
235 ExReleaseResourceLite(&UserLock
);
236 KeLeaveCriticalRegion();