Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
13 changes: 7 additions & 6 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> 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 {
Expand Down Expand Up @@ -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;
Expand Down
Loading