https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0bc00267df2f644d329a5…
commit 0bc00267df2f644d329a5b0823052293c0108384
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Wed Aug 4 09:49:18 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Fri Aug 6 10:15:02 2021 +0200
[WIN32K] Init User part after GDI one.
But Initialize user lock first thing to avoid hitting newly introduced ASSERTS
This partly reverts commit 515d83a883ae01c8ccaca6d56e47d0ae4bdb0305.
---
win32ss/user/ntuser/main.c | 35 ++++++++++++++++++++++++++++++++++-
win32ss/user/ntuser/ntuser.c | 18 ------------------
win32ss/user/ntuser/ntuser.h | 1 +
3 files changed, 35 insertions(+), 19 deletions(-)
diff --git a/win32ss/user/ntuser/main.c b/win32ss/user/ntuser/main.c
index 1c8e0c53337..8f593d02fff 100644
--- a/win32ss/user/ntuser/main.c
+++ b/win32ss/user/ntuser/main.c
@@ -896,6 +896,21 @@ DriverUnload(IN PDRIVER_OBJECT DriverObject)
} \
}
+// Lock & return on failure
+#define USERLOCK_AND_ROF(x) \
+{ \
+ UserEnterExclusive(); \
+ Status = (x); \
+ UserLeave(); \
+ if (!NT_SUCCESS(Status)) \
+ { \
+ DPRINT1("Failed '%s' (0x%lx)\n", #x, Status); \
+ return Status; \
+ } \
+}
+
+
+
/*
* This definition doesn't work
*/
@@ -968,7 +983,24 @@ DriverEntry(
return STATUS_UNSUCCESSFUL;
}
- NT_ROF(InitUserImpl());
+ /* Init the global user lock */
+ ExInitializeResourceLite(&UserLock);
+
+ /* Lock while we use the heap (UserHeapAlloc asserts on this) */
+ UserEnterExclusive();
+
+ /* Allocate global server info structure */
+ gpsi = UserHeapAlloc(sizeof(*gpsi));
+ UserLeave();
+ if (!gpsi)
+ {
+ DPRINT1("Failed allocate server info structure!\n");
+ UserLeave();
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ RtlZeroMemory(gpsi, sizeof(*gpsi));
+ DPRINT("Global Server Data -> %p\n", gpsi);
NT_ROF(InitGdiHandleTable());
NT_ROF(InitPaletteImpl());
@@ -983,6 +1015,7 @@ DriverEntry(
NT_ROF(InitLDEVImpl());
NT_ROF(InitDeviceImpl());
NT_ROF(InitDcImpl());
+ USERLOCK_AND_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 9ada594c363..32805901b33 100644
--- a/win32ss/user/ntuser/ntuser.c
+++ b/win32ss/user/ntuser/ntuser.c
@@ -79,22 +79,6 @@ InitUserImpl(VOID)
NTSTATUS Status;
HKEY hKey;
- 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");
@@ -122,8 +106,6 @@ InitUserImpl(VOID)
InitSysParams();
- UserLeave();
-
return STATUS_SUCCESS;
}
diff --git a/win32ss/user/ntuser/ntuser.h b/win32ss/user/ntuser/ntuser.h
index 78b6bacd965..d456564b159 100644
--- a/win32ss/user/ntuser/ntuser.h
+++ b/win32ss/user/ntuser/ntuser.h
@@ -18,6 +18,7 @@ extern BOOL g_AlwaysDisplayVersion;
extern ATOM gaGuiConsoleWndClass;
extern ATOM AtomDDETrack;
extern ATOM AtomQOS;
+extern ERESOURCE UserLock;
CODE_SEG("INIT") NTSTATUS NTAPI InitUserImpl(VOID);
VOID FASTCALL CleanupUserImpl(VOID);