|
|
@@ -3,6 +3,15 @@
|
|
|
|
|
|
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
|
|
|
|
|
+#ifdef _WIN32
|
|
|
+#include <cstring> // for memset, strncpy
|
|
|
+#include <processthreadsapi.h>
|
|
|
+#include <windows.h>
|
|
|
+#elif defined(YUZU_UNIX)
|
|
|
+#include <unistd.h>
|
|
|
+#endif
|
|
|
+
|
|
|
+#include <cstdio>
|
|
|
#include <filesystem>
|
|
|
#include <fstream>
|
|
|
#include "common/fs/fs.h"
|
|
|
@@ -10,7 +19,7 @@
|
|
|
#include "common/logging/log.h"
|
|
|
#include "video_core/vulkan_common/vulkan_instance.h"
|
|
|
#include "video_core/vulkan_common/vulkan_library.h"
|
|
|
-#include "yuzu/check_vulkan.h"
|
|
|
+#include "yuzu/startup_checks.h"
|
|
|
#include "yuzu/uisettings.h"
|
|
|
|
|
|
constexpr char TEMP_FILE_NAME[] = "vulkan_check";
|
|
|
@@ -51,3 +60,53 @@ bool CheckVulkan() {
|
|
|
std::filesystem::remove(temp_file_loc);
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+bool StartupChecks() {
|
|
|
+#ifdef _WIN32
|
|
|
+ const bool env_var_set = SetEnvironmentVariableA(STARTUP_CHECK_ENV_VAR, "ON");
|
|
|
+ if (!env_var_set) {
|
|
|
+ LOG_ERROR(Frontend, "SetEnvironmentVariableA failed to set {}, {}", STARTUP_CHECK_ENV_VAR,
|
|
|
+ GetLastError());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ STARTUPINFOA startup_info;
|
|
|
+ PROCESS_INFORMATION process_info;
|
|
|
+
|
|
|
+ std::memset(&startup_info, '\0', sizeof(startup_info));
|
|
|
+ std::memset(&process_info, '\0', sizeof(process_info));
|
|
|
+ startup_info.cb = sizeof(startup_info);
|
|
|
+
|
|
|
+ char p_name[255];
|
|
|
+ std::strncpy(p_name, "yuzu.exe", 255);
|
|
|
+
|
|
|
+ // TODO: use argv[0] instead of yuzu.exe
|
|
|
+ const bool process_created = CreateProcessA(nullptr, // lpApplicationName
|
|
|
+ p_name, // lpCommandLine
|
|
|
+ nullptr, // lpProcessAttributes
|
|
|
+ nullptr, // lpThreadAttributes
|
|
|
+ false, // bInheritHandles
|
|
|
+ 0, // dwCreationFlags
|
|
|
+ nullptr, // lpEnvironment
|
|
|
+ nullptr, // lpCurrentDirectory
|
|
|
+ &startup_info, // lpStartupInfo
|
|
|
+ &process_info // lpProcessInformation
|
|
|
+ );
|
|
|
+ if (!process_created) {
|
|
|
+ LOG_ERROR(Frontend, "CreateProcessA failed, {}", GetLastError());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // wait until the processs exits
|
|
|
+ DWORD exit_code = STILL_ACTIVE;
|
|
|
+ while (exit_code == STILL_ACTIVE) {
|
|
|
+ GetExitCodeProcess(process_info.hProcess, &exit_code);
|
|
|
+ }
|
|
|
+
|
|
|
+ std::fprintf(stderr, "exit code: %d\n", exit_code);
|
|
|
+
|
|
|
+ CloseHandle(process_info.hProcess);
|
|
|
+ CloseHandle(process_info.hThread);
|
|
|
+#endif
|
|
|
+ return true;
|
|
|
+}
|