From d7ecdd9f77afde5134e09c0d391c9585808c87a8 Mon Sep 17 00:00:00 2001 From: supervoidcoder Date: Sun, 15 Feb 2026 21:36:24 -0500 Subject: [PATCH 1/7] fix vscode task --- .vscode/tasks.json | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 705bde4..45f6328 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,15 +2,16 @@ "tasks": [ { "type": "cppbuild", - "label": "C/C++: cl.exe build active file", + "label": "Build win-witr.exe", "command": "cl.exe", "args": [ - "/Zi", + "/O2", + "/std:c++20", "/EHsc", - "/nologo", - "/std:c++20", - "/Fe${fileDirname}\\${fileBasenameNoExtension}.exe", - "${file}" + "main.cpp", + "/DUNICODE", + "/D_UNICODE", + "/Fe:win-witr.exe" ], "options": { "cwd": "${fileDirname}" From ff90a997f5e617ff555c5652bd2e2e77882e4c0f Mon Sep 17 00:00:00 2001 From: supervoidcoder Date: Sun, 15 Feb 2026 21:53:07 -0500 Subject: [PATCH 2/7] refactor: Improve argument parsing by storing it all in a vector of strings rather than manually parsing each one on the fly --- main.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index 8258d1b..7cda6af 100644 --- a/main.cpp +++ b/main.cpp @@ -2072,18 +2072,19 @@ ProcInfos findMyProc(const char *procname, HANDLE hSnapshot) { int main(int argc, char* argv[]) { SetConsoleOutputCP(CP_UTF8); virtualTerminalEnabled = IsVirtualTerminalModeEnabled(); - for (int i = 0; i < argc; ++i) { - std::string arg = argv[i]; + std::vector arguments(argv, argv + argc); + for (size_t i = 0; i < arguments.size(); ++i) { + std::string arg = arguments[i]; - if (i == 0 && argc > 1) { + if (i == 0 && arguments.size() > 1) { continue; } - if (argc == 1 || std::string(argv[1]) == "-h" || std::string(argv[1]) == "--help") { + if (arguments.size() == 1 || arguments[1] == "-h" || arguments[1] == "--help") { if (!forkAuthor.empty()) { std::cout << "\nwin-witr - Why is this running? Windows version by supervoidcoder. Fork by " << forkAuthor << std::endl; } else { @@ -2130,9 +2131,9 @@ int main(int argc, char* argv[]) { } if (arg == "--pid") { - if (i + 1 < argc) { + if (i + 1 < arguments.size()) { - std::string pidStr = argv[i + 1]; // never increment the actual variable unless you're actually trying to find the next argument, otherwise + std::string pidStr = arguments[i + 1]; // never increment the actual variable unless you're actually trying to find the next argument, otherwise // skipping arguments will happen and can crash if there is, in fact, no next argument. int pid = 0; From 9a2fe0674dcf31a73877d0696c3b427a859e328f Mon Sep 17 00:00:00 2001 From: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> Date: Tue, 17 Feb 2026 08:14:05 -0500 Subject: [PATCH 3/7] feat: Pass more arguments to PIDInspect so that it knows more stuff about the flags, making it more aware --- main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 7cda6af..4d63b1a 100644 --- a/main.cpp +++ b/main.cpp @@ -1745,7 +1745,8 @@ void FindProcessPorts(DWORD targetPid) { -void PIDinspect(const std::vector& pids, const std::vector& names, HANDLE hshot) { // ooh guys look i'm in the void +void PIDinspect(const std::vector& pids, const std::vector& names, HANDLE hshot, std::vector& statuses, int related, ) { +//^^^ ooh guys look i'm in the void DWORD pid = pids[0]; std::unordered_map pidMap; PROCESSENTRY32 pe32{}; From 4b23499bb473964dbf88b6b438a5b46cf277fd67 Mon Sep 17 00:00:00 2001 From: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> Date: Tue, 17 Feb 2026 13:02:11 -0500 Subject: [PATCH 4/7] feat: normalize arguments whether they use `-`, `--`, or `/` --- main.cpp | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index 4d63b1a..b5cf19c 100644 --- a/main.cpp +++ b/main.cpp @@ -2068,6 +2068,26 @@ ProcInfos findMyProc(const char *procname, HANDLE hSnapshot) { } // The above function is taken from https://cocomelonc.github.io/pentest/2021/09/29/findmyprocess.html, modified simply to use WideToString for the process name comparison among other things. // Thanks! + +std::vector normalizeArgs (std::vector& args) { +// flags could be -, --, or /. heck, + for i in args.size() { + if (args.[i].at(0) == "/") { +args[i].erase(0, 1); } else { + if (args[i].at(0) == "-") { + if (args[i].at(1) == "-") // i could've done stats_with ("--") too but i feel like it takes more performance + // all this arg stuff probably steals milliseconds unfortunately + { + args[i].erase(0, 2); + } else { + args[i].erase(0, 1); + } + } + } + + +} + int main(int argc, char* argv[]) { @@ -2075,17 +2095,18 @@ int main(int argc, char* argv[]) { virtualTerminalEnabled = IsVirtualTerminalModeEnabled(); std::vector arguments(argv, argv + argc); for (size_t i = 0; i < arguments.size(); ++i) { - std::string arg = arguments[i]; + std::vector args = normalizeArgs(arguments); + - if (i == 0 && arguments.size() > 1) { + if (i == 0 && args.size() > 1) { continue; } - if (arguments.size() == 1 || arguments[1] == "-h" || arguments[1] == "--help") { + if (args.size() == 1 || args[1] == "h" || args[1] == "help") { if (!forkAuthor.empty()) { std::cout << "\nwin-witr - Why is this running? Windows version by supervoidcoder. Fork by " << forkAuthor << std::endl; } else { @@ -2126,15 +2147,15 @@ int main(int argc, char* argv[]) { } - if (arg == "-v" || arg == "--version") { + if (args[2] == "v" || args[2] == "version") { std::cout << "\nwin-witr " << version << std::endl; return 0; } - if (arg == "--pid") { - if (i + 1 < arguments.size()) { + if (args[2] == "pid") { + if (i + 1 < args.size()) { - std::string pidStr = arguments[i + 1]; // never increment the actual variable unless you're actually trying to find the next argument, otherwise + std::string pidStr = args[i + 1]; // never increment the actual variable unless you're actually trying to find the next argument, otherwise // skipping arguments will happen and can crash if there is, in fact, no next argument. int pid = 0; @@ -2189,7 +2210,7 @@ int main(int argc, char* argv[]) { return 0; } // check for process name if no recognized flags - else if (arg[0] != '-') { // if it doesn't start with -- or - + else { std::string procName = arg; HANDLE hshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (INVALID_HANDLE_VALUE == hshot) {return 1;} From a4c9ffe8ba71f01849ed6f699c4c9c6e1c16e8c5 Mon Sep 17 00:00:00 2001 From: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> Date: Mon, 23 Feb 2026 08:29:42 -0500 Subject: [PATCH 5/7] fix: --- main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/main.cpp b/main.cpp index b5cf19c..a6a416a 100644 --- a/main.cpp +++ b/main.cpp @@ -2087,6 +2087,7 @@ args[i].erase(0, 1); } else { } +} From 26053e1f6f178084a4c1d43ad0b549fb6e747570 Mon Sep 17 00:00:00 2001 From: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> Date: Mon, 23 Feb 2026 08:48:50 -0500 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=E2=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 54 +++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/main.cpp b/main.cpp index a6a416a..534d6d7 100644 --- a/main.cpp +++ b/main.cpp @@ -184,6 +184,10 @@ std::unordered_map errorHints = { }; +struct Statuses { +bool verbose; +// will probably add more later +}; bool EnableDebugPrivilege() { HANDLE hToken; @@ -1745,7 +1749,7 @@ void FindProcessPorts(DWORD targetPid) { -void PIDinspect(const std::vector& pids, const std::vector& names, HANDLE hshot, std::vector& statuses, int related, ) { +void PIDinspect(const std::vector& pids, const std::vector& names, HANDLE hshot, Statuses stats, int related, ) { //^^^ ooh guys look i'm in the void DWORD pid = pids[0]; std::unordered_map pidMap; @@ -2069,24 +2073,20 @@ ProcInfos findMyProc(const char *procname, HANDLE hSnapshot) { // The above function is taken from https://cocomelonc.github.io/pentest/2021/09/29/findmyprocess.html, modified simply to use WideToString for the process name comparison among other things. // Thanks! -std::vector normalizeArgs (std::vector& args) { -// flags could be -, --, or /. heck, - for i in args.size() { - if (args.[i].at(0) == "/") { -args[i].erase(0, 1); } else { - if (args[i].at(0) == "-") { - if (args[i].at(1) == "-") // i could've done stats_with ("--") too but i feel like it takes more performance - // all this arg stuff probably steals milliseconds unfortunately - { - args[i].erase(0, 2); - } else { - args[i].erase(0, 1); - } - } - } - - -} +std::vector normalizeArgs(std::vector& args) { + // this function can seem a little obfuscated so let me help + for (size_t i = 0; i < args.size(); i++) { + if (args[i].at(0) == "/") { // if it starts with a / + args[i].at(0) = "-"; // then set it to - to normalize the argument, so /help turns into -help + } else if (args[i].at(0) == "-") { // if it starts with a - + if (args[i].at(1) == "-") { // then check if the person put another - like --help + args[i].erase(0, 1); // if so then delete first char and it turns into -help + } else { + // do nothing + } + } + } + return args; } @@ -2095,6 +2095,9 @@ int main(int argc, char* argv[]) { SetConsoleOutputCP(CP_UTF8); virtualTerminalEnabled = IsVirtualTerminalModeEnabled(); std::vector arguments(argv, argv + argc); + Statuses s; + + s.verbose = false; // for now this don't do anything for (size_t i = 0; i < arguments.size(); ++i) { std::vector args = normalizeArgs(arguments); @@ -2107,7 +2110,7 @@ int main(int argc, char* argv[]) { - if (args.size() == 1 || args[1] == "h" || args[1] == "help") { + if (args.size() == 1 || args[1] == "-h" || args[1] == "-help") { if (!forkAuthor.empty()) { std::cout << "\nwin-witr - Why is this running? Windows version by supervoidcoder. Fork by " << forkAuthor << std::endl; } else { @@ -2148,12 +2151,12 @@ int main(int argc, char* argv[]) { } - if (args[2] == "v" || args[2] == "version") { + if (args[1] == "-v" || args[1] == "-version") { std::cout << "\nwin-witr " << version << std::endl; return 0; } - if (args[2] == "pid") { + if (args[1] == "-pid") { if (i + 1 < args.size()) { std::string pidStr = args[i + 1]; // never increment the actual variable unless you're actually trying to find the next argument, otherwise @@ -2194,7 +2197,8 @@ int main(int argc, char* argv[]) { HANDLE hshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (INVALID_HANDLE_VALUE == hshot) {return 1;} - PIDinspect(pids, trash, hshot); + + PIDinspect(pids, trash, hshot, s, 0); CloseHandle(hshot); } else { if (virtualTerminalEnabled) { // ugh i have to do this EVERY SINGLE TIME @@ -2212,13 +2216,13 @@ int main(int argc, char* argv[]) { } // check for process name if no recognized flags else { - std::string procName = arg; + std::string procName = args[1]; HANDLE hshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (INVALID_HANDLE_VALUE == hshot) {return 1;} ProcInfos r = findMyProc(procName.c_str(), hshot); if (!r.pids.empty()) { std::vector dwPids(r.pids.begin(), r.pids.end()); - PIDinspect(dwPids, r.names, hshot); + PIDinspect(dwPids, r.names, hshot, s, 0); CloseHandle(hshot); } else { if (virtualTerminalEnabled) { From 21e5b66bb86217cda48151bf98dd55599852aa0c Mon Sep 17 00:00:00 2001 From: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> Date: Mon, 23 Feb 2026 08:52:59 -0500 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20=E2=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 534d6d7..c87f827 100644 --- a/main.cpp +++ b/main.cpp @@ -1749,7 +1749,7 @@ void FindProcessPorts(DWORD targetPid) { -void PIDinspect(const std::vector& pids, const std::vector& names, HANDLE hshot, Statuses stats, int related, ) { +void PIDinspect(const std::vector& pids, const std::vector& names, HANDLE hshot, Statuses stats, int related ) { //^^^ ooh guys look i'm in the void DWORD pid = pids[0]; std::unordered_map pidMap; @@ -2076,10 +2076,10 @@ ProcInfos findMyProc(const char *procname, HANDLE hSnapshot) { std::vector normalizeArgs(std::vector& args) { // this function can seem a little obfuscated so let me help for (size_t i = 0; i < args.size(); i++) { - if (args[i].at(0) == "/") { // if it starts with a / - args[i].at(0) = "-"; // then set it to - to normalize the argument, so /help turns into -help - } else if (args[i].at(0) == "-") { // if it starts with a - - if (args[i].at(1) == "-") { // then check if the person put another - like --help + if (args[i].at(0) == '/') { // if it starts with a / + args[i].at(0) = '-'; // then set it to - to normalize the argument, so /help turns into -help + } else if (args[i].at(0) == '-') { // if it starts with a - + if (args[i].at(1) == '-') { // then check if the person put another - like --help args[i].erase(0, 1); // if so then delete first char and it turns into -help } else { // do nothing