高手都来看看,分析程序的运行结果~~~
不是病毒,分析理解。
难道C++中 内存都是可以执行的吗?
第一题:
#include <stdio.h>
int main()
{
const short int c1 = 49920;
const int c2 = 1073742008;
int (*pf)() = (int (*)())&c2;
printf("%c%c\n", *(char*)pf()-19, *((char*)pf()+1)-49);
return 0;
}
第二题:
#include <iostream.h>void main(){ unsigned char c[]={0xb8,0x78,0x56,0x34,0x12,0xc3}; // mov eax,12345678h / ret int (*p)()=(int (*)()) &c[0]; cout<<p()<<endl;}
#include <iostream.h>#include <string.h>void main(){ unsigned char c[]={0xb8,0x78,0x56,0x34,0x12,0xc3,0}; // mov eax,12345678h / ret char *p=new char[8]; strcpy(p,(char*)c); int (*f)()=(int (*)()) p; cout<<f()<<endl; delete[]p;}
#include <stdio.h> int main() { const short int c1 = 49920; const int c2 = 1073742008; int (*pf)() = (int (*)())&c2; //这里int (*pf)()是一个系统里面的指针函数???? printf("%c%c\n", *(char*)pf()-19, *((char*)pf()+1)-49); return 0; }
[解决办法]
int (*pf)() = (int (*)())&c2;
新手进来观摩,请问这是一种什么写法?
[解决办法]