[*] NT Processes: GetProcessId() now returns a pointer to a _PROCESS_INFORMATION struct

This commit is contained in:
Reece Wilson 2023-09-15 16:25:40 +01:00
parent 67b047eead
commit 3ba93439c8
2 changed files with 14 additions and 15 deletions

View File

@ -86,8 +86,9 @@ namespace Aurora::Processes
}
AuWin32CloseHandle(this->poke_);
AuWin32CloseHandle(this->process_);
AuWin32CloseHandle(this->hthread_);
this->process_ = INVALID_HANDLE_VALUE;
AuWin32CloseHandle(this->processInfo_.hProcess);
AuWin32CloseHandle(this->processInfo_.hThread);
ShutdownPipes();
}
@ -99,13 +100,13 @@ namespace Aurora::Processes
return {};
}
return ::GetProcessId(this->process_);
return (AuUInt)&this->processInfo_;
}
bool ProcessImpl::TermWinEnumProcesses()
{
#if defined(AURORA_PLATFORM_WIN32)
return SendExitSignal(this->process_);
return SendExitSignal(this->processInfo_.hProcess);
#else
return false;
#endif
@ -502,7 +503,6 @@ namespace Aurora::Processes
return false;
}
PROCESS_INFORMATION processInfo = { 0 };
{
STARTUPINFOW startupInfo = { 0 };
startupInfo.cb = sizeof(startupInfo);
@ -592,7 +592,7 @@ namespace Aurora::Processes
NULL, NULL, true,
uCreateFlags,
envVarBlock.size() ? envVarBlock.data() : nullptr,
wcwd.size() ? wcwd.data() : nullptr, &startupInfo, &processInfo);
wcwd.size() ? wcwd.data() : nullptr, &startupInfo, &this->processInfo_);
if (!result)
{
@ -601,8 +601,7 @@ namespace Aurora::Processes
return false;
}
this->process_ = processInfo.hProcess;
this->hthread_ = processInfo.hThread;
this->process_ = this->processInfo_.hProcess;
RelOtherHandles();
@ -618,7 +617,7 @@ namespace Aurora::Processes
(bool(primary)))
{
::SetProcessAffinityMask(this->process_, primary.lower);
::SetThreadAffinityMask(this->hthread_, primary.lower);
::SetThreadAffinityMask(this->processInfo_.hThread, primary.lower);
}
else
{
@ -629,7 +628,7 @@ namespace Aurora::Processes
if (!this->startup_.bInDebugMode)
{
::ResumeThread(this->hthread_);
::ResumeThread(this->processInfo_.hThread);
}
}
@ -643,7 +642,7 @@ namespace Aurora::Processes
if (this->type_ == ESpawnType::eSpawnChildProcessWorker)
{
#if defined(AURORA_PLATFORM_WIN32)
AssignJobWorker(processInfo.hProcess);
AssignJobWorker(this->processInfo_.hProcess);
#endif
}
}
@ -653,13 +652,14 @@ namespace Aurora::Processes
{
HANDLE b[] =
{
this->poke_, processInfo.hProcess
this->poke_ /*break on AuProcess/ProcessImpl free*/,
this->processInfo_.hProcess /*break on prorcess free*/
};
WaitForMultipleObjects(2, b, FALSE, INFINITE);
DWORD exitCode;
auto result = GetExitCodeProcess(processInfo.hProcess, &exitCode);
auto result = GetExitCodeProcess(this->processInfo_.hProcess, &exitCode);
if (result)
{
this->exitCode_ = exitCode;
@ -687,7 +687,6 @@ namespace Aurora::Processes
return true;
}
void ProcessImpl::RelOtherHandles()
{
if (!this->bDontRelOut_)

View File

@ -43,8 +43,8 @@ namespace Aurora::Processes
void RelOtherHandles();
private:
PROCESS_INFORMATION processInfo_ {};
HANDLE process_ {INVALID_HANDLE_VALUE};
HANDLE hthread_ {INVALID_HANDLE_VALUE};
HANDLE pipeStdOutRead_ {INVALID_HANDLE_VALUE};
HANDLE pipeStdOutWrite_ {INVALID_HANDLE_VALUE};