Class to manage a process handle.
More...
#include <ProcessHandle.hpp>
Class to manage a process handle.
- Note
- This class is used to manage a process handle. It provides methods to attach to a process, check if the handle is valid, and terminate the process.
-
Copy constructors are deleted to prevent copying of the handle.
-
Move constructors are provided to allow moving of the handle.
◆ ProcessHandle() [1/3]
| ProcessHandle::ProcessHandle |
( |
| ) |
|
|
default |
Construct a new Process Handle object.
◆ ~ProcessHandle()
| ProcessHandle::~ProcessHandle |
( |
| ) |
|
Destroy the Process Handle object.
◆ ProcessHandle() [2/3]
◆ ProcessHandle() [3/3]
◆ attach() [1/2]
This function is responsible for opening a process handle with the specified access rights.
- Parameters
-
| processId | Process ID of the target process. |
| desiredAccess | Access rights to be granted to the process handle. |
- Note
- The default access rights are set to full access.
- Returns
- std::expected<void, memex::Error> Returns an expected object containing either void on success or an error on failure.
◆ attach() [2/2]
This function attaches to a process by its name.
- Parameters
-
| processName | Name of the process to attach to. |
- Note
- The process name should be in the format "process.exe".
-
Grants PROCESS_FULL_ACCESS
- Returns
- std::expected<void, memex::Error> Returns an expected object containing either void on success or an error on failure.
◆ isAttached()
| bool ProcessHandle::isAttached |
( |
| ) |
const |
This function checks if the process handle is open.
- Returns
- true if the handle is open
-
false if the handle is not open
◆ native()
| const HANDLE & ProcessHandle::native |
( |
| ) |
const |
This function returns a raw handle to the process.
- Returns
- const HANDLE& Returns a reference to the raw handle.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ processId()
| std::uint32_t ProcessHandle::processId |
( |
| ) |
const |
Getter for the process ID.
- Returns
- std::uint32_t Returns the process ID.
◆ terminate()
| std::expected< void, memex::Error > ProcessHandle::terminate |
( |
unsigned int | exitCode | ) |
|
Terminates the process with the specified exit code.
- Parameters
-
| exitCode | Exit code to be used for termination. |
- Returns
- std::expected<void, memex::Error> Returns an expected object containing either void on success or an error on failure.
The documentation for this class was generated from the following files: