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.

125 lines
2.3 KiB

#ifndef __VMDEFS_H
#define __VMDEFS_H
#include "Windas.h"
union VM_IMM
{
UINT8 u8;
UINT16 u16;
UINT32 u32;
UINT64 u64;
INT8 i8;
INT16 i16;
INT32 i32;
INT64 i64;
PVOID Raw;
};
enum VM_MEMOP_TYPE_ENUM : UCHAR
{
VM_MEMOP_B,
VM_MEMOP_BD,
VM_MEMOP_BIS,
VM_MEMOP_BISD,
VM_MEMOP_TYPE_COUNT
};
enum VM_IREG_ENUM : UCHAR
{
VM_IREG_0,
VM_IREG_1,
VM_IREG_2,
VM_IREG_COUNT,
};
enum VM_OPERAND_SIZE_ENUM : UCHAR
{
VM_OPSIZE_1,
VM_OPSIZE_2,
VM_OPSIZE_4,
VM_OPSIZE_8,
VM_OPSIZE_COUNT
};
enum VM_ICLASS_ENUM : USHORT
{
VM_ICLASS_ENTER,
VM_ICLASS_EXIT,
//Loading from memory into internal registers
//Need to support 3 modes: [BASE], [BASE+OFFSET], [BASE+INDEX*SCALE+OFFSET]
//for 4 possible sizes(1,2,4,8)
//for 3 possible register spots(rax,rbx,rcx
//3 * 4 * 3 = 72
VM_ICLASS_LD_IREG_MEM_START,
VM_ICLASS_LD_IREG_MEM_END = VM_ICLASS_LD_IREG_MEM_START + (VM_IREG_COUNT * VM_OPSIZE_COUNT * VM_MEMOP_TYPE_COUNT) - 1,
//Storing internal registers into memory
VM_ICLASS_ST_IREG_MEM_START,
VM_ICLASS_ST_IREG_MEM_END = VM_ICLASS_ST_IREG_MEM_START + (VM_IREG_COUNT * VM_OPSIZE_COUNT * VM_MEMOP_TYPE_COUNT) - 1,
//Loading scratch registers into internal registers
VM_ICLASS_LD_IREG_REG_START,
VM_ICLASS_LD_IREG_REG_END = VM_ICLASS_LD_IREG_REG_START + (VM_IREG_COUNT * VM_OPSIZE_COUNT) - 1,
//storing internal registers into scratch registers
VM_ICLASS_ST_IREG_REG_START,
VM_ICLASS_ST_IREG_REG_END = VM_ICLASS_ST_IREG_REG_START + (VM_IREG_COUNT * VM_OPSIZE_COUNT) - 1,
//Loading Immediate Values into internal registers
VM_ICLASS_LD_IREG_IMM_START,
VM_ICLASS_LD_IREG_IMM_END = VM_ICLASS_LD_IREG_IMM_START + (VM_IREG_COUNT * VM_OPSIZE_COUNT) - 1,
VM_ICLASS_COUNT,
};
enum VM_REG_ENUM : UCHAR
{
VM_REG_0, //0-15 reserved for converted native registers.
VM_REG_1,
VM_REG_2,
VM_REG_3,
VM_REG_4,
VM_REG_5,
VM_REG_6,
VM_REG_7,
VM_REG_8,
VM_REG_9,
VM_REG_10,
VM_REG_11,
VM_REG_12,
VM_REG_13,
VM_REG_14,
VM_REG_15,
//VM_REG_16, //scratch registers
//VM_REG_17,
//VM_REG_18,
//VM_REG_19,
//VM_REG_20,
//VM_REG_21,
//VM_REG_22,
//VM_REG_23,
//VM_REG_24,
//VM_REG_25,
//VM_REG_26,
//VM_REG_27,
//VM_REG_28,
//VM_REG_29,
//VM_REG_30,
//VM_REG_31,
VM_REG_COUNT
};
typedef struct _VM_HEADER
{
PVOID RegisterFile[VM_REG_COUNT];
PVOID RegisterStorage[16];
PVOID HandlerTable[1];
UINT HandlerTableSize;
}VM_HEADER, * PVM_HEADER;
#endif