Skip to content

Instantly share code, notes, and snippets.

@haileys
Created March 28, 2014 01:57
Show Gist options
  • Save haileys/9823480 to your computer and use it in GitHub Desktop.
Save haileys/9823480 to your computer and use it in GitHub Desktop.
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