CTitleStateMenu: implemented rebooting into installer

This commit is contained in:
Hyper
2024-12-08 02:57:27 +00:00
parent fc9c7ffb3a
commit d69f0442a7
16 changed files with 123 additions and 25 deletions
+1
View File
@@ -0,0 +1 @@
![Ww][Ii][Nn]32/
+17
View File
@@ -0,0 +1,17 @@
#include "process.h"
#include "process_detail.h"
std::filesystem::path os::process::GetExecutablePath()
{
return detail::GetExecutablePath();
}
std::filesystem::path os::process::GetWorkingDirectory()
{
return detail::GetWorkingDirectory();
}
bool os::process::StartProcess(const std::filesystem::path path, const std::vector<std::string> args, std::filesystem::path work)
{
return detail::StartProcess(path, args, work);
}
+8
View File
@@ -0,0 +1,8 @@
#pragma once
namespace os::process
{
std::filesystem::path GetExecutablePath();
std::filesystem::path GetWorkingDirectory();
bool StartProcess(const std::filesystem::path path, const std::vector<std::string> args, std::filesystem::path work = {});
}
+8
View File
@@ -0,0 +1,8 @@
#pragma once
namespace os::process::detail
{
std::filesystem::path GetExecutablePath();
std::filesystem::path GetWorkingDirectory();
bool StartProcess(const std::filesystem::path path, const std::vector<std::string> args, std::filesystem::path work = {});
}
@@ -0,0 +1,45 @@
#include <os/process_detail.h>
std::filesystem::path os::process::detail::GetExecutablePath()
{
char exePath[MAX_PATH];
if (!GetModuleFileNameA(nullptr, exePath, MAX_PATH))
return std::filesystem::path();
return std::filesystem::path(exePath);
}
std::filesystem::path os::process::detail::GetWorkingDirectory()
{
char workPath[MAX_PATH];
if (!GetCurrentDirectoryA(MAX_PATH, workPath))
return std::filesystem::path();
return std::filesystem::path(workPath);
}
bool os::process::detail::StartProcess(const std::filesystem::path path, const std::vector<std::string> args, std::filesystem::path work)
{
if (path.empty())
return false;
if (work.empty())
work = path.parent_path();
auto cli = path.string();
for (auto& arg : args)
cli += " " + arg;
STARTUPINFOA startInfo{ sizeof(STARTUPINFOA) };
PROCESS_INFORMATION procInfo{};
if (!CreateProcessA(path.string().c_str(), cli.data(), nullptr, nullptr, false, 0, nullptr, work.string().c_str(), &startInfo, &procInfo))
return false;
CloseHandle(procInfo.hProcess);
CloseHandle(procInfo.hThread);
return true;
}