From ee73d2fb29593e6b1d15ca71d7d951f95a4d20bf Mon Sep 17 00:00:00 2001 From: _xeroxz Date: Mon, 31 May 2021 23:58:16 -0700 Subject: [PATCH] added clang format, updated main.cpp and removed vmctx deps --- .clang-format | 18 ++++++++++++ dependencies/vmprofiler | 2 +- src/main.cpp | 44 ++---------------------------- src/vmprofiler-cli.vcxproj | 3 ++ src/vmprofiler-cli.vcxproj.filters | 5 ++++ 5 files changed, 29 insertions(+), 43 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..8063c5e --- /dev/null +++ b/.clang-format @@ -0,0 +1,18 @@ +--- +BasedOnStyle: Microsoft +AlignAfterOpenBracket: Align +AllowAllArgumentsOnNextLine: 'true' +AllowAllParametersOfDeclarationOnNextLine: 'true' +AllowShortIfStatementsOnASingleLine: Never +BreakBeforeBraces: Allman +IndentWidth: '4' +Language: Cpp +NamespaceIndentation: All +SpacesInAngles: 'true' +SpacesInCStyleCastParentheses: 'true' +SpacesInContainerLiterals: 'true' +SpacesInParentheses: 'true' +SpacesInSquareBrackets: 'true' +UseTab: Never + +... diff --git a/dependencies/vmprofiler b/dependencies/vmprofiler index b9dc252..4832530 160000 --- a/dependencies/vmprofiler +++ b/dependencies/vmprofiler @@ -1 +1 @@ -Subproject commit b9dc2520fea397d1ff110cabb71786db3375b787 +Subproject commit 4832530dfb2ef7522ed960d3393d44906c42eb74 diff --git a/src/main.cpp b/src/main.cpp index d20db11..01a7f8b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -25,11 +24,7 @@ int __cdecl main(int argc, const char* argv[]) .required(true); parser.add_argument() - .names({ "--vmtrace", "--trace" }) - .description("a vmp2 file generated by a vmtracer"); - - parser.add_argument() - .name("--show-vm-handlers") + .name("--showhandlers") .description("show all vm handlers..."); parser.enable_help(); @@ -124,7 +119,7 @@ int __cdecl main(int argc, const char* argv[]) return -1; } - if (parser.exists("show-vm-handlers")) + if (parser.exists("showhandlers")) { for (auto idx = 0u; idx < vm_handlers.size(); ++idx) { @@ -146,40 +141,5 @@ int __cdecl main(int argc, const char* argv[]) std::printf("=======================================================\n\n"); } } - - if (parser.exists("vmtrace")) - { - std::ifstream vmp2_file( - parser.get("vmtrace").c_str(), std::ios::binary); - - const auto file_size = - std::filesystem::file_size( - parser.get("vmtrace").c_str()); - - const auto file_header = - reinterpret_cast(malloc(file_size)); - - vmp2_file.read((char*)file_header, file_size); - - const auto entry_list = - reinterpret_cast( - reinterpret_cast( - file_header) + file_header->entry_offset); - - std::printf("> module base = 0x%p\n", file_header->module_base); - std::getchar(); - - vm::vmctx_t vmctx( - file_header, - entry_list, - vm_handlers, - module_base, - image_base - ); - - for (auto [virt_instr, log_entry] = vmctx.step(); log_entry && !virt_instr.empty(); - std::tie(virt_instr, log_entry) = vmctx.step()) - std::printf("> %s\n", virt_instr.c_str()); - } std::printf("> finished...\n"); } \ No newline at end of file diff --git a/src/vmprofiler-cli.vcxproj b/src/vmprofiler-cli.vcxproj index ed393c7..3bf9779 100644 --- a/src/vmprofiler-cli.vcxproj +++ b/src/vmprofiler-cli.vcxproj @@ -124,6 +124,9 @@ {d0b6092a-9944-4f24-9486-4b7dae372619} + + + diff --git a/src/vmprofiler-cli.vcxproj.filters b/src/vmprofiler-cli.vcxproj.filters index 766213f..e9bbc2c 100644 --- a/src/vmprofiler-cli.vcxproj.filters +++ b/src/vmprofiler-cli.vcxproj.filters @@ -198,4 +198,9 @@ Header Files + + + Resource Files + + \ No newline at end of file