Enviado em 19/01/2013 - 21:14h
Olá pessoal !!!
#include <stdio.h>
#include <time.h>
int i, x;
/*
void func (void)
{
for (i = 0; i < 100000000; i++)
x++;
}
*/
//-------------------------------------------------------------------
// esse ShellCode abaixo na verdade eh a funcao ( func ) compilada ...
//
// gerado pelo programa: objdump
//
// objdump.exe -d execute.exe > saida.c
//
//-------------------------------------------------------------------
char code[] = {
0x55, // push %ebp
0x89, 0xe5, // mov %esp,%ebp
0xc7, 0x05, 0x70, 0x40, 0x40, 0x00, 0x00, // movl $0x0,0x404070
0x00, 0x00, 0x00, //
0xa1, 0x80, 0x40, 0x40, 0x00, // mov 0x404080,%eax
0xba, 0x00, 0x00, 0x00, 0x00, // mov $0x0,%edx
0x40, // inc %eax
0x42, // inc %edx
0x81, 0xfa, 0xff, 0xe0, 0xf5, 0x05, // cmp $0x5f5e0ff,%edx
0x7e, 0xf6, // jle 4012a7 <_func+0x17>
0x89, 0x15, 0x70, 0x40, 0x40, 0x00, // mov %edx,0x404070
0xa3, 0x80, 0x40, 0x40, 0x00, // mov %eax,0x404080
0x5d, // pop %ebp
0xc3 // ret
};
int main (int argc, char *argv[])
{
clock_t clock_start = clock ();
#ifdef __WIN32__
asm ("call _code");
#endif
#ifdef __linux__
asm ("call code");
#endif
clock_t clock_end = clock ();
float time_used = ((float)(clock_end - clock_start)) / CLOCKS_PER_SEC;
printf("CLOCK TIME: %4.3f - x: %d\n", time_used, x);
return 0;
}