merge-requests/2/head
_xeroxz 4 years ago
parent abda23f07a
commit b9dc2520fe

@ -10,6 +10,12 @@ namespace vm
enum mnemonic_t enum mnemonic_t
{ {
INVALID, INVALID,
PUSHVSP,
SHRQ,
MULQ,
DIVQ,
JMP,
VMEXIT,
SREGQ, SREGQ,
SREGDW, SREGDW,
@ -33,24 +39,14 @@ namespace vm
WRITEDW, WRITEDW,
WRITEW, WRITEW,
PUSHVSP,
ADDQ, ADDQ,
ADDDW, ADDDW,
SHLQ, SHLQ,
SHLDW, SHLDW,
MULQ,
DIVQ,
NANDQ, NANDQ,
NANDDW, NANDDW
JMP,
VMEXIT
}; };
enum extention_t enum extention_t
@ -85,8 +81,6 @@ namespace vm
extern vm::handler::profile_t lconstwsxq; extern vm::handler::profile_t lconstwsxq;
extern vm::handler::profile_t lconstdw; extern vm::handler::profile_t lconstdw;
extern vm::handler::profile_t pushvsp;
extern vm::handler::profile_t addq; extern vm::handler::profile_t addq;
extern vm::handler::profile_t adddw; extern vm::handler::profile_t adddw;
@ -96,42 +90,33 @@ namespace vm
extern vm::handler::profile_t nandq; extern vm::handler::profile_t nandq;
extern vm::handler::profile_t nanddw; extern vm::handler::profile_t nanddw;
extern vm::handler::profile_t mulq;
extern vm::handler::profile_t divq;
extern vm::handler::profile_t jmp;
extern vm::handler::profile_t writeq; extern vm::handler::profile_t writeq;
extern vm::handler::profile_t writedw; extern vm::handler::profile_t writedw;
extern vm::handler::profile_t shrq;
extern vm::handler::profile_t pushvsp;
extern vm::handler::profile_t mulq;
extern vm::handler::profile_t divq;
extern vm::handler::profile_t jmp;
extern vm::handler::profile_t readq; extern vm::handler::profile_t readq;
extern vm::handler::profile_t vmexit; extern vm::handler::profile_t vmexit;
inline std::vector<vm::handler::profile_t*> all = inline std::vector<vm::handler::profile_t*> all =
{ {
&sregq, &sregdw, &sregw, &sregq, &sregdw, &sregw,
&lregq, &lregdw, &lregq, &lregdw,
&lconstq, &lconstbzxw, &lconstbsxdw, &lconstdwsxq, &lconstwsxq, &lconstdw, &lconstq, &lconstbzxw, &lconstbsxdw, &lconstdwsxq, &lconstwsxq, &lconstdw,
&pushvsp,
&addq, &adddw, &addq, &adddw,
&mulq,
&divq,
&shlq, &shldw, &shlq, &shldw,
&writeq, &writedw, &writeq, &writedw,
&readq,
&nandq, &nanddw, &nandq, &nanddw,
&shrq,
&readq,
&mulq,
&pushvsp,
&divq,
&jmp, &jmp,
&vmexit &vmexit
}; };
} }

@ -111,6 +111,8 @@
<ClCompile Include="vmprofiles\nand.cpp" /> <ClCompile Include="vmprofiles\nand.cpp" />
<ClCompile Include="vmprofiles\pushvsp.cpp" /> <ClCompile Include="vmprofiles\pushvsp.cpp" />
<ClCompile Include="vmprofiles\read.cpp" /> <ClCompile Include="vmprofiles\read.cpp" />
<ClCompile Include="vmprofiles\shl.cpp" />
<ClCompile Include="vmprofiles\shr.cpp" />
<ClCompile Include="vmprofiles\sreg.cpp" /> <ClCompile Include="vmprofiles\sreg.cpp" />
<ClCompile Include="vmprofiles\vmexit.cpp" /> <ClCompile Include="vmprofiles\vmexit.cpp" />
<ClCompile Include="vmprofiles\write.cpp" /> <ClCompile Include="vmprofiles\write.cpp" />

@ -74,6 +74,12 @@
<ClCompile Include="vmprofiles\write.cpp"> <ClCompile Include="vmprofiles\write.cpp">
<Filter>Source Files\vmprofiles</Filter> <Filter>Source Files\vmprofiles</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="vmprofiles\shl.cpp">
<Filter>Source Files\vmprofiles</Filter>
</ClCompile>
<ClCompile Include="vmprofiles\shr.cpp">
<Filter>Source Files\vmprofiles</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\include\transform.hpp"> <ClInclude Include="..\include\transform.hpp">

@ -0,0 +1,85 @@
#include "../../include/vmprofiler.hpp"
namespace vm
{
namespace handler
{
namespace profile
{
vm::handler::profile_t shrq =
{
// MOV RAX, [RBP]
// MOV CL, [RBP+0x8]
// SUB RBP, 0x6
// SHR RAX, CL
// MOV [RBP+0x8], RAX
// PUSHFQ
// POP [RBP]
"SHRQ", SHRQ, NULL,
{
{
// MOV RAX, [RBP]
[](const zydis_decoded_instr_t& instr) -> bool
{
return instr.mnemonic == ZYDIS_MNEMONIC_MOV &&
instr.operands[0].type == ZYDIS_OPERAND_TYPE_REGISTER &&
instr.operands[0].reg.value == ZYDIS_REGISTER_RAX &&
instr.operands[1].type == ZYDIS_OPERAND_TYPE_MEMORY &&
instr.operands[1].mem.base == ZYDIS_REGISTER_RBP;
},
// MOV CL, [RBP+0x8]
[](const zydis_decoded_instr_t& instr) -> bool
{
return instr.mnemonic == ZYDIS_MNEMONIC_MOV &&
instr.operands[0].type == ZYDIS_OPERAND_TYPE_REGISTER &&
instr.operands[0].reg.value == ZYDIS_REGISTER_CL &&
instr.operands[1].type == ZYDIS_OPERAND_TYPE_MEMORY &&
instr.operands[1].mem.base == ZYDIS_REGISTER_RBP &&
instr.operands[1].mem.index == 0x8;
},
// SUB RBP, 0x6
[](const zydis_decoded_instr_t& instr) -> bool
{
return instr.mnemonic == ZYDIS_MNEMONIC_SUB &&
instr.operands[0].type == ZYDIS_OPERAND_TYPE_REGISTER &&
instr.operands[0].reg.value == ZYDIS_REGISTER_RBP &&
instr.operands[1].type == ZYDIS_OPERAND_TYPE_IMMEDIATE &&
instr.operands[1].imm.value.u == 0x6;
},
// SHR RAX, CL
[](const zydis_decoded_instr_t& instr) -> bool
{
return instr.mnemonic == ZYDIS_MNEMONIC_SHR &&
instr.operands[0].type == ZYDIS_OPERAND_TYPE_REGISTER &&
instr.operands[0].reg.value == ZYDIS_REGISTER_RAX &&
instr.operands[1].type == ZYDIS_OPERAND_TYPE_REGISTER &&
instr.operands[1].reg.value == ZYDIS_REGISTER_CL;
},
// MOV [RBP+0x8], RAX
[](const zydis_decoded_instr_t& instr) -> bool
{
return instr.mnemonic == ZYDIS_MNEMONIC_MOV &&
instr.operands[0].type == ZYDIS_OPERAND_TYPE_MEMORY &&
instr.operands[0].mem.base == ZYDIS_REGISTER_RBP &&
instr.operands[0].mem.index == 0x8 &&
instr.operands[1].type == ZYDIS_OPERAND_TYPE_REGISTER &&
instr.operands[1].reg.value == ZYDIS_REGISTER_RAX;
},
// PUSHFQ
[](const zydis_decoded_instr_t& instr) -> bool
{
return instr.mnemonic == ZYDIS_MNEMONIC_PUSHFQ;
},
// POP [RBP]
[](const zydis_decoded_instr_t& instr) -> bool
{
return instr.mnemonic == ZYDIS_MNEMONIC_POP &&
instr.operands[0].type == ZYDIS_OPERAND_TYPE_MEMORY &&
instr.operands[0].mem.base == ZYDIS_REGISTER_RBP;
}
}
}
};
}
}
}
Loading…
Cancel
Save