@@ -184,6 +184,10 @@ std::unordered_map<int, std::string> errorHints = {
184184
185185};
186186
187+ struct Statuses {
188+ bool verbose;
189+ // will probably add more later
190+ };
187191
188192bool EnableDebugPrivilege () {
189193 HANDLE hToken;
@@ -1745,7 +1749,8 @@ void FindProcessPorts(DWORD targetPid) {
17451749
17461750
17471751
1748- void PIDinspect (const std::vector<DWORD>& pids, const std::vector<std::string>& names, HANDLE hshot) { // ooh guys look i'm in the void
1752+ void PIDinspect (const std::vector<DWORD>& pids, const std::vector<std::string>& names, HANDLE hshot, Statuses stats, int related ) {
1753+ // ^^^ ooh guys look i'm in the void
17491754 DWORD pid = pids[0 ];
17501755 std::unordered_map<DWORD, PROCESSENTRY32> pidMap;
17511756 PROCESSENTRY32 pe32{};
@@ -2067,23 +2072,46 @@ ProcInfos findMyProc(const char *procname, HANDLE hSnapshot) {
20672072}
20682073// 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.
20692074// Thanks!
2075+
2076+ std::vector<std::string> normalizeArgs (std::vector<std::string>& args) {
2077+ // this function can seem a little obfuscated so let me help
2078+ for (size_t i = 0 ; i < args.size (); i++) {
2079+ if (args[i].empty ()) continue ; // if arg empty then program kaboom but i'm not sure how'd you pass an empty arg
2080+ if (args[i].at (0 ) == ' /' ) { // if it starts with a /
2081+ args[i].at (0 ) = ' -' ; // then set it to - to normalize the argument, so /help turns into -help
2082+ } else if (args[i].at (0 ) == ' -' ) { // if it starts with a -
2083+ if (args[i].size () > 1 && args[i].at (1 ) == ' -' ) { // then check if the person put another - like --help
2084+ args[i].erase (0 , 1 ); // if so then delete first char and it turns into -help
2085+ } else {
2086+ // do nothing
2087+ }
2088+ }
2089+ }
2090+ return args;
2091+ }
2092+
20702093
20712094
20722095int main (int argc, char * argv[]) {
20732096 SetConsoleOutputCP (CP_UTF8);
20742097 virtualTerminalEnabled = IsVirtualTerminalModeEnabled ();
2075- for (int i = 0 ; i < argc; ++i) {
2076- std::string arg = argv[i];
2098+ std::vector<std::string> arguments (argv, argv + argc);
2099+ Statuses s;
2100+
2101+ s.verbose = false ; // for now this don't do anything
2102+ for (size_t i = 0 ; i < arguments.size (); ++i) {
2103+ std::vector<std::string> args = normalizeArgs (arguments);
2104+
20772105
20782106
2079- if (i == 0 && argc > 1 ) {
2107+ if (i == 0 && args. size () > 1 ) {
20802108 continue ;
20812109 }
20822110
20832111
20842112
20852113
2086- if (argc == 1 || std::string (argv [1 ]) == " -h" || std::string (argv [1 ]) == " - -help" ) {
2114+ if (args. size () == 1 || args [1 ] == " -h" || args [1 ] == " -help" ) {
20872115 if (!forkAuthor.empty ()) {
20882116 std::cout << " \n win-witr - Why is this running? Windows version by supervoidcoder. Fork by " << forkAuthor << std::endl;
20892117 } else {
@@ -2124,15 +2152,15 @@ int main(int argc, char* argv[]) {
21242152 }
21252153
21262154
2127- if (arg == " -v" || arg == " - -version" ) {
2155+ if (args[ 1 ] == " -v" || args[ 1 ] == " -version" ) {
21282156 std::cout << " \n win-witr " << version << std::endl;
21292157 return 0 ;
21302158 }
21312159
2132- if (arg == " - -pid" ) {
2133- if (i + 1 < argc ) {
2160+ if (args[ 1 ] == " -pid" ) {
2161+ if (i + 1 < args. size () ) {
21342162
2135- std::string pidStr = argv [i + 1 ]; // never increment the actual variable unless you're actually trying to find the next argument, otherwise
2163+ std::string pidStr = args [i + 1 ]; // never increment the actual variable unless you're actually trying to find the next argument, otherwise
21362164 // skipping arguments will happen and can crash if there is, in fact, no next argument.
21372165
21382166 int pid = 0 ;
@@ -2170,7 +2198,8 @@ int main(int argc, char* argv[]) {
21702198
21712199 HANDLE hshot = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0 );
21722200 if (INVALID_HANDLE_VALUE == hshot) {return 1 ;}
2173- PIDinspect (pids, trash, hshot);
2201+
2202+ PIDinspect (pids, trash, hshot, s, 0 );
21742203 CloseHandle (hshot);
21752204 } else {
21762205 if (virtualTerminalEnabled) { // ugh i have to do this EVERY SINGLE TIME
@@ -2187,14 +2216,14 @@ int main(int argc, char* argv[]) {
21872216 return 0 ;
21882217 }
21892218 // check for process name if no recognized flags
2190- else if (arg[ 0 ] != ' - ' ) { // if it doesn't start with -- or -
2191- std::string procName = arg ;
2219+ else {
2220+ std::string procName = args[ 1 ] ;
21922221 HANDLE hshot = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0 );
21932222 if (INVALID_HANDLE_VALUE == hshot) {return 1 ;}
21942223 ProcInfos r = findMyProc (procName.c_str (), hshot);
21952224 if (!r.pids .empty ()) {
21962225 std::vector<DWORD> dwPids (r.pids .begin (), r.pids .end ());
2197- PIDinspect (dwPids, r.names , hshot);
2226+ PIDinspect (dwPids, r.names , hshot, s, 0 );
21982227 CloseHandle (hshot);
21992228 } else {
22002229 if (virtualTerminalEnabled) {
0 commit comments