Skip to content

Instantly share code, notes, and snippets.

@brianairb
Last active Jan 4, 2016
Embed
What would you like to do?
dump_stack function from picoCTF 2013
#include <stdio.h>
void dump_stack(void **stack, size_t n, void **arg0) {
printf("Stack dump:\n");
while (n-- > 0) {
printf("0x%08x: 0x%08x", &stack[n], stack[n]);
if (n == 0) {
printf(" (beginning of buffer)");
}
if (&stack[n] == arg0 + 1) {
printf(" (second argument)");
}
if (&stack[n] == arg0) {
printf(" (first argument)");
}
if (&stack[n] == arg0 - 1) {
printf(" (saved eip)");
}
if (&stack[n] == arg0 - 2) {
printf(" (saved ebp)");
}
printf("\n");
}
}
#ifndef _DUMP_STACK_H
#define _DUMP_STACK_H
void dump_stack(void **stack, size_t n, void **arg0);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment