1218 |
0xc3, /* ret */ |
0xc3, /* ret */ |
1219 |
}; |
}; |
1220 |
|
|
1221 |
|
typedef int FuncType(void); |
1222 |
|
|
1223 |
void test_self_modifying_code(void) |
void test_self_modifying_code(void) |
1224 |
{ |
{ |
1225 |
int (*func)(void); |
int i; |
1226 |
|
|
|
func = (void *)code; |
|
1227 |
printf("self modifying code:\n"); |
printf("self modifying code:\n"); |
1228 |
printf("func1 = 0x%x\n", func()); |
printf("func1 = 0x%x\n", ((FuncType *)code)()); |
1229 |
code[1] = 0x2; |
for(i = 2; i <= 4; i++) { |
1230 |
printf("func1 = 0x%x\n", func()); |
code[1] = i; |
1231 |
|
printf("func%d = 0x%x\n", i, ((FuncType *)code)()); |
1232 |
|
} |
1233 |
} |
} |
1234 |
|
|
1235 |
static void *call_end __init_call = NULL; |
static void *call_end __init_call = NULL; |