#include #include #include #include #include #include /** * execute a program from an absolute path * * \param path absolute path to program (duh) * \return program return value, 1 if it does not exist or -1 on error */ int execute(const std::string& path) { if (pid_t child = fork()) { int exitcode = -1; waitpid(child, &exitcode, 0); return exitcode; } else { char* args[] = { strdup(path.c_str()), nullptr }; execv(args[0], args); // this should only be reached if we cant load the program std::exit(1); } } int main() { bool ok = true; // dynamic linking fun std::cout << "Regenerating dynamic linker cache\n"; // ok = execute("/Windows/System32/ldconfig.exe") == 0; // we are never ok ok = false; // failure :> if (!ok) { std::cout << "Unable to complete preinitialization. You have been dropped into a minimal recovery environment. Good luck" << std::endl; execute("/Windows/System32/bash.exe"); } return 0; }