From 1ce9a78e69a9fb0d44a476f39e79a8125853cf92 Mon Sep 17 00:00:00 2001 From: _xeroxz Date: Wed, 23 Jun 2021 23:53:04 -0700 Subject: [PATCH] removed shitmake, added visual studios --- .clang-format | 4 +- .gitignore | 49 ------------------ .gitmodules | 12 ----- CMakeLists.txt | 4 -- demo/CMakeLists.txt | 14 ----- demo/dependencies/cli-parser | 1 - demo/dependencies/linux-pe | 1 - demo/src/main.cpp | 30 ----------- dependencies/mbuild | 1 - dependencies/xed | 1 - include/deconstructor.hpp | 10 ---- include/llodctor_base.cpp | 6 +++ include/llodctor_base.hpp | 15 ++++++ include/llodctor_pe.hpp | 10 ++++ include/lloiff.hpp | 49 ++++++++++++++++++ include/lloutils.hpp | 52 +++++++++++++++++++ llo-s1.sln | 25 +++++++++ llo-s1.vcxproj | 99 ++++++++++++++++++++++++++++++++++++ llo-s1.vcxproj.filters | 46 +++++++++++++++++ llo-s1.vcxproj.user | 4 ++ src/deconstructor.cpp | 0 src/llodctor_pe.cpp | 6 +++ src/main.cpp | 17 +++++++ 23 files changed, 331 insertions(+), 125 deletions(-) delete mode 100644 .gitignore delete mode 100644 .gitmodules delete mode 100644 CMakeLists.txt delete mode 100644 demo/CMakeLists.txt delete mode 160000 demo/dependencies/cli-parser delete mode 160000 demo/dependencies/linux-pe delete mode 100644 demo/src/main.cpp delete mode 160000 dependencies/mbuild delete mode 160000 dependencies/xed delete mode 100644 include/deconstructor.hpp create mode 100644 include/llodctor_base.cpp create mode 100644 include/llodctor_base.hpp create mode 100644 include/llodctor_pe.hpp create mode 100644 include/lloiff.hpp create mode 100644 include/lloutils.hpp create mode 100644 llo-s1.sln create mode 100644 llo-s1.vcxproj create mode 100644 llo-s1.vcxproj.filters create mode 100644 llo-s1.vcxproj.user delete mode 100644 src/deconstructor.cpp create mode 100644 src/llodctor_pe.cpp create mode 100644 src/main.cpp diff --git a/.clang-format b/.clang-format index faf0576..8063c5e 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,4 @@ ---- +--- BasedOnStyle: Microsoft AlignAfterOpenBracket: Align AllowAllArgumentsOnNextLine: 'true' @@ -15,4 +15,4 @@ SpacesInParentheses: 'true' SpacesInSquareBrackets: 'true' UseTab: Never -... \ No newline at end of file +... diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 6da7216..0000000 --- a/.gitignore +++ /dev/null @@ -1,49 +0,0 @@ -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - -CMakeLists.txt.user -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -Makefile -cmake_install.cmake -install_manifest.txt -compile_commands.json -CTestTestfile.cmake -_deps - -build/ - -dependencies/mbuild/ -dependencies/xed/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 0832fe2..0000000 --- a/.gitmodules +++ /dev/null @@ -1,12 +0,0 @@ -[submodule "dependencies/xed"] - path = dependencies/xed - url = https://github.com/intelxed/xed.git -[submodule "dependencies/mbuild"] - path = dependencies/mbuild - url = https://github.com/intelxed/mbuild.git -[submodule "demo/dependencies/linux-pe"] - path = demo/dependencies/linux-pe - url = https://github.com/can1357/linux-pe.git -[submodule "demo/dependencies/cli-parser"] - path = demo/dependencies/cli-parser - url = https://githacks.org/_xeroxz/cli-parser.git diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 1282b01..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 3.0) -project(llo-stage-one) -add_subdirectory(demo/) -add_library(${PROJECT_NAME} src/deconstructor.cpp) \ No newline at end of file diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt deleted file mode 100644 index 1185f49..0000000 --- a/demo/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.0) -project(llo-stage-one-demo) - -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_FLAGS -Winvalid-constexpr) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - -if(MSVC) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17") -endif(MSVC) - -include_directories(dependencies/cli-parser/ dependencies/linux-pe/includes/) -add_executable(${PROJECT_NAME} src/main.cpp) \ No newline at end of file diff --git a/demo/dependencies/cli-parser b/demo/dependencies/cli-parser deleted file mode 160000 index 1aedaf8..0000000 --- a/demo/dependencies/cli-parser +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1aedaf8bb7f383f54b7cd498767611535526da85 diff --git a/demo/dependencies/linux-pe b/demo/dependencies/linux-pe deleted file mode 160000 index db2b7af..0000000 --- a/demo/dependencies/linux-pe +++ /dev/null @@ -1 +0,0 @@ -Subproject commit db2b7af6e6beae1bc391ff8f8e5c97b963dc3258 diff --git a/demo/src/main.cpp b/demo/src/main.cpp deleted file mode 100644 index 0289977..0000000 --- a/demo/src/main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include "cli-parser.hpp" -#include "linuxpe" - -int main(int argc, const char** argv) -{ - argparse::argument_parser_t cli_parser("llo-stage-one demo", "CLI, LLO, stage one demo..."); - cli_parser - .add_argument() - .names({"-i", "--input"}) - .required(true) - .description("input file, must be a file format supported by stage one modules..."); - - cli_parser.enable_help(); - auto err = cli_parser.parse(argc, argv); - - if (err) - { - std::cout << err << std::endl; - return -1; - } - - if ( cli_parser.exists( "help" ) ) - { - cli_parser.print_help(); - return 0; - } - - // win::dos_header_t image_dos; -} \ No newline at end of file diff --git a/dependencies/mbuild b/dependencies/mbuild deleted file mode 160000 index 09b6654..0000000 --- a/dependencies/mbuild +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 09b6654be0c52bf1df44e88c88b411a67b624cbd diff --git a/dependencies/xed b/dependencies/xed deleted file mode 160000 index 428712c..0000000 --- a/dependencies/xed +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 428712c28e831573579b7f749db63d3a58dcdbd9 diff --git a/include/deconstructor.hpp b/include/deconstructor.hpp deleted file mode 100644 index 06308fb..0000000 --- a/include/deconstructor.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#include - -namespace llo::s1 -{ - class dctor_base_t - { - public: - - }; -} \ No newline at end of file diff --git a/include/llodctor_base.cpp b/include/llodctor_base.cpp new file mode 100644 index 0000000..563ca8b --- /dev/null +++ b/include/llodctor_base.cpp @@ -0,0 +1,6 @@ +#include "llodctor_base.hpp" + +std::shared_ptr< llo::s1::dctor_base_t > llo::s1::dctor_base_t::begin( std::vector< std::uint8_t > &image ) +{ + return nullptr; +} \ No newline at end of file diff --git a/include/llodctor_base.hpp b/include/llodctor_base.hpp new file mode 100644 index 0000000..d6b7f07 --- /dev/null +++ b/include/llodctor_base.hpp @@ -0,0 +1,15 @@ +#include +#include + +#include "lloiff.hpp" + +namespace llo::s1 +{ + class dctor_base_t + { + std::vector< std::uint8_t > raw_img; + public: + static std::shared_ptr begin( std::vector< std::uint8_t > &image ); + virtual bool generate( lloiff_t &iff ); + }; +} // namespace llo::s1 \ No newline at end of file diff --git a/include/llodctor_pe.hpp b/include/llodctor_pe.hpp new file mode 100644 index 0000000..e357d85 --- /dev/null +++ b/include/llodctor_pe.hpp @@ -0,0 +1,10 @@ +#include "llodctor_base.hpp" + +namespace llo::s1 +{ + class dctor_pe_t : public dctor_base_t + { + public: + bool generate( lloiff_t &iff ) override; + }; +} // namespace llo::s1 \ No newline at end of file diff --git a/include/lloiff.hpp b/include/lloiff.hpp new file mode 100644 index 0000000..f3ed851 --- /dev/null +++ b/include/lloiff.hpp @@ -0,0 +1,49 @@ +#include +#include +#include +#include + +#include "lloutils.hpp" + +namespace llo +{ + class lloiff_t + { + public: + explicit lloiff_t( std::string &file_name ) + { + this->file_name.make( file_name ); + } + + class section_offset_t + { + 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< std::uint8_t > section_raw; + }; + + static std::shared_ptr< lloiff_t > begin( std::string &file_name ) + { + return std::make_shared< lloiff_t >( file_name ); + } + + private: + llo::utils::hash_t< std::string > file_name; + std::vector< section_t > sections; + }; +} // namespace llo \ No newline at end of file diff --git a/include/lloutils.hpp b/include/lloutils.hpp new file mode 100644 index 0000000..a762f19 --- /dev/null +++ b/include/lloutils.hpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include + +namespace llo::utils +{ + template < class number_t > number_t generate_random_number( const number_t minimum, const number_t maximum ) + { + static_assert( std::is_arithmetic_v< number_t >, "type is not arithmetic..." ); + + std::random_device rd; + std::mt19937 mt( rd() ); + std::uniform_real_distribution< double > dist( 1.0, 10.0 ); + return dist( mt ); + } + + template < class T > class hash_t + { + std::size_t hash_result; + const T data; + + public: + hash_t() + { + } + + hash_t( const T &data ) : data{ data } + { + auto random_num = + llo::utils::generate_random_number< std::uint64_t >( 0, std::numeric_limits< std::uint64_t >::max() ); + + this->hash_result = std::hash< T >{}( data ) + std::hash< std::uint64_t >{}( random_num ); + } + + static std::shared_ptr< hash_t > make( const T &data ) + { + return std::make_shared< hash_t >( data ); + } + + T &get_data() const + { + return data; + } + + std::size_t get_hash() const + { + return hash_result; + } + }; +} // namespace llo::utils \ No newline at end of file diff --git a/llo-s1.sln b/llo-s1.sln new file mode 100644 index 0000000..68d7650 --- /dev/null +++ b/llo-s1.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31321.278 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "llo-s1", "llo-s1.vcxproj", "{CAA703F1-D4E7-4EA6-95F4-7F32D86600AE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CAA703F1-D4E7-4EA6-95F4-7F32D86600AE}.Debug|x64.ActiveCfg = Debug|x64 + {CAA703F1-D4E7-4EA6-95F4-7F32D86600AE}.Debug|x64.Build.0 = Debug|x64 + {CAA703F1-D4E7-4EA6-95F4-7F32D86600AE}.Release|x64.ActiveCfg = Release|x64 + {CAA703F1-D4E7-4EA6-95F4-7F32D86600AE}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {736A1595-59D0-4743-8E38-2FF832200232} + EndGlobalSection +EndGlobal diff --git a/llo-s1.vcxproj b/llo-s1.vcxproj new file mode 100644 index 0000000..463586c --- /dev/null +++ b/llo-s1.vcxproj @@ -0,0 +1,99 @@ + + + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + 16.0 + Win32Proj + {caa703f1-d4e7-4ea6-95f4-7f32d86600ae} + llos1 + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + true + + + false + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpplatest + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/llo-s1.vcxproj.filters b/llo-s1.vcxproj.filters new file mode 100644 index 0000000..f6945c3 --- /dev/null +++ b/llo-s1.vcxproj.filters @@ -0,0 +1,46 @@ + + + + + {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 + + + {f02de5e5-e0f4-4244-a05f-45e095918bff} + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/llo-s1.vcxproj.user b/llo-s1.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/llo-s1.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/deconstructor.cpp b/src/deconstructor.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/llodctor_pe.cpp b/src/llodctor_pe.cpp new file mode 100644 index 0000000..88edb2a --- /dev/null +++ b/src/llodctor_pe.cpp @@ -0,0 +1,6 @@ +#include "..\include\llodctor_pe.hpp" + +bool llo::s1::dctor_pe_t::generate( lloiff_t &iff ) +{ + return false; +} diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..833267b --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,17 @@ +#include "../include/llodctor_pe.hpp" +#include "../include/lloiff.hpp" + +int main() +{ + std::string file_name = "test.exe"; + std::vector< std::uint8_t > image; + + llo::lloiff_t iif( file_name ); + auto pe_dctor = llo::s1::dctor_base_t::begin( image ); + + if ( !pe_dctor->generate( iif ) ) + { + std::printf( "> failed to generate iff...\n" ); + return -1; + } +} \ No newline at end of file