From 515d83a883ae01c8ccaca6d56e47d0ae4bdb0305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Fri, 30 Jul 2021 15:38:10 +0200 Subject: [PATCH] [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; }