retdec
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Member Functions | Private Attributes | List of all members
retdec::unpackertool::Plugin Class Referenceabstract

The abstract base of unpacking plugin. More...

#include <plugin.h>

Inheritance diagram for retdec::unpackertool::Plugin:
Inheritance graph
[legend]
Collaboration diagram for retdec::unpackertool::Plugin:
Collaboration graph
[legend]

Classes

struct  Arguments
 
struct  Info
 The structure representing the plugin metadata. More...
 

Public Member Functions

virtual ~Plugin ()=default
 
const Plugin::InfogetInfo () const
 
const Plugin::ArgumentsgetStartupArguments () const
 
PluginExitCode run (const Plugin::Arguments &args)
 
virtual void prepare ()=0
 
virtual void unpack ()=0
 
virtual void cleanup ()=0
 
template<typename... Args>
void log (const Args &... args)
 
template<typename... Args>
void error (const Args &... args)
 

Static Public Member Functions

template<typename T >
static T * instance ()
 

Protected Member Functions

 Plugin ()
 
 Plugin (const Plugin &)
 
Pluginoperator= (const Plugin &)
 

Protected Attributes

Plugin::Info info
 The static info of the plugin. More...
 
Plugin::Arguments startupArgs
 Startup arguments of the plugin. More...
 

Static Private Member Functions

template<typename T , typename... Args>
static void logImpl (Logger &out, const T &data, const Args &... args)
 
static void logImpl (Logger &out)
 

Private Attributes

PluginExitCode _cachedExitCode
 Cached exit code of the plugin for the unpacked file. More...
 

Detailed Description

The abstract base of unpacking plugin.

Represents the unpacking plugin capable of unpacking the specified version of packer. It is an abstract class that is implemented in every single plugin. Plugins are located in unpackertool/plugins/ where every plugin has its own folder. These steps need to be followed to create a new plugin:

  1. Create new folder for your plugin in unpackertool/plugins/ and add 'add_subdirectory(YOUR_PLUGIN)' into unpackertool/plugins/CMakeLists.txt.
  2. Create CMakeLists.txt in your new folder based on the template in unpackertool/plugins/example/.
  3. Subclass Plugin class while
  4. Put Plugin<YOUR_PLUGIN_CLASS>::instance() into PluginMgr::plugins in unpackertool/plugin_mgr.cpp.

Constructor & Destructor Documentation

◆ ~Plugin()

virtual retdec::unpackertool::Plugin::~Plugin ( )
virtualdefault

◆ Plugin() [1/2]

retdec::unpackertool::Plugin::Plugin ( )
inlineprotected

◆ Plugin() [2/2]

retdec::unpackertool::Plugin::Plugin ( const Plugin )
protected

Member Function Documentation

◆ cleanup()

virtual void retdec::unpackertool::Plugin::cleanup ( )
pure virtual

Pure virtual method that performs freeing of all owned resources.

Implemented in retdec::unpackertool::upx::UpxPlugin, retdec::unpackertool::mpress::MpressPlugin, and retdec::unpackertool::example::ExamplePlugin.

◆ error()

template<typename... Args>
void retdec::unpackertool::Plugin::error ( const Args &...  args)
inline

Prints the error message on the standard error output prepending the message with '[ERROR] [PLUGIN-NAME]'. End of line is automatically inserted at the end of the message.

Template Parameters
ArgsTypes of data to print.
Parameters
argsData to print.

◆ getInfo()

const Plugin::Info* retdec::unpackertool::Plugin::getInfo ( ) const
inline

Returns the static info of the plugin.

Returns
Plugin::Info structure containing static plugin info.

◆ getStartupArguments()

const Plugin::Arguments* retdec::unpackertool::Plugin::getStartupArguments ( ) const
inline

Returns the startup arguments of the plugin.

Returns
Plugin::Arguments structure containing startup arguments of the plugin.

◆ instance()

template<typename T >
static T* retdec::unpackertool::Plugin::instance ( )
inlinestatic

Returns the instance of specific type of plugin. This should be the only way how plugin instances are obtained.

Returns
Plugin instance.

◆ log()

template<typename... Args>
void retdec::unpackertool::Plugin::log ( const Args &...  args)
inline

Prints the message on the standard output prepending the message with '[PLUGIN-NAME]'. End of line is automatically inserted at the end of the message.

Template Parameters
ArgsTypes of data to print.
Parameters
argsData to print.

◆ logImpl() [1/2]

static void retdec::unpackertool::Plugin::logImpl ( Logger out)
inlinestaticprivate

◆ logImpl() [2/2]

template<typename T , typename... Args>
static void retdec::unpackertool::Plugin::logImpl ( Logger out,
const T &  data,
const Args &...  args 
)
inlinestaticprivate

◆ operator=()

Plugin& retdec::unpackertool::Plugin::operator= ( const Plugin )
protected

◆ prepare()

virtual void retdec::unpackertool::Plugin::prepare ( )
pure virtual

Pure virtual method that performs preparation of unpacking.

Implemented in retdec::unpackertool::upx::UpxPlugin, retdec::unpackertool::mpress::MpressPlugin, and retdec::unpackertool::example::ExamplePlugin.

◆ run()

PluginExitCode retdec::unpackertool::Plugin::run ( const Plugin::Arguments args)
inline

Runs the plugin and all its phases. Also sets the startup arguments of the plugin.

Parameters
argsThe plugin arguments. See Plugin::Info.
Returns
Exit code of the plugin.

◆ unpack()

virtual void retdec::unpackertool::Plugin::unpack ( )
pure virtual

Pure virtual method that performs the unpacking in the specific plugins.

Implemented in retdec::unpackertool::upx::UpxPlugin, retdec::unpackertool::mpress::MpressPlugin, and retdec::unpackertool::example::ExamplePlugin.

Member Data Documentation

◆ _cachedExitCode

PluginExitCode retdec::unpackertool::Plugin::_cachedExitCode
private

Cached exit code of the plugin for the unpacked file.

◆ info

Plugin::Info retdec::unpackertool::Plugin::info
protected

The static info of the plugin.

◆ startupArgs

Plugin::Arguments retdec::unpackertool::Plugin::startupArgs
protected

Startup arguments of the plugin.


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