Arion 1.0.2-alpha
A high-performance C++ framework for emulating executable binaries.
 
Loading...
Searching...
No Matches
arion::GdtManager Class Reference

A class used to setup and interact with the Global Descriptor Table (GDT). More...

#include <gdt_manager.hpp>

Public Member Functions

 GdtManager (std::weak_ptr< Arion > arion)
 
void setup ()
 
uint8_t find_free_idx (uint8_t start_idx)
 
uint16_t setup_selector (uint8_t idx, uint16_t flags)
 
uint32_t get_segment_base (uint16_t selector)
 
void insert_entry (uint8_t idx, uint32_t base, uint32_t limit, uint8_t access, uint8_t flags)
 

Static Public Member Functions

static std::unique_ptr< GdtManagerinitialize (std::weak_ptr< Arion > arion)
 

Private Member Functions

uint64_t setup_entry (uint32_t base, uint32_t limit, uint8_t access, uint8_t flags)
 

Private Attributes

ADDR gdt_addr
 The address where the GDT stands in memory.
 
std::weak_ptr< Arionarion
 The Arion instance this GdtManager instance is related to.
 

Detailed Description

A class used to setup and interact with the Global Descriptor Table (GDT).

Constructor & Destructor Documentation

◆ GdtManager()

arion::GdtManager::GdtManager ( std::weak_ptr< Arion arion)
inline

A builder for GdtManager instances.

Parameters
[in]arionThe Arion instance this GdtManager instance is related to.

Member Function Documentation

◆ find_free_idx()

uint8_t arion::GdtManager::find_free_idx ( uint8_t  start_idx)

Retrieves the first free index in the GDT, where one segment descriptor can then be inserted.

Returns
The index.

◆ get_segment_base()

uint32_t arion::GdtManager::get_segment_base ( uint16_t  selector)

Fetches a segment base address from the GDT, based on its corresponding selector.

Parameters
[in]selectorThe selector to identify the GDT segment.
Returns
The base address of the segment.

◆ initialize()

static std::unique_ptr< GdtManager > arion::GdtManager::initialize ( std::weak_ptr< Arion arion)
static

Initializes the GdtManager instance.

Parameters
[in]arionThe Arion instance this GdtManager instance is related to.
Returns
The initialized GdtManager.

◆ insert_entry()

void arion::GdtManager::insert_entry ( uint8_t  idx,
uint32_t  base,
uint32_t  limit,
uint8_t  access,
uint8_t  flags 
)

Builds and inserts an entry in the GDT, identifying a segment.

Parameters
[in]idxIndex in the GDT.
[in]baseThe linear address where the segment begins.
[in]limitThe maximum addressable unit.
[in]accessThe Access Byte which stores permissions over the segment.
[in]flagsAdditional flags.

◆ setup()

void arion::GdtManager::setup ( )

Used to GDT in memory and its mandatory segments.

◆ setup_entry()

uint64_t arion::GdtManager::setup_entry ( uint32_t  base,
uint32_t  limit,
uint8_t  access,
uint8_t  flags 
)
private

Generates a segment descriptor to be added to the GDT.

Parameters
[in]baseThe linear address where the segment begins.
[in]limitThe maximum addressable unit.
[in]accessThe Access Byte which stores permissions over the segment.
[in]flagsAdditional flags.
Returns
The segment descriptor.

◆ setup_selector()

uint16_t arion::GdtManager::setup_selector ( uint8_t  idx,
uint16_t  flags 
)

Builds a segment selector, identifying the segment descriptor to use.

Parameters
[in]idxIndex of the selector identifying the descriptor in its table.
[in]flagsFlags related to the selector (table and privileges).
Returns
The selector.

Member Data Documentation

◆ arion

std::weak_ptr<Arion> arion::GdtManager::arion
private

The Arion instance this GdtManager instance is related to.

◆ gdt_addr

ADDR arion::GdtManager::gdt_addr
private

The address where the GDT stands in memory.


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