Skip to content

Commit

Permalink
Update exited string to ignore wait status exit codes, Fix waiter cra…
Browse files Browse the repository at this point in the history
…sh on Win7
  • Loading branch information
dmex committed Jun 27, 2021
1 parent 226e3a9 commit 672a77e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
3 changes: 2 additions & 1 deletion ProcessHacker/include/procprp.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
typedef struct _PH_PROCESS_WAITPROPCONTEXT
{
SLIST_ENTRY ListEntry;
HANDLE PropSheetWindowHandle;
HWND PropSheetWindowHandle;
HANDLE ProcessWaitHandle;
HANDLE ProcessHandle;
PPH_PROCESS_ITEM ProcessItem;
} PH_PROCESS_WAITPROPCONTEXT, *PPH_PROCESS_WAITPROPCONTEXT;

Expand Down
28 changes: 17 additions & 11 deletions ProcessHacker/procprp.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,9 @@ VOID NTAPI PhpProcessPropPageWaitContextDeleteProcedure(
PPH_PROCESS_WAITPROPCONTEXT context = (PPH_PROCESS_WAITPROPCONTEXT)Object;

if (context->ProcessWaitHandle)
RtlDeregisterWait(context->ProcessWaitHandle);
RtlDeregisterWaitEx(context->ProcessWaitHandle, RTL_WAITER_DEREGISTER_WAIT_FOR_COMPLETION);
if (context->ProcessHandle)
NtClose(context->ProcessHandle);
if (context->ProcessItem)
PhDereferenceObject(context->ProcessItem);
}
Expand Down Expand Up @@ -523,6 +525,7 @@ VOID PhpCreateProcessPropSheetWaitContext(
waitContext = PhCreateObjectZero(sizeof(PH_PROCESS_WAITPROPCONTEXT), PhpProcessPropPageWaitContextType);
waitContext->ProcessItem = PhReferenceObject(processItem);
waitContext->PropSheetWindowHandle = GetParent(WindowHandle);
waitContext->ProcessHandle = processHandle;

if (NT_SUCCESS(RtlRegisterWait(
&waitContext->ProcessWaitHandle,
Expand All @@ -539,9 +542,8 @@ VOID PhpCreateProcessPropSheetWaitContext(
{
PhDereferenceObject(waitContext->ProcessItem);
PhDereferenceObject(waitContext);
NtClose(processHandle);
}

NtClose(processHandle);
}

VOID PhpFlushProcessPropSheetWaitContextData(
Expand All @@ -564,27 +566,31 @@ VOID PhpFlushProcessPropSheetWaitContextData(

if (NT_SUCCESS(PhGetProcessBasicInformation(data->ProcessItem->QueryHandle, &basicInfo)))
{
PPH_STRING statusMessage;
PPH_STRING statusMessage = NULL;
PPH_STRING errorMessage;
PH_FORMAT format[5];

PhInitFormatSR(&format[0], data->ProcessItem->ProcessName->sr);
PhInitFormatS(&format[1], L" (");
PhInitFormatU(&format[2], HandleToUlong(data->ProcessItem->ProcessId));

if (errorMessage = PhGetStatusMessage(basicInfo.ExitStatus, 0))
if (basicInfo.ExitStatus < STATUS_WAIT_1 || basicInfo.ExitStatus > STATUS_WAIT_63)
{
PhInitFormatS(&format[3], L") exited with ");
PhInitFormatSR(&format[4], errorMessage->sr);
if (errorMessage = PhGetStatusMessage(basicInfo.ExitStatus, 0))
{
PhInitFormatS(&format[3], L") exited with ");
PhInitFormatSR(&format[4], errorMessage->sr);

statusMessage = PhFormat(format, RTL_NUMBER_OF(format), 0);
PhDereferenceObject(errorMessage);
statusMessage = PhFormat(format, RTL_NUMBER_OF(format), 0);
PhDereferenceObject(errorMessage);
}
}
else

if (PhIsNullOrEmptyString(statusMessage))
{
PhInitFormatS(&format[3], L") exited with 0x");
PhInitFormatX(&format[4], basicInfo.ExitStatus);

//format[4].Type |= FormatPadZeros; format[4].Width = 8;
statusMessage = PhFormat(format, RTL_NUMBER_OF(format), 0);
}

Expand Down

0 comments on commit 672a77e

Please sign in to comment.