Created
May 24, 2017 09:47
-
-
Save mpfund/5ada1c1c7f6b034162a105c8a700bb0b to your computer and use it in GitHub Desktop.
read raw bytes from disk
This file contains hidden or 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 ( | |
"syscall" | |
"fmt" | |
) | |
func main() { | |
disk := "\\\\.\\C:" | |
fd, err := syscall.Open(disk, syscall.O_RDONLY, 0777) | |
if err != nil { | |
fmt.Println("open ",err.Error()) | |
return | |
} | |
buffer := make([]byte, 10, 100) | |
numread, err := syscall.Read(fd, buffer) | |
if err != nil { | |
fmt.Println("read ",err.Error()) | |
} | |
fmt.Printf("Numbytes read: %d\n", numread) | |
fmt.Printf("Buffer: %b\n", buffer) | |
err = syscall.Close(fd) | |
if err != nil { | |
fmt.Print(err.Error(), "\n") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment