You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #52 from supervoidcoder/better-error-handling
feat: enhanced error handing when inspecting processes. Added an intenal lookup table (map) of certain error codes that might show up on win-witr. also changed "Process Ancestry" to "Why It Exists" to match the original witr. etc
// but I'm sure there's someone out there using some ANCIENT old version of Windows that doesn't support it, and we want to support this for all versions.
72
112
// Who knows, I might even test this on windows XP hahahahahaha...
73
113
114
+
115
+
116
+
// Here, we will create an unordered map, essentially a lookup table filled with useful stuff like hints for specific errors
{31, "This error indicates a driver error, but in win-witr, it often means you are calling a pseudo-process, such as System, Registry, or other processes that only exist in RAM as a kernel process. It is often easy to tell them apart if they lack a .exe extension."}
121
+
// So far, these are the only error codes I myself have encountered while using win-witr.
122
+
// Something funny about this tool is that the error descriptions in Windows documentation are sometimes
123
+
// Completely unrelated to what the actual error means in the context of win-witr.
124
+
// For example, ERROR_INVALID_PARAMETER (87) is described as "The parameter is incorrect.", but in win-witr,
125
+
// it usually means that the process or PID you're trying to query doesn't exist.
126
+
// Same for 31, which is described as "A device attached to the system is not functioning.", but in win-witr,
127
+
// I've only gotten it when calling processes like System, Registry, etc.
128
+
129
+
// If you want the full list of win32 error codes, you can find them here: https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-
std::cerr << "Try reopening Windows Terminal as Administrator and running win-witr again." << std::endl;
279
+
} elseif (currentParentExe == "explorer.exe") {
280
+
std::cerr << "It seems you might be opening this as a shortcut with flags from Explorer. For best results, try running win-witr from an elevated Command Prompt or Powershell. " << std::endl;
281
+
std::cout << "\nPress any key to exit...";
282
+
_getch();
283
+
// the process will automatically exit since if you open a terminal based script from explorer, the terminal will close immediately after execution is over
284
+
// either way we want to give the user a chance to read the error message even if they did something as weird as this
std::cerr << "Hah, you're running this in Windows Subsystem for Linux. Run wsl as Admin!" << std::endl;
289
+
290
+
291
+
} elseif (currentParentExe == "git-bash.exe") {
292
+
std::cerr << "Uh, you're running this from Git Bash. Try running this program from an elevated Command Prompt or Powershell." << std::endl;
293
+
}
294
+
else {
295
+
std::cerr << "Try reopening this program (or more likely, the shell you're running this in, currently " << currentParentExe << ") as Administrator and running win-witr again." << std::endl;
0 commit comments