00001 /******************************************************************************** 00002 * libemu 00003 * 00004 * - x86 shellcode emulation - 00005 * 00006 * 00007 * Copyright (C) 2007 Paul Baecher & Markus Koetter 00008 * 00009 * This program is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * as published by the Free Software Foundation; either version 2 00012 * of the License, or (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00022 * 00023 * 00024 * contact nepenthesdev@users.sourceforge.net 00025 * 00026 *******************************************************************************/ 00027 00028 00029 #ifndef HAVE_EMU_CPU_INSTRUCTION 00030 #define HAVE_EMU_CPU_INSTRUCTION 00031 00032 00033 00034 #include <stdint.h> 00035 00036 00037 struct emu_cpu_instruction; 00038 struct emu_cpu; 00039 00040 struct emu_cpu_instruction_info 00041 { 00042 int32_t (*function)(struct emu_cpu *, struct emu_cpu_instruction *); 00043 const char *name; 00044 00045 struct 00046 { 00047 uint8_t s_bit : 1; 00048 uint8_t w_bit : 1; 00049 uint8_t modrm_byte : 4; 00050 uint8_t imm_data : 3; 00051 uint8_t disp_data : 3; 00052 uint8_t level : 2; 00053 uint8_t type : 2; 00054 uint8_t fpu_info : 1; 00055 } format; 00056 }; 00057 00058 struct emu_cpu_instruction 00059 { 00060 uint8_t opc; 00061 uint8_t opc_2nd; 00062 uint16_t prefixes; 00063 uint8_t s_bit : 1; 00064 uint8_t w_bit : 1; 00065 uint8_t operand_size : 2; 00066 00067 struct /* mod r/m data */ 00068 { 00069 union 00070 { 00071 uint8_t mod : 2; 00072 uint8_t x : 2; 00073 }; 00074 00075 union 00076 { 00077 uint8_t reg1 : 3; 00078 uint8_t opc : 3; 00079 uint8_t sreg3 : 3; 00080 uint8_t y : 3; 00081 }; 00082 00083 union 00084 { 00085 uint8_t reg : 3; 00086 uint8_t reg2 : 3; 00087 uint8_t rm : 3; 00088 uint8_t z : 3; 00089 }; 00090 00091 struct 00092 { 00093 uint8_t scale : 2; 00094 uint8_t index : 3; 00095 uint8_t base : 3; 00096 } sib; 00097 00098 union 00099 { 00100 uint8_t s8; 00101 uint16_t s16; 00102 uint32_t s32; 00103 } disp; 00104 00105 uint32_t ea; 00106 } modrm; 00107 00108 uint32_t imm; 00109 uint16_t *imm16; 00110 uint8_t *imm8; 00111 00112 int32_t disp; 00113 00114 00115 }; 00116 00117 00118 00119 00120 #endif
1.6.1