moved some files, starting to design how the classes should work...

_xeroxz
_xeroxz 3 years ago
parent 33d3ded40b
commit 6a2661d410

@ -2,7 +2,8 @@
#include <cstdint>
#include <vector>
#include "lloiff.hpp"
#include <lloiff.hpp>
#include <llosymbol_loader/llosymbol_loader_base.hpp>
namespace llo::s1
{
@ -16,12 +17,19 @@ namespace llo::s1
/// </summary>
std::vector< std::uint8_t > raw_img;
/// <summary>
/// symbol loader used when generating iff...
/// </summary>
llo::s1::symbol_loader_base_t* symbol_loader;
public:
/// <summary>
/// set raw_img to the vector passed by reference...
/// </summary>
/// <param name="image">vector of bytes containing the raw image...</param>
dctor_base_t( std::vector< std::uint8_t > &image ) : raw_img{ image }
explicit dctor_base_t( std::vector< std::uint8_t > &image,
llo::s1::symbol_loader_base_t* symbol_loader = nullptr )
: raw_img{ image }, symbol_loader{ symbol_loader }
{
}

@ -0,0 +1,17 @@
#pragma once
#include <llodctor/llodctor_base.hpp>
namespace llo::s1
{
class dctor_pe_t : public dctor_base_t
{
public:
explicit dctor_pe_t( std::vector< std::uint8_t > &image,
llo::s1::symbol_loader_base_t *symbol_loader = nullptr )
: dctor_base_t( image, symbol_loader )
{
}
bool generate( lloiff_t &iff ) override;
};
} // namespace llo::s1

@ -1,14 +0,0 @@
#pragma once
#include <llodctor_base.hpp>
namespace llo::s1
{
class dctor_pe_t : public dctor_base_t
{
public:
dctor_pe_t( std::vector< std::uint8_t > &image ) : dctor_base_t( image )
{
}
bool generate( lloiff_t &iff ) override;
};
} // namespace llo::s1

@ -0,0 +1,29 @@
#pragma once
#include <cstdint>
#include <lloutils.hpp>
namespace llo
{
class disposition_t
{
llo::utils::hash_t< std::string > iff_name;
llo::utils::hash_t< std::string > section_name;
std::uint32_t offset;
public:
explicit disposition_t( llo::utils::hash_t< std::string > &iff_name,
llo::utils::hash_t< std::string > &section_name, std::uint32_t section_offset )
: iff_name( iff_name ), section_name( section_name ), offset( offset )
{
}
disposition_t( llo::utils::hash_t< std::string > &&iff_name, llo::utils::hash_t< std::string > &&section_name,
std::uint32_t section_offset )
: iff_name( iff_name ), section_name( section_name ), offset( offset )
{
}
llo::utils::hash_t< std::string > get_section() const;
std::uint32_t get_offset() const;
};
} // namespace llo

@ -4,36 +4,27 @@
#include <string>
#include <vector>
#include "lloutils.hpp"
#include <llosymbol/llosymbol_base.hpp>
#include <lloutils.hpp>
namespace llo
{
class lloiff_t
{
public:
explicit lloiff_t( std::string &file_name ) : file_name( file_name )
explicit lloiff_t( std::string &&file_name ) : file_name( file_name )
{
}
class section_offset_t
lloiff_t( std::string &file_name ) : file_name( file_name )
{
public:
llo::utils::hash_t< std::string > section_name;
std::uint32_t offset;
};
class symbol_t
{
public:
llo::utils::hash_t< std::string > symbol_name;
section_offset_t location;
};
}
class section_t
{
public:
llo::utils::hash_t< std::string > section_name;
std::vector< symbol_t > symbols;
std::vector< llo::symbol::symbol_base_t > symbols;
std::vector< std::uint8_t > section_raw;
};
@ -42,6 +33,16 @@ namespace llo
return file_name;
}
std::vector< section_t > get_sections() const
{
return sections;
}
void add_section( section_t &&section )
{
sections.push_back( section );
}
private:
llo::utils::hash_t< std::string > file_name;
std::vector< section_t > sections;

@ -0,0 +1,37 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <llodisposition/llodisposition_types.hpp>
namespace llo::symbol
{
enum class symbol_type_t : std::uint8_t
{
s_invalid,
s_function,
s_data,
s_import,
s_export
};
class symbol_base_t
{
disposition_t disposition;
llo::utils::hash_t< std::string > symbol_name;
std::size_t symbol_size;
public:
explicit symbol_base_t( llo::utils::hash_t< std::string > &&symbol_name, llo::disposition_t &&disposition )
: disposition( disposition ), symbol_name( symbol_name )
{
}
symbol_base_t( llo::utils::hash_t< std::string > &symbol_name, llo::disposition_t &disposition )
: disposition( disposition ), symbol_name( symbol_name )
{
}
virtual symbol_type_t get_type() const;
virtual std::size_t get_size() const;
};
} // namespace llo::symbol

@ -0,0 +1,19 @@
#pragma once
#include <cstdint>
#include <lloiff.hpp>
#include <llosymbol/llosymbol_base.hpp>
#include <string>
#include <vector>
namespace llo::s1
{
class symbol_loader_base_t
{
std::string symbols_path;
public:
symbol_loader_base_t( const std::string &&path ) : symbols_path{ path }
{
}
virtual void load( llo::lloiff_t && ) = 0;
};
} // namespace llo::s1

@ -47,9 +47,21 @@
<ClInclude Include="dependencies\fcml\include\fcml_symbols.h" />
<ClInclude Include="dependencies\fcml\include\fcml_symbols.hpp" />
<ClInclude Include="dependencies\fcml\include\fcml_types.h" />
<ClInclude Include="include\llodctor_base.hpp" />
<ClInclude Include="include\llodctor_pe.hpp" />
<ClInclude Include="include\llodctor\llodctor_base.hpp" />
<ClInclude Include="include\llodctor\llodctor_bin.hpp" />
<ClInclude Include="include\llodctor\llodctor_elf.hpp" />
<ClInclude Include="include\llodctor\llodctor_pe.hpp" />
<ClInclude Include="include\llodisposition\llodisposition_types.hpp" />
<ClInclude Include="include\lloiff.hpp" />
<ClInclude Include="include\llosymbol\llosymbol_base.hpp" />
<ClInclude Include="include\llosymbol\llosymbol_data.hpp" />
<ClInclude Include="include\llosymbol\llosymbol_export.hpp" />
<ClInclude Include="include\llosymbol\llosymbol_function.hpp" />
<ClInclude Include="include\llosymbol\llosymbol_import.hpp" />
<ClInclude Include="include\llosymbol\llosymbol_opaque.hpp" />
<ClInclude Include="include\llosymbol_loader\llosymbol_loader_base.hpp" />
<ClInclude Include="include\llosymbol_loader\llosymbol_loader_map.hpp" />
<ClInclude Include="include\llosymbol_loader\llosymbol_loader_pdb.hpp" />
<ClInclude Include="include\lloutils.hpp" />
</ItemGroup>
<ItemGroup>

@ -15,20 +15,26 @@
<Filter Include="Header Files\fcml">
<UniqueIdentifier>{2d5f480f-e425-4a2c-a285-81d679b2250d}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\llosymbol">
<UniqueIdentifier>{acb72df0-efc5-4108-9db8-850ed74acd41}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\llosymbol_loader">
<UniqueIdentifier>{3c515f99-13ba-45a0-a80e-c7cbff3c5e85}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\llodctor">
<UniqueIdentifier>{9e42261f-c0b7-4650-8d5d-4682ee99948e}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\llodisposition">
<UniqueIdentifier>{3c4da18e-ebe9-4cf0-8edc-025d26da4d13}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\llodctor_base.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\lloiff.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\lloutils.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\llodctor_pe.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="dependencies\fcml\include\fcml_assembler.h">
<Filter>Header Files\fcml</Filter>
</ClInclude>
@ -137,6 +143,48 @@
<ClInclude Include="dependencies\fcml\include\fcml_types.h">
<Filter>Header Files\fcml</Filter>
</ClInclude>
<ClInclude Include="include\llosymbol\llosymbol_base.hpp">
<Filter>Header Files\llosymbol</Filter>
</ClInclude>
<ClInclude Include="include\llosymbol\llosymbol_data.hpp">
<Filter>Header Files\llosymbol</Filter>
</ClInclude>
<ClInclude Include="include\llosymbol\llosymbol_export.hpp">
<Filter>Header Files\llosymbol</Filter>
</ClInclude>
<ClInclude Include="include\llosymbol\llosymbol_function.hpp">
<Filter>Header Files\llosymbol</Filter>
</ClInclude>
<ClInclude Include="include\llosymbol\llosymbol_import.hpp">
<Filter>Header Files\llosymbol</Filter>
</ClInclude>
<ClInclude Include="include\llosymbol\llosymbol_opaque.hpp">
<Filter>Header Files\llosymbol</Filter>
</ClInclude>
<ClInclude Include="include\llosymbol_loader\llosymbol_loader_base.hpp">
<Filter>Header Files\llosymbol_loader</Filter>
</ClInclude>
<ClInclude Include="include\llosymbol_loader\llosymbol_loader_map.hpp">
<Filter>Header Files\llosymbol_loader</Filter>
</ClInclude>
<ClInclude Include="include\llosymbol_loader\llosymbol_loader_pdb.hpp">
<Filter>Header Files\llosymbol_loader</Filter>
</ClInclude>
<ClInclude Include="include\llodctor\llodctor_base.hpp">
<Filter>Header Files\llodctor</Filter>
</ClInclude>
<ClInclude Include="include\llodctor\llodctor_bin.hpp">
<Filter>Header Files\llodctor</Filter>
</ClInclude>
<ClInclude Include="include\llodctor\llodctor_elf.hpp">
<Filter>Header Files\llodctor</Filter>
</ClInclude>
<ClInclude Include="include\llodctor\llodctor_pe.hpp">
<Filter>Header Files\llodctor</Filter>
</ClInclude>
<ClInclude Include="include\llodisposition\llodisposition_types.hpp">
<Filter>Header Files\llodisposition</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include=".clang-format">

@ -1,4 +1,4 @@
#include "..\include\llodctor_pe.hpp"
#include <llodctor/llodctor_pe.hpp>
bool llo::s1::dctor_pe_t::generate( lloiff_t &iff )
{

@ -1,12 +1,14 @@
#define NOMINMAX
#include <fcml_common.hpp>
#include <fcml_intel_dialect.hpp>
#include <llodctor_pe.hpp>
#include <llodctor/llodctor_pe.hpp>
#include <lloiff.hpp>
#include <llosymbol_loader/llosymbol_loader_base.hpp>
int __cdecl main( int argc, const char *argv[] )
{
// read the file path in from cli...
std::string file_name = "test.exe";
// open the image from disk...
std::vector< std::uint8_t > image;
llo::lloiff_t iff( file_name );
@ -14,19 +16,21 @@ int __cdecl main( int argc, const char *argv[] )
std::printf( "> iff name = %s, hash = 0x%p\n", iff.get_name().get_data().c_str(), iff.get_name().get_hash() );
fcml_st_dialect *dialect;
fcml_fn_dialect_init_intel( FCML_INTEL_DIALECT_CF_DEFAULT, &dialect );
fcml_st_disassembler *disassembler;
fcml_fn_disassembler_init( dialect, &disassembler );
fcml_st_disassembler_result result;
fcml_st_disassembler_context context = { 0 };
fcml_fn_disassembler_result_prepare( &result );
if ( !pe_dctor.generate( iff ) )
{
std::printf( "> failed to generate iff...\n" );
return -1;
}
const auto &iff_sections = iff.get_sections();
for ( auto &section : iff_sections )
{
std::printf( "> section name = %s, section uq hash = 0x%p\n", section.section_name.get_data().c_str(),
section.section_name.get_unique_hash() );
for ( auto &symbol : section.symbols )
{
std::printf( "> symbol type = %d, symbol size = 0x%x\n", symbol.get_type(), symbol.get_size() );
}
}
}
Loading…
Cancel
Save