Skip to content

Instantly share code, notes, and snippets.

@stowell
Created February 20, 2016 02:34
Show Gist options
  • Save stowell/a0585dd5303ab69e5efd to your computer and use it in GitHub Desktop.
Save stowell/a0585dd5303ab69e5efd to your computer and use it in GitHub Desktop.
mapped.c
#include <fcntl.h>
#include <sys/mman.h>
typedef unsigned int uintf();
int main(int argc, char* argv[]) {
int fd = open(argv[1], O_RDONLY);
if (-1 == fd) {
return 1;
}
uintf* f = mmap(
0, 4096, PROT_READ | PROT_EXEC, MAP_PRIVATE, fd, 0);
if (MAP_FAILED == f) {
return 2;
}
unsigned int result = f();
if (243 == result) {
return 0;
} else {
return 3;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment