/* .... Giant fucking switch tables */
-
-
-
-
-
typedef enum {
INVALID_INSTR,
LMSW,
} op_form_t;
+static int get_addr_width(struct guest_info * info, struct x86_instr * instr,
+ op_form_t form) {
+ switch (v3_get_vm_cpu_mode(info)) {
+ case REAL:
+ return (instr->prefixes.addr_size) ? 4 : 2;
+ case PROTECTED:
+ case PROTECTED_PAE:
+ return (instr->prefixes.addr_size) ? 2 : 4;
+ case LONG_32_COMPAT:
+ case LONG:
+ default:
+ PrintError("Unsupported CPU mode: %d\n", info->cpu_mode);
+ return -1;
+ }
+}
-static int get_operand_width(struct guest_info * info, struct x86_instr * instr, op_form_t form) {
+static int get_operand_width(struct guest_info * info, struct x86_instr * instr,
+ op_form_t form) {
switch (form) {
case CLTS:
case HLT:
return 0;
-
case MOV_MEM2_8:
case MOV_2MEM_8:
case MOV_MEM2AL_8:
case SETO:
return 1;
-
case LMSW:
case SMSW:
return 2;
return -1;
}
-
case INVLPG:
switch (v3_get_vm_cpu_mode(info)) {
case REAL:
return -1;
}
-
case PUSHF:
case POPF:
switch (v3_get_vm_cpu_mode(info)) {
return -1;
}
-
case MOV_SR2:
case MOV_2SR:
default:
-static inline op_form_t op_code_to_form_0f(uint8_t * instr) {
+static inline op_form_t op_code_to_form_0f(uint8_t * instr, int * length) {
+ *length += 1;
+
switch (instr[1]) {
case 0x01: {
struct modrm_byte * modrm = (struct modrm_byte *)&(instr[2]);
}
-static op_form_t op_code_to_form(uint8_t * instr) {
+static op_form_t op_code_to_form(uint8_t * instr, int * length) {
+ *length += 1;
+
switch (instr[0]) {
case 0x00:
return ADD_2MEM_8;
case 0x0f:
- return op_code_to_form_0f(instr);
+ return op_code_to_form_0f(instr, length);
case 0x10:
return ADC_2MEM_8;