From a7abd2055ca720709e5ac925aaf9cbff3304f04c Mon Sep 17 00:00:00 2001 From: _xeroxz Date: Thu, 24 Jun 2021 20:47:36 -0700 Subject: [PATCH] added dirs for cpp files... working on lib dctor and pe dctor... --- include/llodctor/llodctor_lib.hpp | 6 ++++- include/llodctor/llodctor_pe.hpp | 11 +++++++- .../llosymbol_loader/llosymbol_loader_map.hpp | 7 +---- llo-s1.vcxproj | 8 +++--- llo-s1.vcxproj.filters | 27 ++++++++++++------- {include => src}/llodctor/llodctor_lib.cpp | 1 + src/{ => llodctor}/llodctor_pe.cpp | 5 ---- .../llodisposition/llodisposition_types.cpp | 2 +- .../llosymbol_loader/llosymbol_loader_map.cpp | 1 + src/main.cpp | 15 +++++++---- 10 files changed, 51 insertions(+), 32 deletions(-) rename {include => src}/llodctor/llodctor_lib.cpp (90%) rename src/{ => llodctor}/llodctor_pe.cpp (79%) rename {include => src}/llodisposition/llodisposition_types.cpp (80%) rename {include => src}/llosymbol_loader/llosymbol_loader_map.cpp (92%) diff --git a/include/llodctor/llodctor_lib.hpp b/include/llodctor/llodctor_lib.hpp index a6543c9..39969f1 100644 --- a/include/llodctor/llodctor_lib.hpp +++ b/include/llodctor/llodctor_lib.hpp @@ -12,14 +12,18 @@ namespace llo::s1 { const auto lib_header = reinterpret_cast< const ar::header_t * >( image.data() ); auto lib_entry = &lib_header->first_entry; + ar::entry_t *string_table = nullptr; do { + if ( lib_entry->is_string_table() ) + string_table = ( ar::entry_t * )lib_entry; + // skip these since we dont want to extract them... they are not obj files... if ( lib_entry->is_string_table() || lib_entry->is_symbol_table() ) continue; - std::printf( "> object name = %s\n", lib_entry->to_string()); + std::printf( "> object name = %s\n", lib_entry->to_string( string_table ) ); } while ( ( lib_entry = lib_header->first_entry.next() ) ); } void generate( lloiff_t &iff ) override; diff --git a/include/llodctor/llodctor_pe.hpp b/include/llodctor/llodctor_pe.hpp index 770fdd5..ee92895 100644 --- a/include/llodctor/llodctor_pe.hpp +++ b/include/llodctor/llodctor_pe.hpp @@ -1,16 +1,25 @@ #pragma once -#include #include +#include namespace llo::s1 { class dctor_pe_t : public dctor_base_t { + win::dos_header_t *dos_header; + win::section_header_t *sections; + std::uint32_t section_count; + std::uint32_t entry_point; + 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 ) { + dos_header = reinterpret_cast< win::dos_header_t * >( raw_img.data() ); + sections = dos_header->get_nt_headers()->get_sections(); + section_count = dos_header->get_nt_headers()->file_header.num_sections; + entry_point = dos_header->get_nt_headers()->optional_header.entry_point; } void generate( lloiff_t &iff ) override; diff --git a/include/llosymbol_loader/llosymbol_loader_map.hpp b/include/llosymbol_loader/llosymbol_loader_map.hpp index 379c00a..2dab180 100644 --- a/include/llosymbol_loader/llosymbol_loader_map.hpp +++ b/include/llosymbol_loader/llosymbol_loader_map.hpp @@ -5,14 +5,9 @@ namespace llo::s1 class symbol_loader_map_t : public symbol_loader_base_t { public: - explicit symbol_loader_map_t( std::string &&path ) : symbol_loader_base_t( path ) + explicit symbol_loader_map_t( const std::string &path ) : symbol_loader_base_t( path ) { } - - symbol_loader_map_t( std::string &path ) : symbol_loader_base_t( path ) - { - } - void load( llo::lloiff_t &iff ) override; }; } // namespace llo::s1 \ No newline at end of file diff --git a/llo-s1.vcxproj b/llo-s1.vcxproj index efaa38e..1ed8d22 100644 --- a/llo-s1.vcxproj +++ b/llo-s1.vcxproj @@ -105,10 +105,10 @@ - - - - + + + + diff --git a/llo-s1.vcxproj.filters b/llo-s1.vcxproj.filters index 981dca8..b49619f 100644 --- a/llo-s1.vcxproj.filters +++ b/llo-s1.vcxproj.filters @@ -42,6 +42,15 @@ {98d78f45-088b-441d-b20f-f4b2e7cec972} + + {d76f131b-ba41-4e64-918a-03c5a526c281} + + + {9bd2b0b0-4ae2-4d9d-8620-4b596f84d20d} + + + {4370901a-12c1-43ce-883a-6a6c3f48845a} + @@ -309,9 +318,6 @@ - - Source Files - Source Files @@ -324,14 +330,17 @@ Header Files\fcml - - Source Files + + Source Files\llodctor - - Source Files + + Source Files\llosymbol_loader - - Source Files + + Source Files\llodctor + + + Source Files\llodisposition \ No newline at end of file diff --git a/include/llodctor/llodctor_lib.cpp b/src/llodctor/llodctor_lib.cpp similarity index 90% rename from include/llodctor/llodctor_lib.cpp rename to src/llodctor/llodctor_lib.cpp index a4841f3..bcd6c40 100644 --- a/include/llodctor/llodctor_lib.cpp +++ b/src/llodctor/llodctor_lib.cpp @@ -2,4 +2,5 @@ void llo::s1::dctor_lib_t::generate( lloiff_t &iff ) { + // TODO } \ No newline at end of file diff --git a/src/llodctor_pe.cpp b/src/llodctor/llodctor_pe.cpp similarity index 79% rename from src/llodctor_pe.cpp rename to src/llodctor/llodctor_pe.cpp index d01a5ad..192b7a0 100644 --- a/src/llodctor_pe.cpp +++ b/src/llodctor/llodctor_pe.cpp @@ -2,11 +2,6 @@ void llo::s1::dctor_pe_t::generate( lloiff_t &iff ) { - auto dos_header = reinterpret_cast< win::dos_header_t * >( raw_img.data() ); - auto sections = dos_header->get_nt_headers()->get_sections(); - auto section_count = dos_header->get_nt_headers()->file_header.num_sections; - auto entry_point = dos_header->get_nt_headers()->optional_header.entry_point; - // lift section information to iff... for ( auto idx = 0u; idx < section_count; ++idx ) { diff --git a/include/llodisposition/llodisposition_types.cpp b/src/llodisposition/llodisposition_types.cpp similarity index 80% rename from include/llodisposition/llodisposition_types.cpp rename to src/llodisposition/llodisposition_types.cpp index 5450668..bde7350 100644 --- a/include/llodisposition/llodisposition_types.cpp +++ b/src/llodisposition/llodisposition_types.cpp @@ -4,5 +4,5 @@ std::shared_ptr< llo::disposition_t > llo::disposition_t::make( const llo::utils const llo::utils::hash_t< std::string > §ion_name, std::uint32_t section_offset ) { - return std::make_shared< disposition_t >( iff_name, section_name, section_offset ); + return std::make_shared< llo::disposition_t >( iff_name, section_name, section_offset ); } \ No newline at end of file diff --git a/include/llosymbol_loader/llosymbol_loader_map.cpp b/src/llosymbol_loader/llosymbol_loader_map.cpp similarity index 92% rename from include/llosymbol_loader/llosymbol_loader_map.cpp rename to src/llosymbol_loader/llosymbol_loader_map.cpp index eeeaf48..6c7e756 100644 --- a/include/llosymbol_loader/llosymbol_loader_map.cpp +++ b/src/llosymbol_loader/llosymbol_loader_map.cpp @@ -2,4 +2,5 @@ void llo::s1::symbol_loader_map_t::load( llo::lloiff_t &iff ) { + // TODO } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 0524b99..2e00638 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -59,6 +59,11 @@ int __cdecl main( int argc, const char *argv[] ) // TODO: // symbol_loader = std::make_shared< llo::s1::symbol_loader_pdb_t >( symbols_file ); } + else + { + std::printf( "[!] unknown symbol file extension: %s\n", symbols_file.extension().c_str() ); + return -1; + } } std::shared_ptr< llo::s1::dctor_base_t > file_dctor = nullptr; @@ -69,15 +74,15 @@ int __cdecl main( int argc, const char *argv[] ) { file_dctor = std::make_shared< llo::s1::dctor_pe_t >( image, symbol_loader.get() ); } - else if ( file_path.extension().compare( ".o" ) ) - { - // TODO: elf file format... - return -1; - } else if ( file_path.extension().compare( ".lib" ) ) { file_dctor = std::make_shared< llo::s1::dctor_lib_t >( image, symbol_loader.get() ); } + else if ( file_path.extension().compare( ".o" ) || file_path.extension().compare( ".so" ) ) + { + // TODO: + // file_dctor = std::make_shared< llo::s1::dctor_elf_t >( image, symbol_loader.get() ); + } else { std::printf( "[!] unknown file extension: %s\n", file_path.extension().c_str() );