-
Notifications
You must be signed in to change notification settings - Fork 1
/
prog.c
48 lines (32 loc) · 798 Bytes
/
prog.c
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
#include <stdio.h>
//
// Defined in get_eip.asm
//
uintptr_t get_eip(void);
void h(void);
void g(void);
void f() {
uintptr_t *basePointer;
uintptr_t *retAddr;
__asm mov basePointer, ebp;
retAddr = _ReturnAddress();
printf(" f: _ReturnAddress = %x, ebp+1 = %x\n", retAddr, *(basePointer+1));
}
void g() {
uintptr_t eip;
printf("In f_3\n");
f();
eip = get_eip();
//
// get_eip() returned the address of the instruction
// that followed the get_eip() call.
// The x86 call instruction consists of 5 bytes. Thus,
// we have to subtract 5 bytes to get the address of the
// instruction that follows the call f() instruction.
//
eip = eip - 5;
printf(" eip following call of f = %x\n", eip);
}
int main() {
g();
}