added clang format, updated main.cpp and removed vmctx deps

merge-requests/1/head
_xeroxz 4 years ago
parent 0a8a67a311
commit ee73d2fb29

@ -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
...

@ -1 +1 @@
Subproject commit b9dc2520fea397d1ff110cabb71786db3375b787 Subproject commit 4832530dfb2ef7522ed960d3393d44906c42eb74

@ -4,7 +4,6 @@
#include <filesystem> #include <filesystem>
#include <vmp2.hpp> #include <vmp2.hpp>
#include <vmctx.h>
#include <vmprofiler.hpp> #include <vmprofiler.hpp>
#include <cli-parser.hpp> #include <cli-parser.hpp>
#include <xtils.hpp> #include <xtils.hpp>
@ -25,11 +24,7 @@ int __cdecl main(int argc, const char* argv[])
.required(true); .required(true);
parser.add_argument() parser.add_argument()
.names({ "--vmtrace", "--trace" }) .name("--showhandlers")
.description("a vmp2 file generated by a vmtracer");
parser.add_argument()
.name("--show-vm-handlers")
.description("show all vm handlers..."); .description("show all vm handlers...");
parser.enable_help(); parser.enable_help();
@ -124,7 +119,7 @@ int __cdecl main(int argc, const char* argv[])
return -1; return -1;
} }
if (parser.exists("show-vm-handlers")) if (parser.exists("showhandlers"))
{ {
for (auto idx = 0u; idx < vm_handlers.size(); ++idx) 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"); std::printf("=======================================================\n\n");
} }
} }
if (parser.exists("vmtrace"))
{
std::ifstream vmp2_file(
parser.get<std::string>("vmtrace").c_str(), std::ios::binary);
const auto file_size =
std::filesystem::file_size(
parser.get<std::string>("vmtrace").c_str());
const auto file_header =
reinterpret_cast<vmp2::file_header*>(malloc(file_size));
vmp2_file.read((char*)file_header, file_size);
const auto entry_list =
reinterpret_cast<vmp2::entry_t*>(
reinterpret_cast<std::uintptr_t>(
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"); std::printf("> finished...\n");
} }

@ -124,6 +124,9 @@
<Project>{d0b6092a-9944-4f24-9486-4b7dae372619}</Project> <Project>{d0b6092a-9944-4f24-9486-4b7dae372619}</Project>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="..\.clang-format" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

@ -198,4 +198,9 @@
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="..\.clang-format">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project> </Project>
Loading…
Cancel
Save