3 using namespace CYB::Platform::Win32;
8 if(Sys::Call(Sys::TERMINATE_PROC, FHandle) == 0)
14 FHandle(reinterpret_cast<Win32::HANDLE>(System::
Sys::Call(
Sys::GET_CURRENT_PROCESS)))
18 FHandle(AMove.FHandle)
20 AMove.FHandle =
nullptr;
25 AMove.FHandle =
nullptr;
30 if(FHandle !=
nullptr)
37 STARTUPINFO StartupInfo{
sizeof(STARTUPINFO),
nullptr,
nullptr,
nullptr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
nullptr, 0, 0, 0};
38 PROCESS_INFORMATION ProcessInformation;
41 const auto Result(MM.Call<CYB::Platform::Modules::Kernel32::CreateProcessW>(ExeAs16.WString(), CmdlAs16.
WideData(),
nullptr,
nullptr, FALSE, DWORD(0),
nullptr,
nullptr, &StartupInfo, &ProcessInformation));
44 switch (MM.Call<CYB::Platform::Modules::Kernel32::GetLastError>()) {
45 case ERROR_ACCESS_DENIED:
47 case ERROR_FILE_NOT_FOUND:
49 case ERROR_ELEVATION_REQUIRED:
52 SHELLEXECUTEINFO ShellExecuteInfo{
sizeof(SHELLEXECUTEINFO), SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS,
nullptr, L
"runas", ExeAs16.WString(), CmdlAs16.
WString(),
nullptr, SW_SHOWNORMAL, 0,
nullptr,
nullptr, 0 };
53 ShellExecuteInfo.hIcon = 0;
54 ShellExecuteInfo.hMonitor = 0;
55 ShellExecuteInfo.hProcess = 0;
56 const auto Result2(MM.Call<CYB::Platform::Modules::Shell::ShellExecuteExW>(&ShellExecuteInfo));
57 if (Result2 == TRUE) {
60 return ShellExecuteInfo.hProcess;
67 MM.Call<CYB::Platform::Modules::Kernel32::CloseHandle>(ProcessInformation.hThread);
68 return ProcessInformation.hProcess;
72 FHandle(CreateProcess(APath, ACommandLine))
76 return Core().
FModuleManager.
Call<Modules::Kernel32::WaitForSingleObject>(FHandle, Win32::DWORD(0)) == WAIT_TIMEOUT;
80 if (Active() && ARHS.Active()) {
81 const auto Result(
Core().FModuleManager.Call<Modules::Kernel32::GetProcessId>(FHandle));
89 const auto Result(
Core().FModuleManager.Call<Modules::Kernel32::WaitForSingleObject>(FHandle, AMilliseconds == 0 ? INFINITE : AMilliseconds));
90 API::Assert::NotEqual<decltype(Result)>(Result, WAIT_FAILED);
91 return Result == WAIT_OBJECT_0;
97 auto& MM(
Core().FModuleManager);
98 if (MM.Call<Modules::Kernel32::GetExitCodeProcess>(FHandle, &Result) == 0) {
99 const auto ErrorCode(MM.Call<Modules::Kernel32::GetLastError>());
100 API::Assert::NotEqual<decltype(ErrorCode)>(ErrorCode, ERROR_INVALID_HANDLE);
103 return static_cast<int>(Result);
A variable length UTF-8 string.
wchar_t * WideData(void) noexcept
Get the underlying wide char array.
UTF-16 String enabled only under windows.
Platform::Modules::Manager FModuleManager
Loads and contains required modules.
static void LessThan(const AType &ALHS, const AType &ARHS) noexcept
Less than assertion function. May not be evaluated.
A required file was not found in the filesystem.
static void NotEqual(const AType &ALHS, const AType &ARHS) noexcept
Unequivalence assertion function. May not be evaluated.
Exceptions caused by external call failures or invalid external data. Only classifies ones that can p...
Tried to check the error code of a Process the OS would not allow.
Process could not be terminated, most likely due to insufficient priviledges.
const wchar_t * WString(void) const noexcept
Get the underlying const wide char array.
Generic error for read failures. See functions for further documentation.
Precompiled header for inter-engine operations.
Engine::Core & Core(void) noexcept
Retrieve the Core singleton.
Exceptions that are thrown internally in the engine that the should never see, these are a superset o...
Process could not be created for unknown reasons.