Skip to content

Instantly share code, notes, and snippets.

@amexn-me
Last active October 19, 2023 19:49
Show Gist options
  • Save amexn-me/59928f2c2900b12ec2f1f76ce39e2cb2 to your computer and use it in GitHub Desktop.
Save amexn-me/59928f2c2900b12ec2f1f76ce39e2cb2 to your computer and use it in GitHub Desktop.
Make a Windows 32bit exe console-less (silent mode for exe built through pkg)
package main
import (
"log"
"os"
)
func main() {
// Open the EXE file for reading and writing
filename := "to_convert_x32.exe"
file, err := os.OpenFile(filename, os.O_RDWR, 0644)
if err != nil {
log.Fatal(err)
}
defer file.Close()
// Modify the subsystem field at offset 0x180 (13th byte)
offset := int64(0x180) + 12
newSubsystem := byte(2)
_, err = file.WriteAt([]byte{newSubsystem}, offset)
if err != nil {
log.Fatal(err)
}
log.Println("Subsystem changed to GUI & it will remain silent.")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment