From 358bb7d046cd0054fbc8374dbf955e1aa7ddc04a Mon Sep 17 00:00:00 2001 From: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> Date: Thu, 29 Jan 2026 16:12:23 -0500 Subject: [PATCH 1/5] feat: Add Target and Process fields, just like witr. This makes it so you can see the name and pid of the process name you are looking up. It can be a bit redundant, but it's in witr, so hey --- main.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index e3b2dc9..e93dc5c 100644 --- a/main.cpp +++ b/main.cpp @@ -377,8 +377,33 @@ std::optional GetUserNameFromProcess(DWORD id) // Permalink: https://stackoverflow.com/a/73242956 // Thanks! +std::string GetProcessNameFromPid(DWORD pid) { + HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + if (snapshot == INVALID_HANDLE_VALUE) { + return "" // vroken + } + + PROCESSENTRY32 pe{}; + pe.dwSize = sizeof(PROCESSENTRY32); + + if (Process32First(snapshot, &pe)) { + do { + if (pe.th32ProcessID == pid) { + CloseHandle(snapshot); + return WideToString(pe.szExeFile); + } + } while (Process32Next(snapshot, &pe)); + } + + CloseHandle(snapshot); + return std::to_string(pid); +} void PrintAncestry(DWORD pid) { + // now we're geting the name +// we're making it slower by adding a bunch of snapshots +// but again, we'll optimize and refactor later, i need this to work first + /* ~~~~~~~~~~~~~TODO: This tree is flipped. The output should be like this, as shown in the original witr: @@ -558,6 +583,11 @@ CloseHandle(hSnapshot); // we're only closing the handle until we finish messing void PIDinspect(DWORD pid) { // ooh guys look i'm in the void + std::string procName = GetProcessNameFromPid(pid) + std::cout << "Target: " << procName << std::endl; + std::cout << "Process: " << procName << "pid " << std::to_string(pid) << std::endl; + + HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); // The above little handle opener is currently a somwehat "agressive" flag, since it // Requests read access directly to the process' actual memory. This can get us rejected if called @@ -575,6 +605,7 @@ void PIDinspect(DWORD pid) { // ooh guys look i'm in the void bool queryError = false; if (!hProcess) { errorCode = GetLastError(); + if (IsVirtualTerminalModeEnabled()) { @@ -837,7 +868,7 @@ int main(int argc, char* argv[]) { std::string procName = arg; int pid = findMyProc(procName.c_str()); if (pid != 0) { - std::cout << "Process Name specified: " << procName << " (PID " << pid << ")" << std::endl; + PIDinspect(static_cast(pid)); } else { if (IsVirtualTerminalModeEnabled()) { From 9616ba59cd04cfa12000f2fe37298916a8f9f950 Mon Sep 17 00:00:00 2001 From: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> Date: Thu, 29 Jan 2026 16:24:35 -0500 Subject: [PATCH 2/5] feat: Add color to Target and Process like witr. Also add error validation this fixes syntax error btw lol --- main.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index e93dc5c..3c982b3 100644 --- a/main.cpp +++ b/main.cpp @@ -380,7 +380,7 @@ std::optional GetUserNameFromProcess(DWORD id) std::string GetProcessNameFromPid(DWORD pid) { HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (snapshot == INVALID_HANDLE_VALUE) { - return "" // vroken + return ""; // vroken } PROCESSENTRY32 pe{}; @@ -583,9 +583,23 @@ CloseHandle(hSnapshot); // we're only closing the handle until we finish messing void PIDinspect(DWORD pid) { // ooh guys look i'm in the void - std::string procName = GetProcessNameFromPid(pid) - std::cout << "Target: " << procName << std::endl; - std::cout << "Process: " << procName << "pid " << std::to_string(pid) << std::endl; + std::string procName = GetProcessNameFromPid(pid); + if (IsVirtualTerminalModeEnabled()) { + if (procName == ""){ + std::cout << "\033[34mTarget:\033[0m N/A\n\033[34mProcess:\033[0m N/A\n"; + } else { + std::cout << "\033[34mTarget:\033[0m " << procName << "\033[0m" << std::endl; + std::cout << "\033[34mProcess:\033[0m " << procName << "\033[90m(pid " << std::to_string(pid) << ")\033[0m" << std::endl; + } + } else { + if (procName == ""){ + std::cout << "Target: N/A\nProcess: N/A\n"; + } else { + std::cout << "Target: " << procName << std::endl; + std::cout << "Process: " << procName << "(pid " << std::to_string(pid) << << ")" << std::endl; + } + } + HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); From 657ae0e6d4a1248c9c982b3302b689d091ad7f2e Mon Sep 17 00:00:00 2001 From: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> Date: Thu, 29 Jan 2026 16:26:38 -0500 Subject: [PATCH 3/5] fix: Fix syntax error in Line 599 regarding misplaced << in cout fluffing up my commit messages is so fun so that the release looks good --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 3c982b3..a754c82 100644 --- a/main.cpp +++ b/main.cpp @@ -596,7 +596,7 @@ void PIDinspect(DWORD pid) { // ooh guys look i'm in the void std::cout << "Target: N/A\nProcess: N/A\n"; } else { std::cout << "Target: " << procName << std::endl; - std::cout << "Process: " << procName << "(pid " << std::to_string(pid) << << ")" << std::endl; + std::cout << "Process: " << procName << "(pid " << std::to_string(pid) << ")" << std::endl; } } From ae895161f59dcdc9ad396a1384417b7fe96363cf Mon Sep 17 00:00:00 2001 From: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> Date: Thu, 29 Jan 2026 16:30:02 -0500 Subject: [PATCH 4/5] style: Add a space in the Process entry to make it look better and remove redundant output --- main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index a754c82..009b14d 100644 --- a/main.cpp +++ b/main.cpp @@ -589,14 +589,14 @@ void PIDinspect(DWORD pid) { // ooh guys look i'm in the void std::cout << "\033[34mTarget:\033[0m N/A\n\033[34mProcess:\033[0m N/A\n"; } else { std::cout << "\033[34mTarget:\033[0m " << procName << "\033[0m" << std::endl; - std::cout << "\033[34mProcess:\033[0m " << procName << "\033[90m(pid " << std::to_string(pid) << ")\033[0m" << std::endl; + std::cout << "\033[34mProcess:\033[0m " << procName << "\033[90m (pid " << std::to_string(pid) << ")\033[0m" << std::endl; } } else { if (procName == ""){ std::cout << "Target: N/A\nProcess: N/A\n"; } else { std::cout << "Target: " << procName << std::endl; - std::cout << "Process: " << procName << "(pid " << std::to_string(pid) << ")" << std::endl; + std::cout << "Process: " << procName << " (pid " << std::to_string(pid) << ")" << std::endl; } } @@ -861,7 +861,7 @@ int main(int argc, char* argv[]) { } - std::cout << "PID specified: " << pid << std::endl; + PIDinspect(static_cast(pid)); } else { if (IsVirtualTerminalModeEnabled()) { // ugh i have to do this EVERY SINGLE TIME From ed7e904ec4ff0d51afb1c6fb08c25ff1d95fb472 Mon Sep 17 00:00:00 2001 From: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> Date: Thu, 29 Jan 2026 16:56:05 -0500 Subject: [PATCH 5/5] =?UTF-8?q?Avoid=20returning=20the=20PID=20as=20a=20?= =?UTF-8?q?=E2=80=9Cprocess=20name=E2=80=9D=20when=20no=20match=20is=20fou?= =?UTF-8?q?nd.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the PID isn’t found in the snapshot, returning std::to_string(pid) makes PIDinspect print the PID as the process name, which is misleading for nonexistent processes. Now it's fixed --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 009b14d..4d1db61 100644 --- a/main.cpp +++ b/main.cpp @@ -396,7 +396,7 @@ std::string GetProcessNameFromPid(DWORD pid) { } CloseHandle(snapshot); - return std::to_string(pid); + return ""; } void PrintAncestry(DWORD pid) {