37 _Inout_ UINT32 *packageFullNameLength,
38 _Out_opt_ PWSTR packageFullName
43 _Reserved_ UINT32 reserved,
44 _Inout_ UINT32 *pathLength,
49 _In_ PCWSTR packageFullName,
51 _Inout_ UINT32 *bufferLength,
52 _Out_opt_ BYTE *buffer
55 GUID
XP_CONTEXT_GUID = { 0xbeb1b341, 0x6837, 0x4c83, { 0x83, 0x66, 0x2b, 0x45, 0x1e, 0x7c, 0xe6, 0x9b } };
56 GUID
VISTA_CONTEXT_GUID = { 0xe2011457, 0x1546, 0x43c5, { 0xa5, 0xfe, 0x00, 0x8d, 0xee, 0xe3, 0xd3, 0xf0 } };
57 GUID
WIN7_CONTEXT_GUID = { 0x35138b9a, 0x5d96, 0x4fbd, { 0x8e, 0x2d, 0xa2, 0x44, 0x02, 0x25, 0xf9, 0x3a } };
58 GUID
WIN8_CONTEXT_GUID = { 0x4a2f28e3, 0x53b9, 0x4441, { 0xba, 0x9c, 0xd6, 0x9d, 0x4a, 0x4a, 0x6e, 0x38 } };
59 GUID
WINBLUE_CONTEXT_GUID = { 0x1f676c76, 0x80e1, 0x4239, { 0x95, 0xbb, 0x83, 0xd0, 0xf6, 0xd0, 0xda, 0x78 } };
73 for (i = 0; i < Process->NumberOfThreads; i++)
76 Process->Threads[i].ThreadState !=
Waiting ||
77 Process->Threads[i].WaitReason != Suspended
82 return Process->NumberOfThreads != 0;
93 _In_ HANDLE ProcessHandle,
98 PROCESS_BASIC_INFORMATION basicInfo;
134 data = UlongToPtr(data32);
169 return STATUS_UNSUCCESSFUL;
205 return STATUS_SUCCESS;
209 _In_ HANDLE ProcessHandle
218 if (!getPackageFullName)
220 if (!getPackageFullName)
226 result = getPackageFullName(ProcessHandle, &nameLength, name->
Buffer);
228 if (result == ERROR_INSUFFICIENT_BUFFER)
233 result = getPackageFullName(ProcessHandle, &nameLength, name->
Buffer);
236 if (result == ERROR_SUCCESS)
249 _In_ PWSTR PackageFullName
255 PVOID packageIdBuffer;
256 ULONG packageIdBufferSize;
258 if (!packageIdFromFullName)
260 if (!packageIdFromFullName)
263 packageIdBufferSize = 100;
264 packageIdBuffer = PhAllocate(packageIdBufferSize);
266 result = packageIdFromFullName(PackageFullName, PACKAGE_INFORMATION_BASIC, &packageIdBufferSize, (PBYTE)packageIdBuffer);
268 if (result == ERROR_INSUFFICIENT_BUFFER)
271 packageIdBuffer = PhAllocate(packageIdBufferSize);
273 result = packageIdFromFullName(PackageFullName, PACKAGE_INFORMATION_BASIC, &packageIdBufferSize, (PBYTE)packageIdBuffer);
276 if (result == ERROR_SUCCESS)
278 return packageIdBuffer;
305 result = getPackagePath(PackageId, 0, &pathLength, path->
Buffer);
307 if (result == ERROR_INSUFFICIENT_BUFFER)
312 result = getPackagePath(PackageId, 0, &pathLength, path->
Buffer);
315 if (result == ERROR_SUCCESS)
335 _In_ HANDLE ProcessHandle,
341 PROCESS_BASIC_INFORMATION basicInfo;
347 BOOLEAN isWow64 =
FALSE;
359 return STATUS_SUCCESS;
374 name = newFileName->
sr;
440 *KnownProcessType = knownProcessType;
445 static BOOLEAN NTAPI PhpSvchostCommandLineCallback(
448 _In_opt_ PVOID Context
453 if (Option && Option->Id == 1)
478 KnownCommandLine->ServiceHost.GroupName = NULL;
485 PhpSvchostCommandLineCallback,
489 if (KnownCommandLine->ServiceHost.GroupName)
523 while (i < CommandLine->Length / 2 && CommandLine->Buffer[i] ==
' ')
554 KnownCommandLine->RunDllAsApp.FileName = dllName;
555 KnownCommandLine->RunDllAsApp.ProcedureName = procedureName;
565 ULONG_PTR indexOfProcessId;
570 HANDLE clsidKeyHandle;
571 HANDLE inprocServer32KeyHandle;
587 while (i < (ULONG)CommandLine->Length / 2 && CommandLine->Buffer[i] ==
' ')
602 if (indexOfProcessId == -1)
607 indexOfProcessId + 11,
608 (ULONG)argPart->
Length / 2 - indexOfProcessId - 11
618 KnownCommandLine->ComSurrogate.Guid = guid;
619 KnownCommandLine->ComSurrogate.Name = NULL;
620 KnownCommandLine->ComSurrogate.FileName = NULL;
632 KnownCommandLine->ComSurrogate.Name =
636 &inprocServer32KeyHandle,
643 KnownCommandLine->ComSurrogate.FileName =
647 &KnownCommandLine->ComSurrogate.FileName->sr
650 KnownCommandLine->ComSurrogate.FileName = fileName;
653 NtClose(inprocServer32KeyHandle);
656 NtClose(clsidKeyHandle);
670 _In_ WNDENUMPROC Callback,
674 HWND childWindow = NULL;
677 while (i < Limit && (childWindow = FindWindowEx(hWnd, childWindow, NULL, NULL)))
679 if (!Callback(childWindow, lParam))
686 typedef struct _GET_PROCESS_MAIN_WINDOW_CONTEXT
689 HWND ImmersiveWindow;
702 WINDOWINFO windowInfo;
704 if (!IsWindowVisible(hwnd))
707 GetWindowThreadProcessId(hwnd, &processId);
709 if (UlongToHandle(processId) == context->ProcessId &&
710 !((parentWindow = GetParent(hwnd)) && IsWindowVisible(parentWindow)) &&
713 if (!context->ImmersiveWindow && context->IsImmersive &&
714 GetProp(hwnd, L
"Windows.ImmersiveShell.IdentifyAsMainCoreWindow"))
716 context->ImmersiveWindow = hwnd;
719 windowInfo.cbSize =
sizeof(WINDOWINFO);
721 if (!context->Window && GetWindowInfo(hwnd, &windowInfo) && (windowInfo.dwStyle & WS_DLGFRAME))
723 context->Window = hwnd;
726 if (!context->IsImmersive)
736 _In_opt_ HANDLE ProcessHandle
740 HANDLE processHandle = NULL;
746 processHandle = ProcessHandle;
755 if (!ProcessHandle && processHandle)
756 NtClose(processHandle);
758 return context.ImmersiveWindow ? context.ImmersiveWindow : context.Window;
763 _In_ SC_HANDLE ServiceHandle
767 LPQUERY_SERVICE_CONFIG config;
779 if (config->dwServiceType & SERVICE_WIN32)
813 length = String->Length / 2;
818 for (i = 0; i < length; i++)
820 if (String->Buffer[i] ==
'\\' || String->Buffer[i] == Delimiter)
822 temp[1] = String->Buffer[i];
843 length = String->Length / 2;
846 for (i = 0; i < length; i++)
848 if (String->Buffer[i] ==
'\\')
874 if (node->child && node->child->type ==
MXML_OPAQUE && node->child->value.opaque)
896 _In_ BOOLEAN UseShellExecute,
897 _In_opt_ PWSTR ErrorMessage
918 executeString = newString;
954 PhShowStatus(hWnd, L
"Unable to execute the command", status, 0);
975 if (searchPath->
Length != 0)
997 _Inout_ LPNMLVGETINFOTIP GetInfoTip,
1002 ULONG bufferRemaining;
1005 if (GetInfoTip->dwFlags == 0)
1009 if (GetInfoTip->cchTextMax - copyIndex < 2)
1012 bufferRemaining = GetInfoTip->cchTextMax - copyIndex - 1;
1013 GetInfoTip->pszText[copyIndex - 1] =
'\n';
1018 bufferRemaining = GetInfoTip->cchTextMax;
1021 copyLength = min((ULONG)Tip->Length / 2, bufferRemaining - 1);
1023 &GetInfoTip->pszText[copyIndex],
1027 GetInfoTip->pszText[copyIndex + copyLength] = 0;
1031 _In_ HWND ListViewHandle
1043 _In_ HWND ListViewHandle
1051 _In_ HWND ListViewHandle,
1052 _In_ ULONG Behaviors
1055 if (((LPNMHDR)lParam)->hwndFrom == ListViewHandle && ((LPNMHDR)lParam)->code == LVN_KEYDOWN)
1057 LPNMLVKEYDOWN keyDown = (LPNMLVKEYDOWN)lParam;
1059 switch (keyDown->wVKey)
1064 if (GetKeyState(VK_CONTROL) < 0)
1071 if (GetKeyState(VK_CONTROL) < 0)
1080 _In_ HWND ListViewHandle,
1091 if ((selectedIndex = ListView_GetNextItem(ListViewHandle, -1, LVNI_SELECTED)) != -1)
1093 if (ListView_GetItemRect(ListViewHandle, selectedIndex, &bounds, LVIR_BOUNDS))
1098 GetClientRect(ListViewHandle, &clientRect);
1100 if (Point->x < 0 || Point->y < 0 || Point->x >= clientRect.right || Point->y >= clientRect.bottom)
1107 ClientToScreen(ListViewHandle, Point);
1115 ClientToScreen(ListViewHandle, Point);
1127 if (GetObject(Font,
sizeof(LOGFONT), &logFont))
1129 logFont.lfWeight = NewWeight;
1130 return CreateFontIndirect(&logFont);
1139 _In_ HWND WindowHandle,
1140 _In_ ULONG OpacityPercent
1143 if (OpacityPercent == 0)
1147 RedrawWindow(WindowHandle, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
1154 OpacityPercent = min(OpacityPercent, 90);
1157 SetLayeredWindowAttributes(
1160 (BYTE)(255 * (100 - OpacityPercent) / 100),
1166 _In_opt_ PWSTR PositionSettingName,
1167 _In_opt_ PWSTR SizeSettingName,
1168 _In_ HWND WindowHandle
1173 if (PositionSettingName && SizeSettingName)
1187 SendMessage(WindowHandle, WM_SIZING, WMSZ_BOTTOMRIGHT, (LPARAM)&rectForAdjust);
1190 MoveWindow(WindowHandle, windowRectangle.
Left, windowRectangle.
Top,
1199 flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOREDRAW | SWP_NOSIZE | SWP_NOZORDER;
1201 if (PositionSettingName)
1204 flags &= ~SWP_NOMOVE;
1212 if (SizeSettingName)
1215 flags &= ~SWP_NOSIZE;
1223 SetWindowPos(WindowHandle, NULL, position.
X, position.
Y, size.
X, size.
Y, flags);
1228 _In_opt_ PWSTR PositionSettingName,
1229 _In_opt_ PWSTR SizeSettingName,
1230 _In_ HWND WindowHandle
1233 WINDOWPLACEMENT placement = {
sizeof(placement) };
1235 MONITORINFO monitorInfo = {
sizeof(MONITORINFO) };
1237 GetWindowPlacement(WindowHandle, &placement);
1241 if (GetMonitorInfo(MonitorFromRect(&placement.rcNormalPosition, MONITOR_DEFAULTTOPRIMARY), &monitorInfo))
1243 windowRectangle.
Left += monitorInfo.rcWork.left - monitorInfo.rcMonitor.left;
1244 windowRectangle.
Top += monitorInfo.rcWork.top - monitorInfo.rcMonitor.top;
1247 if (PositionSettingName)
1249 if (SizeSettingName)
1255 _In_ HWND ListViewHandle
1267 _In_ HWND ListViewHandle
1291 _Out_opt_ PULONG MajorVersion,
1292 _Out_opt_ PULONG MinorVersion,
1293 _Reserved_ PULONG Reserved,
1294 _Out_opt_ PULONG RevisionNumber
1311 SYSTEMTIME systemTime;
1346 _In_opt_ PWSTR Parameters,
1347 _In_ ULONG ShowWindowType,
1349 _In_ ULONG AppFlags,
1350 _In_opt_ ULONG Timeout,
1351 _Out_opt_ PHANDLE ProcessHandle
1368 _In_opt_ PWSTR FileName,
1369 _In_opt_ PWSTR Parameters,
1370 _In_ ULONG ShowWindowType,
1372 _In_ ULONG AppFlags,
1373 _In_opt_ ULONG Timeout,
1374 _Out_opt_ PHANDLE ProcessHandle
1457 parameters = Parameters;
1470 if (AppFlags & PH_SHELL_APP_PROPAGATE_PARAMETERS)
1481 BOOL (NTAPI *debugSetProcessKillOnExit)(
BOOL);
1482 BOOL (NTAPI *debugActiveProcessStop)(DWORD);
1483 BOOLEAN originalValue;
1484 STARTUPINFO startupInfo;
1485 PROCESS_INFORMATION processInfo;
1487 if (!(debugSetProcessKillOnExit =
PhGetModuleProcAddress(L
"kernel32.dll",
"DebugSetProcessKillOnExit")) ||
1494 originalValue = NtCurrentPeb()->ReadImageFileExecOptions;
1495 NtCurrentPeb()->ReadImageFileExecOptions =
FALSE;
1497 memset(&startupInfo, 0,
sizeof(STARTUPINFO));
1498 startupInfo.cb =
sizeof(STARTUPINFO);
1499 memset(&processInfo, 0,
sizeof(PROCESS_INFORMATION));
1503 if (CreateProcess(FileName, NULL, NULL, NULL,
FALSE, DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS, NULL, NULL, &startupInfo, &processInfo))
1506 debugSetProcessKillOnExit(
FALSE);
1507 debugActiveProcessStop(processInfo.dwProcessId);
1511 if (processInfo.hProcess)
1512 NtClose(processInfo.hProcess);
1513 if (processInfo.hThread)
1514 NtClose(processInfo.hThread);
1516 NtCurrentPeb()->ReadImageFileExecOptions = originalValue;
1538 ULONG minimumNumberOfColumns;
1541 Data->Selection = NULL;
1542 Data->ProcessedId = 0;
1560 if (sortColumn != Data->DefaultSortColumn || sortOrder != Data->DefaultSortOrder)
1567 if (!(Flags & PH_TN_COLUMN_MENU_NO_VISIBILITY))
1571 if (resetSortMenuItem)
1578 minimumNumberOfColumns = 2;
1580 minimumNumberOfColumns = 1;
1582 if (!Data->MouseEvent || !Data->MouseEvent->Column ||
1583 Data->MouseEvent->Column->Fixed ||
1592 if (resetSortMenuItem)
1596 if (!Data->MouseEvent || !Data->MouseEvent->Column)
1603 _Inout_ HWND TreeNewHandle,
1604 _In_ ULONG DefaultSortColumn,
1645 DefaultSortColumn = id;
1656 DefaultSortColumn = 0;
1671 if (!Data->Selection)
1674 switch (Data->Selection->Id)
1678 TreeNew_SetSort(Data->TreeNewHandle, Data->DefaultSortColumn, Data->DefaultSortOrder);
1683 if (Data->MouseEvent && Data->MouseEvent->Column)
1708 if (Data->MouseEvent && Data->MouseEvent->Column && !Data->MouseEvent->Column->Fixed)
1710 column.
Id = Data->MouseEvent->Column->Id;
1714 InvalidateRect(Data->TreeNewHandle, NULL,
FALSE);
1728 Data->ProcessedId = Data->Selection->Id;
1746 _In_ HWND TreeNewHandle,
1750 Support->FilterList = NULL;
1751 Support->TreeNewHandle = TreeNewHandle;
1752 Support->NodeList = NodeList;
1765 _In_opt_ PVOID Context
1774 if (!Support->FilterList)
1789 if (!Support->FilterList)
1792 index = PhFindItemList(Support->FilterList, Entry);
1811 if (Support->FilterList)
1813 for (i = 0; i < Support->FilterList->Count; i++)
1817 entry = Support->FilterList->Items[i];
1836 for (i = 0; i < Support->NodeList->Count; i++)
1840 node = Support->NodeList->Items[i];
1858 context = Item->Context;
1865 _In_ ULONG InsertAfterId,
1866 _In_ HWND TreeNewHandle,
1871 ULONG indexInParent;
1881 if (!
PhFindEMenuItemEx(Menu, 0, NULL, InsertAfterId, &parentItem, &indexInParent))
1888 context->
Id = Column->Id;
1898 if (Column->CustomDraw)
1913 ULONG selectedCount;
1923 context = SelectedItem->Context;
1929 for (i = 0; i < count; i++)
1937 getCellText.
Flags = 0;
1938 getCellText.
Node = node;
1939 getCellText.
Id = context->
Id;
1948 if (stringBuilder.
String->
Length != 0 && selectedCount == 1)
1958 _In_ HWND RegeditWindow,
1960 _In_ BOOLEAN UsePhSvc
1964 HMENU favoritesMenu;
1969 if (!(menu = GetMenu(RegeditWindow)))
1976 SendMessage(RegeditWindow, WM_MENUSELECT, MAKEWPARAM(3, MF_POPUP), (LPARAM)menu);
1978 if (!(favoritesMenu = GetSubMenu(menu, 3)))
1983 count = GetMenuItemCount(favoritesMenu);
1990 for (i = 3; i < count; i++)
1992 MENUITEMINFO info = {
sizeof(MENUITEMINFO) };
1995 info.fMask = MIIM_ID | MIIM_STRING;
1996 info.dwTypeData = buffer;
1997 info.cch =
sizeof(buffer) /
sizeof(WCHAR);
1998 GetMenuItemInfo(favoritesMenu, i,
TRUE, &info);
2000 if (info.cch == FavoriteName->Length / 2)
2005 text.
Length = info.cch * 2;
2022 SendMessage(RegeditWindow, WM_COMMAND, MAKEWPARAM(
id, 0), 0);
2028 PostMessage(RegeditWindow, WM_MENUSELECT, MAKEWPARAM(0, 0xffff), 0);
2031 if (IsIconic(RegeditWindow))
2033 ShowWindow(RegeditWindow, SW_RESTORE);
2034 SetForegroundWindow(RegeditWindow);
2038 SetForegroundWindow(RegeditWindow);
2058 BOOLEAN result =
FALSE;
2060 HANDLE favoritesKeyHandle;
2061 WCHAR favoriteName[32];
2066 regeditWindow = FindWindow(L
"RegEdit_RegEdit", NULL);
2083 &favoritesKeyHandle,
2093 memcpy(favoriteName, L
"A_ProcessHacker", 15 *
sizeof(WCHAR));
2106 NtClose(favoritesKeyHandle);