Skip to content

Commit

Permalink
Merge branch 'master' into master-dm
Browse files Browse the repository at this point in the history
  • Loading branch information
DartVanya committed Jan 28, 2025
2 parents edf884f + 3ee4b7d commit 0c07b10
Show file tree
Hide file tree
Showing 82 changed files with 3,636 additions and 2,228 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
*.vspscc
*_i.c
*_p.c
*.bak

# Visual C++ cache files
*.aps
Expand Down
12 changes: 6 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@
</Link>
</ItemDefinitionGroup>

<Import Project="packages\Microsoft.Windows.SDK.CPP.10.0.26100.2161\build\native\Microsoft.Windows.SDK.cpp.props" Condition="Exists('packages\Microsoft.Windows.SDK.CPP.10.0.26100.2161\build\native\Microsoft.Windows.SDK.cpp.props')"/>
<Import Project="packages\Microsoft.Windows.SDK.CPP.x86.10.0.26100.2161\build\native\Microsoft.Windows.SDK.cpp.x86.props" Condition="Exists('packages\Microsoft.Windows.SDK.CPP.x86.10.0.26100.2161\build\native\Microsoft.Windows.SDK.cpp.x86.props') and '$(Platform)' == 'Win32'"/>
<Import Project="packages\Microsoft.Windows.SDK.CPP.x64.10.0.26100.2161\build\native\Microsoft.Windows.SDK.cpp.x64.props" Condition="Exists('packages\Microsoft.Windows.SDK.CPP.x64.10.0.26100.2161\build\native\Microsoft.Windows.SDK.cpp.x64.props') and '$(Platform)' == 'x64'"/>
<Import Project="packages\Microsoft.Windows.SDK.CPP.ARM64.10.0.26100.2161\build\native\Microsoft.Windows.SDK.cpp.ARM64.props" Condition="Exists('packages\Microsoft.Windows.SDK.CPP.ARM64.10.0.26100.2161\build\native\Microsoft.Windows.SDK.cpp.ARM64.props') and '$(Platform)' == 'ARM64'"/>
<Import Project="packages\Microsoft.Windows.WDK.x64.10.0.26100.2161\build\native\Microsoft.Windows.WDK.x64.props" Condition="Exists('packages\Microsoft.Windows.WDK.x64.10.0.26100.2161\build\native\Microsoft.Windows.WDK.x64.props') and '$(Platform)' == 'x64'"/>
<Import Project="packages\Microsoft.Windows.WDK.ARM64.10.0.26100.2161\build\native\Microsoft.Windows.WDK.ARM64.props" Condition="Exists('packages\Microsoft.Windows.WDK.ARM64.10.0.26100.2161\build\native\Microsoft.Windows.WDK.ARM64.props') and '$(Platform)' == 'ARM64'"/>
<Import Project="packages\Microsoft.Windows.SDK.CPP.10.0.26100.2454\build\native\Microsoft.Windows.SDK.cpp.props" Condition="Exists('packages\Microsoft.Windows.SDK.CPP.10.0.26100.2454\build\native\Microsoft.Windows.SDK.cpp.props')"/>
<Import Project="packages\Microsoft.Windows.SDK.CPP.x86.10.0.26100.2454\build\native\Microsoft.Windows.SDK.cpp.x86.props" Condition="Exists('packages\Microsoft.Windows.SDK.CPP.x86.10.0.26100.2454\build\native\Microsoft.Windows.SDK.cpp.x86.props') and '$(Platform)' == 'Win32'"/>
<Import Project="packages\Microsoft.Windows.SDK.CPP.x64.10.0.26100.2454\build\native\Microsoft.Windows.SDK.cpp.x64.props" Condition="Exists('packages\Microsoft.Windows.SDK.CPP.x64.10.0.26100.2454\build\native\Microsoft.Windows.SDK.cpp.x64.props') and '$(Platform)' == 'x64'"/>
<Import Project="packages\Microsoft.Windows.SDK.CPP.ARM64.10.0.26100.2454\build\native\Microsoft.Windows.SDK.cpp.ARM64.props" Condition="Exists('packages\Microsoft.Windows.SDK.CPP.ARM64.10.0.26100.2454\build\native\Microsoft.Windows.SDK.cpp.ARM64.props') and '$(Platform)' == 'ARM64'"/>
<Import Project="packages\Microsoft.Windows.WDK.x64.10.0.26100.2454\build\native\Microsoft.Windows.WDK.x64.props" Condition="Exists('packages\Microsoft.Windows.WDK.x64.10.0.26100.2454\build\native\Microsoft.Windows.WDK.x64.props') and '$(Platform)' == 'x64'"/>
<Import Project="packages\Microsoft.Windows.WDK.ARM64.10.0.26100.2454\build\native\Microsoft.Windows.WDK.ARM64.props" Condition="Exists('packages\Microsoft.Windows.WDK.ARM64.10.0.26100.2454\build\native\Microsoft.Windows.WDK.ARM64.props') and '$(Platform)' == 'ARM64'"/>
</Project>
2,171 changes: 1,081 additions & 1,090 deletions SystemInformer/SystemInformer.def

Large diffs are not rendered by default.

28 changes: 18 additions & 10 deletions SystemInformer/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -2314,16 +2314,21 @@ BOOLEAN PhUiRestartProcess(
{
if (Process->ProcessId == shellClientId.UniqueProcess)
{
status = PhOpenProcess(
if (NT_SUCCESS(PhOpenProcess(
&processHandle,
PROCESS_TERMINATE,
Process->ProcessId
);

if (NT_SUCCESS(status))
)))
{
PhTerminateProcess(processHandle, STATUS_SUCCESS);
status = PhTerminateProcess(
processHandle,
STATUS_SUCCESS
);

NtClose(processHandle);

if (NT_SUCCESS(status))
goto CleanupExit;
}
}
}
Expand Down Expand Up @@ -2361,7 +2366,7 @@ BOOLEAN PhUiRestartProcess(

if (!NT_SUCCESS(status = PhGetProcessEnvironment(
processHandle,
Process->IsWow64Process ? PH_GET_PROCESS_ENVIRONMENT_WOW64 : 0,
!!Process->IsWow64Process,
&environmentBuffer,
&environmentLength
)))
Expand Down Expand Up @@ -5110,18 +5115,21 @@ BOOLEAN PhUiCloseConnections(
_In_ ULONG NumberOfConnections
)
{
ULONG (WINAPI* SetTcpEntry_I)(_In_ PMIB_TCPROW pTcpRow) = NULL;
static ULONG (WINAPI* SetTcpEntry_I)(_In_ PMIB_TCPROW pTcpRow) = NULL;
BOOLEAN success = TRUE;
BOOLEAN cancelled = FALSE;
ULONG result;
ULONG i;
MIB_TCPROW tcpRow;

SetTcpEntry_I = PhGetDllProcedureAddress(L"iphlpapi.dll", "SetTcpEntry", 0);
if (!SetTcpEntry_I)
{
SetTcpEntry_I = PhGetDllProcedureAddress(L"iphlpapi.dll", "SetTcpEntry", 0);
}

if (!SetTcpEntry_I)
{
PhShowError2(WindowHandle, L"This feature is not supported by your operating system.", L"%s", L"");
PhShowStatus(WindowHandle, L"Unable to close the TCP connection", STATUS_NOT_SUPPORTED, 0);
return FALSE;
}

Expand Down Expand Up @@ -5805,7 +5813,7 @@ BOOLEAN PhUiUnloadModule(

if (status == STATUS_DLL_NOT_FOUND)
{
PhShowError2(WindowHandle, L"Unable to find the module to unload.", L"%s", L"");
PhShowStatus(WindowHandle, L"Unable to unload the module", 0, ERROR_MOD_NOT_FOUND);
return FALSE;
}

Expand Down
30 changes: 20 additions & 10 deletions SystemInformer/admintask.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <phapp.h>
#include <appsup.h>
#include <taskschd.h>
#include <secwmi.h>

DEFINE_GUID(CLSID_TaskScheduler, 0x0f87369f, 0xa4e5, 0x4cfc, 0xbd, 0x3e, 0x73, 0xe6, 0x15, 0x45, 0x72, 0xdd);
DEFINE_GUID(IID_ITaskService, 0x2FABA4C7, 0x4DA9, 0x4013, 0x96, 0x97, 0x20, 0xCC, 0x3F, 0xD4, 0x0F, 0x85);
Expand Down Expand Up @@ -61,12 +62,12 @@ HRESULT PhCreateAdminTask(
if (FAILED(status))
goto CleanupExit;

taskNameString = SysAllocStringLen(TaskName->Buffer, (UINT32)TaskName->Length / sizeof(WCHAR));
taskFileNameString = SysAllocStringLen(FileName->Buffer, (UINT32)FileName->Length / sizeof(WCHAR));
taskFolderString = SysAllocStringLen(PhNtPathSeperatorString.Buffer, (UINT32)PhNtPathSeperatorString.Length / sizeof(WCHAR));
taskTimeLimitString = SysAllocStringLen(taskTimeLimit.Buffer, (UINT32)taskTimeLimit.Length / sizeof(WCHAR));
taskNameString = PhStringRefToBSTR(TaskName);
taskFileNameString = PhStringRefToBSTR(FileName);
taskFolderString = PhStringRefToBSTR(&PhNtPathSeperatorString);
taskTimeLimitString = PhStringRefToBSTR(&taskTimeLimit);
#if (PH_ADMIN_TASK_FORWARD_COMMANDLINE_UNPRIVILEGED)
taskArgumentsString = SysAllocStringLen(taskArguments.Buffer, (UINT32)taskArguments.Length / sizeof(WCHAR));
taskArgumentsString = PhStringRefToBSTR(&taskArguments);
#endif

status = ITaskService_Connect(
Expand Down Expand Up @@ -161,6 +162,15 @@ HRESULT PhCreateAdminTask(
if (FAILED(status))
goto CleanupExit;

#define TASK_RUNLEVEL_LUA 0
#define TASK_RUNLEVEL_HIGHEST 1
#define RUNLEVEL_ADMIN 2
#define RUNLEVEL_MAX_NON_UIA 3
#define RUNLEVEL_LUA_UIA 4
#define RUNLEVEL_HIGHEST_UIA 5
#define RUNLEVEL_ADMIN_UIA 6
#define RUNLEVEL_MAX 7

IPrincipal_put_RunLevel(taskPrincipal, TASK_RUNLEVEL_HIGHEST);
IPrincipal_put_LogonType(taskPrincipal, TASK_LOGON_INTERACTIVE_TOKEN);

Expand Down Expand Up @@ -285,8 +295,8 @@ HRESULT PhDeleteAdminTask(
if (FAILED(status))
goto CleanupExit;

taskNameString = SysAllocStringLen(TaskName->Buffer, (UINT32)TaskName->Length / sizeof(WCHAR));
taskFolderString = SysAllocStringLen(PhNtPathSeperatorString.Buffer, (UINT32)PhNtPathSeperatorString.Length / sizeof(WCHAR));
taskNameString = PhStringRefToBSTR(TaskName);
taskFolderString = PhStringRefToBSTR(&PhNtPathSeperatorString);

status = ITaskService_Connect(
taskService,
Expand Down Expand Up @@ -352,8 +362,8 @@ HRESULT PhRunAsAdminTask(
if (FAILED(status))
goto CleanupExit;

taskNameString = SysAllocStringLen(TaskName->Buffer, (UINT32)TaskName->Length / sizeof(WCHAR));
taskFolderString = SysAllocStringLen(PhNtPathSeperatorString.Buffer, (UINT32)PhNtPathSeperatorString.Length / sizeof(WCHAR));
taskNameString = PhStringRefToBSTR(TaskName);
taskFolderString = PhStringRefToBSTR(&PhNtPathSeperatorString);

status = ITaskService_Connect(
taskService,
Expand Down Expand Up @@ -392,7 +402,7 @@ HRESULT PhRunAsAdminTask(
if (NT_SUCCESS(PhGetProcessCommandLineStringRef(&commandline)))
{
V_VT(&params) = VT_BSTR;
V_BSTR(&params) = SysAllocStringLen(commandline.Buffer, (UINT32)commandline.Length / sizeof(WCHAR));
V_BSTR(&params) = PhStringRefToBSTR(&commandline);
}
}
#endif
Expand Down
32 changes: 17 additions & 15 deletions SystemInformer/findobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,8 @@ VOID PhpPopulateObjectTypes(

ReleaseDC(Context->TypeWindowHandle, comboDc);

maxLength += PhGetSystemMetrics(SM_CXVSCROLL, PhGetWindowDpi(Context->TypeWindowHandle)) * 2;

if (maxLength)
{
SendMessage(Context->TypeWindowHandle, CB_SETDROPPEDWIDTH, maxLength, 0);
Expand Down Expand Up @@ -832,7 +834,7 @@ static NTSTATUS NTAPI SearchHandleFunction(

if (NT_SUCCESS(PhGetHandleInformation(
handleContext->ProcessHandle,
(HANDLE)handleContext->HandleInfo->HandleValue,
handleContext->HandleInfo->HandleValue,
handleContext->HandleInfo->ObjectTypeIndex,
NULL,
&typeName,
Expand All @@ -852,15 +854,15 @@ static NTSTATUS NTAPI SearchHandleFunction(
MatchSearchString(context, &upperBestObjectName->sr)) &&
MatchTypeString(context, &upperTypeName->sr)) ||
PhSearchControlMatchPointer(context->SearchMatchHandle, handleContext->HandleInfo->Object) ||
PhSearchControlMatchPointer(context->SearchMatchHandle, (PVOID)handleContext->HandleInfo->HandleValue))
PhSearchControlMatchPointer(context->SearchMatchHandle, handleContext->HandleInfo->HandleValue))
{
PPHP_OBJECT_SEARCH_RESULT searchResult;

searchResult = PhAllocateZero(sizeof(PHP_OBJECT_SEARCH_RESULT));
searchResult->ProcessId = (HANDLE)handleContext->HandleInfo->UniqueProcessId;
searchResult->ProcessId = handleContext->HandleInfo->UniqueProcessId;
searchResult->ResultType = HandleSearchResult;
searchResult->Object = handleContext->HandleInfo->Object;
searchResult->Handle = (HANDLE)handleContext->HandleInfo->HandleValue;
searchResult->Handle = handleContext->HandleInfo->HandleValue;
searchResult->TypeName = typeName;
searchResult->ObjectName = objectName;
searchResult->BestObjectName = bestObjectName;
Expand Down Expand Up @@ -937,7 +939,7 @@ static BOOLEAN NTAPI EnumModulesCallback(
searchResult = PhAllocateZero(sizeof(PHP_OBJECT_SEARCH_RESULT));
searchResult->ProcessId = moduleContext->ProcessId;
searchResult->ResultType = (Module->Type == PH_MODULE_TYPE_MAPPED_FILE || Module->Type == PH_MODULE_TYPE_MAPPED_IMAGE) ? MappedFileSearchResult : ModuleSearchResult;
searchResult->Handle = (HANDLE)Module->BaseAddress;
searchResult->Handle = Module->BaseAddress;
searchResult->TypeName = PhCreateString(typeName);
PhSetReference(&searchResult->BestObjectName, filenameWin32);
PhSetReference(&searchResult->ObjectName, Module->FileName);
Expand Down Expand Up @@ -1005,24 +1007,24 @@ NTSTATUS PhpFindObjectsThreadStart(

processHandlePtr = PhFindItemSimpleHashtable(
processHandleHashtable,
(PVOID)handleInfo->UniqueProcessId
handleInfo->UniqueProcessId
);

if (processHandlePtr)
{
processHandle = (HANDLE)*processHandlePtr;
processHandle = *processHandlePtr;
}
else
{
if (NT_SUCCESS(PhOpenProcess(
&processHandle,
PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION,
(HANDLE)handleInfo->UniqueProcessId
)))
handleInfo->UniqueProcessId
)))
{
PhAddItemSimpleHashtable(
processHandleHashtable,
(PVOID)handleInfo->UniqueProcessId,
handleInfo->UniqueProcessId,
processHandle
);
}
Expand All @@ -1031,12 +1033,12 @@ NTSTATUS PhpFindObjectsThreadStart(
if (NT_SUCCESS(PhOpenProcess(
&processHandle,
PROCESS_QUERY_INFORMATION,
(HANDLE)handleInfo->UniqueProcessId
)))
handleInfo->UniqueProcessId
)))
{
PhAddItemSimpleHashtable(
processHandleHashtable,
(PVOID)handleInfo->UniqueProcessId,
handleInfo->UniqueProcessId,
processHandle
);
}
Expand Down Expand Up @@ -1084,7 +1086,7 @@ NTSTATUS PhpFindObjectsThreadStart(
i = 0;

while (PhEnumHashtable(processHandleHashtable, &entry, &i))
NtClose((HANDLE)entry->Value);
NtClose(entry->Value);
}

PhDereferenceObject(processHandleHashtable);
Expand Down Expand Up @@ -1777,7 +1779,7 @@ VOID PhShowFindObjectsDialog(
{
if (!NT_SUCCESS(PhCreateThreadEx(&PhFindObjectsThreadHandle, PhpFindObjectsDialogThreadStart, NULL)))
{
PhShowError2(PhMainWndHandle, L"Unable to create the window.", L"%s", L"");
PhShowStatus(PhMainWndHandle, L"Unable to create the window.", 0, ERROR_OUTOFMEMORY);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion SystemInformer/hidnproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ INT_PTR CALLBACK PhpZombieProcessesDlgProc(
if (NT_SUCCESS(status))
{
PhSetDialogItemText(hwndDlg, IDC_DESCRIPTION,
PhaFormatString(L"%u Zombie process(es), %u terminated process(es).",
PhaFormatString(L"%u zombie process(es), %u terminated process(es).",
NumberOfZombieProcesses, NumberOfTerminatedProcesses)->Buffer
);
InvalidateRect(GetDlgItem(hwndDlg, IDC_DESCRIPTION), NULL, TRUE);
Expand Down
2 changes: 1 addition & 1 deletion SystemInformer/include/miniinfop.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ typedef struct _PH_MIP_GROUP_NODE
HANDLE RepresentativeProcessId;
LARGE_INTEGER RepresentativeCreateTime;
BOOLEAN RepresentativeIsHung;

BOOLEAN RepresentativeIsTerminated;
PPH_STRING TooltipText;
} PH_MIP_GROUP_NODE, *PPH_MIP_GROUP_NODE;

Expand Down
16 changes: 15 additions & 1 deletion SystemInformer/include/phplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ typedef enum _PH_GENERAL_CALLBACK
GeneralCallbackProcessProviderAddedEvent, // [process provider thread]
GeneralCallbackProcessProviderModifiedEvent, // [process provider thread]
GeneralCallbackProcessProviderRemovedEvent, // [process provider thread]
GeneralCallbackProcessProviderUpdatedEvent, // [process provider thread]
GeneralCallbackProcessProviderUpdatedEvent, // PPH_PROCESS_PROVIDER_UPDATED_EVENT [process provider thread]
GeneralCallbackServiceProviderAddedEvent, // [service provider thread]
GeneralCallbackServiceProviderModifiedEvent, // [service provider thread]
GeneralCallbackServiceProviderRemovedEvent, // [service provider thread]
Expand All @@ -78,6 +78,8 @@ typedef enum _PH_GENERAL_CALLBACK
GeneralCallbackDeviceNotificationEvent, // [device provider thread]

GeneralCallbackTrayIconsInitializing, // [work queue thread]
GeneralCallbackTrayIconsUpdatedEvent,

GeneralCallbackWindowNotifyEvent,
GeneralCallbackProcessStatsNotifyEvent,
GeneralCallbackSettingsUpdated,
Expand All @@ -99,6 +101,18 @@ typedef enum _PH_PLUGIN_CALLBACK
PluginCallbackMaximum
} PH_PLUGIN_CALLBACK, *PPH_PLUGIN_CALLBACK;

// Provider events

typedef struct _PH_PROCESS_PROVIDER_UPDATED_EVENT
{
ULONG RunCount;
} PH_PROCESS_PROVIDER_UPDATED_EVENT, *PPH_PROCESS_PROVIDER_UPDATED_EVENT;

#define PH_PROCESS_PROVIDER_UPDATED_EVENT_PTR(RunCount) \
&(PH_PROCESS_PROVIDER_UPDATED_EVENT){ (RunCount) }

// Plugin events

typedef struct _PH_PLUGIN_GET_HIGHLIGHTING_COLOR
{
// Parameter is:
Expand Down
4 changes: 4 additions & 0 deletions SystemInformer/include/procprpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ typedef struct _PH_STATISTICS_CONTEXT
ULONG64 IoOtherCountDelta; ULONG64 IoOtherCountDeltaMin; ULONG64 IoOtherCountDeltaMax; ULONG64 IoOtherCountDeltaDiff;
ULONG64 OtherTransferCount; ULONG64 OtherTransferCountMin; ULONG64 OtherTransferCountMax; ULONG64 OtherTransferCountDiff;
ULONG64 IoOtherDelta; ULONG64 IoOtherDeltaMin; ULONG64 IoOtherDeltaMax; ULONG64 IoOtherDeltaDiff;

ULONG64 IoTotal; ULONG64 IoTotalMin; ULONG64 IoTotalMax; ULONG64 IoTotalDiff;
ULONG64 IoTotalDelta; ULONG64 IoTotalDeltaMin; ULONG64 IoTotalDeltaMax; ULONG64 IoTotalDeltaDiff;

} PH_STATISTICS_CONTEXT, *PPH_STATISTICS_CONTEXT;

#define WM_PH_PERFORMANCE_UPDATE (WM_APP + 241)
Expand Down
16 changes: 12 additions & 4 deletions SystemInformer/include/sysinfop.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,20 @@ VOID PhSipLayoutMemoryGraphs(
_In_ HWND hwnd
);

VOID PhSipNotifyCommitGraph(
_In_ NMHDR *Header
BOOLEAN NTAPI PhSipNotifyCommitGraph(
_In_ HWND GraphHandle,
_In_ ULONG GraphMessage,
_In_ PVOID Parameter1,
_In_ PVOID Parameter2,
_In_ PVOID Context
);

VOID PhSipNotifyPhysicalGraph(
_In_ NMHDR *Header
BOOLEAN NTAPI PhSipNotifyPhysicalGraph(
_In_ HWND GraphHandle,
_In_ ULONG GraphMessage,
_In_ PVOID Parameter1,
_In_ PVOID Parameter2,
_In_ PVOID Context
);

VOID PhSipUpdateMemoryGraphs(
Expand Down
8 changes: 1 addition & 7 deletions SystemInformer/itemtips.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,9 @@ VOID PhpFillUmdfDrivers(
)))
return;

#ifdef _WIN64
// Just in case.
if (Process->IsWow64Process)
flags |= PH_GET_PROCESS_ENVIRONMENT_WOW64;
#endif

if (NT_SUCCESS(PhGetProcessEnvironment(
processHandle,
flags,
!!Process->IsWow64Process,
&environment,
&environmentLength
)))
Expand Down
Loading

0 comments on commit 0c07b10

Please sign in to comment.