Skip to content

Commit

Permalink
modify dump file flag, when file exist, override it.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilanyu committed Jun 4, 2017
1 parent d0e5bfa commit 64f1fb9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions memdump.go
Expand Up @@ -14,8 +14,8 @@ func main() {
end_addr_hex := flag.String("eaddr", "0", "end addr(hex)")
fileName := flag.String("filename", "memdump.mem", "filename")
flag.Parse()
start_addr,_ := strconv.ParseInt(*start_addr_hex, 16, 64)
end_addr,_ := strconv.ParseInt(*end_addr_hex, 16, 64)
start_addr, _ := strconv.ParseInt(*start_addr_hex, 16, 64)
end_addr, _ := strconv.ParseInt(*end_addr_hex, 16, 64)
length := end_addr - start_addr
if err := syscall.PtraceAttach(*pid); err != nil {
fmt.Errorf("PtraceAttach is err: %s", err)
Expand All @@ -35,7 +35,7 @@ func main() {
fmt.Errorf("Read is err: %s", err)
}
fmt.Println("read " + strconv.Itoa(n))
fpw, err := os.OpenFile(*fileName, os.O_RDONLY|os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0755)
fpw, err := os.OpenFile(*fileName, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0755)
defer fpw.Close()
fpw.Write(buf)
if err := syscall.PtraceDetach(*pid); err != nil {
Expand Down

0 comments on commit 64f1fb9

Please sign in to comment.