Skip to content

Commit

Permalink
Merge pull request #482 from processhacker/master
Browse files Browse the repository at this point in the history
[pull] master from processhacker:master
  • Loading branch information
pull[bot] authored Jun 5, 2022
2 parents 4570376 + b52b921 commit d5c42c3
Show file tree
Hide file tree
Showing 25 changed files with 833 additions and 117 deletions.
1 change: 1 addition & 0 deletions ProcessHacker/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -3079,6 +3079,7 @@ BOOLEAN PhUiLoadDllProcess(
PPH_STRING fileName;

fileDialog = PhCreateOpenFileDialog();
PhSetFileDialogOptions(fileDialog, PH_FILEDIALOG_DONTADDTORECENT);
PhSetFileDialogFilter(fileDialog, filters, RTL_NUMBER_OF(filters));

if (!PhShowFileDialog(hWnd, fileDialog))
Expand Down
48 changes: 16 additions & 32 deletions ProcessHacker/affinity.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,45 +320,29 @@ INT_PTR CALLBACK PhpProcessAffinityDlgProc(
context->ProcessItem->ProcessId
)))
{
USHORT groupBuffer[20] = { 0 };
USHORT groupCount = RTL_NUMBER_OF(groupBuffer);

if (NT_SUCCESS(PhGetProcessGroupInformation(
processHandle,
&groupCount,
groupBuffer
)) && groupCount > 1)
{
// We can't change affinity of multi-group processes. We can only change
// affinity for individual threads in this case. (dmex).
status = STATUS_RETRY;
}
status = PhGetProcessGroupAffinity(processHandle, &processGroupAffinity);

if (NT_SUCCESS(status))
// Add workaround for current process (dmex)
if (status == STATUS_INVALID_PARAMETER && context->ProcessItem->ProcessId == NtCurrentProcessId())
{
status = PhGetProcessGroupAffinity(processHandle, &processGroupAffinity);
PROCESS_BASIC_INFORMATION basicInfo;

if (status == STATUS_INVALID_PARAMETER && context->ProcessItem->ProcessId == NtCurrentProcessId())
{
PROCESS_BASIC_INFORMATION basicInfo;

status = PhGetProcessBasicInformation(processHandle, &basicInfo);

if (NT_SUCCESS(status))
{
processGroupAffinity.Mask = basicInfo.AffinityMask;
}
}
status = PhGetProcessBasicInformation(processHandle, &basicInfo);

if (NT_SUCCESS(status))
{
context->AffinityMask = processGroupAffinity.Mask;
context->AffinityGroup = processGroupAffinity.Group;
processGroupAffinity.Mask = basicInfo.AffinityMask;
}
}

if (context->GroupComboHandle)
{
ComboBox_SetCurSel(context->GroupComboHandle, processGroupAffinity.Group);
}
if (NT_SUCCESS(status))
{
context->AffinityMask = processGroupAffinity.Mask;
context->AffinityGroup = processGroupAffinity.Group;

if (context->GroupComboHandle)
{
ComboBox_SetCurSel(context->GroupComboHandle, processGroupAffinity.Group);
}
}

Expand Down
6 changes: 4 additions & 2 deletions ProcessHacker/hidnproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ INT_PTR CALLBACK PhpHiddenProcessesDlgProc(

PhSetApplicationWindowIcon(hwndDlg);

PhCenterWindow(hwndDlg, GetParent(hwndDlg));
PhHiddenProcessesListViewHandle = lvHandle = GetDlgItem(hwndDlg, IDC_PROCESSES);
methodHandle = GetDlgItem(hwndDlg, IDC_METHOD);

Expand Down Expand Up @@ -160,7 +159,10 @@ INT_PTR CALLBACK PhpHiddenProcessesDlgProc(
MinimumSize.bottom = 140;
MapDialogRect(hwndDlg, &MinimumSize);

PhLoadWindowPlacementFromSetting(L"HiddenProcessesWindowPosition", L"HiddenProcessesWindowSize", hwndDlg);
if (PhGetIntegerPairSetting(L"HiddenProcessesWindowPosition").X)
PhLoadWindowPlacementFromSetting(L"HiddenProcessesWindowPosition", L"HiddenProcessesWindowSize", hwndDlg);
else
PhCenterWindow(hwndDlg, GetParent(hwndDlg));

EnableWindow(GetDlgItem(hwndDlg, IDC_TERMINATE), FALSE);
}
Expand Down
2 changes: 1 addition & 1 deletion ProcessHacker/hndlstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ INT_PTR CALLBACK PhpHandleStatisticsDlgProc(
ULONG_PTR i;

PhSetApplicationWindowIcon(hwndDlg);
PhCenterWindow(hwndDlg, GetParent(hwndDlg));

processId = context->ProcessId;
context->ListViewHandle = GetDlgItem(hwndDlg, IDC_LIST);
Expand All @@ -168,6 +167,7 @@ INT_PTR CALLBACK PhpHandleStatisticsDlgProc(

if (PhGetScalableIntegerPairSetting(L"HandleStatisticsWindowSize", TRUE).X)
PhLoadWindowPlacementFromSetting(NULL, L"HandleStatisticsWindowSize", hwndDlg);
PhCenterWindow(hwndDlg, GetParent(hwndDlg));

for (i = 0; i < context->Handles->NumberOfHandles; i++)
{
Expand Down
12 changes: 10 additions & 2 deletions ProcessHacker/include/mainwnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ extern BOOLEAN PhMainWndExiting;
#define WM_PH_UPDATE_FONT (WM_APP + 136)
// end_phapppub
#define WM_PH_INVOKE (WM_APP + 145)
#define WM_PH_CALLBACK (WM_APP + 146)
#define WM_PH_LAST (WM_APP + 146)
#define WM_PH_LAST (WM_APP + 145)

// begin_phapppub
PHAPPAPI
Expand Down Expand Up @@ -115,6 +114,15 @@ PhPluginInvokeWindowCallback(
#define ProcessHacker_IconClick() \
PhPluginInvokeWindowCallback(PH_MAINWINDOW_CALLBACK_TYPE_ICON_CLICK, 0, 0)

// begin_phapppub
PHAPPAPI
PVOID
NTAPI
PhPluginCreateTabPage(
_In_ PVOID Page
);
// end_phapppub

typedef struct _PH_SHOW_MEMORY_EDITOR
{
HWND OwnerWindow;
Expand Down
20 changes: 9 additions & 11 deletions ProcessHacker/mainwnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ VOID PhMwpOnCommand(
PVOID fileDialog = PhCreateOpenFileDialog();

PhSetFileDialogFilter(fileDialog, filters, RTL_NUMBER_OF(filters));
PhSetFileDialogOptions(fileDialog, PH_FILEDIALOG_NOPATHVALIDATE);
PhSetFileDialogOptions(fileDialog, PH_FILEDIALOG_NOPATHVALIDATE | PH_FILEDIALOG_DONTADDTORECENT);

if (PhShowFileDialog(WindowHandle, fileDialog))
{
Expand Down Expand Up @@ -2019,15 +2019,6 @@ ULONG_PTR PhMwpOnUserMessage(
function((PVOID)WParam);
}
break;
case WM_PH_CALLBACK:
{
PVOID (NTAPI *function)(PVOID);

function = (PVOID)LParam;

return (ULONG_PTR)function((PVOID)WParam);
}
break;
}

return 0;
Expand Down Expand Up @@ -3849,7 +3840,7 @@ PVOID PhPluginInvokeWindowCallback(
break;
case PH_MAINWINDOW_CALLBACK_TYPE_CREATE_TAB_PAGE:
{
return (PVOID)SendMessage(PhMainWndHandle, WM_PH_CALLBACK, (WPARAM)lparam, (LPARAM)PhMwpCreatePage);
return NULL; //(PVOID)SendMessage(PhMainWndHandle, WM_PH_CALLBACK, (WPARAM)lparam, (LPARAM)PhMwpCreatePage);
}
break;
case PH_MAINWINDOW_CALLBACK_TYPE_GET_UPDATE_AUTOMATICALLY:
Expand All @@ -3869,3 +3860,10 @@ PVOID PhPluginInvokeWindowCallback(

return NULL;
}

PVOID PhPluginCreateTabPage(
_In_ PVOID Page
)
{
return PhMwpCreatePage(Page);
}
23 changes: 19 additions & 4 deletions ProcessHacker/proctree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3924,7 +3924,7 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
}

// NOTE: Windows Task Manager doesn't loop subitems when summing the totals but instead just returns the system totals.
// We could do the same for some columns like CPU when/if the loop becomes a performance issue but sum the real values for now. (dmex)
// We should do the same for some columns like CPU when/if the below loop/aggregate fields becomes a performance issue. (dmex)

for (ULONG i = 0; i < ProcessNodeList->Count; i++)
{
Expand Down Expand Up @@ -4017,13 +4017,28 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback(
}
break;
case PHPRTLC_CYCLES:
PhpAggregateFieldTotal(node, AggregateTypeInt64, AggregateLocationProcessItem, FIELD_OFFSET(PH_PROCESS_ITEM, CycleTimeDelta.Value), &number);
{
if (node->ProcessId == SYSTEM_IDLE_PROCESS_ID)
continue;

PhpAggregateFieldTotal(node, AggregateTypeInt64, AggregateLocationProcessItem, FIELD_OFFSET(PH_PROCESS_ITEM, CycleTimeDelta.Value), &number);
}
break;
case PHPRTLC_CYCLESDELTA:
PhpAggregateFieldTotal(node, AggregateTypeInt64, AggregateLocationProcessItem, FIELD_OFFSET(PH_PROCESS_ITEM, CycleTimeDelta.Delta), &number);
{
if (node->ProcessId == SYSTEM_IDLE_PROCESS_ID)
continue;

PhpAggregateFieldTotal(node, AggregateTypeInt64, AggregateLocationProcessItem, FIELD_OFFSET(PH_PROCESS_ITEM, CycleTimeDelta.Delta), &number);
}
break;
case PHPRTLC_CONTEXTSWITCHES:
PhpAggregateFieldTotal(node, AggregateTypeInt32, AggregateLocationProcessItem, FIELD_OFFSET(PH_PROCESS_ITEM, ContextSwitchesDelta.Value), &number);
{
if (node->ProcessId == SYSTEM_IDLE_PROCESS_ID)
continue;

PhpAggregateFieldTotal(node, AggregateTypeInt32, AggregateLocationProcessItem, FIELD_OFFSET(PH_PROCESS_ITEM, ContextSwitchesDelta.Value), &number);
}
break;
case PHPRTLC_CONTEXTSWITCHESDELTA:
{
Expand Down
2 changes: 1 addition & 1 deletion phnt/include/ntexapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ NtWaitForWorkViaWorkerFactory(
_Out_writes_to_(Count, *PacketsReturned) struct _FILE_IO_COMPLETION_INFORMATION *MiniPackets,
_In_ ULONG Count,
_Out_ PULONG PacketsReturned,
_In_ PWORKER_FACTORY_DEFERRED_WORK DeferredWork
_In_ struct _WORKER_FACTORY_DEFERRED_WORK* DeferredWork
);

#else
Expand Down
35 changes: 19 additions & 16 deletions phnt/include/ntmisc.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,46 +70,49 @@ NtTraceEvent(

typedef enum _TRACE_CONTROL_INFORMATION_CLASS
{
TraceControlStartLogger = 1,
TraceControlStopLogger = 2,
TraceControlQueryLogger = 3,
TraceControlUpdateLogger = 4,
TraceControlFlushLogger = 5,
TraceControlIncrementLoggerFile = 6,

TraceControlStartLogger = 1, // inout WMI_LOGGER_INFORMATION
TraceControlStopLogger = 2, // inout WMI_LOGGER_INFORMATION
TraceControlQueryLogger = 3, // inout WMI_LOGGER_INFORMATION
TraceControlUpdateLogger = 4, // inout WMI_LOGGER_INFORMATION
TraceControlFlushLogger = 5, // inout WMI_LOGGER_INFORMATION
TraceControlIncrementLoggerFile = 6, // inout WMI_LOGGER_INFORMATION
TraceControlUnknown = 7,
// unused
TraceControlRealtimeConnect = 11,
TraceControlActivityIdCreate = 12,
TraceControlWdiDispatchControl = 13,
TraceControlRealtimeDisconnectConsumerByHandle = 14,
TraceControlRealtimeDisconnectConsumerByHandle = 14, // in HANDLE
TraceControlRegisterGuidsCode = 15,
TraceControlReceiveNotification = 16,
TraceControlSendDataBlock = 17, // EnableGuid
TraceControlSendDataBlock = 17, // ETW_ENABLE_NOTIFICATION_PACKET
TraceControlSendReplyDataBlock = 18,
TraceControlReceiveReplyDataBlock = 19,
TraceControlWdiUpdateSem = 20,
TraceControlEnumTraceGuidList = 21,
TraceControlGetTraceGuidInfo = 22,
TraceControlEnumTraceGuidList = 21, // out GUID[]
TraceControlGetTraceGuidInfo = 22, // in GUID, out TRACE_GUID_INFO
TraceControlEnumerateTraceGuids = 23,
TraceControlRegisterSecurityProv = 24,
TraceControlQueryReferenceTime = 25,
TraceControlTrackProviderBinary = 26,
TraceControlTrackProviderBinary = 26, // in HANDLE
TraceControlAddNotificationEvent = 27,
TraceControlUpdateDisallowList = 28,
TraceControlSetEnableAllKeywordsCode = 29,
TraceControlSetProviderTraitsCode = 30,
TraceControlUseDescriptorTypeCode = 31,
TraceControlEnumTraceGroupList = 32,
TraceControlGetTraceGroupInfo = 33,
TraceControlTraceSetDisallowList= 34,
TraceControlTraceSetDisallowList = 34,
TraceControlSetCompressionSettings = 35,
TraceControlGetCompressionSettings= 36,
TraceControlGetCompressionSettings = 36,
TraceControlUpdatePeriodicCaptureState = 37,
TraceControlGetPrivateSessionTraceHandle = 38,
TraceControlRegisterPrivateSession = 39,
TraceControlQuerySessionDemuxObject = 40,
TraceControlSetProviderBinaryTracking = 41,
TraceControlMaxLoggers = 42,
TraceControlMaxPmcCounter = 43
TraceControlMaxLoggers = 42, // out ULONG
TraceControlMaxPmcCounter = 43, // out ULONG
TraceControlQueryUsedProcessorCount = 44, // ULONG // since WIN11
TraceControlGetPmcOwnership = 45,
} TRACE_CONTROL_INFORMATION_CLASS;

#if (PHNT_VERSION >= PHNT_VISTA)
Expand Down
1 change: 1 addition & 0 deletions phnt/include/ntobapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ typedef enum _OBJECT_INFORMATION_CLASS
#else
#define ObjectBasicInformation 0
#define ObjectNameInformation 1
#define ObjectTypeInformation 2
#define ObjectTypesInformation 3
#define ObjectHandleFlagInformation 4
#define ObjectSessionInformation 5
Expand Down
13 changes: 4 additions & 9 deletions phnt/include/ntzwapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -3346,14 +3346,6 @@ ZwQueueApcThreadEx(
_In_opt_ PVOID ApcArgument3
);

#if !defined(NTDDI_WIN10_FE) || (NTDDI_VERSION < NTDDI_WIN10_FE)
typedef enum _QUEUE_USER_APC_FLAGS
{
QUEUE_USER_APC_FLAGS_NONE = 0x0,
QUEUE_USER_APC_FLAGS_SPECIAL_USER_APC = 0x1,
} QUEUE_USER_APC_FLAGS;
#endif

NTSYSCALLAPI
NTSTATUS
NTAPI
Expand Down Expand Up @@ -4603,7 +4595,10 @@ NTSTATUS
NTAPI
ZwWaitForWorkViaWorkerFactory(
_In_ HANDLE WorkerFactoryHandle,
_Out_ struct _FILE_IO_COMPLETION_INFORMATION *MiniPacket
_Out_writes_to_(Count, *PacketsReturned) struct _FILE_IO_COMPLETION_INFORMATION *MiniPackets,
_In_ ULONG Count,
_Out_ PULONG PacketsReturned,
_In_ struct _WORKER_FACTORY_DEFERRED_WORK* DeferredWork
);

NTSYSCALLAPI
Expand Down
Loading

0 comments on commit d5c42c3

Please sign in to comment.