CACAO
Public Member Functions | Private Member Functions | Private Attributes
cacao::Patcher Class Referenceabstract

Patcher super class. More...

Inheritance diagram for cacao::Patcher:
cacao::LegacyPatcher cacao::PatcherBase cacao::InitializeClassPatcher

Public Member Functions

 Patcher ()
 
virtual ~Patcher ()
 
bool patch ()
 This a wrapper to set the done flag. More...
 
virtual uintptr_t get_mpc () const =0
 get the absolute position in code segment More...
 
virtual void emit ()=0
 Generates the code for the patcher traps. More...
 
virtual void reposition (intptr_t base)=0
 reposition to another base More...
 
bool is_patched () const
 Check already patched. More...
 
virtual bool check_is_patched () const =0
 Check if the patcher is already patched. More...
 
virtual const char * get_name () const
 print patcher information More...
 
virtual OStreamprint (OStream &OS) const
 print patcher information More...
 

Private Member Functions

virtual bool patch_impl ()=0
 This function performs the patching. More...
 

Private Attributes

bool done
 

Detailed Description

Patcher super class.

This class is intended to replace the patchref_t patcher references. The goal is to replace function pointers by virtual functions and void pointers by member variables. Although we need a vtbl_ptr for virtual functions and a smart pointer for list storage this might even reduce the overall memory consumption because not all fields of patchref_t are needed by all patchers. But the main focus is on encapsulation and usability.

Todo:
Remove/adopt the text above if the legacy patchref_t framework has been removed.

Definition at line 49 of file PatcherNew.hpp.

Constructor & Destructor Documentation

cacao::Patcher::Patcher ( )

Definition at line 37 of file PatcherNew.cpp.

cacao::Patcher::~Patcher ( )
virtual

Definition at line 41 of file PatcherNew.cpp.

Member Function Documentation

virtual bool cacao::Patcher::check_is_patched ( ) const
pure virtual

Check if the patcher is already patched.

This is done by comparing the machine instruction.

Returns
true if patched, false otherwise.
See Also
is_patched

Implemented in cacao::InitializeClassPatcher, and cacao::LegacyPatcher.

virtual void cacao::Patcher::emit ( )
pure virtual

Generates the code for the patcher traps.

Implemented in cacao::InitializeClassPatcher, and cacao::LegacyPatcher.

virtual uintptr_t cacao::Patcher::get_mpc ( ) const
pure virtual

get the absolute position in code segment

Deprecated:

Implemented in cacao::PatcherBase, and cacao::LegacyPatcher.

const char * cacao::Patcher::get_name ( ) const
virtual

print patcher information

Reimplemented in cacao::InitializeClassPatcher, cacao::PatcherBase, and cacao::LegacyPatcher.

Definition at line 45 of file PatcherNew.cpp.

bool cacao::Patcher::is_patched ( ) const
inline

Check already patched.

In contrast to check_is_patched this method simply queries a boolean variable whereas check_is_patched inspects to machine code.

See Also
check_is_patched

Definition at line 93 of file PatcherNew.hpp.

bool cacao::Patcher::patch ( )
inline

This a wrapper to set the done flag.

Definition at line 63 of file PatcherNew.hpp.

virtual bool cacao::Patcher::patch_impl ( )
privatepure virtual

This function performs the patching.

Implemented in cacao::InitializeClassPatcher, and cacao::LegacyPatcher.

OStream & cacao::Patcher::print ( OStream OS) const
virtual

print patcher information

Reimplemented in cacao::LegacyPatcher.

Definition at line 49 of file PatcherNew.cpp.

virtual void cacao::Patcher::reposition ( intptr_t  base)
pure virtual

reposition to another base

Implemented in cacao::PatcherBase, and cacao::LegacyPatcher.

Field Documentation

bool cacao::Patcher::done
private

Definition at line 51 of file PatcherNew.hpp.


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