added lib dctor... beginning work on symbol loader(s)...

_xeroxz
_xeroxz 3 years ago
parent fa2bbf6768
commit b3a0af913d

@ -1,2 +1,3 @@
# stage-one
this is a draft showing how stage one might be implimented using c++ inheritance. please refer to main.cpp for more.

@ -0,0 +1,5 @@
#include <llodctor/llodctor_lib.hpp>
void llo::s1::dctor_lib_t::generate( lloiff_t &iff )
{
}

@ -0,0 +1,27 @@
#include <coff/archive.hpp>
#include <llodctor/llodctor_base.hpp>
namespace llo::s1
{
class dctor_lib_t : public dctor_base_t
{
public:
explicit dctor_lib_t( const std::vector< std::uint8_t > &image,
llo::s1::symbol_loader_base_t *symbol_loader = nullptr )
: dctor_base_t( image, symbol_loader )
{
const auto lib_header = reinterpret_cast< const ar::header_t * >( image.data() );
auto lib_entry = &lib_header->first_entry;
do
{
// 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());
} while ( ( lib_entry = lib_header->first_entry.next() ) );
}
void generate( lloiff_t &iff ) override;
};
} // namespace llo::s1

@ -9,7 +9,7 @@ namespace llo
public:
explicit disposition_t( const llo::utils::hash_t< std::string > &iff_name,
const llo::utils::hash_t< std::string > &section_name, std::uint32_t section_offset )
: iff_name( iff_name ), section_name( section_name ), offset( offset )
: iff_name( iff_name ), section_name( section_name ), offset( section_offset )
{
}

@ -105,6 +105,7 @@
<ClCompile Include="dependencies\fcml\include\fcml_gas_mnemonics.cpp" />
<ClCompile Include="dependencies\fcml\include\fcml_intel_mnemonics.cpp" />
<ClCompile Include="dependencies\fcml\include\fcml_registers.cpp" />
<ClCompile Include="include\llodctor\llodctor_lib.cpp" />
<ClCompile Include="include\llodisposition\llodisposition_types.cpp" />
<ClCompile Include="include\llosymbol_loader\llosymbol_loader_map.cpp" />
<ClCompile Include="src\llodctor_pe.cpp" />
@ -163,6 +164,8 @@
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>$(ProjectDir)dependencies\fcml\fcml.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateMapFile>true</GenerateMapFile>
<MapExports>true</MapExports>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -181,6 +184,8 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>$(ProjectDir)dependencies\fcml\fcml.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateMapFile>true</GenerateMapFile>
<MapExports>true</MapExports>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

@ -330,5 +330,8 @@
<ClCompile Include="include\llodisposition\llodisposition_types.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="include\llodctor\llodctor_lib.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

@ -1,4 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommandArguments>-i llo-s1.exe -s llo-s1.map</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommandArguments>-i llo-s1.exe -s llo-s1.map</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

@ -17,15 +17,18 @@ void llo::s1::dctor_pe_t::generate( lloiff_t &iff )
// check to see if this section contains the entry point of the module...
if ( entry_point >= sections[ idx ].virtual_address &&
entry_point < sections[ idx ].virtual_address + sections[ idx ].virtual_size )
{
// lift entry point to iff...
iff.entry =
llo::disposition_t::make( iff.name, section_name, sections[ idx ].virtual_address - entry_point );
llo::disposition_t::make( iff.name, section_name, ( entry_point - sections[ idx ].virtual_address ) );
}
// copy the sections raw bytes...
section.raw.insert( section.raw.begin(), raw_img.data(), raw_img.data() + sections[ idx ].ptr_raw_data );
iff.sections.push_back( section );
}
// run symbol loader pass... this could be pdb, map, etc...
if ( symbol_loader )
symbol_loader->load( iff );
}

@ -3,6 +3,7 @@
#include <cli-parser.hpp>
#include <filesystem>
#include <llodctor/llodctor_lib.hpp>
#include <llodctor/llodctor_pe.hpp>
#include <llosymbol_loader/llosymbol_loader_map.hpp>
@ -73,6 +74,10 @@ int __cdecl main( int argc, const char *argv[] )
// 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
{
std::printf( "[!] unknown file extension: %s\n", file_path.extension().c_str() );
@ -83,7 +88,7 @@ int __cdecl main( int argc, const char *argv[] )
file_dctor->generate( iff );
std::printf( "> number of sections = %d\n", iff.sections.size() );
if ( iff.entry )
if ( iff.entry.get() )
std::printf( "> entry section name = %s, section offest = 0x%x\n", iff.entry->section_name.get_data().c_str(),
iff.entry->offset );

Loading…
Cancel
Save