64,654
社区成员
发帖
与我相关
我的任务
分享
#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 <iostream>
using namespace std;
void main()
{
char *p="\hb8\h78\h56\h34\h12\hc3";
int (*f)()=(int (*)()) p;
cout<<f()<<endl;
}
#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;
}