memex
Loading...
Searching...
No Matches
ProcessHandle Class Reference

Class to manage a process handle. More...

#include <ProcessHandle.hpp>

Public Member Functions

 ProcessHandle ()=default
 Construct a new Process Handle object.
 
 ~ProcessHandle ()
 Destroy the Process Handle object.
 
 ProcessHandle (const ProcessHandle &)=delete
 
ProcessHandleoperator= (const ProcessHandle &)=delete
 
 ProcessHandle (ProcessHandle &&) noexcept
 
ProcessHandleoperator= (ProcessHandle &&) noexcept
 
std::expected< void, memex::Errorattach (std::uint32_t processId, memex::AccessMask desiredAccess=memex::AccessMask::Full)
 This function is responsible for opening a process handle with the specified access rights.
 
bool isAttached () const
 This function checks if the process handle is open.
 
const HANDLE & native () const
 This function returns a raw handle to the process.
 
std::uint32_t processId () const
 Getter for the process ID.
 
std::expected< void, memex::Errorattach (typed::tstring_view processName)
 This function attaches to a process by its name.
 
std::expected< void, memex::Errorterminate (unsigned int exitCode)
 Terminates the process with the specified exit code.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ProcessHandle() [1/3]

ProcessHandle::ProcessHandle ( )
default

Construct a new Process Handle object.

◆ ~ProcessHandle()

ProcessHandle::~ProcessHandle ( )

Destroy the Process Handle object.

◆ ProcessHandle() [2/3]

ProcessHandle::ProcessHandle ( const ProcessHandle & )
delete

◆ ProcessHandle() [3/3]

ProcessHandle::ProcessHandle ( ProcessHandle && other)
noexcept

Member Function Documentation

◆ attach() [1/2]

std::expected< void, memex::Error > ProcessHandle::attach ( std::uint32_t processId,
memex::AccessMask desiredAccess = memex::AccessMask::Full )

This function is responsible for opening a process handle with the specified access rights.

Parameters
processIdProcess ID of the target process.
desiredAccessAccess 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attach() [2/2]

std::expected< void, memex::Error > ProcessHandle::attach ( typed::tstring_view processName)

This function attaches to a process by its name.

Parameters
processNameName 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.
Here is the call graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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.
Here is the caller graph for this function:

◆ operator=() [1/2]

ProcessHandle & ProcessHandle::operator= ( const ProcessHandle & )
delete

◆ operator=() [2/2]

ProcessHandle & ProcessHandle::operator= ( ProcessHandle && other)
noexcept

◆ processId()

std::uint32_t ProcessHandle::processId ( ) const

Getter for the process ID.

Returns
std::uint32_t Returns the process ID.
Here is the caller graph for this function:

◆ terminate()

std::expected< void, memex::Error > ProcessHandle::terminate ( unsigned int exitCode)

Terminates the process with the specified exit code.

Parameters
exitCodeExit 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: