|
|
|
#pragma once
|
|
|
|
#include <coff/archive.hpp>
|
|
|
|
#include <coff/image.hpp>
|
|
|
|
#include <theo/engine/iff.hpp>
|
|
|
|
#include <theo/engine/swapchain.hpp>
|
|
|
|
|
|
|
|
namespace theo
|
|
|
|
{
|
|
|
|
class obf_pass_t
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
obf_pass_t()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void obfuscate( theo::iff_t & ) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class obf_pass_section_t : public obf_pass_t
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
obf_pass_section_t()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void obfuscate( theo::iff_t::section_t &iff_section ) = 0;
|
|
|
|
|
|
|
|
void obfuscate( theo::iff_t &iff ) override
|
|
|
|
{
|
|
|
|
std::for_each( iff.sections.begin(), iff.sections.end(),
|
|
|
|
[ & ]( theo::iff_t::section_t &iff_section ) { obfuscate( iff_section ); } );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class obf_pass_deadstore_t : public obf_pass_section_t
|
|
|
|
{
|
|
|
|
using callback_t = std::function< void( theo::iff_t::section_t &iff_section ) >;
|
|
|
|
const callback_t callback;
|
|
|
|
|
|
|
|
public:
|
|
|
|
obf_pass_deadstore_t( const callback_t &callback ) : callback( callback )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void obfuscate( theo::iff_t::section_t &iff_section ) override
|
|
|
|
{
|
|
|
|
// TODO impliment deadstore here...
|
|
|
|
callback( iff_section );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class engine_t
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit engine_t( const std::vector< std::uint8_t > &lib_img );
|
|
|
|
void push( std::shared_ptr< obf_pass_t > obf_pass );
|
|
|
|
void pop();
|
|
|
|
void run();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector< std::shared_ptr< obf_pass_t > > obf_passes;
|
|
|
|
std::shared_ptr< theo::swapchain_t > swapchain;
|
|
|
|
};
|
|
|
|
} // namespace theo
|