Created
March 28, 2014 01:57
-
-
Save haileys/9823480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main; | |
import "log" | |
/* | |
#include <sys/mman.h> | |
void mock_ptr(size_t addr) | |
{ | |
mprotect((void*)(addr & ~4095), 4096, PROT_READ | PROT_WRITE | PROT_EXEC); | |
unsigned char* ptr = (void*)addr; | |
*ptr = 0xc3; | |
} | |
*/ | |
import "C" | |
func main() { | |
// run `nm foo | grep 'log.Fatal'` and replace the | |
// address here with what nm says: | |
C.mock_ptr(0x24c90); | |
log.Fatal("oops!"); | |
log.Printf("still alive!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment