[NTOS:EX] Do not ignore PsCreateSystemThread return value

CORE-17637
This commit is contained in:
Jérôme Gardou 2021-06-17 17:41:37 +02:00 committed by Jérôme Gardou
parent 93c0d324e0
commit cf1a95a588

View file

@ -254,6 +254,7 @@ ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType,
HANDLE hThread;
ULONG Context;
KPRIORITY Priority;
NTSTATUS Status;
/* Check if this is going to be a dynamic thread */
Context = WorkQueueType;
@ -262,13 +263,19 @@ ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType,
if (Dynamic) Context |= EX_DYNAMIC_WORK_THREAD;
/* Create the System Thread */
PsCreateSystemThread(&hThread,
THREAD_ALL_ACCESS,
NULL,
NULL,
NULL,
ExpWorkerThreadEntryPoint,
UlongToPtr(Context));
Status = PsCreateSystemThread(&hThread,
THREAD_ALL_ACCESS,
NULL,
NULL,
NULL,
ExpWorkerThreadEntryPoint,
UlongToPtr(Context));
if (!NT_SUCCESS(Status))
{
/* Well... */
DPRINT1("Failed to create worker thread: 0x%08x\n", Status);
return;
}
/* If the thread is dynamic */
if (Dynamic)
@ -519,6 +526,7 @@ ExpInitializeWorkerThreads(VOID)
HANDLE ThreadHandle;
PETHREAD Thread;
ULONG i;
NTSTATUS Status;
/* Setup the stack swap support */
ExInitializeFastMutex(&ExpWorkerSwapinMutex);
@ -576,13 +584,17 @@ ExpInitializeWorkerThreads(VOID)
ExpCreateWorkerThread(HyperCriticalWorkQueue, FALSE);
/* Create the balance set manager thread */
PsCreateSystemThread(&ThreadHandle,
THREAD_ALL_ACCESS,
NULL,
0,
NULL,
ExpWorkerThreadBalanceManager,
NULL);
Status = PsCreateSystemThread(&ThreadHandle,
THREAD_ALL_ACCESS,
NULL,
0,
NULL,
ExpWorkerThreadBalanceManager,
NULL);
if (!NT_SUCCESS(Status))
{
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
/* Get a pointer to it for the shutdown process */
ObReferenceObjectByHandle(ThreadHandle,