Last active
November 11, 2022 04:45
-
-
Save Icedude907/a82b2611915e254f1bdf5fd1a17408a2 to your computer and use it in GitHub Desktop.
ArgDump.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <iostream> | |
#include <fstream> | |
#include <filesystem> | |
// Dumps arguments given to a file in the working directory. If it doesn't have permissions it dumps to the temp folder | |
// Made to monitor the startup of a process with a short lifespan | |
// Note: Working Directory != Process Directory. You may need to search a bit | |
int main(int argc, char** argv){ | |
std::ofstream outfile; | |
auto path = std::filesystem::current_path() / "args.txt"; | |
// If that path is unavaliable we dump somewhere else | |
outfile.open(path); | |
if(!outfile){ | |
std::cout << "There was an error opening the output file in this directory. Dumping temp somewhere" << std::endl; | |
path = std::filesystem::temp_directory_path() / "argdump" / "args.txt"; | |
outfile.open(path); | |
} | |
for(size_t i = 0; i < argc; i++){ | |
outfile << argv[i] << "\n"; | |
} | |
outfile.flush(); | |
outfile.close(); | |
std::cout << "Args dumped to file in " << path.string() << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment