函数指针与硬编码测试

#include "stdio.h"
#include "windows.h"

unsigned char arr[]={
	0x55,
	0x8B,0xEC,
	0x83,0xEC,0x40,
	0x53,
	0x56,
	0x57,
	0x8D,0x7D,0xC0,
	0xB9,0x10,0x00,0x00,0x00,
	0xB8,0xCC,0xCC,0xCC,0xCC,
	0xF3,0xAB,
	0x8B,0x45,0x08,
	0x03,0x45,0x0C,
	0x5F,
	0x5E,
	0x5B,
	0x8B,0xE5,
	0x5D,
	0xC3
};

void main()
{
	__asm{
		mov eax,eax
	}
	
	int (*p)(int,int);
	int (__stdcall *px)(int,int);

	p= (int (__cdecl *)(int,int))&arr;
	int x = p(1,2);
	printf("%d \n",x);
	return;	
	
}



测试案例二


#include "stdio.h"

unsigned char code[]={
0x55,0x8B,0xEC,0x83,
0xEC,0x40,0x53,
0x56,0x57,0x8D,
0x7D,0xC0,0xB9,
0x10,0x00,0x00,
0x00,0xB8,0xCC,0xCC,
0xCC,0xCC,0xF3,0xAB,
0x8B,0x45,0x08,0x03,0x45,0x0C,
0x03,0x45,0x10,0x03,0x45,0x14,
0x03,0x45,0x18,0x5F,0x5E,
0x5B,0x8B,0xE5,0x5D,0xC3
};

void main()
{
	int (__cdecl *px)(int,int,int,int,int);
	px = (int (__cdecl *)(int,int,int,int,int))&code;

	int res  = px(1,1,1,1,1);

	printf("%d \n",res);
	
}

原文链接: 函数指针与硬编码测试 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( https://gyarmy.com/post-293.html )

发表评论

0则评论给“函数指针与硬编码测试”