https://git.reactos.org/?p=reactos.git;a=commitdiff;h=515d83a883ae01c8ccaca…
commit 515d83a883ae01c8ccaca6d56e47d0ae4bdb0305
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Fri Jul 30 15:38:10 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Tue Aug 3 23:13:19 2021 +0200
[WIN32K] On init, start by initializing NtUser stuff
Allocate gpsi (Global Server Info) after initializing & grabbing Userlock
---
win32ss/user/ntuser/main.c | 12 +-----------
win32ss/user/ntuser/ntuser.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/win32ss/user/ntuser/main.c b/win32ss/user/ntuser/main.c
index f054021d853..1c8e0c53337 100644
--- a/win32ss/user/ntuser/main.c
+++ b/win32ss/user/ntuser/main.c
@@ -968,16 +968,7 @@ DriverEntry(
return STATUS_UNSUCCESSFUL;
}
- /* Allocate global server info structure */
- gpsi = UserHeapAlloc(sizeof(*gpsi));
- if (!gpsi)
- {
- DPRINT1("Failed allocate server info structure!\n");
- return STATUS_UNSUCCESSFUL;
- }
-
- RtlZeroMemory(gpsi, sizeof(*gpsi));
- DPRINT("Global Server Data -> %p\n", gpsi);
+ NT_ROF(InitUserImpl());
NT_ROF(InitGdiHandleTable());
NT_ROF(InitPaletteImpl());
@@ -992,7 +983,6 @@ DriverEntry(
NT_ROF(InitLDEVImpl());
NT_ROF(InitDeviceImpl());
NT_ROF(InitDcImpl());
- NT_ROF(InitUserImpl());
NT_ROF(InitWindowStationImpl());
NT_ROF(InitDesktopImpl());
NT_ROF(InitInputImpl());
diff --git a/win32ss/user/ntuser/ntuser.c b/win32ss/user/ntuser/ntuser.c
index 44fa120c9c6..9ada594c363 100644
--- a/win32ss/user/ntuser/ntuser.c
+++ b/win32ss/user/ntuser/ntuser.c
@@ -81,6 +81,20 @@ InitUserImpl(VOID)
ExInitializeResourceLite(&UserLock);
+ /* Hold global resource to make sanity checks happy. */
+ UserEnterExclusive();
+
+ /* Allocate global server info structure */
+ gpsi = UserHeapAlloc(sizeof(*gpsi));
+ if (!gpsi)
+ {
+ ERR("Failed allocate server info structure!\n");
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ RtlZeroMemory(gpsi, sizeof(*gpsi));
+ TRACE("Global Server Data -> %p\n", gpsi);
+
if (!UserCreateHandleTable())
{
ERR("Failed creating handle table\n");
@@ -108,6 +122,8 @@ InitUserImpl(VOID)
InitSysParams();
+ UserLeave();
+
return STATUS_SUCCESS;
}