diff --git a/.gitmodules b/.gitmodules index 498d034..54bcaee 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "dependencies/xed"] path = dependencies/xed url = https://github.com/intelxed/xed.git +[submodule "dependencies/cli-parser"] + path = dependencies/cli-parser + url = https://githacks.org/_xeroxz/cli-parser.git diff --git a/dependencies/cli-parser b/dependencies/cli-parser new file mode 160000 index 0000000..1aedaf8 --- /dev/null +++ b/dependencies/cli-parser @@ -0,0 +1 @@ +Subproject commit 1aedaf8bb7f383f54b7cd498767611535526da85 diff --git a/examples/demo/demo.vcxproj b/examples/demo/demo.vcxproj new file mode 100644 index 0000000..f448972 --- /dev/null +++ b/examples/demo/demo.vcxproj @@ -0,0 +1,67 @@ + + + + + Release + x64 + + + + 16.0 + Win32Proj + {934a746a-6706-4d7b-8e20-8d876dfc9bcf} + demo + 10.0 + + + + StaticLibrary + false + ClangCL + true + Unicode + + + + + + + + + + + + false + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + Disabled + + + Console + true + true + true + + + false + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/demo/demo.vcxproj.filters b/examples/demo/demo.vcxproj.filters new file mode 100644 index 0000000..e02497e --- /dev/null +++ b/examples/demo/demo.vcxproj.filters @@ -0,0 +1,26 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + + + Source Files + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/examples/demo/main.cpp b/examples/demo/main.cpp new file mode 100644 index 0000000..070d9df --- /dev/null +++ b/examples/demo/main.cpp @@ -0,0 +1,9 @@ +#include "module.h" +#include + +inline double g_version = 1.0; + +int main() +{ + std::printf( "> g_version = %f, get_version = %f\n", g_version, get_version() ); +} \ No newline at end of file diff --git a/examples/demo/module.cpp b/examples/demo/module.cpp new file mode 100644 index 0000000..a40dcf0 --- /dev/null +++ b/examples/demo/module.cpp @@ -0,0 +1,8 @@ +#include "module.h" + +inline double g_version = 2.0; + +double get_version() +{ + return g_version; +} \ No newline at end of file diff --git a/examples/demo/module.h b/examples/demo/module.h new file mode 100644 index 0000000..722ad81 --- /dev/null +++ b/examples/demo/module.h @@ -0,0 +1,2 @@ +#pragma once +double get_version(); \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index e69de29..40ab3c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -0,0 +1,49 @@ +#define _CRT_SECURE_NO_WARNINGS +#include +#include +#include +#include + +int __cdecl main( int argc, const char *argv[] ) +{ + argparse::argument_parser_t cli_parser( "theodosis.exe", "Theodosis v2.0" ); + cli_parser.add_argument().names( { "-i", "--input" } ).description( ".lib file path..." ).required( "true" ); + cli_parser.enable_help(); + + auto err = cli_parser.parse( argc, argv ); + const auto umtils = xtils::um_t::get_instance(); + + if ( err ) + { + std::cout << err << std::endl; + return -1; + } + + if ( cli_parser.exists( "help" ) ) + { + cli_parser.print_help(); + return 0; + } + + std::vector< std::uint8_t > lib; + umtils->open_binary_file( cli_parser.get< std::string >( "i" ), lib ); + ar::view lib_view( lib.data(), lib.size() ); + + const auto &symbol_map = lib_view.read_symbols(); + for ( auto itr = lib_view.begin(); itr != lib_view.end(); ++itr ) + { + std::printf( "> itr->to_string = %s\n", itr->to_string( lib_view.string_table ).data() ); + + auto coff_img = reinterpret_cast< coff::image_t * >( itr->data() ); + std::printf( "> number of sections = %d\n", coff_img->file_header.num_sections ); + + for ( auto idx = 0u; idx < coff_img->file_header.num_sections; ++idx ) + { + if ( coff_img->get_section( idx )->is_discardable() ) + continue; + + std::printf( "> section name = %s\n", + coff_img->get_section( idx )->name.to_string( coff_img->get_strings() ).data() ); + } + } +} \ No newline at end of file diff --git a/theodosius.sln b/theodosius.sln index e6ba36d..f9f26f9 100644 --- a/theodosius.sln +++ b/theodosius.sln @@ -5,16 +5,27 @@ VisualStudioVersion = 16.0.31321.278 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "theodosius", "theodosius.vcxproj", "{43FB71D4-D87D-4639-A906-14B5797DB1B0}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demo", "examples\demo\demo.vcxproj", "{934A746A-6706-4D7B-8E20-8D876DFC9BCF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {43FB71D4-D87D-4639-A906-14B5797DB1B0}.Debug|x64.ActiveCfg = Debug|x64 {43FB71D4-D87D-4639-A906-14B5797DB1B0}.Debug|x64.Build.0 = Debug|x64 + {43FB71D4-D87D-4639-A906-14B5797DB1B0}.Debug|x86.ActiveCfg = Debug|x64 {43FB71D4-D87D-4639-A906-14B5797DB1B0}.Release|x64.ActiveCfg = Release|x64 {43FB71D4-D87D-4639-A906-14B5797DB1B0}.Release|x64.Build.0 = Release|x64 + {43FB71D4-D87D-4639-A906-14B5797DB1B0}.Release|x86.ActiveCfg = Release|x64 + {934A746A-6706-4D7B-8E20-8D876DFC9BCF}.Debug|x64.ActiveCfg = Release|x64 + {934A746A-6706-4D7B-8E20-8D876DFC9BCF}.Debug|x86.ActiveCfg = Release|x64 + {934A746A-6706-4D7B-8E20-8D876DFC9BCF}.Release|x64.ActiveCfg = Release|x64 + {934A746A-6706-4D7B-8E20-8D876DFC9BCF}.Release|x64.Build.0 = Release|x64 + {934A746A-6706-4D7B-8E20-8D876DFC9BCF}.Release|x86.ActiveCfg = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/theodosius.vcxproj b/theodosius.vcxproj index 01782f2..8c957ad 100644 --- a/theodosius.vcxproj +++ b/theodosius.vcxproj @@ -14,7 +14,78 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 16.0 @@ -25,7 +96,7 @@ - Application + StaticLibrary true v142 Unicode @@ -51,9 +122,11 @@ true + $(ProjectDir)dependencies\xtils;$(ProjectDir)dependencies\linux-pe\includes;$(ProjectDir)dependencies\xed\include\public\xed;$(ProjectDir)dependencies\cli-parser\;$(IncludePath) false + $(ProjectDir)dependencies\xtils;$(ProjectDir)dependencies\linux-pe\includes;$(ProjectDir)dependencies\xed\include\public\xed;$(ProjectDir)dependencies\cli-parser\;$(IncludePath) @@ -61,11 +134,18 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true + stdcpplatest Console true + + true + + + false + @@ -75,6 +155,8 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true + stdcpplatest + true Console @@ -82,6 +164,12 @@ true true + + true + + + false + diff --git a/theodosius.vcxproj.filters b/theodosius.vcxproj.filters index 255c041..aaa6a67 100644 --- a/theodosius.vcxproj.filters +++ b/theodosius.vcxproj.filters @@ -13,6 +13,24 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + {c7926665-f94f-4aa7-8db6-04868b714961} + + + {9fa35ee0-9866-4ed9-996b-a32009ac1e6e} + + + {aa335741-7895-421e-8488-c2c52ff977af} + + + {9c128039-3345-4362-aa51-ca73c9468e24} + + + {f44c90d8-6a59-451a-8596-5bae5018d121} + + + {57f58b85-e562-44a1-a017-dd0237aa0d80} + @@ -20,8 +38,217 @@ - + Resource Files + + Header Files\linux-pe + + + + + Header Files\linux-pe + + + Header Files\linux-pe\nt + + + Header Files\linux-pe\nt + + + Header Files\linux-pe\nt + + + Header Files\linux-pe\nt + + + Header Files\linux-pe\nt\directories + + + Header Files\linux-pe\nt\directories + + + Header Files\linux-pe\nt\directories + + + Header Files\linux-pe\nt\directories + + + Header Files\linux-pe\nt\directories + + + Header Files\linux-pe\nt\directories + + + Header Files\linux-pe\nt\directories + + + Header Files\linux-pe\nt\directories + + + Header Files\linux-pe\nt\directories + + + Header Files\linux-pe\nt\directories + + + Header Files\linux-pe\nt\directories + + + Header Files\linux-pe\coff + + + Header Files\linux-pe\coff + + + Header Files\linux-pe\coff + + + Header Files\linux-pe\coff + + + Header Files\linux-pe\coff + + + Header Files\linux-pe\coff + + + Header Files\linux-pe\coff + + + Header Files\linux-pe\coff + + + Header Files\linux-pe\coff + + + Header Files\linux-pe\coff + + + Header Files\linux-pe\coff\auxiliaries + + + Header Files\linux-pe\coff\auxiliaries + + + Header Files\linux-pe\coff\auxiliaries + + + Header Files\linux-pe\coff\auxiliaries + + + Header Files\linux-pe\coff\auxiliaries + + + Header Files + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + + + Header Files\xed + \ No newline at end of file