[ to3a @ 11.11.2005. 21:25 ] @
Ucinilo mi se zanimljivim, pa eto, mozda nekome i zatreba ... Code: #include <stdio.h> #include <stdlib.h> void main(void) { int i = 1; void (__cdecl *test_fun )(int *); char *fun; fun = (char *) malloc(1024); // mov eax, DWORD PTR [esp+4] fun[0] = 0x8b; fun[1] = 0x44; fun[2] = 0x24; fun[3] = 0x04; // inc DWORD PTR [eax] fun[4] = 0xff; fun[5] = 0x00; // ret fun[6] = 0xc3; // nop, za svaki slucaj, nije neophodno... fun[7] = 0x90; fun[8] = 0x90; fun[9] = 0x90; test_fun = (void (__cdecl *)(int *)) fun; fprintf(stderr, "before test i = %d.\n", i); test_fun(&i); fprintf(stderr, " after test i = %d.\n", i); free(fun); } Pozdrav, To3A |