[WIN32K] Init User part after GDI one.

But Initialize user lock first thing to avoid hitting newly introduced ASSERTS

This partly reverts commit 515d83a883.
This commit is contained in:
Jérôme Gardou 2021-08-04 09:49:18 +02:00 committed by Jérôme Gardou
parent c0c9b1445d
commit 0bc00267df
3 changed files with 35 additions and 19 deletions

View file

@ -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());

View file

@ -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;
}

View file

@ -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);