plugify  1.0.0.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
plugify::Assembly Class Reference

Represents an assembly (module) within a process. More...

#include <assembly.hpp>

Classes

struct  Section
 Represents a section of the assembly. More...
 

Public Types

using SearchDirs = std::vector< std::filesystem::path >
 

Public Member Functions

 Assembly ()
 Default constructor initializing handle to nullptr.
 
 ~Assembly ()
 Destructor.
 
 Assembly (const Assembly &)=delete
 
Assemblyoperator= (const Assembly &)=delete
 
 Assembly (Assembly &&rhs) noexcept=delete
 
Assemblyoperator= (Assembly &&rhs) noexcept=delete
 
 Assembly (std::string_view moduleName, LoadFlag flags=LoadFlag::Default, const SearchDirs &additionalSearchDirectories={}, bool sections=false)
 Constructs an Assembly object with the specified module name, flags, and sections. More...
 
 Assembly (const char *moduleName, LoadFlag flags=LoadFlag::Default, const SearchDirs &additionalSearchDirectories={}, bool sections=false)
 Constructs an Assembly object with a char pointer as module name. More...
 
 Assembly (const std::string &moduleName, LoadFlag flags=LoadFlag::Default, const SearchDirs &additionalSearchDirectories={}, bool sections=false)
 Constructs an Assembly object with a string as module name. More...
 
 Assembly (const std::filesystem::path &modulePath, LoadFlag flags=LoadFlag::Default, const SearchDirs &additionalSearchDirectories={}, bool sections=false)
 Constructs an Assembly object with a filesystem path as module path. More...
 
 Assembly (MemAddr moduleMemory, LoadFlag flags=LoadFlag::Default, const SearchDirs &additionalSearchDirectories={}, bool sections=false)
 Constructs an Assembly object with a memory address. More...
 
MemAddr FindPattern (MemAddr pattern, std::string_view mask, MemAddr startAddress=nullptr, Section *moduleSection=nullptr) const
 Finds an array of bytes in process memory using SIMD instructions. More...
 
MemAddr FindPattern (std::string_view pattern, MemAddr startAddress=nullptr, Section *moduleSection=nullptr) const
 Finds a string pattern in process memory using SIMD instructions. More...
 
MemAddr GetVirtualTableByName (std::string_view tableName, bool decorated=false) const
 Gets an address of a virtual method table by RTTI type descriptor name. More...
 
MemAddr GetFunctionByName (std::string_view functionName) const noexcept
 Gets an address of a function by its name. More...
 
Section GetSectionByName (std::string_view sectionName) const noexcept
 Gets a module section by name. More...
 
void * GetHandle () const noexcept
 Returns the module handle. More...
 
MemAddr GetBase () const noexcept
 Returns the module base address. More...
 
const std::filesystem::path & GetPath () const noexcept
 Returns the module path. More...
 
const std::string & GetError () const noexcept
 Returns the module error. More...
 
bool IsValid () const noexcept
 Checks if the assembly is valid. More...
 
 operator bool () const noexcept
 Conversion operator to check if the assembly is valid. More...
 
bool operator== (const Assembly &assembly) const noexcept
 Equality operator. More...
 

Static Public Member Functions

static std::pair< std::vector< uint8_t >, std::string > PatternToMaskedBytes (std::string_view input)
 Converts a string pattern with wildcards to an array of bytes and mask. More...
 

Detailed Description

Represents an assembly (module) within a process.

Definition at line 15 of file assembly.hpp.

Constructor & Destructor Documentation

◆ Assembly() [1/5]

plugify::Assembly::Assembly ( std::string_view  moduleName,
LoadFlag  flags = LoadFlag::Default,
const SearchDirs &  additionalSearchDirectories = {},
bool  sections = false 
)
explicit

Constructs an Assembly object with the specified module name, flags, and sections.

Parameters
moduleNameThe name of the module.
flagsOptional flags for module initialization.
additionalSearchDirectoriesOptional additional search directories.
sectionsOptional flag indicating if sections should be initialized.

◆ Assembly() [2/5]

plugify::Assembly::Assembly ( const char *  moduleName,
LoadFlag  flags = LoadFlag::Default,
const SearchDirs &  additionalSearchDirectories = {},
bool  sections = false 
)
inlineexplicit

Constructs an Assembly object with a char pointer as module name.

Parameters
moduleNameThe name of the module as a char pointer.
flagsOptional flags for module initialization.
additionalSearchDirectoriesOptional additional search directories.
sectionsOptional flag indicating if sections should be initialized.

Definition at line 85 of file assembly.hpp.

◆ Assembly() [3/5]

plugify::Assembly::Assembly ( const std::string &  moduleName,
LoadFlag  flags = LoadFlag::Default,
const SearchDirs &  additionalSearchDirectories = {},
bool  sections = false 
)
inlineexplicit

Constructs an Assembly object with a string as module name.

Parameters
moduleNameThe name of the module as a string.
flagsOptional flags for module initialization.
additionalSearchDirectoriesOptional additional search directories.
sectionsOptional flag indicating if sections should be initialized.

Definition at line 95 of file assembly.hpp.

◆ Assembly() [4/5]

plugify::Assembly::Assembly ( const std::filesystem::path &  modulePath,
LoadFlag  flags = LoadFlag::Default,
const SearchDirs &  additionalSearchDirectories = {},
bool  sections = false 
)
explicit

Constructs an Assembly object with a filesystem path as module path.

Parameters
modulePathThe filesystem path of the module.
flagsOptional flags for module initialization.
additionalSearchDirectoriesOptional additional search directories.
sectionsOptional flag indicating if sections should be initialized.

◆ Assembly() [5/5]

plugify::Assembly::Assembly ( MemAddr  moduleMemory,
LoadFlag  flags = LoadFlag::Default,
const SearchDirs &  additionalSearchDirectories = {},
bool  sections = false 
)
explicit

Constructs an Assembly object with a memory address.

Parameters
moduleMemoryThe memory address of the module.
flagsOptional flags for module initialization.
additionalSearchDirectoriesOptional additional search directories.
sectionsOptional flag indicating if sections should be initialized.

Member Function Documentation

◆ FindPattern() [1/2]

MemAddr plugify::Assembly::FindPattern ( MemAddr  pattern,
std::string_view  mask,
MemAddr  startAddress = nullptr,
Section moduleSection = nullptr 
) const

Finds an array of bytes in process memory using SIMD instructions.

Parameters
patternThe byte pattern to search for.
maskThe mask corresponding to the byte pattern.
startAddressThe start address for the search.
moduleSectionThe module section to search within.
Returns
The memory address where the pattern is found, or nullptr if not found.

◆ FindPattern() [2/2]

MemAddr plugify::Assembly::FindPattern ( std::string_view  pattern,
MemAddr  startAddress = nullptr,
Section moduleSection = nullptr 
) const

Finds a string pattern in process memory using SIMD instructions.

Parameters
patternThe string pattern to search for.
startAddressThe start address for the search.
moduleSectionThe module section to search within.
Returns
The memory address where the pattern is found, or nullptr if not found.

◆ GetBase()

MemAddr plugify::Assembly::GetBase ( ) const
noexcept

Returns the module base address.

Returns
The base address of the module.

◆ GetError()

const std::string& plugify::Assembly::GetError ( ) const
noexcept

Returns the module error.

Returns
The error string of the module.

◆ GetFunctionByName()

MemAddr plugify::Assembly::GetFunctionByName ( std::string_view  functionName) const
noexcept

Gets an address of a function by its name.

Parameters
functionNameThe name of the function.
Returns
The memory address of the function, or nullptr if not found.

◆ GetHandle()

void* plugify::Assembly::GetHandle ( ) const
noexcept

Returns the module handle.

Returns
The module handle.

◆ GetPath()

const std::filesystem::path& plugify::Assembly::GetPath ( ) const
noexcept

Returns the module path.

Returns
The path of the module.

◆ GetSectionByName()

Section plugify::Assembly::GetSectionByName ( std::string_view  sectionName) const
noexcept

Gets a module section by name.

Parameters
sectionNameThe name of the section (e.g., ".rdata", ".text").
Returns
The Section object representing the module section.

◆ GetVirtualTableByName()

MemAddr plugify::Assembly::GetVirtualTableByName ( std::string_view  tableName,
bool  decorated = false 
) const

Gets an address of a virtual method table by RTTI type descriptor name.

Parameters
tableNameThe name of the virtual table.
decoratedIndicates whether the name is decorated.
Returns
The memory address of the virtual table, or nullptr if not found.

◆ IsValid()

bool plugify::Assembly::IsValid ( ) const
inlinenoexcept

Checks if the assembly is valid.

Returns
True if the assembly is valid, false otherwise.

Definition at line 192 of file assembly.hpp.

◆ operator bool()

plugify::Assembly::operator bool ( ) const
inlineexplicitnoexcept

Conversion operator to check if the assembly is valid.

Returns
True if the assembly is valid, false otherwise.

Definition at line 198 of file assembly.hpp.

◆ operator==()

bool plugify::Assembly::operator== ( const Assembly assembly) const
inlinenoexcept

Equality operator.

Parameters
assemblyThe other Assembly object to compare with.
Returns
True if both Assembly objects are equal, false otherwise.

Definition at line 205 of file assembly.hpp.

◆ PatternToMaskedBytes()

static std::pair<std::vector<uint8_t>, std::string> plugify::Assembly::PatternToMaskedBytes ( std::string_view  input)
static

Converts a string pattern with wildcards to an array of bytes and mask.

Parameters
inputThe input pattern string.
Returns
A pair containing the byte array and the mask string.

The documentation for this class was generated from the following file: