Skip to content

Commit

Permalink
Update to latest SDK, Update status messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dmex committed Dec 13, 2024
1 parent e1943d2 commit 451eb95
Show file tree
Hide file tree
Showing 45 changed files with 330 additions and 226 deletions.
1 change: 1 addition & 0 deletions SystemInformer/SystemInformer.def
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ EXPORTS
PhQuerySymbolicLinkObject
PhQueryTokenVariableSize
PhQueryValueKey
PhQueueUserWorkItem
PhReadFile
PhResolveDevicePrefix
PhRevertImpersonationToken
Expand Down
27 changes: 18 additions & 9 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 @@ -5112,18 +5117,22 @@ 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 @@ -5807,7 +5816,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
2 changes: 1 addition & 1 deletion SystemInformer/findobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,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
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
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
6 changes: 3 additions & 3 deletions SystemInformer/memedit.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ INT_PTR CALLBACK PhpMemoryEditorDlgProc(

if (context->RegionSize > 1024 * 1024 * 1024) // 1 GB
{
PhShowError2(context->OwnerHandle, L"Unable to edit the memory region because it is too large.", L"%s", L"");
PhShowStatus(context->OwnerHandle, L"Unable to edit the memory region.", 0, MEM_E_INVALID_SIZE);
return TRUE;
}

context->Buffer = PhAllocatePage(context->RegionSize, NULL);

if (!context->Buffer)
{
PhShowError2(context->OwnerHandle, L"Unable to allocate memory for the buffer.", L"%s", L"");
PhShowStatus(context->OwnerHandle, L"Unable to edit the memory region.", 0, ERROR_OUTOFMEMORY);
return TRUE;
}

Expand Down Expand Up @@ -442,7 +442,7 @@ INT_PTR CALLBACK PhpMemoryEditorDlgProc(
{
if (offset >= context->RegionSize)
{
PhShowError2(hwndDlg, L"The offset is too large.", L"%s", L"");
PhShowStatus(hwndDlg, L"Unable to edit the memory region.", 0, MEM_E_INVALID_SIZE);
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion SystemInformer/memlists.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ VOID PhShowMemoryListCommand(
}
else if (!PhGetOwnTokenAttributes().Elevated)
{
PhShowError2(ParentWindow, L"Memory Command", L"System Informer must run elevated to empty all.");
PhShowStatus(ParentWindow, L"Unable to empty the memory list.", 0, ERROR_ELEVATION_REQUIRED);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion SystemInformer/memsrch.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ INT_PTR CALLBACK PhpMemoryStringDlgProc(

if (minimumLength < 4)
{
PhShowError2(hwndDlg, L"The minimum length must be at least 4.", L"%s", L"");
PhShowError2(hwndDlg, L"Unable to search for strings.", L"%s", L"The minimum length must be at least 4.");
break;
}

Expand Down
7 changes: 4 additions & 3 deletions SystemInformer/memsrcht.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ INT_PTR CALLBACK PhpMemoryStringsMinimumLengthDlgProc(

if (!minimumLength || minimumLength > MAXULONG32)
{
PhShowError2(hwndDlg, L"Invalid minimum length.", L"%s", L"");
PhShowError2(hwndDlg, L"Unable to update the length.", L"%s", L"The minimum length is invalid.");
break;
}

Expand Down Expand Up @@ -1579,12 +1579,13 @@ BOOLEAN PhpShowMemoryStringTreeDialog(
context->UseClone = UseClone;
context->PrevNodeList = PrevNodeList;

if (!NT_SUCCESS(PhCreateThread2(PhpShowMemoryStringDialogThreadStart, context)))
if (!NT_SUCCESS(status = PhCreateThread2(PhpShowMemoryStringDialogThreadStart, context)))
{
PhShowError2(ParentWindowHandle, L"Unable to create the window.", L"%s", L"");
PhDereferenceObject(context->ProcessItem);
NtClose(context->ProcessHandle);
PhFree(context);

PhShowStatus(ParentWindowHandle, L"Unable to create the window.", status, 0);
return FALSE;
}

Expand Down
2 changes: 1 addition & 1 deletion SystemInformer/procprv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3225,7 +3225,7 @@ VOID PhProcessProviderUpdate(
}
}

PhInvokeCallback(PhGetGeneralCallback(GeneralCallbackProcessProviderUpdatedEvent), UlongToPtr(runCount));
PhInvokeCallback(PhGetGeneralCallback(GeneralCallbackProcessProviderUpdatedEvent), PH_PROCESS_PROVIDER_UPDATED_EVENT_PTR(runCount));
runCount++;
}

Expand Down
7 changes: 6 additions & 1 deletion SystemInformer/procrec.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ INT_PTR CALLBACK PhpProcessRecordDlgProc(
}
else
{
PhShowError2(hwndDlg, L"The process has already terminated; only the process record is available.", L"%s", L"");
PhShowError2(
hwndDlg,
L"Unable to show the process properties.",
L"%s",
L"The process has already terminated; only the process record is available."
);
}
}
break;
Expand Down
10 changes: 2 additions & 8 deletions SystemInformer/prpgenv.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ VOID PhpRefreshEnvironmentList(
if (NT_SUCCESS(status))
{
HANDLE tokenHandle;
ULONG flags = 0;

PhCreateEnvironmentBlock(&systemDefaultEnvironment, NULL, FALSE);

Expand All @@ -244,14 +243,9 @@ VOID PhpRefreshEnvironmentList(
NtClose(tokenHandle);
}

#ifdef _WIN64
if (ProcessItem->IsWow64Process)
flags |= PH_GET_PROCESS_ENVIRONMENT_WOW64;
#endif

status = PhGetProcessEnvironment(
processHandle,
flags,
!!ProcessItem->IsWow64Process,
&environment,
&environmentLength
);
Expand Down Expand Up @@ -360,7 +354,6 @@ VOID PhpRefreshEnvironmentList(
}
}

PhApplyTreeNewFilters(&Context->TreeFilterSupport);
TreeNew_NodesStructured(Context->TreeNewHandle);

if (systemDefaultEnvironment)
Expand Down Expand Up @@ -1452,6 +1445,7 @@ INT_PTR CALLBACK PhpProcessEnvironmentDlgProc(
PhLoadSettingsEnvironmentList(context);

PhpRefreshEnvironmentList(context, processItem);
PhApplyTreeNewFilters(&context->TreeFilterSupport);

PhInitializeWindowTheme(hwndDlg, PhEnableThemeSupport);
}
Expand Down
1 change: 1 addition & 0 deletions SystemInformer/prpggen.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ INT_PTR CALLBACK PhpProcessGeneralDlgProc(
else
{
PhShowError2(hwndDlg, L"The process does not exist.", L"%s", L"");
PhShowStatus(hwndDlg, L"The process does not exist.", STATUS_NOT_FOUND, 0);
}
}
break;
Expand Down
2 changes: 1 addition & 1 deletion SystemInformer/prpgvdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ INT_PTR CALLBACK PhpProcessVdmHostProcessDlgProc(
{
if (!PhpTerminateVdmTask(processItem, entry->Task16))
{
PhShowError2(hwndDlg, L"Unable to terminate the task.", L"%s", L"");
PhShowStats(hwndDlg, L"Unable to terminate the task.", 0, PhGetLastError());
}
}
break;
Expand Down
8 changes: 4 additions & 4 deletions SystemInformer/prpgwmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,11 +1027,11 @@ VOID PhpShowWmiProviderStatus(
{
if (Message)
{
PhShowError2(hWnd, Message, L"%s", statusMessage->Buffer);
PhShowError2(hWnd, Message, L"%s", PhGetString(statusMessage));
}
else
{
PhShowError2(hWnd, statusMessage->Buffer, L"%s", L"");
PhShowError2(hWnd, L"Unable to perform the operation.", L"%s", PhGetString(statusMessage));
}

PhDereferenceObject(statusMessage);
Expand All @@ -1040,11 +1040,11 @@ VOID PhpShowWmiProviderStatus(
{
if (Message)
{
PhShowError2(hWnd, Message, L"%s", L"");
PhShowError2(hWnd, L"Unable to perform the operation.", L"%s", Message);
}
else
{
PhShowError2(hWnd, L"Unable to perform the operation.", L"%s", L"");
PhShowStatus(hWnd, L"Unable to perform the operation.", STATUS_UNSUCCESSFUL, 0);
}
}
}
Expand Down
Loading

0 comments on commit 451eb95

Please sign in to comment.