#include 
void f1(int &a)
{
 a=a+5;
}

void f2(int &a)
{
 a=a-5;
}
int main(int argc, char* argv[])
{
 int a;
 MEMORY_BASIC_INFORMATION mb;
 unsigned char * ptr1=(char *)(void*)f1,*ptr2=(char *)(void *)f2;
 VirtualQuery(ptr1,&mb,sizeof(mb));
 DWORD     oldprotect;
 VirtualProtect(ptr1, 4, PAGE_WRITECOPY, &oldprotect);
 for (int i=0;;i++)
 {
  ptr1=ptr2;
  if (ptr1[i-1]==0xC3 && ptr1==0x90) break;
 }
 VirtualProtect(ptr1, 4, PAGE_EXECUTE, &oldprotect);
 a=5;
 f1(a);
 return 0;
}
Hosted by uCoz