aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/winapi/process.hpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-03-10 12:39:04 +0500
committerEgor Tensin <Egor.Tensin@gmail.com>2022-03-10 12:48:59 +0500
commit4a13df61b92b8bf673f8a71d5fa0abf0356a4899 (patch)
tree071a3830ce0f2309e40a4bb16b7dd42018bd852f /include/winapi/process.hpp
parentMakefile: remove stupid header, etc. (diff)
downloadwinapi-common-4a13df61b92b8bf673f8a71d5fa0abf0356a4899.tar.gz
winapi-common-4a13df61b92b8bf673f8a71d5fa0abf0356a4899.zip
add Doxygen docs
Diffstat (limited to 'include/winapi/process.hpp')
-rw-r--r--include/winapi/process.hpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/include/winapi/process.hpp b/include/winapi/process.hpp
index d5a4ed5..92d9da5 100644
--- a/include/winapi/process.hpp
+++ b/include/winapi/process.hpp
@@ -20,6 +20,7 @@
namespace winapi {
+/** @brief Process parameters for Process::create(). */
struct ProcessParameters {
enum ConsoleCreationMode {
ConsoleNone,
@@ -34,6 +35,7 @@ struct ProcessParameters {
ConsoleCreationMode console_mode = ConsoleNew;
};
+/** @brief Process parameters for Process::shell(). */
struct ShellParameters : ProcessParameters {
static ShellParameters runas(const CommandLine& cmd_line) {
ShellParameters params{cmd_line};
@@ -46,36 +48,66 @@ struct ShellParameters : ProcessParameters {
boost::optional<std::string> verb;
};
+/**
+ * @brief Create a new process or open an existing process.
+ */
class Process {
public:
using ID = DWORD;
+ /** Create a new process using ProcessParameters. */
static Process create(ProcessParameters);
+ /** Create a new process using the given command line. */
static Process create(const CommandLine&);
+ /** Create a new process using the given command line and IO settings. */
static Process create(const CommandLine&, process::IO);
+ /** Create a new shell process using ShellParameters. */
static Process shell(const ShellParameters&);
+ /** Create a new shell process using the given command line. */
static Process shell(const CommandLine&);
+ /** Open the current process. */
static Process current();
- static Process open(ID, DWORD permissions = default_permissions());
+ /**
+ * Open an existing process.
+ * @param id Process ID.
+ * @param permissions Required permissions.
+ */
+ static Process open(ID id, DWORD permissions = default_permissions());
+ /** Open an existing process with read permissions. */
static Process open_r(ID);
+ /** Permissions that allow to query process's status. */
static DWORD default_permissions();
+ /** Permissions that allows to read process's memory. */
static DWORD read_permissions();
+ /** Get this process's ID. */
ID get_id() const { return m_id; }
+ /** Get this process's handle. */
const Handle& get_handle() const { return m_handle; }
+ /** Check if this process is running (i.e. not terminated). */
bool is_running() const;
+ /** Wait for the process to terminate. */
void wait() const;
+ /** Make this process terminate with an exit code. */
void terminate(int ec = 0) const;
+ /** Same as calling terminate() and wait(). */
void shut_down(int ec = 0) const;
+ /** Get terminated process's exit code. */
int get_exit_code() const;
+ /** Get this process's executable path. */
std::string get_exe_path() const;
+ /** Get a binary resource from the process's executable. */
static Resource get_resource(uint32_t id);
+ /**
+ * Get a string resource from the process's executable.
+ * @return UTF-8 string.
+ */
static std::string get_resource_string(uint32_t id);
private: