2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: ntuser init. and main funcs.
5 * FILE: subsystems/win32/win32k/ntuser/ntuser.c
9 DBG_DEFAULT_CHANNEL(UserMisc
);
11 /* GLOBALS *******************************************************************/
13 PTHREADINFO gptiCurrent
= NULL
;
15 ATOM AtomMessage
; // Window Message atom.
16 ATOM AtomWndObj
; // Window Object atom.
17 ATOM AtomLayer
; // Window Layer atom.
18 ATOM AtomFlashWndState
; // Window Flash State atom.
20 HINSTANCE hModClient
= NULL
;
21 BOOL ClientPfnInit
= FALSE
;
23 /* 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 AtomWndObj
= IntAddGlobalAtom(L
"SysWNDO", TRUE
);
45 AtomLayer
= IntAddGlobalAtom(L
"SysLayer", TRUE
);
46 AtomFlashWndState
= IntAddGlobalAtom(L
"FlashWState", TRUE
);
48 return STATUS_SUCCESS
;
51 /* FUNCTIONS *****************************************************************/
60 ExInitializeResourceLite(&UserLock
);
62 if (!UserCreateHandleTable())
64 ERR("Failed creating handle table\n");
65 return STATUS_INSUFFICIENT_RESOURCES
;
68 Status
= InitSessionImpl();
69 if (!NT_SUCCESS(Status
))
71 ERR("Error init session impl.\n");
79 return STATUS_SUCCESS
;
89 HANDLE hPowerRequestEvent
,
90 HANDLE hMediaRequestEvent
)
92 static const DWORD wPattern55AA
[] = /* 32 bit aligned */
93 { 0x55555555, 0xaaaaaaaa, 0x55555555, 0xaaaaaaaa,
94 0x55555555, 0xaaaaaaaa, 0x55555555, 0xaaaaaaaa };
95 HBITMAP hPattern55AABitmap
= NULL
;
98 // Set W32PF_Flags |= (W32PF_READSCREENACCESSGRANTED | W32PF_IOWINSTA)
99 // Create Object Directory,,, Looks like create workstation. "\\Windows\\WindowStations"
100 // Create Event for Diconnect Desktop.
102 /* Initialize Video. */
103 Status
= InitVideo();
104 if (!NT_SUCCESS(Status
)) return Status
;
108 // DrvChangeDisplaySettings.
109 // Update Shared Device Caps.
110 // Initialize User Screen.
112 // Create ThreadInfo for this Thread!
117 // Callback to User32 Client Thread Setup
119 co_IntClientThreadSetup();
122 // Set Global SERVERINFO Error flags.
125 NtUserUpdatePerUserSystemParameters(0, TRUE
);
129 if (gpsi
->hbrGray
== NULL
)
131 hPattern55AABitmap
= GreCreateBitmap(8, 8, 1, 1, (LPBYTE
)wPattern55AA
);
132 gpsi
->hbrGray
= IntGdiCreatePatternBrush(hPattern55AABitmap
);
133 GreDeleteObject(hPattern55AABitmap
);
134 GreSetBrushOwner(gpsi
->hbrGray
, GDI_OBJ_HMGR_PUBLIC
);
137 return STATUS_SUCCESS
;
141 Called from win32csr.
147 HANDLE hPowerRequestEvent
,
148 HANDLE hMediaRequestEvent
)
152 ERR("Enter NtUserInitialize(%lx, %p, %p)\n",
153 dwWinVersion
, hPowerRequestEvent
, hMediaRequestEvent
);
155 /* Check the Windows version */
156 if (dwWinVersion
!= 0)
158 return STATUS_UNSUCCESSFUL
;
161 /* Acquire exclusive lock */
162 UserEnterExclusive();
164 /* Check if we are already initialized */
168 return STATUS_UNSUCCESSFUL
;
171 // Initialize Power Request List.
172 // Initialize Media Change.
173 // InitializeGreCSRSS();
175 // Startup DxGraphics.
176 // calls ** IntGdiGetLanguageID() and sets it **.
177 // Enables Fonts drivers, Initialize Font table & Stock Fonts.
180 /* Initialize USER */
181 Status
= UserInitialize(hPowerRequestEvent
, hMediaRequestEvent
);
183 /* Set us as initialized */
184 gbInitialized
= TRUE
;
194 True if current thread owns the lock (possibly shared)
196 BOOL FASTCALL
UserIsEntered(VOID
)
198 return ExIsResourceAcquiredExclusiveLite(&UserLock
)
199 || ExIsResourceAcquiredSharedLite(&UserLock
);
202 BOOL FASTCALL
UserIsEnteredExclusive(VOID
)
204 return ExIsResourceAcquiredExclusiveLite(&UserLock
);
207 VOID FASTCALL
CleanupUserImpl(VOID
)
209 ExDeleteResourceLite(&UserLock
);
212 VOID FASTCALL
UserEnterShared(VOID
)
214 KeEnterCriticalRegion();
215 ExAcquireResourceSharedLite(&UserLock
, TRUE
);
218 VOID FASTCALL
UserEnterExclusive(VOID
)
221 KeEnterCriticalRegion();
222 ExAcquireResourceExclusiveLite(&UserLock
, TRUE
);
223 gptiCurrent
= PsGetCurrentThreadWin32Thread();
226 VOID FASTCALL
UserLeave(VOID
)
229 ExReleaseResourceLite(&UserLock
);
230 KeLeaveCriticalRegion();