forked from IDontCode/Theodosius
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.7 KiB
54 lines
1.7 KiB
4 years ago
|
#include <coff/archive.hpp>
|
||
|
#include <coff/image.hpp>
|
||
|
#include <theo/obf_pass.hpp>
|
||
|
|
||
|
namespace theo
|
||
|
{
|
||
|
class engine_t
|
||
|
{
|
||
|
class swapchain_t
|
||
|
{
|
||
|
std::vector< std::uint8_t > front, back;
|
||
|
std::vector< std::vector< std::uint8_t > > objs;
|
||
|
|
||
|
public:
|
||
|
class iff_t
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// swapchain_t is the only one who needs to call iff_t::flush...
|
||
|
/// so its a friend class... flush is also private...
|
||
|
/// </summary>
|
||
|
friend class swapchain_t;
|
||
|
|
||
|
public:
|
||
|
struct section_t
|
||
|
{
|
||
|
coff::section_header_t header;
|
||
|
std::vector< std::pair< std::uint32_t, coff::symbol_t > > symbols;
|
||
|
};
|
||
|
|
||
|
explicit iff_t( coff::image_t *img );
|
||
|
std::vector< section_t > sections;
|
||
|
|
||
|
private:
|
||
|
/// <summary>
|
||
|
/// flush changes from "sections" back to img...
|
||
|
/// </summary>
|
||
|
void flush();
|
||
|
coff::image_t *img;
|
||
|
};
|
||
|
explicit swapchain_t( const std::vector< std::uint8_t > &img );
|
||
|
std::shared_ptr< swapchain_t > make( const std::vector< std::uint8_t > &img );
|
||
|
void swap( std::vector< iff_t > &iffs );
|
||
|
};
|
||
|
|
||
|
public:
|
||
|
explicit engine_t( const std::vector< std::uint8_t > &lib_img );
|
||
|
void add_pass( const obf_pass_t &pass );
|
||
|
void run( std::vector< std::uint8_t > &result );
|
||
|
|
||
|
private:
|
||
|
swapchain_t swap;
|
||
|
std::vector< theo::obf_pass_t > passes;
|
||
|
};
|
||
|
} // namespace theo
|