emu_cpu.h

Go to the documentation of this file.
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 #ifndef HAVE_EMU_CPU_H
00029 #define HAVE_EMU_CPU_H
00030 
00031 #include <inttypes.h>
00032 
00033 struct emu;
00034 struct emu_cpu;
00035 
00036 enum emu_reg32 {
00037         eax = 0, ecx, edx, ebx, esp, ebp, esi, edi
00038 };
00039 
00040 
00041 enum emu_reg16
00042 {
00043         ax =  0,/* eax */
00044         cx,     /* ecx */
00045         dx,     /* edx */
00046         bx,     /* ebx */
00047         sp,     /* esp */
00048         bp,     /* ebp */
00049         si,     /* esp */
00050         di      /* edi */
00051 
00052 };
00053 
00054 
00055 enum emu_reg8
00056 {
00057         al=0,   /* eax */
00058         cl,     /* ecx */
00059         dl,     /* edx */
00060         bl,     /* ebx */
00061         ah,     /* eax */
00062         ch,     /* ecx */
00063         dh,     /* edx */
00064         bh      /* ebx */
00065 
00066 };
00067 
00068 struct emu_cpu *emu_cpu_new(struct emu *e);
00069 
00070 uint32_t emu_cpu_reg32_get(struct emu_cpu *cpu_p, enum emu_reg32 reg);
00071 void  emu_cpu_reg32_set(struct emu_cpu *cpu_p, enum emu_reg32 reg, uint32_t val);
00072 
00073 uint16_t emu_cpu_reg16_get(struct emu_cpu *cpu_p, enum emu_reg16 reg);
00074 void emu_cpu_reg16_set(struct emu_cpu *cpu_p, enum emu_reg16 reg, uint16_t val);
00075 
00076 uint8_t emu_cpu_reg8_get(struct emu_cpu *cpu_p, enum emu_reg8 reg);
00077 void emu_cpu_reg8_set(struct emu_cpu *cpu_p, enum emu_reg8 reg, uint8_t val);
00078 
00079 uint32_t emu_cpu_eflags_get(struct emu_cpu *c);
00080 void emu_cpu_eflags_set(struct emu_cpu *c, uint32_t val);
00081 
00088 void emu_cpu_eip_set(struct emu_cpu *c, uint32_t eip);
00089 
00097 uint32_t emu_cpu_eip_get(struct emu_cpu *c);
00098 
00099 
00108 int32_t emu_cpu_parse(struct emu_cpu *c);
00109 
00118 int32_t emu_cpu_step(struct emu_cpu *c);
00119 
00120 int32_t emu_cpu_run(struct emu_cpu *c);
00121 
00122 void emu_cpu_free(struct emu_cpu *c);
00123 
00124 void emu_cpu_debug_print(struct emu_cpu *c);
00125 
00126 void emu_cpu_debugflag_set(struct emu_cpu *c, uint8_t flag);
00127 void emu_cpu_debugflag_unset(struct emu_cpu *c, uint8_t flag);
00128 
00129 
00130 #endif /* HAVEEMU_CPU_H */

Generated on Sun Jan 9 16:47:44 2011 for libemu by  doxygen 1.6.1