Skip to content

Commit

Permalink
Remove legacy Vista support
Browse files Browse the repository at this point in the history
  • Loading branch information
dmex committed Jun 13, 2017
1 parent 4e89d8f commit 8cdd6d8
Show file tree
Hide file tree
Showing 21 changed files with 124 additions and 400 deletions.
1 change: 0 additions & 1 deletion ProcessHacker/ProcessHacker.rc
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ BEGIN
BEGIN
MENUITEM "&Go to process\aEnter", ID_NETWORK_GOTOPROCESS
MENUITEM "Go to service", ID_NETWORK_GOTOSERVICE
MENUITEM "View &stack", ID_NETWORK_VIEWSTACK
MENUITEM "C&lose", ID_NETWORK_CLOSE
MENUITEM SEPARATOR
MENUITEM "&Copy\aCtrl+C", ID_NETWORK_COPY
Expand Down
20 changes: 1 addition & 19 deletions ProcessHacker/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,32 +726,14 @@ static BOOLEAN PhpIsDangerousProcess(
)
{
NTSTATUS status;
HANDLE processHandle;
PPH_STRING fileName;
PPH_STRING systemDirectory;
ULONG i;

if (ProcessId == SYSTEM_PROCESS_ID)
return TRUE;

if (WINDOWS_HAS_IMAGE_FILE_NAME_BY_PROCESS_ID)
{
status = PhGetProcessImageFileNameByProcessId(ProcessId, &fileName);
}
else
{
if (!NT_SUCCESS(status = PhOpenProcess(
&processHandle,
ProcessQueryAccess,
ProcessId
)))
return FALSE;

status = PhGetProcessImageFileName(processHandle, &fileName);
NtClose(processHandle);
}

if (!NT_SUCCESS(status))
if (!NT_SUCCESS(status = PhGetProcessImageFileNameByProcessId(ProcessId, &fileName)))
return FALSE;

PhMoveReference(&fileName, PhGetFileName(fileName));
Expand Down
8 changes: 2 additions & 6 deletions ProcessHacker/chproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ static VOID PhpRefreshProcessList(
HANDLE tokenHandle;
PTOKEN_USER user;

if (!WINDOWS_HAS_IMAGE_FILE_NAME_BY_PROCESS_ID && process->UniqueProcessId != SYSTEM_PROCESS_ID)
PhGetProcessImageFileName(processHandle, &fileName);

if (NT_SUCCESS(PhOpenProcessToken(processHandle, TOKEN_QUERY, &tokenHandle)))
{
if (NT_SUCCESS(PhGetTokenUser(tokenHandle, &user)))
Expand All @@ -140,11 +137,10 @@ static VOID PhpRefreshProcessList(
if (process->UniqueProcessId == SYSTEM_IDLE_PROCESS_ID && !userName && PhLocalSystemName)
PhSetReference(&userName, PhLocalSystemName);

if (WINDOWS_HAS_IMAGE_FILE_NAME_BY_PROCESS_ID && process->UniqueProcessId != SYSTEM_PROCESS_ID)
PhGetProcessImageFileNameByProcessId(process->UniqueProcessId, &fileName);

if (process->UniqueProcessId == SYSTEM_PROCESS_ID)
fileName = PhGetKernelFileName();
else
PhGetProcessImageFileNameByProcessId(process->UniqueProcessId, &fileName);

if (fileName)
PhMoveReference(&fileName, PhGetFileName(fileName));
Expand Down
105 changes: 22 additions & 83 deletions ProcessHacker/hndlprv.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,105 +315,44 @@ NTSTATUS PhEnumHandlesGeneric(
// Enumerate handles using KProcessHacker. Unlike with NtQuerySystemInformation,
// this only enumerates handles for a single process and saves a lot of processing.

if (NT_SUCCESS(status = KphEnumerateProcessHandles2(ProcessHandle, &handles)))
{
convertedHandles = PhAllocate(
FIELD_OFFSET(SYSTEM_HANDLE_INFORMATION_EX, Handles) +
sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX) * handles->HandleCount
);
if (!NT_SUCCESS(status = KphEnumerateProcessHandles2(ProcessHandle, &handles)))
return status;

convertedHandles->NumberOfHandles = handles->HandleCount;
convertedHandles = PhAllocate(
FIELD_OFFSET(SYSTEM_HANDLE_INFORMATION_EX, Handles) +
sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX) * handles->HandleCount
);

for (i = 0; i < handles->HandleCount; i++)
{
convertedHandles->Handles[i].Object = handles->Handles[i].Object;
convertedHandles->Handles[i].UniqueProcessId = (ULONG_PTR)ProcessId;
convertedHandles->Handles[i].HandleValue = (ULONG_PTR)handles->Handles[i].Handle;
convertedHandles->Handles[i].GrantedAccess = (ULONG)handles->Handles[i].GrantedAccess;
convertedHandles->Handles[i].CreatorBackTraceIndex = 0;
convertedHandles->Handles[i].ObjectTypeIndex = handles->Handles[i].ObjectTypeIndex;
convertedHandles->Handles[i].HandleAttributes = handles->Handles[i].HandleAttributes;
}
convertedHandles->NumberOfHandles = handles->HandleCount;

PhFree(handles);
for (i = 0; i < handles->HandleCount; i++)
{
convertedHandles->Handles[i].Object = handles->Handles[i].Object;
convertedHandles->Handles[i].UniqueProcessId = (ULONG_PTR)ProcessId;
convertedHandles->Handles[i].HandleValue = (ULONG_PTR)handles->Handles[i].Handle;
convertedHandles->Handles[i].GrantedAccess = (ULONG)handles->Handles[i].GrantedAccess;
convertedHandles->Handles[i].CreatorBackTraceIndex = 0;
convertedHandles->Handles[i].ObjectTypeIndex = handles->Handles[i].ObjectTypeIndex;
convertedHandles->Handles[i].HandleAttributes = handles->Handles[i].HandleAttributes;
}

*Handles = convertedHandles;
*FilterNeeded = FALSE;
PhFree(handles);

return status;
}
*Handles = convertedHandles;
*FilterNeeded = FALSE;
}

if (WindowsVersion >= WINDOWS_XP)
else
{
PSYSTEM_HANDLE_INFORMATION_EX handles;

// Enumerate handles using the new method; no conversion
// necessary.

if (!NT_SUCCESS(status = PhEnumHandlesEx(&handles)))
return status;

*Handles = handles;
*FilterNeeded = TRUE;
}
else
{
PSYSTEM_HANDLE_INFORMATION handles;
PSYSTEM_HANDLE_INFORMATION_EX convertedHandles;
ULONG count;
ULONG allocatedCount;
ULONG i;

// Enumerate handles using the old info class and convert
// the relevant entries to the new format.

if (!NT_SUCCESS(status = PhEnumHandles(&handles)))
return status;

count = 0;
allocatedCount = 100;

convertedHandles = PhAllocate(
FIELD_OFFSET(SYSTEM_HANDLE_INFORMATION_EX, Handles) +
sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX) * allocatedCount
);

for (i = 0; i < handles->NumberOfHandles; i++)
{
if ((HANDLE)handles->Handles[i].UniqueProcessId != ProcessId)
continue;

if (count == allocatedCount)
{
allocatedCount *= 2;
convertedHandles = PhReAllocate(
convertedHandles,
FIELD_OFFSET(SYSTEM_HANDLE_INFORMATION_EX, Handles) +
sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX) * allocatedCount
);
}

convertedHandles->Handles[count].Object = handles->Handles[i].Object;
convertedHandles->Handles[count].UniqueProcessId = (ULONG_PTR)handles->Handles[i].UniqueProcessId;
convertedHandles->Handles[count].HandleValue = (ULONG_PTR)handles->Handles[i].HandleValue;
convertedHandles->Handles[count].GrantedAccess = handles->Handles[i].GrantedAccess;
convertedHandles->Handles[count].CreatorBackTraceIndex = handles->Handles[i].CreatorBackTraceIndex;
convertedHandles->Handles[count].ObjectTypeIndex = handles->Handles[i].ObjectTypeIndex;
convertedHandles->Handles[count].HandleAttributes = (ULONG)handles->Handles[i].HandleAttributes;

count++;
}

convertedHandles->NumberOfHandles = count;

PhFree(handles);

*Handles = convertedHandles;
*FilterNeeded = FALSE;
}

return STATUS_SUCCESS;
return status;
}

NTSTATUS PhpCreateHandleItemFunction(
Expand Down
3 changes: 0 additions & 3 deletions ProcessHacker/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,6 @@ VOID PhInitializeKph(
PUCHAR signature;
ULONG signatureSize;

if (WindowsVersion < WINDOWS_7)
return;

kprocesshackerFileName = PhConcatStringRef2(&PhApplicationDirectory->sr, &kprocesshacker);
processhackerSigFileName = PhConcatStringRef2(&PhApplicationDirectory->sr, &processhackerSig);

Expand Down
12 changes: 0 additions & 12 deletions ProcessHacker/mainwnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1520,18 +1520,6 @@ VOID PhMwpOnCommand(
}
}
break;
case ID_NETWORK_VIEWSTACK:
{
PPH_NETWORK_ITEM networkItem = PhGetSelectedNetworkItem();

if (networkItem)
{
PhReferenceObject(networkItem);
PhShowNetworkStackDialog(PhMainWndHandle, networkItem);
PhDereferenceObject(networkItem);
}
}
break;
case ID_NETWORK_CLOSE:
{
PPH_NETWORK_ITEM *networkItems;
Expand Down
7 changes: 1 addition & 6 deletions ProcessHacker/memprv.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,12 +780,7 @@ NTSTATUS PhQueryMemoryItemList(
PhpUpdateMemoryRegionTypes(List, processHandle);

if (Flags & PH_QUERY_MEMORY_WS_COUNTERS)
{
if (WindowsVersion >= WINDOWS_SERVER_2003)
PhpUpdateMemoryWsCounters(List, processHandle);
else
PhpUpdateMemoryWsCountersOld(List, processHandle);
}
PhpUpdateMemoryWsCounters(List, processHandle);

NtClose(processHandle);

Expand Down
6 changes: 0 additions & 6 deletions ProcessHacker/mwpgnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,6 @@ VOID PhMwpInitializeNetworkMenu(
PhEnableEMenuItem(Menu, ID_NETWORK_COPY, TRUE);
}

if (WindowsVersion >= WINDOWS_VISTA)
{
if (item = PhFindEMenuItem(Menu, 0, NULL, ID_NETWORK_VIEWSTACK))
PhDestroyEMenuItem(item);
}

// Go to Service
if (NumberOfNetworkItems != 1 || !NetworkItems[0]->OwnerName)
{
Expand Down
2 changes: 1 addition & 1 deletion ProcessHacker/mwpgproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ BOOLEAN PhMwpProcessesPageCallback(

if (menuItem = PhFindEMenuItem(menu, 0, NULL, ID_VIEW_SHOWCPUBELOW001))
{
if (WindowsVersion >= WINDOWS_7 && PhEnableCycleCpuUsage)
if (PhEnableCycleCpuUsage)
{
if (PhCsShowCpuBelow001)
menuItem->Flags |= PH_EMENU_CHECKED;
Expand Down
13 changes: 0 additions & 13 deletions ProcessHacker/netprv.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,19 +814,6 @@ BOOLEAN PhGetNetworkConnections(
tableSize = 0;
GetExtendedTcpTable(NULL, &tableSize, FALSE, AF_INET6, TCP_TABLE_OWNER_MODULE_ALL, 0);

// Note: On Windows XP, GetExtendedTcpTable had a bug where it calculated the required buffer size
// for IPv6 TCP_TABLE_OWNER_MODULE_ALL requests incorrectly, causing it to return the wrong size
// and overrun the provided buffer instead of returning an error. The size should be:
// = FIELD_OFFSET(MIB_TCP6TABLE_OWNER_MODULE, table) + sizeof(MIB_TCP6ROW_OWNER_MODULE) * (number of entries)
// However, the function calculated it as:
// = FIELD_OFFSET(MIB_TCP6TABLE_OWNER_MODULE, table) + sizeof(MIB_TCP6ROW_OWNER_PID) * (number of entries)
// A workaround is implemented below.
if (WindowsVersion <= WINDOWS_XP && tableSize >= (ULONG)FIELD_OFFSET(MIB_TCP6TABLE_OWNER_MODULE, table)) // make sure we don't wrap around
{
tableSize = FIELD_OFFSET(MIB_TCP6TABLE_OWNER_MODULE, table) +
(tableSize - FIELD_OFFSET(MIB_TCP6TABLE_OWNER_MODULE, table)) / sizeof(MIB_TCP6ROW_OWNER_PID) * sizeof(MIB_TCP6ROW_OWNER_MODULE);
}

table = PhAllocate(tableSize);

if (GetExtendedTcpTable(table, &tableSize, FALSE, AF_INET6, TCP_TABLE_OWNER_MODULE_ALL, 0) == 0)
Expand Down
13 changes: 2 additions & 11 deletions ProcessHacker/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,7 @@ VOID PhpAdvancedPageLoad(
SetDlgItemCheckForSetting(hwndDlg, IDC_ENABLENETWORKRESOLVE, L"EnableNetworkResolve");
SetDlgItemCheckForSetting(hwndDlg, IDC_PROPAGATECPUUSAGE, L"PropagateCpuUsage");
SetDlgItemCheckForSetting(hwndDlg, IDC_ENABLEINSTANTTOOLTIPS, L"EnableInstantTooltips");

if (WindowsVersion >= WINDOWS_7)
SetDlgItemCheckForSetting(hwndDlg, IDC_ENABLECYCLECPUUSAGE, L"EnableCycleCpuUsage");
SetDlgItemCheckForSetting(hwndDlg, IDC_ENABLECYCLECPUUSAGE, L"EnableCycleCpuUsage");

SetDlgItemInt(hwndDlg, IDC_SAMPLECOUNT, PhGetIntegerSetting(L"SampleCount"), FALSE);
SetDlgItemCheckForSetting(hwndDlg, IDC_SAMPLECOUNTAUTOMATIC, L"SampleCountAutomatic");
Expand Down Expand Up @@ -762,9 +760,7 @@ VOID PhpAdvancedPageSave(
SetSettingForDlgItemCheckRestartRequired(hwndDlg, IDC_ENABLENETWORKRESOLVE, L"EnableNetworkResolve");
SetSettingForDlgItemCheck(hwndDlg, IDC_PROPAGATECPUUSAGE, L"PropagateCpuUsage");
SetSettingForDlgItemCheck(hwndDlg, IDC_ENABLEINSTANTTOOLTIPS, L"EnableInstantTooltips");

if (WindowsVersion >= WINDOWS_7)
SetSettingForDlgItemCheckRestartRequired(hwndDlg, IDC_ENABLECYCLECPUUSAGE, L"EnableCycleCpuUsage");
SetSettingForDlgItemCheckRestartRequired(hwndDlg, IDC_ENABLECYCLECPUUSAGE, L"EnableCycleCpuUsage");

sampleCount = GetDlgItemInt(hwndDlg, IDC_SAMPLECOUNT, NULL, FALSE);
SetSettingForDlgItemCheckRestartRequired(hwndDlg, IDC_SAMPLECOUNTAUTOMATIC, L"SampleCountAutomatic");
Expand Down Expand Up @@ -874,11 +870,6 @@ INT_PTR CALLBACK PhpOptionsAdvancedDlgProc(
EnableWindow(GetDlgItem(hwndDlg, IDC_SAMPLECOUNT), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_SAMPLECOUNTAUTOMATIC), FALSE);
}
else
{
if (WindowsVersion < WINDOWS_7)
EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLECYCLECPUUSAGE), FALSE); // cycle-based CPU usage not available before Windows 7
}
}
break;
case WM_DESTROY:
Expand Down
Loading

0 comments on commit 8cdd6d8

Please sign in to comment.