Paste: test case

Author: slava
Mode: c
Date: Mon, 27 Sep 2010 19:30:40
Plain Text |
#include <stdlib.h>
#include <sys/mman.h>

typedef void (* func)();

int main()
{
	char *mem = mmap(NULL,
		getpagesize(),
		PROT_EXEC | PROT_READ | PROT_WRITE,
		MAP_PRIVATE | MAP_ANONYMOUS,
		-1,
		0);
	if(!mem)
	{
		perror("mmap");
		exit(1);
	}

	mem[0] = 0xc3;

	func f = (func)mem;
	f();
}

New Annotation

Summary:
Author:
Mode:
Body: