AuroraRuntime/Source/Processes/Process.NT.hpp
Reece 0a38ffacfa [+] NT: IProcess::AsLoopSource()
[*] NT: Bug fix: our side of the process streams were not marked as FILE_FLAG_OVERLAPPED
[+] CreatePipeEx.NT.cpp
2022-05-05 11:26:21 +01:00

72 lines
2.0 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Process.NT.hpp
Date: 2022-1-29
Author: Reece
***/
#pragma once
#include <Source/IO/FS/Async.NT.hpp>
namespace Aurora::Processes
{
class ProcessImpl : public IProcess
{
public:
ProcessImpl(const StartupParmaters &params);
~ProcessImpl();
bool TermWinEnumProcesses();
bool TryKill() override;
bool HasExited();
AuUInt GetProcessId() override;
bool Terminate() override;
AuSPtr<Threading::IWaitable> AsWaitable() override;
AuSPtr<Loop::ILoopSource> AsLoopSource() override;
AuSInt GetExitCode() override;
void ShutdownPipes();
bool Read(EStandardHandle stream, const AuMemoryViewStreamWrite &destination, bool nonblock) override;
bool Write(const AuMemoryViewStreamRead &source) override;
AuSPtr<IO::FS::IAsyncTransaction> NewAsyncTransaction() override;
AuSPtr<IO::FS::IAsyncTransaction> NewErrorStreamAsyncTransaction() override;
bool Start() override;
bool Init();
private:
HANDLE pipeStdOutRead_ {INVALID_HANDLE_VALUE};
HANDLE pipeStdOutWrite_ {INVALID_HANDLE_VALUE};
HANDLE pipeStdErrRead_ {INVALID_HANDLE_VALUE};
HANDLE pipeStdErrWrite_ {INVALID_HANDLE_VALUE};
HANDLE pipeStdInRead_ {INVALID_HANDLE_VALUE};
HANDLE pipeStdInWrite_ {INVALID_HANDLE_VALUE};
AuSPtr<Loop::ILoopSource> loopSource_;
AuSPtr<IO::FS::FileHandle> fsHandle_;
AuSPtr<IO::FS::NtAsyncFileStream> fsStream_;
AuSPtr<IO::FS::FileHandle> fsErrorHandle_;
AuSPtr<IO::FS::NtAsyncFileStream> fsErrorStream_;
StartupParmaters startup_;
ESpawnType type_;
AuList<const char *> cargs_;
AuString windowsCli_;
AuThreads::ThreadUnique_t thread_;
HANDLE process_ {INVALID_HANDLE_VALUE};
HANDLE hthread_ {INVALID_HANDLE_VALUE};
AuSInt exitCode_;
};
}