Skip to content

Instantly share code, notes, and snippets.

@syohex
Created November 11, 2020 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syohex/2a3d49bda13c2fd232d156bf6ba9ed74 to your computer and use it in GitHub Desktop.
Save syohex/2a3d49bda13c2fd232d156bf6ba9ed74 to your computer and use it in GitHub Desktop.
Check Windows binary architecture in Golang
package main
import (
"debug/pe"
"fmt"
"os"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("Usage: win_exe_check exe_file")
return
}
file, err := pe.Open(os.Args[1])
if err != nil {
fmt.Println(err)
return
}
// Print 8664 (x64), 14c(x86)
fmt.Printf("machine: %x\n", file.Machine)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment