/usr/include/emu/emu_cpu_stack.h is in libemu-dev 0.2.0+git20120122-1.2+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | /********************************************************************************
* libemu
*
* - x86 shellcode emulation -
*
*
* Copyright (C) 2007 Paul Baecher & Markus Koetter
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*
* contact nepenthesdev@users.sourceforge.net
*
*******************************************************************************/
#ifndef EMU_CPU_STACK_H_
#define EMU_CPU_STACK_H_
#define PUSH_DWORD(cpu, arg) \
{ \
uint32_t pushme; \
bcopy(&(arg), &pushme, 4); \
if (cpu->reg[esp] < 4) \
{ \
emu_errno_set((cpu)->emu, ENOMEM); \
emu_strerror_set((cpu)->emu, \
"ran out of stack space writing a dword\n"); \
return -1; \
} \
cpu->reg[esp]-=4; \
{ \
int32_t memret = emu_memory_write_dword(cpu->mem, cpu->reg[esp], pushme); \
if (memret != 0) \
return memret; \
} \
}
#define PUSH_WORD(cpu, arg) \
{ \
uint16_t pushme; \
bcopy(&(arg), &pushme, 2); \
if (cpu->reg[esp] < 2) \
{ \
emu_errno_set((cpu)->emu, ENOMEM); \
emu_strerror_set((cpu)->emu, \
"ran out of stack space writing a word\n"); \
return -1; \
} \
cpu->reg[esp]-=2; \
{ \
int32_t memret = emu_memory_write_word(cpu->mem, cpu->reg[esp], pushme);\
if (memret != 0) \
return memret; \
} \
}
#define PUSH_BYTE(cpu, arg) \
{ \
uint8_t pushme = arg; \
if (cpu->reg[esp] < 1) \
{ \
emu_errno_set((cpu)->emu, ENOMEM); \
emu_strerror_set((cpu)->emu, \
"ran out of stack space writing a byte\n"); \
return -1; \
} \
cpu->reg[esp]-=1; \
{ \
int32_t memret = emu_memory_write_byte(cpu->mem, cpu->reg[esp], pushme); \
if (memret != 0) \
return memret; \
} \
}
#define POP_DWORD(cpu, dst_p) \
{ int32_t ret = emu_memory_read_dword(cpu->mem, cpu->reg[esp], dst_p); \
if( ret != 0 ) \
return ret; \
else \
if ( dst_p != &cpu->reg[esp] ) \
cpu->reg[esp] += 4; }
#define POP_WORD(cpu, dst_p) \
{ int32_t ret = emu_memory_read_word(cpu->mem, cpu->reg[esp], dst_p); \
if( ret != 0 ) \
return ret; \
else \
cpu->reg[esp] += 2; }
#define POP_BYTE(cpu, dst_p) \
{ int32_t ret = emu_memory_read_byte(cpu->mem, cpu->reg[esp], dst_p); \
if( ret != 0 ) \
return ret; \
else \
cpu->reg[esp] += 1; }
#endif /*EMU_CPU_STACK_H_*/
|