You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
2.2 KiB
139 lines
2.2 KiB
#pragma once
|
|
#include <transform.hpp>
|
|
|
|
namespace vm
|
|
{
|
|
namespace handler
|
|
{
|
|
using instr_callback_t = bool(*)(const zydis_decoded_instr_t& instr);
|
|
|
|
enum mnemonic_t
|
|
{
|
|
INVALID,
|
|
|
|
SREGQ,
|
|
SREGDW,
|
|
SREGW,
|
|
|
|
LREGQ,
|
|
LREGDW,
|
|
|
|
LCONSTQ,
|
|
LCONSTBZXW,
|
|
LCONSTBSXDW,
|
|
LCONSTDWSXQ,
|
|
LCONSTWSXQ,
|
|
LCONSTDW,
|
|
|
|
READQ,
|
|
READDW,
|
|
READW,
|
|
|
|
WRITEQ,
|
|
WRITEDW,
|
|
WRITEW,
|
|
|
|
PUSHVSP,
|
|
|
|
ADDQ,
|
|
ADDDW,
|
|
|
|
SHLQ,
|
|
SHLDW,
|
|
|
|
MULQ,
|
|
|
|
DIVQ,
|
|
|
|
NANDQ,
|
|
NANDDW,
|
|
|
|
JMP,
|
|
|
|
VMEXIT
|
|
};
|
|
|
|
enum extention_t
|
|
{
|
|
none,
|
|
sign_extend,
|
|
zero_extend
|
|
};
|
|
|
|
struct profile_t
|
|
{
|
|
const char* name;
|
|
mnemonic_t mnemonic;
|
|
u8 imm_size;
|
|
std::vector<instr_callback_t> signature;
|
|
extention_t extention;
|
|
};
|
|
|
|
namespace profile
|
|
{
|
|
extern vm::handler::profile_t sregq;
|
|
extern vm::handler::profile_t sregdw;
|
|
extern vm::handler::profile_t sregw;
|
|
|
|
extern vm::handler::profile_t lregq;
|
|
extern vm::handler::profile_t lregdw;
|
|
|
|
extern vm::handler::profile_t lconstq;
|
|
extern vm::handler::profile_t lconstbzxw;
|
|
extern vm::handler::profile_t lconstbsxdw;
|
|
extern vm::handler::profile_t lconstdwsxq;
|
|
extern vm::handler::profile_t lconstwsxq;
|
|
extern vm::handler::profile_t lconstdw;
|
|
|
|
extern vm::handler::profile_t pushvsp;
|
|
|
|
extern vm::handler::profile_t addq;
|
|
extern vm::handler::profile_t adddw;
|
|
|
|
extern vm::handler::profile_t shlq;
|
|
extern vm::handler::profile_t shldw;
|
|
|
|
extern vm::handler::profile_t nandq;
|
|
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 writedw;
|
|
|
|
extern vm::handler::profile_t readq;
|
|
extern vm::handler::profile_t vmexit;
|
|
|
|
inline std::vector<vm::handler::profile_t*> all =
|
|
{
|
|
&sregq, &sregdw, &sregw,
|
|
|
|
&lregq, &lregdw,
|
|
|
|
&lconstq, &lconstbzxw, &lconstbsxdw, &lconstdwsxq, &lconstwsxq, &lconstdw,
|
|
|
|
&pushvsp,
|
|
|
|
&addq, &adddw,
|
|
|
|
&mulq,
|
|
|
|
&divq,
|
|
|
|
&shlq, &shldw,
|
|
|
|
&writeq, &writedw,
|
|
|
|
&readq,
|
|
|
|
&nandq, &nanddw,
|
|
|
|
&jmp,
|
|
|
|
&vmexit
|
|
};
|
|
}
|
|
}
|
|
} |