[*] NT: AuProcess this is better

This commit is contained in:
Reece Wilson 2023-09-12 02:01:12 +01:00
parent b46390f83a
commit ffd61d4d54

View File

@ -295,14 +295,22 @@ namespace Aurora::Processes
}
else if (this->startup_.fwdOut == EStreamForward::eCurrentProcess)
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE hHandle = GetStdHandle(STD_OUTPUT_HANDLE);
if (handle != INVALID_HANDLE_VALUE && handle)
if (hHandle != INVALID_HANDLE_VALUE)
{
SetHandleInformation(handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
HANDLE hTargetProcess = ::GetCurrentProcess();
this->bDontRelOut_ = true;
this->pipeStdOutWrite_ = handle;
if (!::DuplicateHandle(hTargetProcess,
hHandle,
hTargetProcess,
&this->pipeStdOutWrite_,
GENERIC_READ | GENERIC_WRITE,
TRUE,
0))
{
return false;
}
}
}
@ -347,14 +355,22 @@ namespace Aurora::Processes
}
else if (this->startup_.fwdErr == EStreamForward::eCurrentProcess)
{
HANDLE handle = GetStdHandle(STD_ERROR_HANDLE);
HANDLE hHandle = GetStdHandle(STD_ERROR_HANDLE);
if (handle != INVALID_HANDLE_VALUE && handle)
if (hHandle != INVALID_HANDLE_VALUE)
{
SetHandleInformation(handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
HANDLE hTargetProcess = ::GetCurrentProcess();
this->bDontRelErr_ = true;
this->pipeStdErrWrite_ = handle;
if (!::DuplicateHandle(hTargetProcess,
hHandle,
hTargetProcess,
&this->pipeStdErrWrite_,
GENERIC_READ | GENERIC_WRITE,
TRUE,
0))
{
return false;
}
}
}
@ -399,14 +415,22 @@ namespace Aurora::Processes
}
else if (this->startup_.fwdIn == EStreamForward::eCurrentProcess)
{
HANDLE handle = GetStdHandle(STD_ERROR_HANDLE);
HANDLE hHandle = GetStdHandle(STD_INPUT_HANDLE);
if (handle != INVALID_HANDLE_VALUE && handle)
if (hHandle != INVALID_HANDLE_VALUE)
{
SetHandleInformation(handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
HANDLE hTargetProcess = ::GetCurrentProcess();
this->bDontRelIn_ = true;
this->pipeStdInRead_ = handle;
if (!::DuplicateHandle(hTargetProcess,
hHandle,
hTargetProcess,
&this->pipeStdInRead_,
GENERIC_READ,
TRUE,
0))
{
return false;
}
}
}