Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@luser
Forked from anonymous/dump.c.txt
Last active December 16, 2015 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luser/5461845 to your computer and use it in GitHub Desktop.
Save luser/5461845 to your computer and use it in GitHub Desktop.
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int test(int x, int y) {
return x + y - x * y;
}
int end() {
return 0;
}
int main() {
pid_t pid = getpid();
char cmd[1024];
char tempfile[] = "/tmp/procmem-XXXXXX";
int fd = mkstemp(tempfile);
write(fd, &test, &end - &test);
close(fd);
snprintf(cmd, 1024, "objdump -b binary -m i386 -M att-mnemonic,x86-64 --adjust-vma=%p -D %s", &test, tempfile);
fprintf(stderr, "running: '%s'\n", cmd);
system(cmd);
fprintf(stderr, "done\n");
unlink(tempfile);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment